Mercurial > dwindows
changeset 670:0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
Fixes for listboxes not immediately redrawing when updated.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 27 Feb 2011 08:18:20 +0000 |
parents | 62aae18e7b7d |
children | c60a4f6cfae8 |
files | mac/dw.m |
diffstat | 1 files changed, 46 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- 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; } /*