--- np2/macosx/toolwin.cpp 2003/11/05 15:12:17 1.3 +++ np2/macosx/toolwin.cpp 2003/11/05 16:15:44 1.5 @@ -12,8 +12,6 @@ #include "soundmng.h" #include "fdefine.h" -//for 10.2 -//#define JAGUAR enum { IDC_TOOLHDDACC = 0, @@ -115,8 +113,22 @@ static void openpopup(HIPoint location); static void skinchange(void); static DragReceiveHandlerUPP dr; +static bool isPUMA; + // ---- +static void checkOSVersion(void) { + long res; + Gestalt(gestaltSystemVersion, &res); + if (res<0x1020) { + isPUMA = true; + } + else { + isPUMA = false; + } +} + + static PicHandle skinload(const char *path, Rect* bounds) { char fname[MAX_PATH]; @@ -600,13 +612,15 @@ static pascal OSErr DragReceiver( Window static WindowRef makeNibWindow (IBNibRef nibRef) { OSStatus err; WindowRef win = NULL; -#ifndef JAGUAR - Rect bounds; - SetRect(&bounds, 0, 0, 100, 100); - err = CreateNewWindow(kFloatingWindowClass, kWindowStandardHandlerAttribute, &bounds, &win); -#else - err = CreateWindowFromNib(nibRef, CFSTR("ToolWindow"), &win); -#endif + + if (isPUMA) { + Rect bounds; + SetRect(&bounds, 0, 0, 100, 100); + err = CreateNewWindow(kFloatingWindowClass, kWindowStandardHandlerAttribute, &bounds, &win); + } + else { + err = CreateWindowFromNib(nibRef, CFSTR("ToolWindow"), &win); + } if (err == noErr) { InstallStandardEventHandler(GetWindowEventTarget(win)); EventTypeSpec list[]={ @@ -783,6 +797,8 @@ void toolwin_open(void) { toolwin_close(); return; } + + checkOSVersion(); ZeroMemory(&toolwin, sizeof(toolwin)); hbmp = skinload(np2tool.skin, &bounds); @@ -796,31 +812,31 @@ void toolwin_open(void) { goto twope_err2; } -#ifndef JAGUAR - toolwincreate(hWnd); -#endif + if (isPUMA) { + toolwincreate(hWnd); + } SizeWindow(hWnd, bounds.right-bounds.left, bounds.bottom-bounds.top, true); ControlButtonContentInfo info; info.contentType = kControlContentPictHandle; info.u.picture = hbmp; CreatePictureControl(hWnd, &bounds, &info, true, &image); InstallControlEventHandler (image, NewEventHandlerUPP(cfControlproc), GetEventTypeCount(list), list, (void *)hWnd, &ref); + if (!isPUMA) { + toolwincreate(hWnd); + } -#ifdef JAGUAR - toolwincreate(hWnd); -#endif - -#ifndef JAGUAR - if (np2tool.posy < 35) np2tool.posy = 35; - if (np2tool.posx < 5 ) np2tool.posx = 5; - MoveWindow(hWnd, np2tool.posx, np2tool.posy, true); - ShowWindow(hWnd); -#else - SetDrawerParent(hWnd, hWndMain); - SetDrawerOffsets(hWnd, (640-(bounds.right-bounds.left))/2-11, (640-(bounds.right-bounds.left))/2-11); - SetDrawerPreferredEdge(hWnd, kWindowEdgeTop); - OpenDrawer(hWnd, kWindowEdgeDefault, 1); -#endif + if (isPUMA) { + if (np2tool.posy < 35) np2tool.posy = 35; + if (np2tool.posx < 5 ) np2tool.posx = 5; + MoveWindow(hWnd, np2tool.posx, np2tool.posy, true); + ShowWindow(hWnd); + } + else{ + SetDrawerParent(hWnd, hWndMain); + SetDrawerOffsets(hWnd, (640-(bounds.right-bounds.left))/2-11, (640-(bounds.right-bounds.left))/2-11); + SetDrawerPreferredEdge(hWnd, kWindowEdgeTop); + OpenDrawer(hWnd, kWindowEdgeDefault, 1); + } return; @@ -835,11 +851,12 @@ twope_err1: void toolwin_close(void) { if (toolwin.hwnd) { -#ifdef JAGUAR - CloseDrawer(toolwin.hwnd, 0); -#else - DisposeWindow(toolwin.hwnd); -#endif + if (isPUMA) { + HideWindow(toolwin.hwnd); + } + else { + CloseDrawer(toolwin.hwnd, 0); + } RemoveReceiveHandler(dr, toolwin.hwnd); toolwindestroy(); DisposeWindow(toolwin.hwnd);