|
|
| version 1.1, 2003/11/03 10:19:43 | version 1.4, 2003/11/05 16:08:59 |
|---|---|
| Line 5 | Line 5 |
| #include "dosio.h" | #include "dosio.h" |
| #include "ini.h" | #include "ini.h" |
| #include "resource.h" | #include "resource.h" |
| #include "toolmac.h" | #include "toolwin.h" |
| #include "np2opening.h" | #include "np2opening.h" |
| #include "dialogutils.h" | #include "dialogutils.h" |
| #include "dialog.h" | #include "dialog.h" |
| #include "soundmng.h" | #include "soundmng.h" |
| #include "fdefine.h" | #include "fdefine.h" |
| enum { | enum { |
| IDC_TOOLHDDACC = 0, | IDC_TOOLHDDACC = 0, |
| IDC_TOOLFDD1ACC, | IDC_TOOLFDD1ACC, |
| Line 114 static DragReceiveHandlerUPP dr; | Line 115 static DragReceiveHandlerUPP dr; |
| // ---- | // ---- |
| static bool isPuma(void) { | |
| long res; | |
| Gestalt(gestaltSystemVersion, &res); | |
| if (res<0x1020) { | |
| return(true); | |
| } | |
| return(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 441 static void toolwindestroy(void) { | Line 452 static void toolwindestroy(void) { |
| static pascal OSStatus cfWinproc(EventHandlerCallRef myHandler, EventRef event, void* userData) { | static pascal OSStatus cfWinproc(EventHandlerCallRef myHandler, EventRef event, void* userData) { |
| OSStatus err = eventNotHandledErr; | OSStatus err = eventNotHandledErr; |
| HICommand cmd; | HICommand cmd; |
| ControlRef sub; | |
| int i; | |
| if (GetEventClass(event)==kEventClassCommand && GetEventKind(event)==kEventCommandProcess ) { | if (GetEventClass(event)==kEventClassCommand && GetEventKind(event)==kEventCommandProcess ) { |
| GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &cmd); | GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &cmd); |
| Line 497 static pascal OSStatus cfWinproc(EventHa | Line 510 static pascal OSStatus cfWinproc(EventHa |
| err=noErr; | err=noErr; |
| break; | break; |
| case kEventWindowDrawContent: | |
| case kEventWindowShown: | |
| for (i=0; i<IDC_MAXITEMS; i++) { | |
| sub = toolwin.sub[i]; | |
| if (sub) { | |
| Draw1Control(sub); | |
| } | |
| } | |
| break; | |
| default: | default: |
| break; | break; |
| } | } |
| Line 557 static pascal OSErr DragReceiver( Window | Line 581 static pascal OSErr DragReceiver( Window |
| } | } |
| } | } |
| // アイテムは1つだけか? | |
| UInt16 numItems; | UInt16 numItems; |
| CountDragItems( theDrag, &numItems ); | CountDragItems( theDrag, &numItems ); |
| if ( numItems != 1 ) | if ( numItems != 1 ) |
| { // 複数ある | { |
| return( -1 ); // 取り扱わない | return( -1 ); |
| } | } |
| // アイテムリファレンスを取り出す | |
| DragItemRef ItemRef; | DragItemRef ItemRef; |
| GetDragItemReferenceNumber( theDrag, 1, &ItemRef ); | GetDragItemReferenceNumber( theDrag, 1, &ItemRef ); |
| // フレーバタイプを調べる | |
| FlavorType Type; | FlavorType Type; |
| GetFlavorType( theDrag, ItemRef, 1, &Type ); | GetFlavorType( theDrag, ItemRef, 1, &Type ); |
| // ファイルか? | |
| if ( Type != flavorTypeHFS ) | if ( Type != flavorTypeHFS ) |
| { // ファイルではない | { |
| return( -1 ); // 取り扱わない | return( -1 ); |
| } | } |
| // FSSpecを得る | |
| HFSFlavor aHFSFlavor; | HFSFlavor aHFSFlavor; |
| Size dataSize = sizeof(aHFSFlavor); | Size dataSize = sizeof(aHFSFlavor); |
| GetFlavorData( theDrag, ItemRef, flavorTypeHFS, &aHFSFlavor, &dataSize, 0 ); | GetFlavorData( theDrag, ItemRef, flavorTypeHFS, &aHFSFlavor, &dataSize, 0 ); |
| Line 589 static pascal OSErr DragReceiver( Window | Line 608 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; |
| #if 0 | |
| Rect bounds; | if (isPuma()) { |
| SetRect(&bounds, 0, 0, 100, 100); | Rect bounds; |
| err = CreateNewWindow(kOverlayWindowClass, 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)); | |
| EventTypeSpec list[]={ | EventTypeSpec list[]={ |
| { kEventClassCommand, kEventCommandProcess }, | { kEventClassCommand, kEventCommandProcess }, |
| { kEventClassWindow, kEventWindowClose }, | { kEventClassWindow, kEventWindowClose }, |
| { kEventClassWindow, kEventWindowShown }, | |
| { kEventClassWindow, kEventWindowDrawContent }, | |
| }; | }; |
| EventHandlerRef ref; | EventHandlerRef ref; |
| InstallWindowEventHandler (win, NewEventHandlerUPP(cfWinproc), GetEventTypeCount(list), list, (void *)win, &ref); | InstallWindowEventHandler (win, NewEventHandlerUPP(cfWinproc), GetEventTypeCount(list), list, (void *)win, &ref); |
| Line 782 void toolwin_open(void) { | Line 806 void toolwin_open(void) { |
| goto twope_err2; | goto twope_err2; |
| } | } |
| if (isPuma()) { | |
| toolwincreate(hWnd); | |
| } | |
| 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()) { | |
| toolwincreate(hWnd); | |
| } | |
| toolwincreate(hWnd); | if (isPuma()) { |
| if (np2tool.posy < 35) np2tool.posy = 35; | |
| #if 0 | if (np2tool.posx < 5 ) np2tool.posx = 5; |
| if (np2tool.posy < 30) np2tool.posy = 30; | MoveWindow(hWnd, np2tool.posx, np2tool.posy, true); |
| if (np2tool.posx < 5 ) np2tool.posx = 5; | ShowWindow(hWnd); |
| MoveWindow(hWnd, np2tool.posx, np2tool.posy, true); | } |
| ShowWindow(hWnd); | else{ |
| #else | SetDrawerParent(hWnd, hWndMain); |
| SetDrawerParent(hWnd, hWndMain); | SetDrawerOffsets(hWnd, (640-(bounds.right-bounds.left))/2-11, (640-(bounds.right-bounds.left))/2-11); |
| SetDrawerOffsets(hWnd, (640-(bounds.right-bounds.left))/2-11, (640-(bounds.right-bounds.left))/2-11); | SetDrawerPreferredEdge(hWnd, kWindowEdgeTop); |
| SetDrawerPreferredEdge(hWnd, kWindowEdgeTop); | OpenDrawer(hWnd, kWindowEdgeDefault, 1); |
| OpenDrawer(hWnd, kWindowEdgeDefault, 1); | } |
| #endif | |
| return; | return; |
| Line 816 twope_err1: | Line 845 twope_err1: |
| void toolwin_close(void) { | void toolwin_close(void) { |
| if (toolwin.hwnd) { | if (toolwin.hwnd) { |
| CloseDrawer(toolwin.hwnd, 0); | if (!isPuma()) { |
| CloseDrawer(toolwin.hwnd, 0); | |
| } | |
| else{ | |
| DisposeWindow(toolwin.hwnd); | |
| } | |
| RemoveReceiveHandler(dr, toolwin.hwnd); | RemoveReceiveHandler(dr, toolwin.hwnd); |
| toolwindestroy(); | toolwindestroy(); |
| DisposeWindow(toolwin.hwnd); | DisposeWindow(toolwin.hwnd); |