--- np2/macosx/toolwin.cpp 2003/11/05 16:08:59 1.4 +++ np2/macosx/toolwin.cpp 2003/11/05 17:58:01 1.7 @@ -113,15 +113,19 @@ static void openpopup(HIPoint location); static void skinchange(void); static DragReceiveHandlerUPP dr; +static bool isPUMA; + // ---- -static bool isPuma(void) { +static void checkOSVersion(void) { long res; Gestalt(gestaltSystemVersion, &res); if (res<0x1020) { - return(true); + isPUMA = true; + } + else { + isPUMA = false; } - return(false); } @@ -609,7 +613,7 @@ static WindowRef makeNibWindow (IBNibRef OSStatus err; WindowRef win = NULL; - if (isPuma()) { + if (isPUMA) { Rect bounds; SetRect(&bounds, 0, 0, 100, 100); err = CreateNewWindow(kFloatingWindowClass, kWindowStandardHandlerAttribute, &bounds, &win); @@ -793,6 +797,8 @@ void toolwin_open(void) { toolwin_close(); return; } + + checkOSVersion(); ZeroMemory(&toolwin, sizeof(toolwin)); hbmp = skinload(np2tool.skin, &bounds); @@ -806,7 +812,7 @@ void toolwin_open(void) { goto twope_err2; } - if (isPuma()) { + if (isPUMA) { toolwincreate(hWnd); } SizeWindow(hWnd, bounds.right-bounds.left, bounds.bottom-bounds.top, true); @@ -815,22 +821,28 @@ void toolwin_open(void) { info.u.picture = hbmp; CreatePictureControl(hWnd, &bounds, &info, true, &image); InstallControlEventHandler (image, NewEventHandlerUPP(cfControlproc), GetEventTypeCount(list), list, (void *)hWnd, &ref); - if (!isPuma()) { + if (!isPUMA) { toolwincreate(hWnd); } - - if (isPuma()) { +#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 + 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{ + 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; @@ -845,12 +857,16 @@ twope_err1: void toolwin_close(void) { if (toolwin.hwnd) { - if (!isPuma()) { - CloseDrawer(toolwin.hwnd, 0); +#ifndef AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER + HideWindow(toolwin.hwnd); +#else + if (isPUMA) { + HideWindow(toolwin.hwnd); } - else{ - DisposeWindow(toolwin.hwnd); + else { + CloseDrawer(toolwin.hwnd, 0); } +#endif RemoveReceiveHandler(dr, toolwin.hwnd); toolwindestroy(); DisposeWindow(toolwin.hwnd); @@ -971,6 +987,7 @@ const DISKACC *accterm; // ---- static const char ini_title[] = "NP2 tool"; +static const char inifile[] = "np2.cfg"; // same file name.. static const INITBL iniitem[] = { {"WindposX", INITYPE_SINT32, &np2tool.posx, 0}, @@ -998,12 +1015,6 @@ static const INITBL iniitem[] = { {"FD2NAME7", INITYPE_STR, np2tool.fdd[1].name[7], MAX_PATH}}; -void initgetfile(char *path, UINT size) { - - file_cpyname(path, file_getcd("np2"), size); - file_catname(path, ".ini", size); -} - void toolwin_readini(void) { char path[MAX_PATH]; @@ -1011,7 +1022,7 @@ void toolwin_readini(void) { ZeroMemory(&np2tool, sizeof(np2tool)); np2tool.posx = 0; np2tool.posy = 0; - initgetfile(path, sizeof(path)); + file_cpyname(path, file_getcd(inifile), sizeof(path)); ini_read(path, ini_title, iniitem, sizeof(iniitem)/sizeof(INITBL)); } @@ -1019,6 +1030,7 @@ void toolwin_writeini(void) { char path[MAX_PATH]; - initgetfile(path, sizeof(path)); - ini_write(path, ini_title, iniitem, sizeof(iniitem)/sizeof(INITBL)); + file_cpyname(path, file_getcd(inifile), sizeof(path)); + ini_write(path, ini_title, iniitem, sizeof(iniitem)/sizeof(INITBL), FALSE); } +