changeset 443:e99cd6e45c0b

Need to have a application package directory for binaries to properly run under MacOS. So added necessary files and a script to generate the package directory on MacOS.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 30 May 2003 19:50:18 +0000
parents 7c8bd3bc6c27
children faaeec0dba1d
files Makefile.in dwtest.c mac/Info.plist mac/PkgInfo mac/dw.c mac/dwtest.r mac/finishup.sh
diffstat 7 files changed, 92 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.in	Fri May 30 17:36:01 2003 +0000
+++ b/Makefile.in	Fri May 30 19:50:18 2003 +0000
@@ -117,13 +117,15 @@
 	$(CC) -c $(INCPATH) $(CCFLAGS) -o $@ $(srcdir)/ci.c
 
 dwtest.o: $(srcdir)/dwtest.c
-	$(CC) -c $(INCPATH) $(CCFLAGS) -o $@ $(srcdir)/dwtest.c
+	$(CC) -c $(INCPATH) $(CCFLAGS) -o $@ $(srcdir)/dwtest.c	
                 
 ci: ci.o
 	$(CC) -o ci ci.o -L$(PREFIX)/lib -ldw -ldwcompat $(LFLAGS)
                 
 dwtest: dwtest.o
 	$(CC) -o dwtest dwtest.o -L$(PREFIX)/lib -ldw -ldwcompat $(LFLAGS)
+	chmod +x mac/finishup.sh
+	mac/finishup.sh
 
 zip:
 	zip dwindows$(VER_MAJ)$(VER_MIN).zip $(srcdir)/license.txt $(srcdir)/makefile.* $(srcdir)/readme $(srcdir)/*.c $(srcdir)/dw.h  $(srcdir)/compat.h \
--- a/dwtest.c	Fri May 30 17:36:01 2003 +0000
+++ b/dwtest.c	Fri May 30 19:50:18 2003 +0000
@@ -31,10 +31,18 @@
 int main(int argc, char *argv[])
 {
     DWEnv env;
+    HWND window;
+    
+    dw_init(TRUE, argc, argv);
+    
+    window = dw_window_new(HWND_DESKTOP, "Test Window", flStyle);
+    dw_window_set_pos_size(window, 100, 100, 300, 200);
+    dw_window_show(window);
     
     dw_environment_query(&env);
-    printf("Operating System: %s %d.%d\nBuild: %d.%d\n", env.osName, env.MajorVersion, env.MinorVersion, 
-            env.MajorBuild, env.MinorBuild);
+    dw_messagebox("Title", DW_MB_OK | DW_MB_INFORMATION, "Operating System: %s %d.%d\nBuild: %d.%d\n", 
+                env.osName, env.MajorVersion, env.MinorVersion, env.MajorBuild, env.MinorBuild);
+            
     return 0;
 }
 #else
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mac/Info.plist	Fri May 30 19:50:18 2003 +0000
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>English</string>
+	<key>CFBundleExecutable</key>
+	<string>dwtest</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundlePackageType</key>
+	<string>APPL</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>0.1</string>
+	<key>CSResourcesFileMapped</key>
+	<true/>
+</dict>
+</plist>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mac/PkgInfo	Fri May 30 19:50:18 2003 +0000
@@ -0,0 +1,1 @@
+APPL????
\ No newline at end of file
--- a/mac/dw.c	Fri May 30 17:36:01 2003 +0000
+++ b/mac/dw.c	Fri May 30 19:50:18 2003 +0000
@@ -31,6 +31,7 @@
 
 const Rect CreationRect = { 0, 0, 2000, 1000 };
 WindowRef CreationWindow = 0;
+ControlRef RootControl = 0;
 
 /* List of signals and their equivilent MacOS event */
 #define SIGNALMAX 15
@@ -590,6 +591,10 @@
  */
 int API dw_init(int newthread, int argc, char *argv[])
 {
+	CreateNewWindow (kDocumentWindowClass, 0,
+                        &CreationRect, &CreationWindow);
+        CreateRootControl(CreationWindow, &RootControl);
+        HideWindow(CreationWindow);
 	return 0;
 }
 
@@ -775,6 +780,7 @@
  */
 int API dw_window_raise(HWND handle)
 {
+        BringToFront((WindowRef)handle);
 	return 0;
 }
 
@@ -795,6 +801,7 @@
  */
 int API dw_window_show(HWND handle)
 {
+        ShowWindow((WindowRef)handle);
 	return 0;
 }
 
@@ -815,6 +822,7 @@
  */
 int API dw_window_hide(HWND handle)
 {
+        HideWindow((WindowRef)handle);
 	return 0;
 }
 
@@ -825,6 +833,7 @@
  */
 int API dw_window_destroy(HWND handle)
 {
+        DisposeWindow((WindowRef)handle);
 	return 0;
 }
 
@@ -926,9 +935,13 @@
 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle)
 {
 	WindowRef hwnd = 0;
+        ControlRef rootcontrol = 0;
+        
 	CreateNewWindow (kDocumentWindowClass, flStyle,
 					 &CreationRect, &hwnd);
-	return (HWND)hwnd;
+        CreateRootControl(hwnd, &rootcontrol);
+	dw_window_set_text((HWND)hwnd, title);
+        return (HWND)hwnd;
 }
 
 /*
@@ -1364,7 +1377,10 @@
 void API dw_window_set_text(HWND handle, char *text)
 {
     CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS);
-    SetControlTitleWithCFString(handle, cftext);
+    if(IsValidWindowRef((WindowRef)handle))
+        SetWindowTitleWithCFString((WindowRef)handle, cftext);
+    else
+        SetControlTitleWithCFString(handle, cftext);
     CFRelease(cftext);
 }
 
@@ -1377,7 +1393,27 @@
  */
 char * API dw_window_get_text(HWND handle)
 {
-	return NULL;
+    CFStringRef cftext;
+    char *ret = NULL;
+    
+    if(IsValidWindowRef((WindowRef)handle))
+        CopyWindowTitleAsCFString((WindowRef)handle, &cftext);
+    else
+    {
+        Str255 str;
+        
+        GetControlTitle(handle, str);
+        cftext = CFStringCreateWithPascalString(NULL, str, CFStringGetSystemEncoding());
+    }
+    
+    if(cftext)
+    {
+        int length = CFStringGetLength(cftext) + 1;
+        char *ret = malloc(length);
+        CFStringGetCString(cftext, ret, length, kCFStringEncodingDOSLatinUS);
+        CFRelease(cftext);
+    }
+    return ret;
 }
 
 /*
@@ -1441,6 +1477,7 @@
  */
 void API dw_window_set_usize(HWND handle, ULONG width, ULONG height)
 {
+        SizeWindow((WindowRef)handle, (short)width, (short)height, TRUE);
 }
 
 /*
@@ -1475,6 +1512,7 @@
  */
 void API dw_window_set_pos(HWND handle, ULONG x, ULONG y)
 {
+        MoveWindow((WindowRef)handle, (short)x, (short)y, FALSE);
 }
 
 /*
@@ -1488,6 +1526,8 @@
  */
 void API dw_window_set_pos_size(HWND handle, ULONG x, ULONG y, ULONG width, ULONG height)
 {
+        dw_window_set_pos(handle, x, y);
+        dw_window_set_usize(handle, width, height);
 }
 
 /*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mac/dwtest.r	Fri May 30 19:50:18 2003 +0000
@@ -0,0 +1,2 @@
+/* dwtest.r */
+#include <Carbon/Carbon.r>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mac/finishup.sh	Fri May 30 19:50:18 2003 +0000
@@ -0,0 +1,13 @@
+#!/bin/sh
+PLATFORM=`uname -s`
+
+if [ $PLATFORM = "Darwin" ]
+then
+    mkdir -p dwtest.app/Contents/MacOS
+    mkdir -p dwtest.app/Contents/Resources
+    
+    cp -f mac/Info.plist dwtest.app/Contents
+    cp -f mac/PkgInfo dwtest.app/Contents
+    cp -f dwtest dwtest.app/Contents/MacOS
+    /Developer/Tools/Rez  -o dwtest.app/Contents/Resources/dwtest.rsrc  -d "SystemSevenOrLater=1" -useDF mac/dwtest.r
+fi
\ No newline at end of file