|
|
| version 1.3, 2003/11/05 15:12:17 | version 1.7, 2003/11/05 17:58:01 |
|---|---|
| Line 12 | Line 12 |
| #include "soundmng.h" | #include "soundmng.h" |
| #include "fdefine.h" | #include "fdefine.h" |
| //for 10.2 | |
| //#define JAGUAR | |
| enum { | enum { |
| IDC_TOOLHDDACC = 0, | IDC_TOOLHDDACC = 0, |
| Line 115 static void openpopup(HIPoint location); | Line 113 static void openpopup(HIPoint location); |
| static void skinchange(void); | static void skinchange(void); |
| static DragReceiveHandlerUPP dr; | 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) { | static PicHandle skinload(const char *path, Rect* bounds) { |
| char fname[MAX_PATH]; | char fname[MAX_PATH]; |
| Line 600 static pascal OSErr DragReceiver( Window | Line 612 static pascal OSErr DragReceiver( Window |
| static WindowRef makeNibWindow (IBNibRef nibRef) { | static WindowRef makeNibWindow (IBNibRef nibRef) { |
| OSStatus err; | OSStatus err; |
| WindowRef win = NULL; | WindowRef win = NULL; |
| #ifndef JAGUAR | |
| Rect bounds; | if (isPUMA) { |
| SetRect(&bounds, 0, 0, 100, 100); | Rect bounds; |
| err = CreateNewWindow(kFloatingWindowClass, kWindowStandardHandlerAttribute, &bounds, &win); | SetRect(&bounds, 0, 0, 100, 100); |
| #else | err = CreateNewWindow(kFloatingWindowClass, kWindowStandardHandlerAttribute, &bounds, &win); |
| err = CreateWindowFromNib(nibRef, CFSTR("ToolWindow"), &win); | } |
| #endif | else { |
| err = CreateWindowFromNib(nibRef, CFSTR("ToolWindow"), &win); | |
| } | |
| if (err == noErr) { | if (err == noErr) { |
| InstallStandardEventHandler(GetWindowEventTarget(win)); | InstallStandardEventHandler(GetWindowEventTarget(win)); |
| EventTypeSpec list[]={ | EventTypeSpec list[]={ |
| Line 783 void toolwin_open(void) { | Line 797 void toolwin_open(void) { |
| toolwin_close(); | toolwin_close(); |
| return; | return; |
| } | } |
| checkOSVersion(); | |
| ZeroMemory(&toolwin, sizeof(toolwin)); | ZeroMemory(&toolwin, sizeof(toolwin)); |
| hbmp = skinload(np2tool.skin, &bounds); | hbmp = skinload(np2tool.skin, &bounds); |
| Line 796 void toolwin_open(void) { | Line 812 void toolwin_open(void) { |
| goto twope_err2; | goto twope_err2; |
| } | } |
| #ifndef JAGUAR | if (isPUMA) { |
| toolwincreate(hWnd); | toolwincreate(hWnd); |
| #endif | } |
| SizeWindow(hWnd, bounds.right-bounds.left, bounds.bottom-bounds.top, true); | SizeWindow(hWnd, bounds.right-bounds.left, bounds.bottom-bounds.top, true); |
| ControlButtonContentInfo info; | ControlButtonContentInfo info; |
| info.contentType = kControlContentPictHandle; | info.contentType = kControlContentPictHandle; |
| info.u.picture = hbmp; | info.u.picture = hbmp; |
| CreatePictureControl(hWnd, &bounds, &info, true, &image); | CreatePictureControl(hWnd, &bounds, &info, true, &image); |
| InstallControlEventHandler (image, NewEventHandlerUPP(cfControlproc), GetEventTypeCount(list), list, (void *)hWnd, &ref); | InstallControlEventHandler (image, NewEventHandlerUPP(cfControlproc), GetEventTypeCount(list), list, (void *)hWnd, &ref); |
| if (!isPUMA) { | |
| #ifdef JAGUAR | toolwincreate(hWnd); |
| toolwincreate(hWnd); | } |
| #endif | #ifndef AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER |
| #ifndef JAGUAR | |
| if (np2tool.posy < 35) np2tool.posy = 35; | if (np2tool.posy < 35) np2tool.posy = 35; |
| if (np2tool.posx < 5 ) np2tool.posx = 5; | if (np2tool.posx < 5 ) np2tool.posx = 5; |
| MoveWindow(hWnd, np2tool.posx, np2tool.posy, true); | MoveWindow(hWnd, np2tool.posx, np2tool.posy, true); |
| ShowWindow(hWnd); | ShowWindow(hWnd); |
| #else | #else |
| SetDrawerParent(hWnd, hWndMain); | if (isPUMA) { |
| SetDrawerOffsets(hWnd, (640-(bounds.right-bounds.left))/2-11, (640-(bounds.right-bounds.left))/2-11); | if (np2tool.posy < 35) np2tool.posy = 35; |
| SetDrawerPreferredEdge(hWnd, kWindowEdgeTop); | if (np2tool.posx < 5 ) np2tool.posx = 5; |
| OpenDrawer(hWnd, kWindowEdgeDefault, 1); | 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 | #endif |
| return; | return; |
| Line 835 twope_err1: | Line 857 twope_err1: |
| void toolwin_close(void) { | void toolwin_close(void) { |
| if (toolwin.hwnd) { | if (toolwin.hwnd) { |
| #ifdef JAGUAR | #ifndef AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER |
| CloseDrawer(toolwin.hwnd, 0); | HideWindow(toolwin.hwnd); |
| #else | #else |
| DisposeWindow(toolwin.hwnd); | if (isPUMA) { |
| HideWindow(toolwin.hwnd); | |
| } | |
| else { | |
| CloseDrawer(toolwin.hwnd, 0); | |
| } | |
| #endif | #endif |
| RemoveReceiveHandler(dr, toolwin.hwnd); | RemoveReceiveHandler(dr, toolwin.hwnd); |
| toolwindestroy(); | toolwindestroy(); |
| Line 960 const DISKACC *accterm; | Line 987 const DISKACC *accterm; |
| // ---- | // ---- |
| static const char ini_title[] = "NP2 tool"; | static const char ini_title[] = "NP2 tool"; |
| static const char inifile[] = "np2.cfg"; // same file name.. | |
| static const INITBL iniitem[] = { | static const INITBL iniitem[] = { |
| {"WindposX", INITYPE_SINT32, &np2tool.posx, 0}, | {"WindposX", INITYPE_SINT32, &np2tool.posx, 0}, |
| Line 987 static const INITBL iniitem[] = { | Line 1015 static const INITBL iniitem[] = { |
| {"FD2NAME7", INITYPE_STR, np2tool.fdd[1].name[7], MAX_PATH}}; | {"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) { | void toolwin_readini(void) { |
| char path[MAX_PATH]; | char path[MAX_PATH]; |
| Line 1000 void toolwin_readini(void) { | Line 1022 void toolwin_readini(void) { |
| ZeroMemory(&np2tool, sizeof(np2tool)); | ZeroMemory(&np2tool, sizeof(np2tool)); |
| np2tool.posx = 0; | np2tool.posx = 0; |
| np2tool.posy = 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)); | ini_read(path, ini_title, iniitem, sizeof(iniitem)/sizeof(INITBL)); |
| } | } |
| Line 1008 void toolwin_writeini(void) { | Line 1030 void toolwin_writeini(void) { |
| char path[MAX_PATH]; | char path[MAX_PATH]; |
| initgetfile(path, sizeof(path)); | file_cpyname(path, file_getcd(inifile), sizeof(path)); |
| ini_write(path, ini_title, iniitem, sizeof(iniitem)/sizeof(INITBL)); | ini_write(path, ini_title, iniitem, sizeof(iniitem)/sizeof(INITBL), FALSE); |
| } | } |