# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1298794700 0 # Node ID 0b920d0dc13eac3367bbe5e84fa57968b3c301fb # Parent 62aae18e7b7d01ad52cfe3abbe48c096dd2bbf09 Implemented bitmap buttons and pixmaps from bundle resources. Fixes for listboxes not immediately redrawing when updated. diff -r 62aae18e7b7d -r 0b920d0dc13e mac/dw.m --- a/mac/dw.m Sun Feb 27 06:00:49 2011 +0000 +++ b/mac/dw.m Sun Feb 27 08:18:20 2011 +0000 @@ -1975,10 +1975,22 @@ * text: Bubble help text to be displayed. * id: An ID of a bitmap in the resource file. */ -HWND API dw_bitmapbutton_new(char *text, ULONG id) -{ - NSLog(@"dw_bitmapbutton_new() unimplemented\n"); - return HWND_DESKTOP; +HWND API dw_bitmapbutton_new(char *text, ULONG resid) +{ + NSBundle *bundle = [NSBundle mainBundle]; + NSString *respath = [bundle resourcePath]; + NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid]; + NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath]; + DWButton *button = _button_new("", resid); + [button setImage:image]; + //[button setBezelStyle:0]; + [button setButtonType:NSMomentaryLight]; + [button setBordered:NO]; + [bundle release]; + [respath release]; + [filepath release]; + [image release]; + return button; } /* @@ -2314,6 +2326,7 @@ NSArray *newrow = [NSArray arrayWithObject:nstr]; [cont addRow:newrow]; + [cont reloadData]; [newrow release]; } @@ -2377,6 +2390,7 @@ [newrow release]; } + [cont reloadData]; } } @@ -2400,6 +2414,7 @@ DWContainer *cont = handle; [cont clear]; + [cont reloadData]; } } @@ -2502,6 +2517,7 @@ NSString *nstr = [ NSString stringWithUTF8String:buffer ]; [cont editCell:nstr at:index and:0]; + [cont reloadData]; } } @@ -2605,6 +2621,7 @@ DWContainer *cont = handle; [cont removeRow:index]; + [cont reloadData]; } } @@ -3551,7 +3568,11 @@ void API dw_container_clear(HWND handle, int redraw) { DWContainer *cont = handle; - return [cont clear]; + [cont clear]; + if(redraw) + { + [cont reloadData]; + } } /* @@ -3878,10 +3899,26 @@ * Returns: * A handle to a pixmap or NULL on failure. */ -HPIXMAP API dw_pixmap_grab(HWND handle, ULONG id) -{ - NSLog(@"dw_pixmap_grab() unimplemented\n"); - return HWND_DESKTOP; +HPIXMAP API dw_pixmap_grab(HWND handle, ULONG resid) +{ + HPIXMAP pixmap; + + if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) + return NULL; + + NSBundle *bundle = [NSBundle mainBundle]; + NSString *respath = [bundle resourcePath]; + NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid]; + NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath]; + NSSize size = [image size]; + pixmap->width = size.width; + pixmap->height = size.height; + pixmap->handle = image; + [bundle release]; + [respath release]; + [filepath release]; + [image release]; + return pixmap; } /*