--- np2/macosx/toolwin.cpp 2003/11/08 17:54:26 1.8
+++ np2/macosx/toolwin.cpp 2003/11/13 18:17:42 1.11
@@ -107,24 +107,27 @@ static const OSType subcommand[11] ={ '-
'exit',
};
+#define BASENUMBER 4
static const ControlID popup[2] = { {'pop1', 1}, {'pop2', 2} };
static DragReceiveHandlerUPP dr;
static bool isPUMA;
static void openpopup(HIPoint location);
-static void skinchange(void);
+static void skinchange(bool remake);
// ----
static void checkOSVersion(void) {
- long res;
- Gestalt(gestaltSystemVersion, &res);
- if (res<0x1020) {
- isPUMA = true;
- }
- else {
- isPUMA = false;
+ static long res = 0;
+ if (!res) {
+ Gestalt(gestaltSystemVersion, &res);
+ if (res<0x1020) {
+ isPUMA = true;
+ }
+ else {
+ isPUMA = false;
+ }
}
}
@@ -165,7 +168,7 @@ static PicHandle skinload(const char *pa
return(ret);
}
}
- return(getBMPfromResource("np2tool", bounds));
+ return(getBMPfromResource("np2tool.bmp", bounds));
}
// ----
@@ -533,6 +536,15 @@ static pascal OSStatus cfWinproc(EventHa
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;
@@ -556,7 +568,7 @@ OSErr setDropFile(FSSpec spec, int drv)
case FTYPE_TEXT:
strcpy(np2tool.skin, fname);
- skinchange();
+ skinchange(true);
break;
case FTYPE_THD:
@@ -628,11 +640,12 @@ static WindowRef makeNibWindow (IBNibRef
if (err == noErr) {
InstallStandardEventHandler(GetWindowEventTarget(win));
EventTypeSpec list[]={
- { kEventClassCommand, kEventCommandProcess },
- { kEventClassWindow, kEventWindowClose },
- { kEventClassWindow, kEventWindowShown },
- { kEventClassWindow, kEventWindowDrawContent },
- { kEventClassWindow, kEventWindowFocusAcquired },
+ { kEventClassCommand, kEventCommandProcess },
+ { kEventClassWindow, kEventWindowClose },
+ { kEventClassWindow, kEventWindowShown },
+ { kEventClassWindow, kEventWindowDrawContent },
+ { kEventClassWindow, kEventWindowFocusAcquired },
+ { kEventClassKeyboard, kEventRawKeyDown},
};
EventHandlerRef ref;
InstallWindowEventHandler (win, NewEventHandlerUPP(cfWinproc), GetEventTypeCount(list), list, (void *)win, &ref);
@@ -662,61 +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];
char longname[256];
AppendMenuItemTextWithCFString(ret, CFCopyLocalizedString(CFSTR("Select Skin..."),"Slect Skin"), kMenuItemAttrIconDisabled, NULL,NULL);
AppendMenu(ret, "\p-");
base = np2tool.skin;
- AppendMenuItemTextWithCFString(ret, CFCopyLocalizedString(CFSTR("Base Skin"),"Base Skin"), kMenuItemAttrIconDisabled, NULL,NULL);
+ AppendMenuItemTextWithCFString(ret, CFCopyLocalizedString(CFSTR(""),"Base Skin"), kMenuItemAttrIconDisabled, NULL,NULL);
if (base[0] == '\0') {
- DisableMenuItem(ret, 3);
+ CheckMenuItem(ret, BASENUMBER-1, true);
}
for (cnt=0; cnti; j--) {
- id[j] = id[j-1];
- }
- id[i] = cnt;
- file[cnt] = p;
+ UInt32 attr = kMenuItemAttrIconDisabled;
+ if (file_attr(p) != FILEATTR_ARCHIVE) {
+ attr |= kMenuItemAttrDisabled;
+ }
+ ZeroMemory(longname, sizeof(longname));
+ if (!getLongFileName(longname, p)) {
+ strcpy(longname, file_getname(p));
+ }
+ AppendMenuItemTextWithCFString(ret, CFStringCreateWithCString(NULL, longname, kCFStringEncodingUTF8), attr, NULL, NULL);
}
for (i=0; i