--- np2/macosx/toolwin.cpp 2003/11/05 15:12:17 1.3 +++ np2/macosx/toolwin.cpp 2003/11/05 17:43:57 1.6 @@ -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,30 +812,36 @@ 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); - -#ifdef JAGUAR - toolwincreate(hWnd); -#endif - -#ifndef JAGUAR + if (!isPUMA) { + toolwincreate(hWnd); + } +#ifndef AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER 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); + 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); + } #endif return; @@ -835,10 +857,15 @@ twope_err1: void toolwin_close(void) { if (toolwin.hwnd) { -#ifdef JAGUAR - CloseDrawer(toolwin.hwnd, 0); +#ifndef AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER + HideWindow(toolwin.hwnd); #else - DisposeWindow(toolwin.hwnd); + if (isPUMA) { + HideWindow(toolwin.hwnd); + } + else { + CloseDrawer(toolwin.hwnd, 0); + } #endif RemoveReceiveHandler(dr, toolwin.hwnd); toolwindestroy();