comparison mac/dw.m @ 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
comparison
equal deleted inserted replaced
669:62aae18e7b7d 670:0b920d0dc13e
1973 * Create a new bitmap button window (widget) to be packed. 1973 * Create a new bitmap button window (widget) to be packed.
1974 * Parameters: 1974 * Parameters:
1975 * text: Bubble help text to be displayed. 1975 * text: Bubble help text to be displayed.
1976 * id: An ID of a bitmap in the resource file. 1976 * id: An ID of a bitmap in the resource file.
1977 */ 1977 */
1978 HWND API dw_bitmapbutton_new(char *text, ULONG id) 1978 HWND API dw_bitmapbutton_new(char *text, ULONG resid)
1979 { 1979 {
1980 NSLog(@"dw_bitmapbutton_new() unimplemented\n"); 1980 NSBundle *bundle = [NSBundle mainBundle];
1981 return HWND_DESKTOP; 1981 NSString *respath = [bundle resourcePath];
1982 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid];
1983 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath];
1984 DWButton *button = _button_new("", resid);
1985 [button setImage:image];
1986 //[button setBezelStyle:0];
1987 [button setButtonType:NSMomentaryLight];
1988 [button setBordered:NO];
1989 [bundle release];
1990 [respath release];
1991 [filepath release];
1992 [image release];
1993 return button;
1982 } 1994 }
1983 1995
1984 /* 1996 /*
1985 * Create a new bitmap button window (widget) to be packed from a file. 1997 * Create a new bitmap button window (widget) to be packed from a file.
1986 * Parameters: 1998 * Parameters:
2312 DWContainer *cont = handle; 2324 DWContainer *cont = handle;
2313 NSString *nstr = [ NSString stringWithUTF8String:text ]; 2325 NSString *nstr = [ NSString stringWithUTF8String:text ];
2314 NSArray *newrow = [NSArray arrayWithObject:nstr]; 2326 NSArray *newrow = [NSArray arrayWithObject:nstr];
2315 2327
2316 [cont addRow:newrow]; 2328 [cont addRow:newrow];
2329 [cont reloadData];
2317 2330
2318 [newrow release]; 2331 [newrow release];
2319 } 2332 }
2320 } 2333 }
2321 2334
2375 2388
2376 [cont addRow:newrow]; 2389 [cont addRow:newrow];
2377 2390
2378 [newrow release]; 2391 [newrow release];
2379 } 2392 }
2393 [cont reloadData];
2380 } 2394 }
2381 } 2395 }
2382 2396
2383 /* 2397 /*
2384 * Clears the listbox's (or combobox) list of all entries. 2398 * Clears the listbox's (or combobox) list of all entries.
2398 else if([object isMemberOfClass:[DWContainer class]]) 2412 else if([object isMemberOfClass:[DWContainer class]])
2399 { 2413 {
2400 DWContainer *cont = handle; 2414 DWContainer *cont = handle;
2401 2415
2402 [cont clear]; 2416 [cont clear];
2417 [cont reloadData];
2403 } 2418 }
2404 } 2419 }
2405 2420
2406 /* 2421 /*
2407 * Returns the listbox's item count. 2422 * Returns the listbox's item count.
2500 { 2515 {
2501 DWContainer *cont = handle; 2516 DWContainer *cont = handle;
2502 NSString *nstr = [ NSString stringWithUTF8String:buffer ]; 2517 NSString *nstr = [ NSString stringWithUTF8String:buffer ];
2503 2518
2504 [cont editCell:nstr at:index and:0]; 2519 [cont editCell:nstr at:index and:0];
2520 [cont reloadData];
2505 } 2521 }
2506 2522
2507 } 2523 }
2508 2524
2509 /* 2525 /*
2603 else if([object isMemberOfClass:[DWContainer class]]) 2619 else if([object isMemberOfClass:[DWContainer class]])
2604 { 2620 {
2605 DWContainer *cont = handle; 2621 DWContainer *cont = handle;
2606 2622
2607 [cont removeRow:index]; 2623 [cont removeRow:index];
2624 [cont reloadData];
2608 } 2625 }
2609 } 2626 }
2610 2627
2611 /* 2628 /*
2612 * Create a new Combobox window (widget) to be packed. 2629 * Create a new Combobox window (widget) to be packed.
3549 * redraw: TRUE to cause the container to redraw immediately. 3566 * redraw: TRUE to cause the container to redraw immediately.
3550 */ 3567 */
3551 void API dw_container_clear(HWND handle, int redraw) 3568 void API dw_container_clear(HWND handle, int redraw)
3552 { 3569 {
3553 DWContainer *cont = handle; 3570 DWContainer *cont = handle;
3554 return [cont clear]; 3571 [cont clear];
3572 if(redraw)
3573 {
3574 [cont reloadData];
3575 }
3555 } 3576 }
3556 3577
3557 /* 3578 /*
3558 * Removes the first x rows from a container. 3579 * Removes the first x rows from a container.
3559 * Parameters: 3580 * Parameters:
3876 * handle: Window handle the pixmap is associated with. 3897 * handle: Window handle the pixmap is associated with.
3877 * id: Resource ID associated with requested pixmap. 3898 * id: Resource ID associated with requested pixmap.
3878 * Returns: 3899 * Returns:
3879 * A handle to a pixmap or NULL on failure. 3900 * A handle to a pixmap or NULL on failure.
3880 */ 3901 */
3881 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG id) 3902 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG resid)
3882 { 3903 {
3883 NSLog(@"dw_pixmap_grab() unimplemented\n"); 3904 HPIXMAP pixmap;
3884 return HWND_DESKTOP; 3905
3906 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
3907 return NULL;
3908
3909 NSBundle *bundle = [NSBundle mainBundle];
3910 NSString *respath = [bundle resourcePath];
3911 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid];
3912 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath];
3913 NSSize size = [image size];
3914 pixmap->width = size.width;
3915 pixmap->height = size.height;
3916 pixmap->handle = image;
3917 [bundle release];
3918 [respath release];
3919 [filepath release];
3920 [image release];
3921 return pixmap;
3885 } 3922 }
3886 3923
3887 /* 3924 /*
3888 * Destroys an allocated pixmap. 3925 * Destroys an allocated pixmap.
3889 * Parameters: 3926 * Parameters: