diff mac/dw.c @ 437:903fb3085d42

More MacOS fixes, make install now works properly. Made special test #ifdef in dwtest so I can test some things as I proceed with the MacOS port.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 28 May 2003 08:00:11 +0000
parents f225f16bebbd
children b559c06a76c2
line wrap: on
line diff
--- a/mac/dw.c	Wed May 28 04:52:34 2003 +0000
+++ b/mac/dw.c	Wed May 28 08:00:11 2003 +0000
@@ -558,6 +558,30 @@
 	}
 }
 
+/* Main MacOS Message loop, all events are handled here. */
+void _doEvents(EventRecord *eventStrucPtr)
+{
+    SignalHandler *tmp = Root;
+    
+    while(tmp)
+    {
+        if(tmp->message == eventStrucPtr->what)
+        {
+            switch(eventStrucPtr->what)
+            {
+            case mouseDown:
+                break;
+            case mouseUp:
+                break;
+            case keyDown:
+                break;
+            }
+        }
+        if(tmp)
+            tmp = tmp->next;
+    }
+}
+
 /*
  * Initializes the Dynamic Windows engine.
  * Parameters:
@@ -574,6 +598,14 @@
  */
 void API dw_main(void)
 {
+    EventRecord eventStructure;
+    int gDone = false;
+    
+    while(!gDone)
+    {
+        if(WaitNextEvent(everyEvent, &eventStructure, 180, 0))
+            _doEvents(&eventStructure);
+    }
 }
 
 /*
@@ -583,6 +615,14 @@
  */
 void API dw_main_sleep(int milliseconds)
 {
+    double start = (double)clock();
+
+    while(((clock() - start) / (CLOCKS_PER_SEC/1000)) <= milliseconds)
+    {
+        EventRecord eventStructure;
+        if(WaitNextEvent(everyEvent, &eventStructure, 1, 0))
+            _doEvents(&eventStructure);
+    }
 }
 
 /*
@@ -590,6 +630,10 @@
  */
 void API dw_main_iteration(void)
 {
+    EventRecord eventStructure;
+    
+    if(WaitNextEvent(everyEvent, &eventStructure, 0, 0))
+            _doEvents(&eventStructure);
 }
 
 /*
@@ -1035,7 +1079,9 @@
 HWND API dw_text_new(char *text, ULONG id)
 {
     HWND hwnd = 0;
-    CreateStaticTextControl (CreationWindow, &CreationRect, text, NULL, &hwnd);
+    CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS);
+    CreateStaticTextControl (CreationWindow, &CreationRect, cftext, NULL, &hwnd);
+    CFRelease(cftext);
     return hwnd;
 }
 
@@ -1048,7 +1094,9 @@
 HWND API dw_status_text_new(char *text, ULONG id)
 {
     HWND hwnd = 0;
-    CreateStaticTextControl (CreationWindow, &CreationRect, text, NULL, &hwnd);
+    CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS);
+    CreateStaticTextControl (CreationWindow, &CreationRect, cftext, NULL, &hwnd);
+    CFRelease(cftext);
     return hwnd;
 }
 
@@ -1073,7 +1121,9 @@
 HWND API dw_entryfield_new(char *text, ULONG id)
 {
     HWND hwnd = 0;
-    CreateEditTextControl(CreationWindow, &CreationRect, text, FALSE, FALSE, NULL, &hwnd);
+    CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS);
+    CreateEditTextControl(CreationWindow, &CreationRect, cftext, FALSE, FALSE, NULL, &hwnd);
+    CFRelease(cftext);
     return hwnd;
 }
 
@@ -1086,7 +1136,9 @@
 HWND API dw_entryfield_password_new(char *text, ULONG id)
 {
     HWND hwnd = 0;
-    CreateEditTextControl(CreationWindow, &CreationRect, text, TRUE, FALSE, NULL, &hwnd);
+    CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS);
+    CreateEditTextControl(CreationWindow, &CreationRect, cftext, TRUE, FALSE, NULL, &hwnd);
+    CFRelease(cftext);
     return hwnd;
 }
 
@@ -1110,7 +1162,9 @@
 HWND API dw_button_new(char *text, ULONG id)
 {
     HWND hwnd = 0;
-    CreatePushButtonControl(CreationWindow, &CreationRect, text, &hwnd);
+    CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS);
+    CreatePushButtonControl(CreationWindow, &CreationRect, cftext, &hwnd);
+    CFRelease(cftext);
     return hwnd;
 }
 
@@ -1161,7 +1215,9 @@
 HWND API dw_radiobutton_new(char *text, ULONG id)
 {
     HWND hwnd = 0;
-    CreateRadioButtonControl(CreationWindow, &CreationRect, text, 0, FALSE, &hwnd);
+    CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS);
+    CreateRadioButtonControl(CreationWindow, &CreationRect, cftext, 0, FALSE, &hwnd);
+    CFRelease(cftext);
     return hwnd;
 }
 
@@ -1215,7 +1271,9 @@
 HWND API dw_checkbox_new(char *text, ULONG id)
 {
     HWND hwnd = 0;
-    CreateCheckBoxControl(CreationWindow, &CreationRect, text, 0, TRUE, &hwnd);
+    CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS);
+    CreateCheckBoxControl(CreationWindow, &CreationRect, cftext, 0, TRUE, &hwnd);
+    CFRelease(cftext);
     return hwnd;
 }
 
@@ -1264,7 +1322,9 @@
  */
 void API dw_window_set_text(HWND handle, char *text)
 {
-	SetControlTitleWithCFString(handle, text);
+    CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS);
+    SetControlTitleWithCFString(handle, cftext);
+    CFRelease(cftext);
 }
 
 /*
@@ -2641,16 +2701,23 @@
 void API dw_environment_query(DWEnv *env)
 {
 	ULONG Build;
+        char verbuf[10];
 
 	if(!env)
 		return;
 
+        Gestalt(gestaltSystemVersion, &Build);
+        
+        sprintf(verbuf, "%04x", Build);
+        
 	strcpy(env->osName,"MacOS");
-	env->MajorVersion = 10;
-	env->MinorVersion = 0;
+	env->MajorBuild = atoi(&verbuf[3]);
+        verbuf[3] = 0;
+	env->MinorVersion = atoi(&verbuf[2]);
+        verbuf[2] = 0;
+	env->MajorVersion = atoi(verbuf);
 
 	env->MinorBuild = 0;
-	env->MajorBuild = 0;
 
 	strcpy(env->buildDate, __DATE__);
 	strcpy(env->buildTime, __TIME__);