changeset 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
files mac/dw.m
diffstat 1 files changed, 53 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mac/dw.m	Wed Feb 23 18:51:15 2011 +0000
+++ b/mac/dw.m	Wed Feb 23 19:41:25 2011 +0000
@@ -435,7 +435,7 @@
 -(void)setUserdata:(void *)input { userdata = input; }
 @end
 
-/* Subclass for a MLE type */
+/* Subclass for a Container/List type */
 @interface DWContainer : NSTableView 
 {
 	void *userdata;
@@ -449,6 +449,20 @@
 -(void)setUserdata:(void *)input { userdata = input; }
 @end
 
+/* Subclass for a Container/List type */
+@interface DWCalendar : NSDatePicker 
+{
+	void *userdata;
+}
+-(void *)userdata;
+-(void)setUserdata:(void *)input;
+@end
+
+@implementation DWCalendar
+-(void *)userdata { return userdata; }
+-(void)setUserdata:(void *)input { userdata = input; }
+@end
+
 typedef struct
 {
 	ULONG message;
@@ -3109,8 +3123,9 @@
  */
 HWND API dw_calendar_new(ULONG id)
 {
-	NSLog(@"dw_calendar_new() unimplemented\n");
-	return HWND_DESKTOP;
+	DWCalendar *calendar = [[DWCalendar alloc] init];
+	/*[calendar setDatePickerMode:UIDatePickerModeDate];*/
+	return calendar;
 }
 
 /*
@@ -3121,7 +3136,14 @@
  */
 void dw_calendar_set_date(HWND handle, unsigned int year, unsigned int month, unsigned int day)
 {
-	NSLog(@"dw_calendar_set_date() unimplemented\n");
+	DWCalendar *calendar = handle;
+	NSDate *date;
+	char buffer[100];
+	
+	sprintf(buffer, "%04d-%02d-%02d 00:00:00 +0600", year, month, day);
+	
+	date = [[NSDate alloc] initWithString:[ NSString stringWithUTF8String:buffer ]];
+	[calendar setDateValue:date];
 }
 
 /*
@@ -3131,7 +3153,11 @@
  */
 void dw_calendar_get_date(HWND handle, unsigned int *year, unsigned int *month, unsigned int *day)
 {
-	NSLog(@"dw_calendar_get_date() unimplemented\n");
+	DWCalendar *calendar = handle;
+	NSDate *date = [calendar dateValue];
+	NSDateFormatter *df = [[NSDateFormatter alloc] init];
+	NSString *nstr = [df stringFromDate:date];
+	sscanf([ nstr UTF8String ], "%d-%d-%d", year, month, day);
 }
 
 /*
@@ -3142,7 +3168,28 @@
  */
 void API dw_html_action(HWND handle, int action)
 {
-	NSLog(@"dw_html_action() unimplemented\n");
+	WebView *html = handle;
+	switch(action)
+	{
+		case DW_HTML_GOBACK:
+			[html goBack];
+			break;
+		case DW_HTML_GOFORWARD:
+			[html goForward];
+			break;
+		case DW_HTML_GOHOME:
+			break;
+		case DW_HTML_SEARCH:
+			break;
+		case DW_HTML_RELOAD:
+			[html reload:html];
+			break;
+		case DW_HTML_STOP:
+			[html stopLoading:html];
+			break;
+		case DW_HTML_PRINT:
+			break;
+	}
 }
 
 /*
@@ -3399,7 +3446,6 @@
 	id menu = menux;
 	NSMenuItem *menuitem = (NSMenuItem *)[menu itemWithTag:itemid];
 	
-	NSLog(@"MenuItem: %x", menuitem);
 	if(menuitem != nil)
 	{
 		if(state & DW_MIS_CHECKED)