--- np2/macosx/toolwin.cpp 2003/11/05 15:12:17 1.3 +++ np2/macosx/toolwin.cpp 2003/11/12 19:06:33 1.10 @@ -12,8 +12,6 @@ #include "soundmng.h" #include "fdefine.h" -//for 10.2 -//#define JAGUAR enum { IDC_TOOLHDDACC = 0, @@ -109,14 +107,31 @@ static const OSType subcommand[11] ={ '- 'exit', }; +#define BASENUMBER 4 static const ControlID popup[2] = { {'pop1', 1}, {'pop2', 2} }; -static void openpopup(HIPoint location); -static void skinchange(void); static DragReceiveHandlerUPP dr; +static bool isPUMA; + +static void openpopup(HIPoint location); +static void skinchange(bool remake); // ---- +static void checkOSVersion(void) { + static long res = 0; + if (!res) { + Gestalt(gestaltSystemVersion, &res); + if (res<0x1020) { + isPUMA = true; + } + else { + isPUMA = false; + } + } +} + + static PicHandle skinload(const char *path, Rect* bounds) { char fname[MAX_PATH]; @@ -153,7 +168,7 @@ static PicHandle skinload(const char *pa return(ret); } } - return(getBMPfromResource("np2tool", bounds)); + return(getBMPfromResource("np2tool", bounds, CFSTR("bmp"))); } // ---- @@ -511,12 +526,25 @@ static pascal OSStatus cfWinproc(EventHa } } break; - + + case kEventWindowFocusAcquired: + SelectWindow(hWndMain); + break; + default: break; } } + else if (GetEventClass(event)==kEventClassKeyboard && GetEventKind(event)==kEventRawKeyDown) { + UInt32 modif; + GetEventParameter (event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modif); + if (modif & cmdKey) { + EventRecord eve; + ConvertEventRefToEventRecord( event,&eve ); + recieveCommand(MenuEvent(&eve)); + } + } (void)myHandler; return err; @@ -540,7 +568,7 @@ OSErr setDropFile(FSSpec spec, int drv) case FTYPE_TEXT: strcpy(np2tool.skin, fname); - skinchange(); + skinchange(true); break; case FTYPE_THD: @@ -600,20 +628,24 @@ 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[]={ - { kEventClassCommand, kEventCommandProcess }, - { kEventClassWindow, kEventWindowClose }, - { kEventClassWindow, kEventWindowShown }, - { kEventClassWindow, kEventWindowDrawContent }, + { kEventClassCommand, kEventCommandProcess }, + { kEventClassWindow, kEventWindowClose }, + { kEventClassWindow, kEventWindowShown }, + { kEventClassWindow, kEventWindowDrawContent }, + { kEventClassWindow, kEventWindowFocusAcquired }, + { kEventClassKeyboard, kEventRawKeyDown}, }; EventHandlerRef ref; InstallWindowEventHandler (win, NewEventHandlerUPP(cfWinproc), GetEventTypeCount(list), list, (void *)win, &ref); @@ -643,63 +675,48 @@ static void createskinmenu(MenuRef ret) const char *base; char *p; UINT i; - UINT j; - UINT id[SKINMRU_MAX]; -const char *file[SKINMRU_MAX]; - Str255 seltext, deftext; + char longname[256]; - mkstr255(seltext, str_skinsel); - AppendMenu(ret, seltext); + AppendMenuItemTextWithCFString(ret, CFCopyLocalizedString(CFSTR("Select Skin..."),"Slect Skin"), kMenuItemAttrIconDisabled, NULL,NULL); AppendMenu(ret, "\p-"); base = np2tool.skin; - mkstr255(deftext, str_skindef); - AppendMenu(ret, deftext); - if (base[0] != '\0') { - EnableMenuItem(ret, 3); + AppendMenuItemTextWithCFString(ret, CFCopyLocalizedString(CFSTR(""),"Base Skin"), kMenuItemAttrIconDisabled, NULL,NULL); + if (base[0] == '\0') { + CheckMenuItem(ret, BASENUMBER-1, true); } for (cnt=0; cnti; j--) { - id[j] = id[j-1]; - } - id[i] = cnt; - file[cnt] = p; - } - for (i=0; i