comparison gtk/dw.c @ 978:2497a806d34e

Fixes to the GTK1/2 module to support the new HICN type, but no major structural changes.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 06 May 2011 02:57:12 +0000
parents e506776e7fd3
children 87dc0f5f96d0
comparison
equal deleted inserted replaced
977:634bb6cecef1 978:2497a806d34e
1841 } 1841 }
1842 } 1842 }
1843 return FALSE; 1843 return FALSE;
1844 } 1844 }
1845 1845
1846 static GdkPixmap *_find_private_pixmap(GdkBitmap **bitmap, long id, unsigned long *userwidth, unsigned long *userheight) 1846 static GdkPixmap *_find_private_pixmap(GdkBitmap **bitmap, HICN icon, unsigned long *userwidth, unsigned long *userheight)
1847 { 1847 {
1848 int id = (int)icon;
1849
1848 if(id < _PixmapCount && _PixmapArray[id].used) 1850 if(id < _PixmapCount && _PixmapArray[id].used)
1849 { 1851 {
1850 *bitmap = _PixmapArray[id].mask; 1852 *bitmap = _PixmapArray[id].mask;
1851 if(userwidth) 1853 if(userwidth)
1852 *userwidth = _PixmapArray[id].width; 1854 *userwidth = _PixmapArray[id].width;
1855 return _PixmapArray[id].pixmap; 1857 return _PixmapArray[id].pixmap;
1856 } 1858 }
1857 return NULL; 1859 return NULL;
1858 } 1860 }
1859 1861
1860 static GdkPixmap *_find_pixmap(GdkBitmap **bitmap, long id, HWND handle, unsigned long *userwidth, unsigned long *userheight) 1862 static GdkPixmap *_find_pixmap(GdkBitmap **bitmap, HICN icon, HWND handle, unsigned long *userwidth, unsigned long *userheight)
1861 { 1863 {
1862 char *data = NULL; 1864 char *data = NULL;
1863 int z; 1865 int z, id = (int)icon;
1864 1866
1865 if(id & (1 << 31)) 1867 if(id & (1 << 31))
1866 return _find_private_pixmap(bitmap, (id & 0xFFFFFF), userwidth, userheight); 1868 return _find_private_pixmap(bitmap, (HICN)(id & 0xFFFFFF), userwidth, userheight);
1867 1869
1868 for(z=0;z<_resources.resource_max;z++) 1870 for(z=0;z<_resources.resource_max;z++)
1869 { 1871 {
1870 if(_resources.resource_id[z] == id) 1872 if(_resources.resource_id[z] == id)
1871 { 1873 {
1896 } 1898 }
1897 return NULL; 1899 return NULL;
1898 } 1900 }
1899 1901
1900 #if GTK_MAJOR_VERSION > 1 1902 #if GTK_MAJOR_VERSION > 1
1901 static GdkPixbuf *_find_private_pixbuf(long id) 1903 static GdkPixbuf *_find_private_pixbuf(HICN icon)
1902 { 1904 {
1905 int id = (int)icon;
1906
1903 if(id < _PixmapCount && _PixmapArray[id].used) 1907 if(id < _PixmapCount && _PixmapArray[id].used)
1904 return _PixmapArray[id].pixbuf; 1908 return _PixmapArray[id].pixbuf;
1905 return NULL; 1909 return NULL;
1906 } 1910 }
1907 1911
1908 static GdkPixbuf *_find_pixbuf(long id) 1912 static GdkPixbuf *_find_pixbuf(HICN icon)
1909 { 1913 {
1910 char *data = NULL; 1914 char *data = NULL;
1911 int z; 1915 int z, id = (int)icon;
1912 1916
1913 if(id & (1 << 31)) 1917 if(id & (1 << 31))
1914 return _find_private_pixbuf((id & 0xFFFFFF)); 1918 return _find_private_pixbuf((HICN)(id & 0xFFFFFF));
1915 1919
1916 for(z=0;z<_resources.resource_max;z++) 1920 for(z=0;z<_resources.resource_max;z++)
1917 { 1921 {
1918 if(_resources.resource_id[z] == id) 1922 if(_resources.resource_id[z] == id)
1919 { 1923 {
3028 3032
3029 DW_MUTEX_LOCK; 3033 DW_MUTEX_LOCK;
3030 if(pointertype & (1 << 31)) 3034 if(pointertype & (1 << 31))
3031 { 3035 {
3032 GdkBitmap *bitmap = NULL; 3036 GdkBitmap *bitmap = NULL;
3033 GdkPixmap *pixmap = _find_private_pixmap(&bitmap, (pointertype & 0xFFFFFF), NULL, NULL); 3037 GdkPixmap *pixmap = _find_private_pixmap(&bitmap, (HICN)(pointertype & 0xFFFFFF), NULL, NULL);
3034 cursor = gdk_cursor_new_from_pixmap(pixmap, (GdkPixmap *)bitmap, &_colors[DW_CLR_WHITE], &_colors[DW_CLR_BLACK], 8, 8); 3038 cursor = gdk_cursor_new_from_pixmap(pixmap, (GdkPixmap *)bitmap, &_colors[DW_CLR_WHITE], &_colors[DW_CLR_BLACK], 8, 8);
3035 } 3039 }
3036 else if(!pointertype) 3040 else if(!pointertype)
3037 cursor = NULL; 3041 cursor = NULL;
3038 else 3042 else
4369 if(!id && !filename) 4373 if(!id && !filename)
4370 return; 4374 return;
4371 4375
4372 DW_MUTEX_LOCK; 4376 DW_MUTEX_LOCK;
4373 if(id) 4377 if(id)
4374 tmp = _find_pixmap(&bitmap, id, handle, NULL, NULL); 4378 tmp = _find_pixmap(&bitmap, (HICN)id, handle, NULL, NULL);
4375 else 4379 else
4376 { 4380 {
4377 char *file = alloca(strlen(filename) + 5); 4381 char *file = alloca(strlen(filename) + 5);
4378 #if GTK_MAJOR_VERSION > 1 4382 #if GTK_MAJOR_VERSION > 1
4379 GdkPixbuf *pixbuf; 4383 GdkPixbuf *pixbuf;
4470 if (!id && !data) 4474 if (!id && !data)
4471 return; 4475 return;
4472 4476
4473 DW_MUTEX_LOCK; 4477 DW_MUTEX_LOCK;
4474 if (id) 4478 if (id)
4475 tmp = _find_pixmap(&bitmap, id, handle, NULL, NULL); 4479 tmp = _find_pixmap(&bitmap, (HICN)id, handle, NULL, NULL);
4476 else 4480 else
4477 { 4481 {
4478 #if GTK_MAJOR_VERSION > 1 4482 #if GTK_MAJOR_VERSION > 1
4479 GdkPixbuf *pixbuf; 4483 GdkPixbuf *pixbuf;
4480 #elif defined(USE_IMLIB) 4484 #elif defined(USE_IMLIB)
5545 5549
5546 pixbuf = _find_pixbuf(icon); 5550 pixbuf = _find_pixbuf(icon);
5547 5551
5548 gtk_tree_store_insert_after(store, iter, (GtkTreeIter *)parent, (GtkTreeIter *)item); 5552 gtk_tree_store_insert_after(store, iter, (GtkTreeIter *)parent, (GtkTreeIter *)item);
5549 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1); 5553 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1);
5550 if(pixbuf && !(icon & (1 << 31))) 5554 if(pixbuf && !((int)icon & (1 << 31)))
5551 g_object_unref(pixbuf); 5555 g_object_unref(pixbuf);
5552 retval = (HTREEITEM)iter; 5556 retval = (HTREEITEM)iter;
5553 } 5557 }
5554 DW_MUTEX_UNLOCK; 5558 DW_MUTEX_UNLOCK;
5555 5559
5698 5702
5699 pixbuf = _find_pixbuf(icon); 5703 pixbuf = _find_pixbuf(icon);
5700 5704
5701 gtk_tree_store_append (store, iter, (GtkTreeIter *)parent); 5705 gtk_tree_store_append (store, iter, (GtkTreeIter *)parent);
5702 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1); 5706 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1);
5703 if(pixbuf && !(icon & (1 << 31))) 5707 if(pixbuf && !((int)icon & (1 << 31)))
5704 g_object_unref(pixbuf); 5708 g_object_unref(pixbuf);
5705 retval = (HTREEITEM)iter; 5709 retval = (HTREEITEM)iter;
5706 } 5710 }
5707 DW_MUTEX_UNLOCK; 5711 DW_MUTEX_UNLOCK;
5708 5712
5838 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store"))) 5842 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store")))
5839 { 5843 {
5840 pixbuf = _find_pixbuf(icon); 5844 pixbuf = _find_pixbuf(icon);
5841 5845
5842 gtk_tree_store_set(store, (GtkTreeIter *)item, 0, title, 1, pixbuf, -1); 5846 gtk_tree_store_set(store, (GtkTreeIter *)item, 0, title, 1, pixbuf, -1);
5843 if(pixbuf && !(icon & (1 << 31))) 5847 if(pixbuf && !((int)icon & (1 << 31)))
5844 g_object_unref(pixbuf); 5848 g_object_unref(pixbuf);
5845 } 5849 }
5846 DW_MUTEX_UNLOCK; 5850 DW_MUTEX_UNLOCK;
5847 #else 5851 #else
5848 GtkWidget *label, *hbox, *pixmap; 5852 GtkWidget *label, *hbox, *pixmap;
6375 * Windows, on GTK this is converted to a pointer 6379 * Windows, on GTK this is converted to a pointer
6376 * to an embedded XPM. 6380 * to an embedded XPM.
6377 */ 6381 */
6378 HICN dw_icon_load(unsigned long module, unsigned long id) 6382 HICN dw_icon_load(unsigned long module, unsigned long id)
6379 { 6383 {
6380 return id; 6384 return (HICN)id;
6381 } 6385 }
6382 6386
6383 /* 6387 /*
6384 * Obtains an icon from a file. 6388 * Obtains an icon from a file.
6385 * Parameters: 6389 * Parameters:
6487 { 6491 {
6488 _PixmapArray[found].used = 0; 6492 _PixmapArray[found].used = 0;
6489 _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL; 6493 _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL;
6490 return 0; 6494 return 0;
6491 } 6495 }
6492 return (HICN)ret | (1 << 31); 6496 return (HICN)(ret | (1 << 31));
6493 } 6497 }
6494 6498
6495 /* 6499 /*
6496 * Obtains an icon from data. 6500 * Obtains an icon from data.
6497 * Parameters: 6501 * Parameters:
6591 { 6595 {
6592 _PixmapArray[found].used = 0; 6596 _PixmapArray[found].used = 0;
6593 _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL; 6597 _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL;
6594 return 0; 6598 return 0;
6595 } 6599 }
6596 return (HICN)ret | (1 << 31); 6600 return (HICN)(ret | (1 << 31));
6597 } 6601 }
6598 6602
6599 /* 6603 /*
6600 * Frees a loaded resource in OS/2 and Windows. 6604 * Frees a loaded resource in OS/2 and Windows.
6601 * Parameters: 6605 * Parameters:
6605 { 6609 {
6606 /* If it is a private icon, find the item 6610 /* If it is a private icon, find the item
6607 * free the associated structures and set 6611 * free the associated structures and set
6608 * the entry to unused. 6612 * the entry to unused.
6609 */ 6613 */
6610 if(handle & (1 << 31)) 6614 if((int)handle & (1 << 31))
6611 { 6615 {
6612 unsigned long id = handle & 0xFFFFFF; 6616 unsigned long id = (int)handle & 0xFFFFFF;
6613 6617
6614 if(id < _PixmapCount && _PixmapArray[id].used) 6618 if(id < _PixmapCount && _PixmapArray[id].used)
6615 { 6619 {
6616 #if GTK_MAJOR_VERSION > 1 6620 #if GTK_MAJOR_VERSION > 1
6617 if(_PixmapArray[id].pixbuf) 6621 if(_PixmapArray[id].pixbuf)
6719 row += (int)gtk_object_get_data(GTK_OBJECT(clist), "_dw_insertpos"); 6723 row += (int)gtk_object_get_data(GTK_OBJECT(clist), "_dw_insertpos");
6720 } 6724 }
6721 6725
6722 if(flag & DW_CFA_BITMAPORICON) 6726 if(flag & DW_CFA_BITMAPORICON)
6723 { 6727 {
6724 long hicon = *((long *)data); 6728 HICN hicon = *((HICN *)data);
6725 GdkBitmap *bitmap = NULL; 6729 GdkBitmap *bitmap = NULL;
6726 GdkPixmap *pixmap = _find_pixmap(&bitmap, hicon, clist, NULL, NULL); 6730 GdkPixmap *pixmap = _find_pixmap(&bitmap, hicon, clist, NULL, NULL);
6727 6731
6728 if(pixmap) 6732 if(pixmap)
6729 gtk_clist_set_pixmap(GTK_CLIST(clist), row, column, pixmap, bitmap); 6733 gtk_clist_set_pixmap(GTK_CLIST(clist), row, column, pixmap, bitmap);
6730 } 6734 }
6731 else if(flag & DW_CFA_STRINGANDICON) 6735 else if(flag & DW_CFA_STRINGANDICON)
6732 { 6736 {
6733 long hicon = *((long *)data); 6737 HICN hicon = *((HICN *)data);
6734 GdkBitmap *bitmap = NULL; 6738 GdkBitmap *bitmap = NULL;
6735 GdkPixmap *pixmap = _find_pixmap(&bitmap, hicon, clist, NULL, NULL); 6739 GdkPixmap *pixmap = _find_pixmap(&bitmap, hicon, clist, NULL, NULL);
6736 6740
6737 if(pixmap) 6741 if(pixmap)
6738 gtk_clist_set_pixtext(GTK_CLIST(clist), row, column, text, 2, pixmap, bitmap); 6742 gtk_clist_set_pixtext(GTK_CLIST(clist), row, column, text, 2, pixmap, bitmap);
8075 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) 8079 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
8076 return NULL; 8080 return NULL;
8077 8081
8078 8082
8079 DW_MUTEX_LOCK; 8083 DW_MUTEX_LOCK;
8080 pixmap->pixmap = _find_pixmap(&pixmap->bitmap, id, handle, &pixmap->width, &pixmap->height); 8084 pixmap->pixmap = _find_pixmap(&pixmap->bitmap, (HICN)id, handle, &pixmap->width, &pixmap->height);
8081 if(pixmap->pixmap) 8085 if(pixmap->pixmap)
8082 { 8086 {
8083 #if GTK_MAJOR_VERSION < 2 8087 #if GTK_MAJOR_VERSION < 2
8084 GdkPixmapPrivate *pvt = (GdkPixmapPrivate *)pixmap->pixmap; 8088 GdkPixmapPrivate *pvt = (GdkPixmapPrivate *)pixmap->pixmap;
8085 pixmap->width = pvt->width; pixmap->height = pvt->height; 8089 pixmap->width = pvt->width; pixmap->height = pvt->height;