changeset 433:f225f16bebbd

Compile fixes for MacOS X.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 27 May 2003 21:43:49 +0000
parents 5f9f185e4aa0
children 062ed9ddf3af
files compat.c compat.h dw.h mac/dw.c
diffstat 4 files changed, 139 insertions(+), 199 deletions(-) [+]
line wrap: on
line diff
--- a/compat.c	Tue May 27 21:27:26 2003 +0000
+++ b/compat.c	Tue May 27 21:43:49 2003 +0000
@@ -5,8 +5,8 @@
 #include <share.h>
 #endif
 
-#ifdef __UNIX__
-#ifdef __FreeBSD__
+#if defined(__UNIX__) || defined(__MAC__)
+#if defined(__FreeBSD__) || defined(__MAC__)
 #include <sys/param.h>
 #include <sys/ucred.h>
 #include <sys/mount.h>
@@ -235,7 +235,7 @@
 		return 0;
 
 	return (long double)((double)spc*(double)bps*(double)fc);
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__MAC__)
 	struct statfs *fsp;
 	int entries, index = 1;
 
@@ -332,7 +332,7 @@
 		return 0;
 
 	return (long double)((double)spc*(double)bps*(double)tc);
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__MAC__)
 	struct statfs *fsp;
 	int entries, index = 1;
 
@@ -426,7 +426,7 @@
 
 	if(GetVolumeInformation(buffer, volname, 100, &spc, &bps, &fc, NULL, 0) != 0)
 		return 1;
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__MAC__)
 	struct statfs *fsp;
 	int entries, index = 1;
 
@@ -495,8 +495,8 @@
 
 void API getfsname(int drive, char *buf, int len)
 {
-#ifdef __UNIX__
-#ifdef __FreeBSD__
+#if defined(__UNIX__) || defined(__MAC__) 
+#if defined(__FreeBSD__) || defined(__MAC__)
 	struct statfs *fsp;
 	int entries, index = 1;
 
--- a/compat.h	Tue May 27 21:27:26 2003 +0000
+++ b/compat.h	Tue May 27 21:43:49 2003 +0000
@@ -4,7 +4,7 @@
 #define _COMPAT_H
 
 /* This header includes and defines everything needed for a given OS/compiler */
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__MAC__)
 #include "config.h"
 
 #include <sys/stat.h>
--- a/dw.h	Tue May 27 21:27:26 2003 +0000
+++ b/dw.h	Tue May 27 21:43:49 2003 +0000
@@ -224,9 +224,20 @@
 
 #if defined(__MAC__)
 /* MacOS specific section */
-#include <carbon.h>
+#include <Carbon/Carbon.h>
 
 typedef ControlRef HWND;
+typedef ThreadID DWTID;
+typedef unsigned long ULONG;
+typedef long LONG;
+typedef unsigned short USHORT;
+typedef short SHORT;
+typedef unsigned short UWORD;
+typedef short WORD ;
+typedef unsigned char UCHAR;
+typedef char CHAR;
+typedef unsigned UINT;
+typedef int INT;
 typedef void *HMTX;
 typedef void *HEV;
 typedef void *HMOD;
@@ -234,6 +245,13 @@
 typedef void *HTREEITEM;
 typedef void *HMENUI;
 
+typedef struct _window_data {
+	UserData *root;
+	HWND clickdefault;
+	ULONG flags;
+	void *data;
+} WindowData;
+
 #define DW_DT_LEFT               0
 #define DW_DT_QUERYEXTENT        0
 #define DW_DT_UNDERSCORE         0
@@ -253,38 +271,38 @@
 #define DW_FCF_TITLEBAR          0
 #define DW_FCF_SYSMENU           0
 #define DW_FCF_MENU              0
-#define DW_FCF_SIZEBORDER        FCF_SIZEBORDER
-#define DW_FCF_MINBUTTON         FCF_MINBUTTON
-#define DW_FCF_MAXBUTTON         FCF_MAXBUTTON
-#define DW_FCF_MINMAX            FCF_MINMAX
-#define DW_FCF_VERTSCROLL        FCF_VERTSCROLL
-#define DW_FCF_HORZSCROLL        FCF_HORZSCROLL
-#define DW_FCF_DLGBORDER         FCF_DLGBORDER
-#define DW_FCF_BORDER            FCF_BORDER
-#define DW_FCF_SHELLPOSITION     FCF_SHELLPOSITION
-#define DW_FCF_TASKLIST          FCF_TASKLIST
-#define DW_FCF_NOBYTEALIGN       FCF_NOBYTEALIGN
-#define DW_FCF_NOMOVEWITHOWNER   FCF_NOMOVEWITHOWNER
-#define DW_FCF_SYSMODAL          FCF_SYSMODAL
-#define DW_FCF_HIDEBUTTON        FCF_HIDEBUTTON
-#define DW_FCF_HIDEMAX           FCF_HIDEMAX
-#define DW_FCF_AUTOICON          FCF_AUTOICON
+#define DW_FCF_SIZEBORDER        0
+#define DW_FCF_MINBUTTON         0
+#define DW_FCF_MAXBUTTON         0
+#define DW_FCF_MINMAX            0
+#define DW_FCF_VERTSCROLL        0
+#define DW_FCF_HORZSCROLL        0
+#define DW_FCF_DLGBORDER         0
+#define DW_FCF_BORDER            0
+#define DW_FCF_SHELLPOSITION     0
+#define DW_FCF_TASKLIST          0
+#define DW_FCF_NOBYTEALIGN       0
+#define DW_FCF_NOMOVEWITHOWNER   0
+#define DW_FCF_SYSMODAL          0
+#define DW_FCF_HIDEBUTTON        0
+#define DW_FCF_HIDEMAX           0
+#define DW_FCF_AUTOICON          0
 
-#define DW_CFA_BITMAPORICON      CFA_BITMAPORICON
-#define DW_CFA_STRING            CFA_STRING
-#define DW_CFA_ULONG             CFA_ULONG
-#define DW_CFA_TIME              CFA_TIME
-#define DW_CFA_DATE              CFA_DATE
-#define DW_CFA_CENTER            CFA_CENTER
-#define DW_CFA_LEFT              CFA_LEFT
-#define DW_CFA_RIGHT             CFA_RIGHT
-#define DW_CFA_HORZSEPARATOR     CFA_HORZSEPARATOR
-#define DW_CFA_SEPARATOR         CFA_SEPARATOR
+#define DW_CFA_BITMAPORICON      1
+#define DW_CFA_STRING            (1 << 1)
+#define DW_CFA_ULONG             (1 << 2)
+#define DW_CFA_TIME              (1 << 3)
+#define DW_CFA_DATE              (1 << 4)
+#define DW_CFA_CENTER            (1 << 5)
+#define DW_CFA_LEFT              (1 << 6)
+#define DW_CFA_RIGHT             (1 << 7)
+#define DW_CFA_HORZSEPARATOR     0
+#define DW_CFA_SEPARATOR         0
 
-#define DW_CRA_SELECTED          CRA_SELECTED
-#define DW_CRA_CURSORED          CRA_CURSORED
+#define DW_CRA_SELECTED          1
+#define DW_CRA_CURSORED          (1 << 1)
 
-#define DW_LS_MULTIPLESEL        LS_MULTIPLESEL
+#define DW_LS_MULTIPLESEL        1
 
 #define DW_LIT_NONE              -1
 
@@ -831,7 +849,7 @@
 /* Public function prototypes */
 void API dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad);
 void API dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad);
-#if !defined(__OS2__) && !defined(__WIN32__) && !defined(__EMX__)
+#if !defined(__OS2__) && !defined(__WIN32__) && !defined(__EMX__) && !defined(__MAC__)
 int API dw_int_init(DWResources *res, int newthread, int *argc, char **argv[]);
 #define dw_init(a, b, c) dw_int_init(&_resources, a, &b, &c)
 #else
--- a/mac/dw.c	Tue May 27 21:27:26 2003 +0000
+++ b/mac/dw.c	Tue May 27 21:43:49 2003 +0000
@@ -29,6 +29,9 @@
 
 } SignalList;
 
+const Rect CreationRect = { 0, 0, 2000, 1000 };
+WindowRef CreationWindow = 0;
+
 /* List of signals and their equivilent MacOS event */
 #define SIGNALMAX 15
 
@@ -41,10 +44,10 @@
 	{ nullEvent,       DW_SIGNAL_DELETE },
 	{ updateEvt,       DW_SIGNAL_EXPOSE },
 	{ nullEvent,       DW_SIGNAL_CLICKED },
-	{ nullEVent,       DW_SIGNAL_ITEM_ENTER },
+	{ nullEvent,       DW_SIGNAL_ITEM_ENTER },
 	{ nullEvent,       DW_SIGNAL_ITEM_CONTEXT },
 	{ nullEvent,       DW_SIGNAL_LIST_SELECT },
-	{ nullEVent,       DW_SIGNAL_ITEM_SELECT },
+	{ nullEvent,       DW_SIGNAL_ITEM_SELECT },
 	{ activateEvt,     DW_SIGNAL_SET_FOCUS },
 	{ nullEvent,       DW_SIGNAL_VALUE_CHANGED },
 	{ nullEvent,       DW_SIGNAL_SWITCH_PAGE }
@@ -95,7 +98,7 @@
 
 	for(z=0;z<SIGNALMAX;z++)
 	{
-		if(stricmp(signame, SignalTranslate[z].name) == 0)
+		if(strcasecmp(signame, SignalTranslate[z].name) == 0)
 			return SignalTranslate[z].message;
 	}
 	return 0L;
@@ -103,6 +106,11 @@
 
 void *_get_window_pointer(HWND handle)
 {
+    return NULL;
+}
+
+void _set_window_pointer(HWND handle, void *pointer)
+{
 }
 
 /* This function will recursively search a box and add up the total height of it */
@@ -531,7 +539,7 @@
 	{
 		if(thisbox->items[z].type == TYPEBOX)
 		{
-			Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER);
+			Box *tmp = _get_window_pointer(thisbox->items[z].hwnd);
 			_changebox(tmp, percent, type);
 		}
 		else
@@ -832,10 +840,10 @@
  */
 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle)
 {
-	HWND hwnd = 0;
+	WindowRef hwnd = 0;
 	CreateNewWindow (kDocumentWindowClass, flStyle,
-					 &contentRect, &theWindow);
-	return hwnd;
+					 &CreationRect, &hwnd);
+	return (HWND)hwnd;
 }
 
 /*
@@ -858,11 +866,9 @@
  */
 HWND API dw_groupbox_new(int type, int pad, char *title)
 {
-OSStatus CreateRadioGroupControl (
-   WindowRef window,
-   const Rect * boundsRect,
-   ControlRef * outControl
-);	return 0;
+    HWND hwnd = 0;
+    CreateRadioGroupControl(CreationWindow, &CreationRect, &hwnd);	
+    return hwnd;
 }
 
 /*
@@ -882,12 +888,9 @@
  */
 HWND API dw_bitmap_new(ULONG id)
 {
-OSStatus CreateImageWellControl (
-   WindowRef window,
-   const Rect * boundsRect,
-   const ControlButtonContentInfo * info,
-   ControlRef * outControl
-);	return 0;
+    HWND hwnd = 0;
+    CreateImageWellControl(CreationWindow, &CreationRect, NULL, &hwnd);	
+    return hwnd;
 }
 
 /*
@@ -898,15 +901,9 @@
  */
 HWND API dw_notebook_new(ULONG id, int top)
 {
-OSStatus CreateTabsControl (
-   WindowRef window,
-   const Rect * boundsRect,
-   ControlTabSize size,
-   ControlTabDirection direction,
-   UInt16 numTabs,
-   const ControlTabEntry * tabArray,
-   ControlRef * outControl
-);	return 0;
+    HWND hwnd = 0;
+    CreateTabsControl(CreationWindow, &CreationRect, kControlTabSizeSmall, kControlTabDirectionNorth, 1, NULL, &hwnd);
+    return hwnd;
 }
 
 /*
@@ -1007,7 +1004,15 @@
  */
 HWND API dw_container_new(ULONG id, int multi)
 {
-	return 0;
+    ListHandle hwnd = 0;
+    Point CellSize;
+    ListDefSpec def;
+    
+    SetPt(&CellSize, 52, 52);
+    /*def.u.userProc = listDefinitionFunctionUPP;*/
+    
+    CreateCustomList(&CreationRect, &CreationRect, CellSize, &def, CreationWindow, TRUE, TRUE, TRUE, TRUE, &hwnd);
+    return (HWND)hwnd;
 }
 
 /*
@@ -1018,7 +1023,7 @@
  */
 HWND API dw_tree_new(ULONG id)
 {
-	return 0;
+	return dw_container_new(id, FALSE);
 }
 
 /*
@@ -1029,13 +1034,9 @@
  */
 HWND API dw_text_new(char *text, ULONG id)
 {
-OSStatus CreateStaticTextControl (
-   WindowRef window,
-   const Rect * boundsRect,
-   CFStringRef text,
-   const ControlFontStyleRec * style,
-   ControlRef * outControl
-);	return 0;
+    HWND hwnd = 0;
+    CreateStaticTextControl (CreationWindow, &CreationRect, text, NULL, &hwnd);
+    return hwnd;
 }
 
 /*
@@ -1046,13 +1047,9 @@
  */
 HWND API dw_status_text_new(char *text, ULONG id)
 {
-OSStatus CreateStaticTextControl (
-   WindowRef window,
-   const Rect * boundsRect,
-   CFStringRef text,
-   const ControlFontStyleRec * style,
-   ControlRef * outControl
-	return 0;
+    HWND hwnd = 0;
+    CreateStaticTextControl (CreationWindow, &CreationRect, text, NULL, &hwnd);
+    return hwnd;
 }
 
 /*
@@ -1062,17 +1059,9 @@
  */
 HWND API dw_mle_new(ULONG id)
 {
-OSStatus CreateScrollingTextBoxControl (
-   WindowRef window,
-   const Rect * boundsRect,
-   SInt16 contentResID,
-   Boolean autoScroll,
-   UInt32 delayBeforeAutoScroll,
-   UInt32 delayBetweenAutoScroll,
-   UInt16 autoScrollAmount,
-   ControlRef * outControl
-);
-	return 0;
+    HWND hwnd = 0;
+    CreateScrollingTextBoxControl(CreationWindow, &CreationRect, id, FALSE, 0, 0, 0, &hwnd);
+    return hwnd;
 }
 
 /*
@@ -1083,15 +1072,9 @@
  */
 HWND API dw_entryfield_new(char *text, ULONG id)
 {
-OSStatus CreateEditTextControl (
-   WindowRef window,
-   const Rect * boundsRect,
-   CFStringRef text,
-   Boolean isPassword,
-   Boolean useInlineInput,
-   const ControlFontStyleRec * style,
-   ControlRef * outControl
-);	return 0;
+    HWND hwnd = 0;
+    CreateEditTextControl(CreationWindow, &CreationRect, text, FALSE, FALSE, NULL, &hwnd);
+    return hwnd;
 }
 
 /*
@@ -1102,15 +1085,9 @@
  */
 HWND API dw_entryfield_password_new(char *text, ULONG id)
 {
-OSStatus CreateEditTextControl (
-   WindowRef window,
-   const Rect * boundsRect,
-   CFStringRef text,
-   Boolean isPassword,
-   Boolean useInlineInput,
-   const ControlFontStyleRec * style,
-   ControlRef * outControl
-	return 0;
+    HWND hwnd = 0;
+    CreateEditTextControl(CreationWindow, &CreationRect, text, TRUE, FALSE, NULL, &hwnd);
+    return hwnd;
 }
 
 /*
@@ -1132,12 +1109,9 @@
  */
 HWND API dw_button_new(char *text, ULONG id)
 {
-OSStatus CreatePushButtonControl (
-   WindowRef window,
-   const Rect * boundsRect,
-   CFStringRef title,
-   ControlRef * outControl
-);	return 0;
+    HWND hwnd = 0;
+    CreatePushButtonControl(CreationWindow, &CreationRect, text, &hwnd);
+    return hwnd;
 }
 
 /*
@@ -1148,14 +1122,9 @@
  */
 HWND API dw_bitmapbutton_new(char *text, ULONG id)
 {
-OSStatus CreatePushButtonWithIconControl (
-   WindowRef window,
-   const Rect * boundsRect,
-   CFStringRef title,
-   ControlButtonContentInfo * icon,
-   ControlPushButtonIconAlignment iconAlignment,
-   ControlRef * outControl
-);	return 0;
+    HWND hwnd = 0;
+    CreatePushButtonWithIconControl(CreationWindow, &CreationRect, 0, NULL, kControlPushButtonIconOnLeft, &hwnd);
+    return hwnd;
 }
 
 /*
@@ -1191,17 +1160,9 @@
  */
 HWND API dw_radiobutton_new(char *text, ULONG id)
 {
-OSStatus CreateRadioButtonControl (
-   WindowRef window,
-   const Rect * boundsRect,
-   CFStringRef title,
-   SInt32 initialValue,
-   Boolean autoToggle,
-   ControlRef * outControl
-);
-
-
-	return 0;
+    HWND hwnd = 0;
+    CreateRadioButtonControl(CreationWindow, &CreationRect, text, 0, FALSE, &hwnd);
+    return hwnd;
 }
 
 
@@ -1214,18 +1175,9 @@
  */
 HWND API dw_slider_new(int vertical, int increments, ULONG id)
 {
-OSStatus CreateSliderControl (
-   WindowRef window,
-   const Rect * boundsRect,
-   SInt32 value,
-   SInt32 minimum,
-   SInt32 maximum,
-   ControlSliderOrientation orientation,
-   UInt16 numTickMarks,
-   Boolean liveTracking,
-   ControlActionUPP liveTrackingProc,
-   ControlRef * outControl
-);	return 0;
+    HWND hwnd = 0;
+    CreateSliderControl(CreationWindow, &CreationRect, 0, 0, increments, kControlSliderDoesNotPoint, 0, FALSE, 0, &hwnd); 
+    return hwnd;
 }
 
 /*
@@ -1237,17 +1189,9 @@
  */
 HWND API dw_scrollbar_new(int vertical, int increments, ULONG id)
 {
-OSStatus CreateScrollBarControl (
-   WindowRef window,
-   const Rect * boundsRect,
-   SInt32 value,
-   SInt32 minimum,
-   SInt32 maximum,
-   SInt32 viewSize,
-   Boolean liveTracking,
-   ControlActionUPP liveTrackingProc,
-   ControlRef * outControl
-);	return 0;
+    HWND hwnd;
+    CreateScrollBarControl(CreationWindow, &CreationRect, 0, 0, increments, increments, FALSE, 0, &hwnd);
+    return hwnd;
 }
 
 /*
@@ -1257,15 +1201,9 @@
  */
 HWND API dw_percent_new(ULONG id)
 {
-OSStatus CreateProgressBarControl (
-   WindowRef window,
-   const Rect * boundsRect,
-   SInt32 value,
-   SInt32 minimum,
-   SInt32 maximum,
-   Boolean indeterminate,
-   ControlRef * outControl
-);	return 0;
+    HWND hwnd = 0;
+    CreateProgressBarControl(CreationWindow, &CreationRect, 0, 0, 100, FALSE, &hwnd);
+    return hwnd;
 }
 
 /*
@@ -1276,14 +1214,9 @@
  */
 HWND API dw_checkbox_new(char *text, ULONG id)
 {
-OSStatus CreateCheckBoxControl (
-   WindowRef window,
-   const Rect * boundsRect,
-   CFStringRef title,
-   SInt32 initialValue,
-   Boolean autoToggle,
-   ControlRef * outControl
-);	return 0;
+    HWND hwnd = 0;
+    CreateCheckBoxControl(CreationWindow, &CreationRect, text, 0, TRUE, &hwnd);
+    return hwnd;
 }
 
 /*
@@ -1294,20 +1227,9 @@
  */
 HWND API dw_listbox_new(ULONG id, int multi)
 {
-OSStatus CreateListBoxControl (
-   WindowRef window,
-   const Rect * boundsRect,
-   Boolean autoSize,
-   SInt16 numRows,
-   SInt16 numColumns,
-   Boolean horizScroll,
-   Boolean vertScroll,
-   SInt16 cellHeight,
-   SInt16 cellWidth,
-   Boolean hasGrowSpace,
-   const ListDefSpec * listDef,
-   ControlRef * outControl
-);	return 0;
+    HWND hwnd = 0;
+    CreateListBoxControl(CreationWindow, &CreationRect, TRUE, 0, 1, FALSE, TRUE, 50, 50, TRUE, NULL, &hwnd);
+    return hwnd;
 }
 
 /*
@@ -1385,15 +1307,13 @@
  */
 HWND API dw_window_from_id(HWND handle, int id)
 {
-	HWND ret;
+	HWND ret = 0;
 
+#if 0
 	ControlID cid = (ControlID)id;
-	GetControlByID(handle, &cid, &ret);
+	GetControlByID((WindowRef)handle, &cid, &ret);
+#endif
 	return ret;
-);
-
-
-	return 0;
 }
 
 /*
@@ -2617,6 +2537,7 @@
  */
 DWTID API dw_thread_new(void *func, void *data, int stack)
 {
+    return (DWTID)-1;
 }
 
 /*
@@ -2673,6 +2594,7 @@
  *       handle: The handle to the splitbar returned by dw_splitbar_new().
  */
 float API dw_splitbar_get(HWND handle)
+{
 	return 0.0;
 }
 
@@ -2820,7 +2742,7 @@
 
 	while(tmp)
 	{
-		if(stricmp(tmp->varname, varname) == 0)
+		if(strcasecmp(tmp->varname, varname) == 0)
 			return tmp;
 		tmp = tmp->next;
 	}
@@ -2873,7 +2795,7 @@
 
 	while(tmp)
 	{
-		if(all || stricmp(tmp->varname, varname) == 0)
+		if(all || strcasecmp(tmp->varname, varname) == 0)
 		{
 			if(!prev)
 			{
@@ -2921,7 +2843,7 @@
 			return;
 
 		blah = calloc(1, sizeof(WindowData));
-		SetWindowProperty(window, QWP_USER, blah);
+		_set_window_pointer(window, blah);
 	}
 
 	if(data)