Mercurial > dwindows
diff mac/dw.c @ 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 | b559c06a76c2 |
children | d9a5f98a1127 |
line wrap: on
line diff
--- 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); } /*