|
|
| version 1.15, 2004/01/05 01:53:34 | version 1.16, 2004/01/11 16:58:47 |
|---|---|
| Line 117 static const ControlID imageid = {'back' | Line 117 static const ControlID imageid = {'back' |
| static DragReceiveHandlerUPP dr; | static DragReceiveHandlerUPP dr; |
| static DragTrackingHandlerUPP tr; | static DragTrackingHandlerUPP tr; |
| static bool isPUMA; | static bool isPUMA, isJaguar; |
| static void openpopup(HIPoint location); | static void openpopup(Point location); |
| static void skinchange(bool remake); | static void skinchange(bool remake); |
| // ---- | // ---- |
| Line 130 static void checkOSVersion(void) { | Line 130 static void checkOSVersion(void) { |
| Gestalt(gestaltSystemVersion, &res); | Gestalt(gestaltSystemVersion, &res); |
| if (res<0x1020) { | if (res<0x1020) { |
| isPUMA = true; | isPUMA = true; |
| isJaguar = false; | |
| } | } |
| else if (res<0x1030) { | |
| isPUMA = false; | |
| isJaguar = true; | |
| } | |
| else { | else { |
| isPUMA = false; | isPUMA = false; |
| isJaguar = false; | |
| } | } |
| } | } |
| } | } |
| Line 213 const char *p; | Line 219 const char *p; |
| p = fdd->name[fdd->pos[i]]; | p = fdd->name[fdd->pos[i]]; |
| success = getLongFileName(cfname, p); | success = getLongFileName(cfname, p); |
| str = CFStringCreateWithCString(NULL, cfname, CFStringGetSystemEncoding()); | str = CFStringCreateWithCString(NULL, cfname, CFStringGetSystemEncoding()); |
| if ((str) && success) { | if (str) { |
| if (file_attr(p) != FILEATTR_ARCHIVE) { | if (success) { |
| attr |= kMenuItemAttrDisabled; | if (file_attr(p) != FILEATTR_ARCHIVE) { |
| } | attr |= kMenuItemAttrDisabled; |
| AppendMenuItemTextWithCFString(menu, str, attr, NULL, NULL); | } |
| AppendMenuItemTextWithCFString(menu, str, attr, NULL, NULL); | |
| } | |
| CFRelease(str); | CFRelease(str); |
| } | } |
| else { | else { |
| Line 249 const char *p; | Line 257 const char *p; |
| CFStringRef title; | CFStringRef title; |
| SetBevelButtonMenuValue(hwnd, sel+1); | SetBevelButtonMenuValue(hwnd, sel+1); |
| CopyMenuItemTextAsCFString(menu, sel+1, &title); | CopyMenuItemTextAsCFString(menu, sel+1, &title); |
| SetControlTitleWithCFString(hwnd, title); | if (title) { |
| SetControlTitleWithCFString(hwnd, title); | |
| CFRelease(title); | |
| } | |
| } | } |
| else { | else { |
| SetControlTitleWithCFString(hwnd, CFSTR(" ")); | SetControlTitleWithCFString(hwnd, CFSTR(" ")); |
| Line 351 static pascal OSStatus cfControlproc(Eve | Line 362 static pascal OSStatus cfControlproc(Eve |
| } | } |
| else if (GetEventClass(event)==kEventClassControl && GetEventKind(event)==kEventControlContextualMenuClick) { | else if (GetEventClass(event)==kEventClassControl && GetEventKind(event)==kEventControlContextualMenuClick) { |
| HIPoint location; | HIPoint location; |
| Point point; | |
| soundmng_stop(); | soundmng_stop(); |
| GetEventParameter (event, kEventParamMouseLocation, typeHIPoint, NULL, sizeof(HIPoint), NULL, &location); | GetEventParameter (event, kEventParamMouseLocation, typeHIPoint, NULL, sizeof(HIPoint), NULL, &location); |
| openpopup(location); | point.h = (short)location.x; |
| point.v = (short)location.y; | |
| if (!isJaguar && !isPUMA) { | |
| GrafPtr port, dst; | |
| bool portchanged; | |
| dst = GetWindowPort(toolwin.hwnd); | |
| portchanged = QDSwapPort(dst, &port); | |
| LocalToGlobal(&point); | |
| if (portchanged) QDSwapPort(port, NULL); | |
| } | |
| openpopup(point); | |
| soundmng_play(); | soundmng_play(); |
| } | } |
| Line 551 static pascal OSStatus cfWinproc(EventHa | Line 574 static pascal OSStatus cfWinproc(EventHa |
| else if (GetEventClass(event)==kEventClassWindow) { | else if (GetEventClass(event)==kEventClassWindow) { |
| switch (GetEventKind(event)) { | switch (GetEventKind(event)) { |
| case kEventWindowClose: | case kEventWindowClose: |
| #ifdef AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER | |
| case kEventWindowDrawerClosed: | |
| #endif | |
| toolwin_close(); | toolwin_close(); |
| err=noErr; | err=noErr; |
| break; | break; |
| Line 566 static pascal OSStatus cfWinproc(EventHa | Line 592 static pascal OSStatus cfWinproc(EventHa |
| err=noErr; | err=noErr; |
| break; | break; |
| case kEventWindowFocusAcquired: | |
| BringToFront(hWndMain); | |
| err = noErr; | |
| break; | |
| default: | default: |
| break; | break; |
| } | } |
| } | } |
| else if (GetEventClass(event)==kEventClassKeyboard) { | else if (GetEventClass(event)==kEventClassKeyboard) { |
| static UInt32 backup = 0; | |
| UInt32 whatHappened = GetEventKind(event); | UInt32 whatHappened = GetEventKind(event); |
| UInt32 key; | UInt32 key; |
| GetEventParameter (event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &key); | GetEventParameter (event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &key); |
| UInt32 modif; | UInt32 modif; |
| GetEventParameter (event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modif); | GetEventParameter (event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modif); |
| switch (whatHappened) | switch (whatHappened) |
| { | { |
| Line 606 static pascal OSStatus cfWinproc(EventHa | Line 625 static pascal OSStatus cfWinproc(EventHa |
| } | } |
| err = noErr; | err = noErr; |
| break; | break; |
| case kEventRawKeyModifiersChanged: | |
| if (modif & shiftKey) keystat_senddata(0x70); | |
| else keystat_senddata(0x70 | 0x80); | |
| if (modif & optionKey) keystat_senddata(0x73); | |
| else keystat_senddata(0x73 | 0x80); | |
| if (modif & controlKey) keystat_senddata(0x74); | |
| else keystat_senddata(0x74 | 0x80); | |
| if ((modif & alphaLock) != (backup & alphaLock)) { | |
| keystat_senddata(0x71); | |
| backup = modif; | |
| } | |
| err = noErr; | |
| break; | |
| default: | default: |
| break; | break; |
| } | } |
| Line 810 static WindowRef makeNibWindow (IBNibRef | Line 816 static WindowRef makeNibWindow (IBNibRef |
| { kEventClassWindow, kEventWindowClose }, | { kEventClassWindow, kEventWindowClose }, |
| { kEventClassWindow, kEventWindowShown }, | { kEventClassWindow, kEventWindowShown }, |
| { kEventClassWindow, kEventWindowDrawContent }, | { kEventClassWindow, kEventWindowDrawContent }, |
| { kEventClassWindow, kEventWindowFocusAcquired }, | { kEventClassKeyboard, kEventRawKeyUp}, |
| { kEventClassKeyboard, kEventRawKeyDown}, | { kEventClassKeyboard, kEventRawKeyDown}, |
| { kEventClassKeyboard, kEventRawKeyRepeat}, | |
| #ifdef AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER | |
| { kEventClassWindow, kEventWindowDrawerClosed }, | |
| #endif | |
| }; | }; |
| 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 903 const char *p; | Line 913 const char *p; |
| // ---- | // ---- |
| static void openpopup(HIPoint location) { | static void openpopup(Point location) { |
| MenuRef hMenu; | MenuRef hMenu; |
| short sel; | short sel; |
| Line 917 static void openpopup(HIPoint location) | Line 927 static void openpopup(HIPoint location) |
| AppendMenuItemTextWithCFString(hMenu, CFCopyLocalizedString(CFSTR("Close"),"ToolWin Close"), kMenuItemAttrIconDisabled, NULL, NULL); | AppendMenuItemTextWithCFString(hMenu, CFCopyLocalizedString(CFSTR("Close"),"ToolWin Close"), kMenuItemAttrIconDisabled, NULL, NULL); |
| DeleteMenu(222); | DeleteMenu(222); |
| selectclose = CountMenuItems(hMenu); | selectclose = CountMenuItems(hMenu); |
| sel = LoWord(PopUpMenuSelect(hMenu, (short)location.y, (short)location.x, 0)); | sel = LoWord(PopUpMenuSelect(hMenu, location.v, location.h, 0)); |
| DisposeMenu(hMenu); | DisposeMenu(hMenu); |
| if (sel == selectclose) { | if (sel == selectclose) { |
| toolwin_close(); | toolwin_close(); |
| Line 954 static void openpopup(HIPoint location) | Line 964 static void openpopup(HIPoint location) |
| } | } |
| static void makeskinimage(WindowRef win,PicHandle bmp, Rect* rect) { | |
| ControlButtonContentInfo info; | |
| ControlRef image; | |
| EventHandlerRef ref; | |
| EventTypeSpec list[]={ | |
| { kEventClassControl, kEventControlContextualMenuClick }, | |
| }; | |
| info.contentType = kControlContentPictHandle; | |
| info.u.picture = bmp; | |
| CreatePictureControl(win, rect, &info, true, &image); | |
| SetControlID(image, &imageid); | |
| InstallControlEventHandler (image, NewEventHandlerUPP(cfControlproc), GetEventTypeCount(list), list, (void *)win, &ref); | |
| } | |
| static void opentoolwin_puma(WindowRef win) { | |
| if (np2tool.posy < 35) np2tool.posy = 35; | |
| if (np2tool.posx < 5 ) np2tool.posx = 5; | |
| MoveWindow(win, np2tool.posx, np2tool.posy, true); | |
| ShowWindow(win); | |
| } | |
| void toolwin_open(void) { | void toolwin_open(void) { |
| PicHandle hbmp; | PicHandle hbmp; |
| WindowRef hWnd = NULL; | WindowRef hWnd = NULL; |
| Rect bounds; | Rect bounds; |
| ControlRef image; | |
| EventTypeSpec list[]={ | |
| { kEventClassControl, kEventControlContextualMenuClick }, | |
| }; | |
| EventHandlerRef ref; | |
| if (toolwin.hwnd) { | if (toolwin.hwnd) { |
| toolwin_close(); | toolwin_close(); |
| Line 984 void toolwin_open(void) { | Line 1011 void toolwin_open(void) { |
| goto twope_err2; | goto twope_err2; |
| } | } |
| if (isPUMA) { | |
| SetWindowBounds(hWnd, kWindowContentRgn, &bounds); | |
| if (isPUMA) { | |
| toolwincreate(hWnd); | toolwincreate(hWnd); |
| makeskinimage(hWnd, hbmp, &bounds); | |
| } | } |
| SizeWindow(hWnd, bounds.right-bounds.left, bounds.bottom-bounds.top, true); | else { |
| ControlButtonContentInfo info; | makeskinimage(hWnd, hbmp, &bounds); |
| info.contentType = kControlContentPictHandle; | |
| info.u.picture = hbmp; | |
| CreatePictureControl(hWnd, &bounds, &info, true, &image); | |
| SetControlID(image, &imageid); | |
| InstallControlEventHandler (image, NewEventHandlerUPP(cfControlproc), GetEventTypeCount(list), list, (void *)hWnd, &ref); | |
| if (!isPUMA) { | |
| toolwincreate(hWnd); | toolwincreate(hWnd); |
| } | } |
| #ifndef AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER | #ifndef AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER |
| if (np2tool.posy < 35) np2tool.posy = 35; | opentoolwin_puma(hWnd); |
| if (np2tool.posx < 5 ) np2tool.posx = 5; | |
| MoveWindow(hWnd, np2tool.posx, np2tool.posy, true); | |
| ShowWindow(hWnd); | |
| #else | #else |
| if (isPUMA) { | if (isPUMA) { |
| if (np2tool.posy < 35) np2tool.posy = 35; | opentoolwin_puma(hWnd); |
| if (np2tool.posx < 5 ) np2tool.posx = 5; | |
| MoveWindow(hWnd, np2tool.posx, np2tool.posy, true); | |
| ShowWindow(hWnd); | |
| } | } |
| else { | else { |
| Rect mainbounds; | Rect mainbounds; |
| Line 1021 void toolwin_open(void) { | Line 1039 void toolwin_open(void) { |
| } | } |
| SetDrawerOffsets(hWnd, width/2-11, width/2-11); | SetDrawerOffsets(hWnd, width/2-11, width/2-11); |
| SetDrawerPreferredEdge(hWnd, kWindowEdgeTop); | SetDrawerPreferredEdge(hWnd, kWindowEdgeTop); |
| const HISize size = {bounds.right-bounds.left, bounds.bottom-bounds.top}; | |
| SetWindowResizeLimits(hWnd, &size, &size); | |
| OpenDrawer(hWnd, kWindowEdgeDefault, 1); | OpenDrawer(hWnd, kWindowEdgeDefault, 1); |
| } | } |
| #endif | #endif |