changeset 441:b559c06a76c2

Implemented more functionality on MacOS and include the platform define in the dw-config C flags.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 30 May 2003 00:47:47 +0000
parents 9af47c551a56
children 7c8bd3bc6c27
files compat.c dw-config.in dw.h mac/dw.c
diffstat 4 files changed, 74 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/compat.c	Thu May 29 18:38:49 2003 +0000
+++ b/compat.c	Fri May 30 00:47:47 2003 +0000
@@ -22,7 +22,7 @@
 #endif
 #include <time.h>
 
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__MAC__)
 void msleep(long period)
 {
 #ifdef __sun__
--- a/dw-config.in	Thu May 29 18:38:49 2003 +0000
+++ b/dw-config.in	Fri May 30 00:47:47 2003 +0000
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 dw_libs="@LIBS@"
-dw_cflags="@CFLAGS@"
+dw_cflags="@CFLAGS@ -D@DW_DEFINE@"
 
 prefix=@prefix@
 exec_prefix=@exec_prefix@
--- a/dw.h	Thu May 29 18:38:49 2003 +0000
+++ b/dw.h	Fri May 30 00:47:47 2003 +0000
@@ -216,8 +216,6 @@
 typedef HMODULE HMOD;
 typedef unsigned short UWORD;
 
-#define DW_NOMENU NULLHANDLE
-
 extern HAB dwhab;
 extern HMQ dwhmq;
 #endif
@@ -308,19 +306,23 @@
 
 #define DW_MLE_CASESENSITIVE     MLFSEARCH_CASESENSITIVE
 
-#define DW_POINTER_ARROW         SPTR_ARROW
-#define DW_POINTER_CLOCK         SPTR_WAIT
+#define DW_POINTER_ARROW         0
+#define DW_POINTER_CLOCK         watchCursor
+
+#define HWND_DESKTOP		 ((HWND)0)
 
 /* flag values for dw_messagebox() */
-#define DW_MB_OK                 MB_OK
-#define DW_MB_OKCANCEL           MB_OKCANCEL
-#define DW_MB_YESNO              MB_YESNO
-#define DW_MB_YESNOCANCEL        MB_YESNOCANCEL
+#define DW_MB_OK                 (1 << 1)
+#define DW_MB_OKCANCEL           (1 << 2)
+#define DW_MB_YESNO              (1 << 3)
+#define DW_MB_YESNOCANCEL        (1 << 4)
 
-#define DW_MB_WARNING            MB_WARNING
-#define DW_MB_ERROR              MB_ERROR
-#define DW_MB_INFORMATION        MB_INFORMATION
-#define DW_MB_QUESTION           MB_QUERY
+#define DW_MB_WARNING            (1 << 10)
+#define DW_MB_ERROR              (1 << 11)
+#define DW_MB_INFORMATION        (1 << 12)
+#define DW_MB_QUESTION           (1 << 13)
+
+
 #endif
 
 /* Windows specific section */
@@ -461,8 +463,6 @@
 } *HPIXMAP;
 
 typedef HWND HMENUI;
-
-#define DW_NOMENU NULL
 #endif
 
 typedef struct _item {
@@ -726,8 +726,6 @@
 typedef GtkWidget *HMENUI;
 typedef void *HTREEITEM;
 
-#define DW_NOMENU NULL
-
 typedef struct _resource_struct {
 	long resource_max, *resource_id;
 	char **resource_data;
@@ -833,6 +831,7 @@
 #define DW_RGB(a, b, c) (0xF0000000 | a | b << 8 | c << 16)
 
 #define DW_MENU_SEPARATOR ""
+#define DW_NOMENU 0
 
 #if defined(__OS2__) || defined(__EMX__)
 #define DW_OS2_RGB(a) ((DW_RED_VALUE(a) << 16) | (DW_GREEN_VALUE(a) << 8) | DW_BLUE_VALUE(a))
--- a/mac/dw.c	Thu May 29 18:38:49 2003 +0000
+++ b/mac/dw.c	Fri May 30 00:47:47 2003 +0000
@@ -688,16 +688,14 @@
  */
 void * API dw_dialog_wait(DWDialog *dialog)
 {
-	void *tmp;
-
-#if 0
-	while (WinGetMsg(dwhab, &qmsg, 0, 0, 0))
-	{
-		WinDispatchMsg(dwhab, &qmsg);
-		if(dialog->done)
-			break;
-	}
-#endif
+        void *tmp;
+        EventRecord eventStructure;
+    
+        while(!dialog->done)
+        {
+            if(WaitNextEvent(everyEvent, &eventStructure, 180, 0))
+                _doEvents(&eventStructure);
+        }
 	dw_event_close(&dialog->eve);
 	tmp = dialog->result;
 	free(dialog);
@@ -716,16 +714,58 @@
 {
 	va_list args;
 	char outbuf[1024];
+        AlertStdCFStringAlertParamRec param;
+        DialogRef dialog;
+        CFStringRef cftext, cftitle;
+        DialogItemIndex item;
+        int ret = DW_MB_RETURN_OK;
+        AlertType alert = kAlertPlainAlert;
 
 	va_start(args, format);
 	vsprintf(outbuf, format, args);
 	va_end(args);
-
-#if 0
-	WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, outbuf, title, 0, MB_OK | MB_INFORMATION | MB_MOVEABLE);
-#endif
-
-	return strlen(outbuf);
+        
+        GetStandardAlertDefaultParams(&param, kStdCFStringAlertVersionOne);
+        param.movable = TRUE;
+        param.helpButton = FALSE;
+        if(flags & DW_MB_INFORMATION)
+            alert = kAlertNoteAlert;
+        else if(flags & DW_MB_ERROR)
+            alert = kAlertStopAlert;
+        else if(flags & DW_MB_WARNING)
+            alert = kAlertCautionAlert;
+            
+        if(flags & DW_MB_OK || flags & DW_MB_OKCANCEL)
+        {
+            param.defaultText = CFSTR("Ok");
+            param.cancelText = flags & DW_MB_OK ? 0 : CFSTR("Cancel");
+        }
+        else
+        {
+            param.defaultText = CFSTR("Yes");
+            param.cancelText = CFSTR("No");
+            param.otherText = CFSTR("Cancel");
+        }
+        cftext = CFStringCreateWithCString(NULL, outbuf, kCFStringEncodingDOSLatinUS);
+        cftitle = CFStringCreateWithCString(NULL, title, kCFStringEncodingDOSLatinUS);
+        if(CreateStandardAlert(alert, cftext, cftitle, &param, &dialog) == noErr)
+        {
+            if(RunStandardAlert(dialog, NULL, &item) == noErr)
+            {
+                if(item == kAlertStdAlertOtherButton)
+                    ret = DW_MB_RETURN_CANCEL;
+                else if(item == kAlertStdAlertCancelButton)
+                {
+                    if(flags & DW_MB_OK || flags & DW_MB_OKCANCEL)
+                        ret = DW_MB_RETURN_CANCEL;
+                    else
+                        ret = DW_MB_RETURN_NO;
+                }
+            }
+        }
+        CFRelease(cftext);
+        CFRelease(cftitle);
+        return ret;
 }
 
 /*
@@ -873,6 +913,7 @@
  */
 void API dw_window_pointer(HWND handle, int pointertype)
 {
+    SetCursor(*GetCursor(pointertype));
 }
 
 /*