# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1298833300 0 # Node ID c60a4f6cfae8fca6ef266a59b6d0876f20b07c06 # Parent 0b920d0dc13eac3367bbe5e84fa57968b3c301fb Implemented icon support on the Mac. In the process created a new HICN type. The existing implementation works well on OS/2 but it is kind of bad on the other platforms. I should revisit the Windows and GTK implementations. The typedef currently in use should be backwards compatible for now. diff -r 0b920d0dc13e -r c60a4f6cfae8 dw.h --- a/dw.h Sun Feb 27 08:18:20 2011 +0000 +++ b/dw.h Sun Feb 27 19:01:40 2011 +0000 @@ -238,6 +238,7 @@ typedef HMODULE HMOD; typedef unsigned short UWORD; typedef unsigned long HSHM; +typedef unsigned long HICN; extern HAB dwhab; extern HMQ dwhmq; @@ -288,6 +289,7 @@ }; typedef void *HTREEITEM; typedef void *HMENUI; +typedef void *HICN; typedef struct _window_data { UserData *root; @@ -366,8 +368,8 @@ #endif #define DW_POINTER_DEFAULT 0 -#define DW_POINTER_ARROW 0 -#define DW_POINTER_CLOCK 0 +#define DW_POINTER_ARROW 1 +#define DW_POINTER_CLOCK 2 #define HWND_DESKTOP ((HWND)0) @@ -605,6 +607,7 @@ typedef HANDLE HEV; typedef HANDLE HMOD; typedef HANDLE HSHM; +typedef unsigned long HICN; typedef struct _container { ColorInfo cinfo; @@ -903,6 +906,7 @@ typedef GtkWidget *HMENUI; typedef void *HTREEITEM; typedef void *HSHM; +typedef unsigned long HICN; typedef struct _resource_struct { long resource_max, *resource_id; @@ -1154,11 +1158,11 @@ long API dw_spinbutton_get_pos(HWND handle); int API dw_checkbox_get(HWND handle); void API dw_checkbox_set(HWND handle, int value); -HTREEITEM API dw_tree_insert(HWND handle, char *title, unsigned long icon, HTREEITEM parent, void *itemdata); -HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, unsigned long icon, HTREEITEM parent, void *itemdata); +HTREEITEM API dw_tree_insert(HWND handle, char *title, HICN icon, HTREEITEM parent, void *itemdata); +HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, HICN icon, HTREEITEM parent, void *itemdata); void API dw_tree_clear(HWND handle); void API dw_tree_item_delete(HWND handle, HTREEITEM item); -void API dw_tree_item_change(HWND handle, HTREEITEM item, char *title, unsigned long icon); +void API dw_tree_item_change(HWND handle, HTREEITEM item, char *title, HICN icon); void API dw_tree_item_expand(HWND handle, HTREEITEM item); void API dw_tree_item_collapse(HWND handle, HTREEITEM item); void API dw_tree_item_select(HWND handle, HTREEITEM item); @@ -1167,10 +1171,10 @@ char * API dw_tree_get_title(HWND handle, HTREEITEM item); HTREEITEM API dw_tree_get_parent(HWND handle, HTREEITEM item); int API dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator); -unsigned long API dw_icon_load(unsigned long module, unsigned long id); -unsigned long API dw_icon_load_from_file(char *filename); -unsigned long API dw_icon_load_from_data(char *data, int len); -void API dw_icon_free(unsigned long handle); +HICN API dw_icon_load(unsigned long module, unsigned long id); +HICN API dw_icon_load_from_file(char *filename); +HICN API dw_icon_load_from_data(char *data, int len); +void API dw_icon_free(HICN handle); void * API dw_container_alloc(HWND handle, int rowcount); void API dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data); void API dw_container_change_item(HWND handle, int column, int row, void *data); @@ -1187,13 +1191,13 @@ void API dw_container_optimize(HWND handle); int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count); void API dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data); -void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon); +void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, HICN icon); void API dw_filesystem_change_item(HWND handle, int column, int row, void *data); -void API dw_filesystem_change_file(HWND handle, int row, char *filename, unsigned long icon); +void API dw_filesystem_change_file(HWND handle, int row, char *filename, HICN icon); int API dw_container_get_column_type(HWND handle, int column); int API dw_filesystem_get_column_type(HWND handle, int column); -void API dw_taskbar_insert(HWND handle, unsigned long icon, char *bubbletext); -void API dw_taskbar_delete(HWND handle, unsigned long icon); +void API dw_taskbar_insert(HWND handle, HICN icon, char *bubbletext); +void API dw_taskbar_delete(HWND handle, HICN icon); int API dw_screen_width(void); int API dw_screen_height(void); unsigned long API dw_color_depth_get(void); diff -r 0b920d0dc13e -r c60a4f6cfae8 gtk/dw.c --- a/gtk/dw.c Sun Feb 27 08:18:20 2011 +0000 +++ b/gtk/dw.c Sun Feb 27 19:01:40 2011 +0000 @@ -3,7 +3,7 @@ * A GTK like implementation of the PM GUI * GTK forwarder module for portabilty. * - * (C) 2000-2004 Brian Smith + * (C) 2000-2011 Brian Smith * (C) 2003-2004 Mark Hessling * (C) 2002 Nickolay V. Shmyrev */ @@ -5503,7 +5503,7 @@ * parent: Parent handle or 0 if root. * itemdata: Item specific data. */ -HTREEITEM dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) +HTREEITEM dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, HICN icon, HTREEITEM parent, void *itemdata) { #if GTK_MAJOR_VERSION > 1 GtkWidget *tree; @@ -5656,7 +5656,7 @@ * parent: Parent handle or 0 if root. * itemdata: Item specific data. */ -HTREEITEM dw_tree_insert(HWND handle, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) +HTREEITEM dw_tree_insert(HWND handle, char *title, HICN icon, HTREEITEM parent, void *itemdata) { #if GTK_MAJOR_VERSION > 1 GtkWidget *tree; @@ -5801,7 +5801,7 @@ * title: The text title of the entry. * icon: Handle to coresponding icon. */ -void dw_tree_item_change(HWND handle, HTREEITEM item, char *title, unsigned long icon) +void dw_tree_item_change(HWND handle, HTREEITEM item, char *title, HICN icon) { #if GTK_MAJOR_VERSION > 1 GtkWidget *tree; @@ -6355,7 +6355,7 @@ * Windows, on GTK this is converted to a pointer * to an embedded XPM. */ -unsigned long dw_icon_load(unsigned long module, unsigned long id) +HICN dw_icon_load(unsigned long module, unsigned long id) { return id; } @@ -6367,7 +6367,7 @@ * DW pick the appropriate file extension. * (ICO on OS/2 or Windows, XPM on Unix) */ -unsigned long API dw_icon_load_from_file(char *filename) +HICN API dw_icon_load_from_file(char *filename) { int found = -1, _locked_by_me = FALSE; #if GTK_MAJOR_VERSION > 1 @@ -6469,7 +6469,7 @@ _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL; return 0; } - return ret | (1 << 31); + return (HICN)ret | (1 << 31); } /* @@ -6478,7 +6478,7 @@ * data: Source of data for image. * len: length of data */ -unsigned long API dw_icon_load_from_data(char *data, int len) +HICN API dw_icon_load_from_data(char *data, int len) { int found = -1, _locked_by_me = FALSE; char *file; @@ -6573,7 +6573,7 @@ _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL; return 0; } - return ret | (1 << 31); + return (HICN)ret | (1 << 31); } /* @@ -6581,7 +6581,7 @@ * Parameters: * handle: Handle to icon returned by dw_icon_load(). */ -void dw_icon_free(unsigned long handle) +void dw_icon_free(HICN handle) { /* If it is a private icon, find the item * free the associated structures and set @@ -6807,7 +6807,7 @@ * row: Zero based row of data being set. * data: Pointer to the data to be added. */ -void API dw_filesystem_change_file(HWND handle, int row, char *filename, unsigned long icon) +void API dw_filesystem_change_file(HWND handle, int row, char *filename, HICN icon) { dw_filesystem_set_file(handle, NULL, row, filename, icon); } @@ -6821,7 +6821,7 @@ * row: Zero based row of data being set. * data: Pointer to the data to be added. */ -void dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon) +void dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, HICN icon) { _dw_container_set_item(handle, pointer, 0, row, (void *)&icon, filename); } @@ -7277,7 +7277,7 @@ * icon: Icon handle to display in the taskbar. * bubbletext: Text to show when the mouse is above the icon. */ -void dw_taskbar_insert(HWND handle, unsigned long icon, char *bubbletext) +void dw_taskbar_insert(HWND handle, HICN icon, char *bubbletext) { /* TODO */ } @@ -7288,7 +7288,7 @@ * handle: Window handle that was used with dw_taskbar_insert(). * icon: Icon handle that was used with dw_taskbar_insert(). */ -void dw_taskbar_delete(HWND handle, unsigned long icon) +void dw_taskbar_delete(HWND handle, HICN icon) { /* TODO */ } diff -r 0b920d0dc13e -r c60a4f6cfae8 mac/dw.m --- a/mac/dw.m Sun Feb 27 08:18:20 2011 +0000 +++ b/mac/dw.m Sun Feb 27 19:01:40 2011 +0000 @@ -5,7 +5,7 @@ * (C) 2011 Brian Smith * * Using garbage collection so requires 10.5 or later. - * clang -std=c99 -g -o dwtest -D__MAC__ -I. mac/dw.m -framework Cocoa -fobjc-gc-only + * clang -std=c99 -g -o dwtest -D__MAC__ -I. dwtest.c mac/dw.m -framework Cocoa -framework WebKit -fobjc-gc-only */ #import #import @@ -123,12 +123,6 @@ int flags = (int)[object pressedMouseButtons]; NSPoint point = [object mouseLocation]; int button = 0; - char *which = "pressed"; - - if(message == 4) - { - which = "released"; - } if(flags & 1) { @@ -143,7 +137,6 @@ button = 3; } - NSLog(@"Button %s x:%d y:%d button:%d\n", which, (int)point.x, (int)point.y, (int)button); return buttonfunc(object, point.x, point.y, button, handler->data); } case 6: @@ -860,67 +853,6 @@ unsigned long _foreground = 0xAAAAAA, _background = 0; -/* This function will recursively search a box and add up the total height of it */ -static void _count_size(HWND thisbox, int type, int *xsize, int *xorigsize) -{ - int size = 0, origsize = 0, z; - DWBox *box = thisbox; - Box *tmp = [box box]; - - if(!tmp) - { - *xsize = *xorigsize = 0; - return; - } - - if(type == tmp->type) - { - /* If the box is going in the direction we want, then we - * return the entire sum of the items. - */ - for(z=0;zcount;z++) - { - if(tmp->items[z].type == TYPEBOX) - { - int s, os; - - _count_size(tmp->items[z].hwnd, type, &s, &os); - size += s; - origsize += os; - } - else - { - size += (type == DW_HORZ ? tmp->items[z].width : tmp->items[z].height); - origsize += (type == DW_HORZ ? tmp->items[z].origwidth : tmp->items[z].origheight); - } - } - } - else - { - /* If the box is not going in the direction we want, then we only - * want to return the maximum value. - */ - int tmpsize = 0, tmporigsize = 0; - - for(z=0;zcount;z++) - { - if(tmp->items[z].type == TYPEBOX) - _count_size(tmp->items[z].hwnd, type, &tmpsize, &tmporigsize); - else - { - tmpsize = (type == DW_HORZ ? tmp->items[z].width : tmp->items[z].height); - tmporigsize = (type == DW_HORZ ? tmp->items[z].origwidth : tmp->items[z].origheight); - } - - if(tmpsize > size) - size = tmpsize; - } - } - - *xsize = size; - *xorigsize = origsize; -} - /* This function calculates how much space the widgets and boxes require * and does expansion as necessary. */ @@ -1282,34 +1214,6 @@ } } -static void _changebox(Box *thisbox, int percent, int type) -{ - int z; - - for(z=0;zcount;z++) - { - if(thisbox->items[z].type == TYPEBOX) - { - DWBox *box = thisbox->items[z].hwnd; - Box *tmp = [box box]; - _changebox(tmp, percent, type); - } - else - { - if(type == DW_HORZ) - { - if(thisbox->items[z].hsize == SIZEEXPAND) - thisbox->items[z].width = (int)(((float)thisbox->items[z].origwidth) * (((float)percent)/((float)100.0))); - } - else - { - if(thisbox->items[z].vsize == SIZEEXPAND) - thisbox->items[z].height = (int)(((float)thisbox->items[z].origheight) * (((float)percent)/((float)100.0))); - } - } - } -} - NSMenu *_generate_main_menu() { /* This only works on 10.6 so we have a backup method */ @@ -1392,14 +1296,17 @@ DWRunLoop = [NSRunLoop alloc]; /* Create object for handling timers */ DWHandler = [[DWTimerHandler alloc] init]; + /* If we aren't using garbage collection we need autorelease pools */ #if !defined(GARBAGE_COLLECT) pool = [[NSAutoreleasePool alloc] init]; #endif + /* Create a default main menu, with just the application menu */ DWMainMenu = _generate_main_menu(); [DWApp setMainMenu:DWMainMenu]; - /*DWObject *test = [[DWObject alloc] init]; + DWObject *test = [[DWObject alloc] init]; + /* Use NSThread to start a dummy thread to initialize the threading subsystem */ NSThread *thread = [[ NSThread alloc] initWithTarget:test selector:@selector(uselessThread:) object:nil]; - [thread start];*/ + [thread start]; return 0; } @@ -1977,6 +1884,7 @@ */ HWND API dw_bitmapbutton_new(char *text, ULONG resid) { + /* TODO: Implement tooltips */ NSBundle *bundle = [NSBundle mainBundle]; NSString *respath = [bundle resourcePath]; NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid]; @@ -2848,6 +2756,7 @@ */ void API dw_color_foreground_set(unsigned long value) { + /* This may need to be thread specific */ _foreground = _get_color(value); } @@ -2859,6 +2768,7 @@ */ void API dw_color_background_set(unsigned long value) { + /* This may need to be thread specific */ _background = _get_color(value); } @@ -3139,7 +3049,7 @@ * parent: Parent handle or 0 if root. * itemdata: Item specific data. */ -HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) +HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, HICN icon, HTREEITEM parent, void *itemdata) { NSLog(@"dw_tree_insert_item_after() unimplemented\n"); return HWND_DESKTOP; @@ -3154,7 +3064,7 @@ * parent: Parent handle or 0 if root. * itemdata: Item specific data. */ -HTREEITEM API dw_tree_insert(HWND handle, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) +HTREEITEM API dw_tree_insert(HWND handle, char *title, HICN icon, HTREEITEM parent, void *itemdata) { NSLog(@"dw_tree_insert_item() unimplemented\n"); return HWND_DESKTOP; @@ -3192,7 +3102,7 @@ * title: The text title of the entry. * icon: Handle to coresponding icon. */ -void API dw_tree_item_change(HWND handle, HTREEITEM item, char *title, unsigned long icon) +void API dw_tree_item_change(HWND handle, HTREEITEM item, char *title, HICN icon) { NSLog(@"dw_tree_item_change() unimplemented\n"); } @@ -3312,6 +3222,11 @@ { NSTableColumn *column = [[NSTableColumn alloc] init]; [[column headerCell] setStringValue:[ NSString stringWithUTF8String:titles[z] ]]; + if(flags[z] & DW_CFA_BITMAPORICON) + { + NSImageCell *imagecell = [[[NSImageCell alloc] init] autorelease]; + [column setDataCell:imagecell]; + } [cont addTableColumn:column]; [cont addColumn:column andType:(int)flags[z]]; } @@ -3376,10 +3291,14 @@ id object = nil; int type = [cont cellType:column]; int lastadd = [cont lastAddPoint]; - + + if(!data) + { + return; + } if(type & DW_CFA_BITMAPORICON) { - /* TODO: Handle image here */ + object = *((NSImage **)data); } else if(type & DW_CFA_STRING) { @@ -3464,8 +3383,9 @@ * row: Zero based row of data being set. * data: Pointer to the data to be added. */ -void API dw_filesystem_change_file(HWND handle, int row, char *filename, unsigned long icon) -{ +void API dw_filesystem_change_file(HWND handle, int row, char *filename, HICN icon) +{ + dw_container_change_item(handle, 0, row, &icon); dw_container_change_item(handle, 1, row, filename); } @@ -3478,8 +3398,9 @@ * row: Zero based row of data being set. * data: Pointer to the data to be added. */ -void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon) -{ +void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, HICN icon) +{ + dw_container_set_item(handle, pointer, 0, row, &icon); dw_container_set_item(handle, pointer, 1, row, filename); } @@ -3668,7 +3589,7 @@ * icon: Icon handle to display in the taskbar. * bubbletext: Text to show when the mouse is above the icon. */ -void API dw_taskbar_insert(HWND handle, unsigned long icon, char *bubbletext) +void API dw_taskbar_insert(HWND handle, HICN icon, char *bubbletext) { NSLog(@"dw_taskbar_insert() unimplemented\n"); } @@ -3679,7 +3600,7 @@ * handle: Window handle that was used with dw_taskbar_insert(). * icon: Icon handle that was used with dw_taskbar_insert(). */ -void API dw_taskbar_delete(HWND handle, unsigned long icon) +void API dw_taskbar_delete(HWND handle, HICN icon) { NSLog(@"dw_taskbar_delete() unimplemented\n"); } @@ -3692,10 +3613,16 @@ * Windows, on GTK this is converted to a pointer * to an embedded XPM. */ -unsigned long API dw_icon_load(unsigned long module, unsigned long id) -{ - NSLog(@"dw_icon_load() unimplemented\n"); - return 0; +HICN API dw_icon_load(unsigned long module, unsigned long resid) +{ + NSBundle *bundle = [NSBundle mainBundle]; + NSString *respath = [bundle resourcePath]; + NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid]; + NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath]; + [bundle release]; + [respath release]; + [filepath release]; + return image; } /* @@ -3705,10 +3632,9 @@ * DW pick the appropriate file extension. * (ICO on OS/2 or Windows, XPM on Unix) */ -unsigned long API dw_icon_load_from_file(char *filename) -{ - NSLog(@"dw_icon_load_from_file() unimplemented\n"); - return 0; +HICN API dw_icon_load_from_file(char *filename) +{ + return [[NSImage alloc] initWithContentsOfFile:[ NSString stringWithUTF8String:filename ]]; } /* @@ -3718,10 +3644,12 @@ * DW pick the appropriate file extension. * (ICO on OS/2 or Windows, XPM on Unix) */ -unsigned long API dw_icon_load_from_data(char *data, int len) -{ - NSLog(@"dw_icon_load_from_data() unimplemented\n"); - return 0; +HICN API dw_icon_load_from_data(char *data, int len) +{ + NSData *thisdata = [[[NSData alloc] dataWithBytes:data length:len] autorelease]; + NSImage *image = [[NSImage alloc] initWithData:thisdata]; + [thisdata release]; + return image; } /* @@ -3729,9 +3657,10 @@ * Parameters: * handle: Handle to icon returned by dw_icon_load(). */ -void API dw_icon_free(unsigned long handle) -{ - NSLog(@"dw_icon_free() unimplemented\n"); +void API dw_icon_free(HICN handle) +{ + NSImage *image = handle; + [image release]; } /* @@ -3880,6 +3809,7 @@ pixmap->width = size.width; pixmap->height = size.height; pixmap->handle = image; + [thisdata release]; return pixmap; } @@ -5127,6 +5057,7 @@ */ void API dw_flush(void) { + /* This may need to be thread specific */ if(_DWLastDrawable) { id object = _DWLastDrawable; @@ -6093,6 +6024,7 @@ { void (*threadfunc)(void *) = NULL; void **tmp = (void **)data; + /* If we aren't using garbage collection we need autorelease pools */ #if !defined(GARBAGE_COLLECT) NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; #endif @@ -6100,6 +6032,7 @@ threadfunc = (void (*)(void *))tmp[0]; threadfunc(tmp[1]); + /* Release the pool when we are done so we don't leak */ #if !defined(GARBAGE_COLLECT) [pool release]; #endif @@ -6327,44 +6260,3 @@ return dw_exec(browser, DW_EXEC_GUI, execargs); } - -#ifdef DWTEST -int main(int argc, char *argv[]) -{ - HWND window, box, vbox, hbox, button, text, checkbox, html; - LONG x, y; - ULONG width, height; - - dw_init(TRUE, argc, argv); - - window = dw_window_new(HWND_DESKTOP, "Dynamic Windows Test", DW_FCF_TITLEBAR | DW_FCF_SYSMENU | DW_FCF_MINMAX | DW_FCF_SIZEBORDER); - box = dw_box_new(DW_VERT, 0); - vbox = dw_groupbox_new(DW_VERT, 4, "Checks"); - checkbox = dw_checkbox_new("Checkbox 1", 0); - dw_box_pack_start(vbox, checkbox, 100, 25, TRUE, FALSE, 2); - checkbox = dw_checkbox_new("Checkbox 2", 0); - dw_box_pack_start(vbox, checkbox, 100, 25, TRUE, FALSE, 2); - checkbox = dw_checkbox_new("Checkbox 3", 0); - dw_box_pack_start(vbox, checkbox, 100, 25, TRUE, FALSE, 2); - hbox = dw_box_new(DW_HORZ, 0); - button = dw_button_new("Test Button", 0); - /*dw_window_disable(button);*/ - text = dw_entryfield_new("Entry", 0); - dw_box_pack_start(hbox, button, 100, 40, TRUE, FALSE, 2); - dw_box_pack_start(hbox, text, 100, 40, TRUE, FALSE, 2); - dw_box_pack_start(vbox, hbox, 0, 0, TRUE, FALSE, 0); - html = dw_html_new(0); - dw_html_url(html, "http://dbsoft.org"); - dw_box_pack_start(vbox, html, 0, 0, TRUE, TRUE, 0); - dw_box_pack_start(box, vbox, 0, 0, TRUE, TRUE, 0); - dw_box_pack_start(window, box, 0, 0, TRUE, TRUE, 0); - dw_window_show(window); - dw_window_set_pos_size(window, 400, 400, 500, 500); - dw_window_get_pos_size(window, &x, &y, &width, &height); - dw_messagebox("Dynamic Windows Information", DW_MB_OK | DW_MB_INFORMATION, "%d %d %d %d %d %d %d\n", (int)x, (int)y, (int)width, (int)height, (int)dw_screen_width(), (int)dw_screen_height(), (int)dw_color_depth_get()); - dw_messagebox("File selection", DW_MB_OK | DW_MB_INFORMATION, "%s", dw_file_browse("Choose file", "", "", DW_FILE_OPEN)); - dw_main(); - - return 0; -} -#endif \ No newline at end of file diff -r 0b920d0dc13e -r c60a4f6cfae8 os2/dw.c --- a/os2/dw.c Sun Feb 27 08:18:20 2011 +0000 +++ b/os2/dw.c Sun Feb 27 19:01:40 2011 +0000 @@ -2,7 +2,7 @@ * Dynamic Windows: * A GTK like implementation of the PM GUI * - * (C) 2000-2004 Brian Smith + * (C) 2000-2011 Brian Smith * (C) 2003-2008 Mark Hessling * (C) 2000 Achim Hasenmueller * (C) 2000 Peter Nielsen @@ -6468,7 +6468,7 @@ * parent: Parent handle or 0 if root. * itemdata: Item specific data. */ -HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) +HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, HICN icon, HTREEITEM parent, void *itemdata) { ULONG cbExtra; PCNRITEM pci; @@ -6526,7 +6526,7 @@ * parent: Parent handle or 0 if root. * itemdata: Item specific data. */ -HTREEITEM API dw_tree_insert(HWND handle, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) +HTREEITEM API dw_tree_insert(HWND handle, char *title, HICN icon, HTREEITEM parent, void *itemdata) { return dw_tree_insert_after(handle, (HTREEITEM)CMA_END, title, icon, parent, itemdata); } @@ -6539,7 +6539,7 @@ * title: The text title of the entry. * icon: Handle to coresponding icon. */ -void API dw_tree_item_change(HWND handle, HTREEITEM item, char *title, unsigned long icon) +void API dw_tree_item_change(HWND handle, HTREEITEM item, char *title, HICN icon) { PCNRITEM pci = (PCNRITEM)item; @@ -6843,7 +6843,7 @@ * Windows, on GTK this is converted to a pointer * to an embedded XPM. */ -unsigned long API dw_icon_load(unsigned long module, unsigned long id) +HICN API dw_icon_load(unsigned long module, unsigned long id) { return WinLoadPointer(HWND_DESKTOP,module,id); } @@ -6855,7 +6855,7 @@ * DW pick the appropriate file extension. * (ICO on OS/2 or Windows, XPM on Unix) */ -unsigned long API dw_icon_load_from_file(char *filename) +HICN API dw_icon_load_from_file(char *filename) { char *file = alloca(strlen(filename) + 5); @@ -6882,9 +6882,9 @@ * DW pick the appropriate file extension. * (ICO on OS/2 or Windows, XPM on Unix) */ -unsigned long API dw_icon_load_from_data(char *data, int len) -{ - unsigned long icon=0; +HICN API dw_icon_load_from_data(char *data, int len) +{ + HICN icon=0; char *file; FILE *fp; @@ -6915,7 +6915,7 @@ * Parameters: * handle: Handle to icon returned by dw_icon_load(). */ -void API dw_icon_free(unsigned long handle) +void API dw_icon_free(HICN handle) { WinDestroyPointer(handle); } @@ -7150,7 +7150,7 @@ * row: Zero based row of data being set. * data: Pointer to the data to be added. */ -void API dw_filesystem_change_file(HWND handle, int row, char *filename, unsigned long icon) +void API dw_filesystem_change_file(HWND handle, int row, char *filename, HICN icon) { dw_container_change_item(handle, 0, row, (void *)&icon); dw_container_change_item(handle, 1, row, (void *)&filename); @@ -7165,7 +7165,7 @@ * row: Zero based row of data being set. * data: Pointer to the data to be added. */ -void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon) +void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, HICN icon) { dw_container_set_item(handle, pointer, 0, row, (void *)&icon); dw_container_set_item(handle, pointer, 1, row, (void *)&filename); @@ -7568,7 +7568,7 @@ * icon: Icon handle to display in the taskbar. * bubbletext: Text to show when the mouse is above the icon. */ -void API dw_taskbar_insert(HWND handle, unsigned long icon, char *bubbletext) +void API dw_taskbar_insert(HWND handle, HICN icon, char *bubbletext) { handle = handle; icon = icon; @@ -7582,7 +7582,7 @@ * handle: Window handle that was used with dw_taskbar_insert(). * icon: Icon handle that was used with dw_taskbar_insert(). */ -void API dw_taskbar_delete(HWND handle, unsigned long icon) +void API dw_taskbar_delete(HWND handle, HICN icon) { handle = handle; icon = icon; diff -r 0b920d0dc13e -r c60a4f6cfae8 win/dw.c --- a/win/dw.c Sun Feb 27 08:18:20 2011 +0000 +++ b/win/dw.c Sun Feb 27 19:01:40 2011 +0000 @@ -2,7 +2,7 @@ * Dynamic Windows: * A GTK like implementation of the Win32 GUI * - * (C) 2000-2005 Brian Smith + * (C) 2000-2011 Brian Smith * (C) 2003-2005 Mark Hessling * */ @@ -7054,7 +7054,7 @@ * parent: Parent handle or 0 if root. * itemdata: Item specific data. */ -HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) +HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, HICN icon, HTREEITEM parent, void *itemdata) { TVITEM tvi; TVINSERTSTRUCT tvins; @@ -7088,7 +7088,7 @@ * parent: Parent handle or 0 if root. * itemdata: Item specific data. */ -HTREEITEM API dw_tree_insert(HWND handle, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) +HTREEITEM API dw_tree_insert(HWND handle, char *title, HICN icon, HTREEITEM parent, void *itemdata) { TVITEM tvi; TVINSERTSTRUCT tvins; @@ -7121,7 +7121,7 @@ * title: The text title of the entry. * icon: Handle to coresponding icon. */ -void API dw_tree_item_change(HWND handle, HTREEITEM item, char *title, unsigned long icon) +void API dw_tree_item_change(HWND handle, HTREEITEM item, char *title, HICN icon) { TVITEM tvi; void **ptrs; @@ -7401,9 +7401,9 @@ * Windows, on GTK this is converted to a pointer * to an embedded XPM. */ -unsigned long API dw_icon_load(unsigned long module, unsigned long id) -{ - return (unsigned long)LoadIcon(DWInstance, MAKEINTRESOURCE(id)); +HICN API dw_icon_load(unsigned long module, unsigned long id) +{ + return (HICN)LoadIcon(DWInstance, MAKEINTRESOURCE(id)); } /* @@ -7413,7 +7413,7 @@ * DW pick the appropriate file extension. * (ICO on OS/2 or Windows, XPM on Unix) */ -unsigned long API dw_icon_load_from_file(char *filename) +HICN API dw_icon_load_from_file(char *filename) { char *file = malloc(strlen(filename) + 5); HANDLE icon; @@ -7436,7 +7436,7 @@ } icon = LoadImage(NULL, file, IMAGE_ICON, 0, 0, LR_LOADFROMFILE); free(file); - return (unsigned long)icon; + return (HICN)icon; } /* @@ -7446,7 +7446,7 @@ * DW pick the appropriate file extension. * (ICO on OS/2 or Windows, XPM on Unix) */ -unsigned long API dw_icon_load_from_data(char *data, int len) +HICN API dw_icon_load_from_data(char *data, int len) { HANDLE icon; char *file; @@ -7471,7 +7471,7 @@ } unlink( file ); } - return (unsigned long)icon; + return (HICN)icon; } /* @@ -7479,7 +7479,7 @@ * Parameters: * handle: Handle to icon returned by dw_icon_load(). */ -void API dw_icon_free(unsigned long handle) +void API dw_icon_free(HICN handle) { DestroyIcon((HICON)handle); } @@ -7574,7 +7574,7 @@ * row: Zero based row of data being set. * data: Pointer to the data to be added. */ -void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon) +void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, HICN icon) { LV_ITEM lvi; @@ -7736,7 +7736,7 @@ * row: Zero based row of data being set. * data: Pointer to the data to be added. */ -void API dw_filesystem_change_file(HWND handle, int row, char *filename, unsigned long icon) +void API dw_filesystem_change_file(HWND handle, int row, char *filename, HICN icon) { dw_filesystem_set_file(handle, NULL, row, filename, icon); } @@ -8096,7 +8096,7 @@ * icon: Icon handle to display in the taskbar. * bubbletext: Text to show when the mouse is above the icon. */ -void API dw_taskbar_insert(HWND handle, unsigned long icon, char *bubbletext) +void API dw_taskbar_insert(HWND handle, HICN icon, char *bubbletext) { NOTIFYICONDATA tnid; @@ -8120,7 +8120,7 @@ * handle: Window handle that was used with dw_taskbar_insert(). * icon: Icon handle that was used with dw_taskbar_insert(). */ -void API dw_taskbar_delete(HWND handle, unsigned long icon) +void API dw_taskbar_delete(HWND handle, HICN icon) { NOTIFYICONDATA tnid;