comparison mac/dw.m @ 729:6712e4211522

Switched to graphical calendar control style... and fixed date querying code. There is probably a better way to do this but it works for now.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 15 Mar 2011 00:45:27 +0000
parents 55f22b39ab57
children d3fb3613726a
comparison
equal deleted inserted replaced
728:55f22b39ab57 729:6712e4211522
5029 * text: The text to be display by the static text widget. 5029 * text: The text to be display by the static text widget.
5030 * id: An ID to be used with dw_window_from_id() or 0L. 5030 * id: An ID to be used with dw_window_from_id() or 0L.
5031 */ 5031 */
5032 HWND API dw_calendar_new(ULONG cid) 5032 HWND API dw_calendar_new(ULONG cid)
5033 { 5033 {
5034 DWCalendar *calendar = [[DWCalendar alloc] init]; 5034 DWCalendar *calendar = [[DWCalendar alloc] init];
5035 /*[calendar setDatePickerMode:UIDatePickerModeDate];*/ 5035 [calendar setDatePickerMode:NSSingleDateMode];
5036 [calendar setDatePickerStyle:NSClockAndCalendarDatePickerStyle];
5037 [calendar setDatePickerElements:NSYearMonthDayDatePickerElementFlag];
5036 [calendar setTag:cid]; 5038 [calendar setTag:cid];
5037 return calendar; 5039 return calendar;
5038 } 5040 }
5039 5041
5040 /* 5042 /*
5041 * Sets the current date of a calendar 5043 * Sets the current date of a calendar
5042 * Parameters: 5044 * Parameters:
5043 * handle: The handle to the calendar returned by dw_calendar_new(). 5045 * handle: The handle to the calendar returned by dw_calendar_new().
5044 * year... 5046 * year...
5045 */ 5047 */
5046 void dw_calendar_set_date(HWND handle, unsigned int year, unsigned int month, unsigned int day) 5048 void dw_calendar_set_date(HWND handle, unsigned int year, unsigned int month, unsigned int day)
5047 { 5049 {
5048 DWCalendar *calendar = handle; 5050 DWCalendar *calendar = handle;
5049 NSDate *date; 5051 NSDate *date;
5050 char buffer[100]; 5052 char buffer[100];
5051 5053
5052 sprintf(buffer, "%04d-%02d-%02d 00:00:00 +0600", year, month, day); 5054 sprintf(buffer, "%04d-%02d-%02d 00:00:00 +0600", year, month, day);
5053 5055
5054 date = [[NSDate alloc] initWithString:[ NSString stringWithUTF8String:buffer ]]; 5056 date = [[NSDate alloc] initWithString:[ NSString stringWithUTF8String:buffer ]];
5055 [calendar setDateValue:date]; 5057 [calendar setDateValue:date];
5056 [date release]; 5058 [date release];
5057 } 5059 }
5058 5060
5059 /* 5061 /*
5060 * Gets the position of a splitbar (pecentage). 5062 * Gets the position of a splitbar (pecentage).
5061 * Parameters: 5063 * Parameters:
5062 * handle: The handle to the splitbar returned by dw_splitbar_new(). 5064 * handle: The handle to the splitbar returned by dw_splitbar_new().
5063 */ 5065 */
5064 void dw_calendar_get_date(HWND handle, unsigned int *year, unsigned int *month, unsigned int *day) 5066 void dw_calendar_get_date(HWND handle, unsigned int *year, unsigned int *month, unsigned int *day)
5065 { 5067 {
5066 DWCalendar *calendar = handle; 5068 DWCalendar *calendar = handle;
5067 NSDate *date = [calendar dateValue]; 5069 NSDate *date = [calendar dateValue];
5068 NSDateFormatter *df = [[NSDateFormatter alloc] init]; 5070 NSDateFormatter *df = [[NSDateFormatter alloc] init];
5069 NSString *nstr = [df stringFromDate:date]; 5071 [df setDateStyle:NSDateFormatterShortStyle];
5070 sscanf([ nstr UTF8String ], "%d-%d-%d", year, month, day); 5072 NSString *nstr = [df stringFromDate:date];
5073 sscanf([ nstr UTF8String ], "%d/%d/%d", month, day, year);
5071 [df release]; 5074 [df release];
5072 } 5075 }
5073 5076
5074 /* 5077 /*
5075 * Causes the embedded HTML widget to take action. 5078 * Causes the embedded HTML widget to take action.