Mercurial > dwindows
comparison mac/dw.m @ 655:27eb39d2577b
Calendar and HTML functions filled in.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 23 Feb 2011 19:41:25 +0000 |
parents | 80e253df49fd |
children | 6c8b95ca877b |
comparison
equal
deleted
inserted
replaced
654:80e253df49fd | 655:27eb39d2577b |
---|---|
433 @implementation DWMLE | 433 @implementation DWMLE |
434 -(void *)userdata { return userdata; } | 434 -(void *)userdata { return userdata; } |
435 -(void)setUserdata:(void *)input { userdata = input; } | 435 -(void)setUserdata:(void *)input { userdata = input; } |
436 @end | 436 @end |
437 | 437 |
438 /* Subclass for a MLE type */ | 438 /* Subclass for a Container/List type */ |
439 @interface DWContainer : NSTableView | 439 @interface DWContainer : NSTableView |
440 { | 440 { |
441 void *userdata; | 441 void *userdata; |
442 } | 442 } |
443 -(void *)userdata; | 443 -(void *)userdata; |
444 -(void)setUserdata:(void *)input; | 444 -(void)setUserdata:(void *)input; |
445 @end | 445 @end |
446 | 446 |
447 @implementation DWContainer | 447 @implementation DWContainer |
448 -(void *)userdata { return userdata; } | |
449 -(void)setUserdata:(void *)input { userdata = input; } | |
450 @end | |
451 | |
452 /* Subclass for a Container/List type */ | |
453 @interface DWCalendar : NSDatePicker | |
454 { | |
455 void *userdata; | |
456 } | |
457 -(void *)userdata; | |
458 -(void)setUserdata:(void *)input; | |
459 @end | |
460 | |
461 @implementation DWCalendar | |
448 -(void *)userdata { return userdata; } | 462 -(void *)userdata { return userdata; } |
449 -(void)setUserdata:(void *)input { userdata = input; } | 463 -(void)setUserdata:(void *)input { userdata = input; } |
450 @end | 464 @end |
451 | 465 |
452 typedef struct | 466 typedef struct |
3107 * text: The text to be display by the static text widget. | 3121 * text: The text to be display by the static text widget. |
3108 * id: An ID to be used with dw_window_from_id() or 0L. | 3122 * id: An ID to be used with dw_window_from_id() or 0L. |
3109 */ | 3123 */ |
3110 HWND API dw_calendar_new(ULONG id) | 3124 HWND API dw_calendar_new(ULONG id) |
3111 { | 3125 { |
3112 NSLog(@"dw_calendar_new() unimplemented\n"); | 3126 DWCalendar *calendar = [[DWCalendar alloc] init]; |
3113 return HWND_DESKTOP; | 3127 /*[calendar setDatePickerMode:UIDatePickerModeDate];*/ |
3128 return calendar; | |
3114 } | 3129 } |
3115 | 3130 |
3116 /* | 3131 /* |
3117 * Sets the current date of a calendar | 3132 * Sets the current date of a calendar |
3118 * Parameters: | 3133 * Parameters: |
3119 * handle: The handle to the calendar returned by dw_calendar_new(). | 3134 * handle: The handle to the calendar returned by dw_calendar_new(). |
3120 * year... | 3135 * year... |
3121 */ | 3136 */ |
3122 void dw_calendar_set_date(HWND handle, unsigned int year, unsigned int month, unsigned int day) | 3137 void dw_calendar_set_date(HWND handle, unsigned int year, unsigned int month, unsigned int day) |
3123 { | 3138 { |
3124 NSLog(@"dw_calendar_set_date() unimplemented\n"); | 3139 DWCalendar *calendar = handle; |
3140 NSDate *date; | |
3141 char buffer[100]; | |
3142 | |
3143 sprintf(buffer, "%04d-%02d-%02d 00:00:00 +0600", year, month, day); | |
3144 | |
3145 date = [[NSDate alloc] initWithString:[ NSString stringWithUTF8String:buffer ]]; | |
3146 [calendar setDateValue:date]; | |
3125 } | 3147 } |
3126 | 3148 |
3127 /* | 3149 /* |
3128 * Gets the position of a splitbar (pecentage). | 3150 * Gets the position of a splitbar (pecentage). |
3129 * Parameters: | 3151 * Parameters: |
3130 * handle: The handle to the splitbar returned by dw_splitbar_new(). | 3152 * handle: The handle to the splitbar returned by dw_splitbar_new(). |
3131 */ | 3153 */ |
3132 void dw_calendar_get_date(HWND handle, unsigned int *year, unsigned int *month, unsigned int *day) | 3154 void dw_calendar_get_date(HWND handle, unsigned int *year, unsigned int *month, unsigned int *day) |
3133 { | 3155 { |
3134 NSLog(@"dw_calendar_get_date() unimplemented\n"); | 3156 DWCalendar *calendar = handle; |
3157 NSDate *date = [calendar dateValue]; | |
3158 NSDateFormatter *df = [[NSDateFormatter alloc] init]; | |
3159 NSString *nstr = [df stringFromDate:date]; | |
3160 sscanf([ nstr UTF8String ], "%d-%d-%d", year, month, day); | |
3135 } | 3161 } |
3136 | 3162 |
3137 /* | 3163 /* |
3138 * Causes the embedded HTML widget to take action. | 3164 * Causes the embedded HTML widget to take action. |
3139 * Parameters: | 3165 * Parameters: |
3140 * handle: Handle to the window. | 3166 * handle: Handle to the window. |
3141 * action: One of the DW_HTML_* constants. | 3167 * action: One of the DW_HTML_* constants. |
3142 */ | 3168 */ |
3143 void API dw_html_action(HWND handle, int action) | 3169 void API dw_html_action(HWND handle, int action) |
3144 { | 3170 { |
3145 NSLog(@"dw_html_action() unimplemented\n"); | 3171 WebView *html = handle; |
3172 switch(action) | |
3173 { | |
3174 case DW_HTML_GOBACK: | |
3175 [html goBack]; | |
3176 break; | |
3177 case DW_HTML_GOFORWARD: | |
3178 [html goForward]; | |
3179 break; | |
3180 case DW_HTML_GOHOME: | |
3181 break; | |
3182 case DW_HTML_SEARCH: | |
3183 break; | |
3184 case DW_HTML_RELOAD: | |
3185 [html reload:html]; | |
3186 break; | |
3187 case DW_HTML_STOP: | |
3188 [html stopLoading:html]; | |
3189 break; | |
3190 case DW_HTML_PRINT: | |
3191 break; | |
3192 } | |
3146 } | 3193 } |
3147 | 3194 |
3148 /* | 3195 /* |
3149 * Render raw HTML code in the embedded HTML widget.. | 3196 * Render raw HTML code in the embedded HTML widget.. |
3150 * Parameters: | 3197 * Parameters: |
3397 void API dw_menu_item_set_state(HMENUI menux, unsigned long itemid, unsigned long state) | 3444 void API dw_menu_item_set_state(HMENUI menux, unsigned long itemid, unsigned long state) |
3398 { | 3445 { |
3399 id menu = menux; | 3446 id menu = menux; |
3400 NSMenuItem *menuitem = (NSMenuItem *)[menu itemWithTag:itemid]; | 3447 NSMenuItem *menuitem = (NSMenuItem *)[menu itemWithTag:itemid]; |
3401 | 3448 |
3402 NSLog(@"MenuItem: %x", menuitem); | |
3403 if(menuitem != nil) | 3449 if(menuitem != nil) |
3404 { | 3450 { |
3405 if(state & DW_MIS_CHECKED) | 3451 if(state & DW_MIS_CHECKED) |
3406 { | 3452 { |
3407 [menuitem setState:NSOnState]; | 3453 [menuitem setState:NSOnState]; |