changeset 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 98d6c00fe11e
children fac2afe7bda3
files Makefile.in dwtest.c mac/dw.c
diffstat 3 files changed, 96 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.in	Wed May 28 04:52:34 2003 +0000
+++ b/Makefile.in	Wed May 28 08:00:11 2003 +0000
@@ -85,11 +85,11 @@
 		$(INSTALL) $(SYSCONF_LINK_TARGET2) $(PREFIX)/lib; \
 		cd $(PREFIX)/lib; \
 		rm -f lib$(TARGET).so lib$(TARGET).so.$(VER_MAJ); \
-		ln -s $(SYSCONF_LINK_TARGET_SHARED)  lib$(TARGET).so; \
-		ln -s $(SYSCONF_LINK_TARGET_SHARED)  lib$(TARGET).so.$(VER_MAJ); \
-		rm -f lib$(TARGET2).so lib$(TARGET2).so.$(VER_MAJ); \
-		ln -s $(SYSCONF_LINK_TARGET_SHARED2) lib$(TARGET2).so; \
-		ln -s $(SYSCONF_LINK_TARGET_SHARED2) lib$(TARGET2).so.$(VER_MAJ)
+		ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).$(SOSUFFIX); \
+		ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).$(SOSUFFIX).$(VER_MAJ); \
+		rm -f lib$(TARGET2).$(SOSUFFIX) lib$(TARGET2).$(SOSUFFIX).$(VER_MAJ); \
+		ln -s $(SYSCONF_LINK_TARGET_SHARED2) lib$(TARGET2).$(SOSUFFIX); \
+		ln -s $(SYSCONF_LINK_TARGET_SHARED2) lib$(TARGET2).$(SOSUFFIX).$(VER_MAJ)
                 
 clean:
 	rm -f *.so
--- a/dwtest.c	Wed May 28 04:52:34 2003 +0000
+++ b/dwtest.c	Wed May 28 08:00:11 2003 +0000
@@ -27,6 +27,18 @@
 unsigned long flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR |
 	DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER;
 
+#ifdef __MAC__
+int main(int argc, char *argv[])
+{
+    DWEnv env;
+    
+    dw_environment_query(&env);
+    printf("Operating System: %s %d.%d\nBuild: %d.%d\n", env.osName, env.MajorVersion, env.MinorVersion, 
+            env.MajorBuild, env.MinorBuild);
+    return 0;
+}
+#else
+
 HWND mainwindow,
      entryfield,
      cursortogglebutton,
@@ -727,3 +739,4 @@
 
 	return 0;
 }
+#endif
--- 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__);