# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1298493950 0 # Node ID 6c8b95ca877b8c2129c21bf54d949b9605faafed # Parent 27eb39d2577ba2d5c056f83e89c4cdcbc557d979 Comboboxes implemented. diff -r 27eb39d2577b -r 6c8b95ca877b mac/dw.m --- a/mac/dw.m Wed Feb 23 19:41:25 2011 +0000 +++ b/mac/dw.m Wed Feb 23 20:45:50 2011 +0000 @@ -449,7 +449,7 @@ -(void)setUserdata:(void *)input { userdata = input; } @end -/* Subclass for a Container/List type */ +/* Subclass for a Calendar type */ @interface DWCalendar : NSDatePicker { void *userdata; @@ -463,6 +463,20 @@ -(void)setUserdata:(void *)input { userdata = input; } @end +/* Subclass for a Combobox type */ +@interface DWComboBox : NSComboBox +{ + void *userdata; +} +-(void *)userdata; +-(void)setUserdata:(void *)input; +@end + +@implementation DWComboBox +-(void *)userdata { return userdata; } +-(void)setUserdata:(void *)input { userdata = input; } +@end + typedef struct { ULONG message; @@ -1883,8 +1897,12 @@ */ int API dw_checkbox_get(HWND handle) { - NSLog(@"dw_checkbox_set() unimplemented\n"); - return 0; + DWButton *button = handle; + if([button state]) + { + return TRUE; + } + return FALSE; } /* @@ -1895,7 +1913,16 @@ */ void API dw_checkbox_set(HWND handle, int value) { - NSLog(@"dw_checkbox_set() unimplemented\n"); + DWButton *button = handle; + if(value) + { + [button setState:NSOnState]; + } + else + { + [button setState:NSOffState]; + } + } /* @@ -1918,7 +1945,14 @@ */ void API dw_listbox_append(HWND handle, char *text) { - NSLog(@"dw_listbox_append() unimplemented\n"); + id object = handle; + + if([object isMemberOfClass:[DWComboBox class]]) + { + DWComboBox *combo = handle; + + [combo addItemWithObjectValue:[ NSString stringWithUTF8String:text ]]; + } } /* @@ -1930,7 +1964,14 @@ */ void API dw_listbox_insert(HWND handle, char *text, int pos) { - NSLog(@"dw_listbox_insert() unimplemented\n"); + id object = handle; + + if([object isMemberOfClass:[DWComboBox class]]) + { + DWComboBox *combo = handle; + + [combo insertItemWithObjectValue:[ NSString stringWithUTF8String:text ] atIndex:pos]; + } } /* @@ -1942,7 +1983,18 @@ */ void API dw_listbox_list_append(HWND handle, char **text, int count) { - NSLog(@"dw_listbox_list_append() unimplemented\n"); + id object = handle; + + if([object isMemberOfClass:[DWComboBox class]]) + { + DWComboBox *combo = handle; + int z; + + for(z=0;z