-/* $Id: mac.c,v 1.43 2003/02/02 15:59:00 ben Exp $ */
+/* $Id: mac.c,v 1.45 2003/02/04 23:39:26 ben Exp $ */
/*
* Copyright (c) 1999 Ben Harris
* All rights reserved.
/*
* Work out what kind of window we're dealing with.
- * Concept shamelessly nicked from SurfWriter.
*/
-static int mac_windowtype(WindowPtr window) {
- int kind;
- long refcon;
-
- if (window == NULL)
- return wNone;
- kind = GetWindowKind(window);
- if (kind < 0)
+static int mac_windowtype(WindowPtr window)
+{
+
+#if !TARGET_API_MAC_CARBON
+ if (GetWindowKind(window) < 0)
return wDA;
- if (GetWVariant(window) == zoomDocProc)
- return wTerminal;
- refcon = GetWRefCon(window);
- if (refcon < 1024)
- return refcon;
- else
- return wSettings;
+#endif
+ return ((WinInfo *)GetWRefCon(window))->wtype;
}
/*
window = FrontWindow();
/* Things which do the same whatever window we're in. */
switch (menu) {
-#if !TARGET_API_MAC_CARBON
case mApple:
switch (item) {
case iAbout:
mac_openabout();
goto done;
+#if !TARGET_API_MAC_CARBON
default:
GetMenuItemText(GetMenuHandle(mApple), item, da);
OpenDeskAcc(da);
goto done;
+#endif
}
break;
-#endif
case mFile:
switch (item) {
case iNew:
VersRecHndl vers;
Rect box;
StringPtr longvers;
+ WinInfo *wi;
if (windows.about)
SelectWindow(windows.about);
else {
windows.about =
GetDialogWindow(GetNewDialog(wAbout, NULL, (WindowPtr)-1));
+ wi = smalloc(sizeof(*wi));
+ wi->s = NULL;
+ wi->wtype = wAbout;
+ SetWRefCon(windows.about, (long)wi);
vers = (VersRecHndl)Get1Resource('vers', 1);
if (vers != NULL && *vers != NULL) {
longvers = (*vers)->shortVersion + (*vers)->shortVersion[0] + 1;
}
static void mac_openlicence(void) {
+ WinInfo *wi;
if (windows.licence)
SelectWindow(windows.licence);
else {
windows.licence = GetNewWindow(wLicence, NULL, (WindowPtr)-1);
+ wi = smalloc(sizeof(*wi));
+ wi->s = NULL;
+ wi->wtype = wLicence;
+ SetWRefCon(windows.licence, (long)wi);
ShowWindow(windows.licence);
}
}
switch (mac_windowtype(window)) {
#if !TARGET_API_MAC_CARBON
case wDA:
- CloseDeskAcc(((WindowPeek)window)->windowKind);
+ CloseDeskAcc(GetWindowKind(window));
break;
#endif
case wTerminal:
* Make the menus look right before the user gets to see them.
*/
#if TARGET_API_MAC_CARBON
-/* XXX Is this good enough? What about Carbon on OS 8.1? */
#define EnableItem EnableMenuItem
#define DisableItem DisableMenuItem
#endif