summaryrefslogtreecommitdiffstats
path: root/mac
diff options
context:
space:
mode:
authorjingham <jingham>1998-11-11 17:28:50 (GMT)
committerjingham <jingham>1998-11-11 17:28:50 (GMT)
commitad5d4d015663fbed6bb4d8ea9d0b1bfda00d82ad (patch)
tree993d1f2ceab5039b6806719996992d39b39829da /mac
parentc7332617ba5dbb6c74ef23c5bca3ea821407ac7f (diff)
downloadtk-ad5d4d015663fbed6bb4d8ea9d0b1bfda00d82ad.zip
tk-ad5d4d015663fbed6bb4d8ea9d0b1bfda00d82ad.tar.gz
tk-ad5d4d015663fbed6bb4d8ea9d0b1bfda00d82ad.tar.bz2
Make the Macintosh Menu's adopt the current Theme Appearance if the Appearance extension (version 1.0.1 or later) is installed
Diffstat (limited to 'mac')
-rw-r--r--mac/MW_TkHeader.pch78
-rw-r--r--mac/README30
-rw-r--r--mac/tkMacAppInit.c9
-rw-r--r--mac/tkMacColor.c10
-rw-r--r--mac/tkMacMenu.c360
-rw-r--r--mac/tkMacPort.h3
-rw-r--r--mac/tkMacWm.c17
7 files changed, 360 insertions, 147 deletions
diff --git a/mac/MW_TkHeader.pch b/mac/MW_TkHeader.pch
index 433795d..f5dcc1d 100644
--- a/mac/MW_TkHeader.pch
+++ b/mac/MW_TkHeader.pch
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: MW_TkHeader.pch,v 1.2 1998/09/14 18:23:33 stanton Exp $
+ * RCS: @(#) $Id: MW_TkHeader.pch,v 1.3 1998/11/11 17:28:50 jingham Exp $
*/
/*
@@ -31,42 +31,13 @@
#pragma precompile_target "MW_TkHeader68K"
#endif
-/*
- * Macintosh Tcl must be compiled with certain compiler options to
- * ensure that it will work correctly. The following pragmas are
- * used to ensure that those options are set correctly. An error
- * will occur at compile time if they are not set correctly.
- */
+#include "tclMacCommonPch.h"
-#if !__option(enumsalwaysint)
-#error Tcl requires the Metrowerks setting "Enums always ints".
-#endif
-
-#if !defined(__POWERPC__)
-#if !__option(far_data)
-#error Tcl requires the Metrowerks setting "Far data".
-#endif
-#endif
-
-#if !defined(__POWERPC__)
-#if !__option(fourbyteints)
-#error Tcl requires the Metrowerks setting "4 byte ints".
-#endif
-#endif
-
-#if !defined(__POWERPC__)
-#if !__option(IEEEdoubles)
-#error Tcl requires the Metrowerks setting "8 byte doubles".
-#endif
+#ifdef TCL_DEBUG
+ #define TK_TEST
#endif
/*
- * The define is used most everywhere to tell Tk (or any Tk
- * extensions) that we are compiling for the Macintosh platform.
- */
-#define MAC_TCL
-
-/*
* The following defines are for the Xlib.h file to force
* it to generate prototypes in the way we need it. This is
* defined here in case X.h & company are ever included before
@@ -77,47 +48,6 @@
#define NeedWidePrototypes 0
/*
- * The following defines control the behavior of the Macintosh
- * Universial Headers.
- */
-
-#define SystemSevenOrLater 1
-#define STRICT_CONTROLS 0
-#define STRICT_WINDOWS 0
-
-/*
- * The appearance manager has not yet been shiped by Apple (10/29/97).
- * It's currently in beta testing which is why we were able to write
- * some code that depends on it. If you have access to the appearance
- * manager you can define the symbol HAVE_APPEARANCE below to compile
- * the code that uses the new appearance manager.
- */
-
-/* #define HAVE_APPEARANCE 1 */
-
-/*
- * Define the following symbol if you want
- * comprehensive debugging turned on.
- */
-
-/* #define TCL_DEBUG */
-
-#ifdef TCL_DEBUG
-# define TCL_MEM_DEBUG
-# define TK_TEST
-# define TCL_TEST
-#endif
-
-/*
- * Apple's Universal Headers 2.0 & 3.0 change alot of names and constants.
- * We will switch to the new names as soon as we can be reasonably sure the
- * number of people with older versions of CodeWarrior, who will then not be
- * able to build Tcl/Tk, is negligible.
- */
-
-#define OLDROUTINENAMES 1
-
-/*
* Place any includes below that will are needed by the majority of the
* and is OK to be in any file in the system.
*/
diff --git a/mac/README b/mac/README
index 9727ce3..d6b2475 100644
--- a/mac/README
+++ b/mac/README
@@ -1,4 +1,4 @@
-Tk 8.0.3 for Macintosh
+Tk 8.0.4 for Macintosh
by Ray Johnson
Scriptics Corporation
@@ -8,7 +8,7 @@ Jim Ingham
Cygnus Solutions
jingham@cygnus.com
-RCS: @(#) $Id: README,v 1.3 1998/09/14 18:23:33 stanton Exp $
+RCS: @(#) $Id: README,v 1.4 1998/11/11 17:29:34 jingham Exp $
1. Introduction
---------------
@@ -34,10 +34,8 @@ applications (like Aaron.) We also use "system" colors so the default
backgrounds etc. will also change colors. We plan to support this
feature - so let me know if something doesn't work quite right.
Unfortunantly, we are not able to change the colors of buttons under
-MacOS 8. We are working on a solution to this.
-In the meantime, if you really must have colored buttons, turn off the
-"System-wide platinum appearance" option in the Appearance Control Panel,
-and you will get the System 7, colorable, buttons back.
+MacOS 8. Doing this is discouraged under Appearance, and we will probably
+not implement it anytime soon.
We also now support native menus! By using the new -menu option
on toplevels you can have a menubar that is cross platform. You
@@ -46,6 +44,9 @@ the documentation for more details. Syd Polk <icepick@eng.sun.com> is
the author of the new menu code. Feel free to contact him if you
have questions or comments about the menu mechanism.
+As of Tk 8.0.4, MacTk menus will adopt the backgrounds, shape, separator, etc
+of the current theme.
+
The "tk_messageBox" command on the Macintosh is now much more
mac-like. I'll probably still need to adjust this more - but it
looks a hell of alot better than it did before.
@@ -113,7 +114,7 @@ Macintosh Tk is distributed in three different forms. This
should make it easier to only download what you need. The
packages are as follows:
-mactk8.0.3.sea.hqx
+mactk8.0.4.sea.hqx
This distribution is a "binary" only release. It contains an
installer program that will install a 68k, PowerPC, or Fat
@@ -121,25 +122,19 @@ mactk8.0.3.sea.hqx
the Tcl & Tk libraries in the Extensions folder inside your
System Folder. (No "INIT"'s or Control Pannels are installed.)
-mactcltk-full-8.0.3.sea.hqx
+mactcltk-full-8.0.4.sea.hqx
This release contains the full release of Tcl and Tk for the
Macintosh plus the More Files package on which Macintosh Tcl and
Tk rely.
-mactk-source-8.0.3.sea.hqx
+mactk-source-8.0.4.sea.hqx
This release contains the complete source to Tk for the Macintosh
In addition, Metrowerks CodeWarrior libraries and project files
are included. However, you must already have the More Files
package to compile this code.
-UNIX Tar file distribution.
- The standard Tcl/Tk source distribution has Mac project files
- in it. Be warned that the Tk project file is lacking one minor
- change compared to the ones in the installers listed above
- having to do with locking down the MDEF resource.
-
5. Documentation
----------------
@@ -187,7 +182,7 @@ following items:
CodeWarrior Pro 1 or higher (CodeWarrior release 9 or higher can work
and we have project files, but we are depricating support)
- 8.0.3 was build with CW Pro 3.
+ 8.0.4 was build with CW Pro 3.
Mac Tcl 8.0 (source)
(which requires More Files 1.4.2 or 1.4.3)
Mac Tk 8.0 (source)
@@ -204,7 +199,8 @@ Special notes:
* We are starting to support the new Appearance Manager that shipped
with MacOS 8.0. The Tk 8.0.3 release is the first Tk release
- that supports the Appearance Manager well.
+ that supports the Appearance Manager well. Tk 8.0.4 extends this support
+ to the menu system.
7. About Dialog
---------------
diff --git a/mac/tkMacAppInit.c b/mac/tkMacAppInit.c
index 92b2c2a..00db916 100644
--- a/mac/tkMacAppInit.c
+++ b/mac/tkMacAppInit.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacAppInit.c,v 1.3 1998/09/14 18:23:34 stanton Exp $
+ * RCS: @(#) $Id: tkMacAppInit.c,v 1.4 1998/11/11 17:29:48 jingham Exp $
*/
#include <Gestalt.h>
@@ -30,6 +30,8 @@ EXTERN int Tktest_Init _ANSI_ARGS_((Tcl_Interp *interp));
#endif /* TK_TEST */
#ifdef TCL_TEST
+EXTERN int Procbodytest_Init _ANSI_ARGS_((Tcl_Interp *interp));
+EXTERN int Procbodytest_SafeInit _ANSI_ARGS_((Tcl_Interp *interp));
EXTERN int TclObjTest_Init _ANSI_ARGS_((Tcl_Interp *interp));
EXTERN int Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp));
#endif /* TCL_TEST */
@@ -149,6 +151,11 @@ Tcl_AppInit(
if (TclObjTest_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
+ if (Procbodytest_Init(interp) == TCL_ERROR) {
+ return TCL_ERROR;
+ }
+ Tcl_StaticPackage(interp, "procbodytest", Procbodytest_Init,
+ Procbodytest_SafeInit);
#endif /* TCL_TEST */
#ifdef TK_TEST
diff --git a/mac/tkMacColor.c b/mac/tkMacColor.c
index 4de218d..d7ee825 100644
--- a/mac/tkMacColor.c
+++ b/mac/tkMacColor.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacColor.c,v 1.2 1998/09/14 18:23:34 stanton Exp $
+ * RCS: @(#) $Id: tkMacColor.c,v 1.3 1998/11/11 17:29:57 jingham Exp $
*/
#include <tkColor.h>
@@ -90,6 +90,8 @@ TkSetMacColor(
case MENU_TEXT_PIXEL:
GetMenuPartColor((pixel >> 24), macColor);
return true;
+ case APPEARANCE_PIXEL:
+ return false;
case PIXEL_MAGIC:
default:
macColor->blue = (unsigned short) ((pixel & 0xFF) << 8);
@@ -252,6 +254,12 @@ TkpGetColor(
GetMenuPartColor(MENU_TEXT_PIXEL, &rgbValue);
pixelCode = MENU_TEXT_PIXEL;
foundSystemColor = true;
+ } else if (!strcasecmp(name+6, "AppearanceColor")) {
+ color.red = 0;
+ color.green = 0;
+ color.blue = 0;
+ pixelCode = APPEARANCE_PIXEL;
+ foundSystemColor = true;
}
if (foundSystemColor) {
diff --git a/mac/tkMacMenu.c b/mac/tkMacMenu.c
index 78ed3eb..5acc734 100644
--- a/mac/tkMacMenu.c
+++ b/mac/tkMacMenu.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacMenu.c,v 1.5 1998/09/14 18:23:37 stanton Exp $
+ * RCS: @(#) $Id: tkMacMenu.c,v 1.6 1998/11/11 17:30:44 jingham Exp $
*/
#include <Menus.h>
@@ -18,11 +18,13 @@
#include <string.h>
#include <ToolUtils.h>
#include <Balloons.h>
+#include <Appearance.h>
#undef Status
#include <Devices.h>
#include "tkMenu.h"
#include "tkMacInt.h"
#include "tkMenuButton.h"
+#include "tkColor.h"
typedef struct MacMenu {
MenuHandle menuHdl; /* The Menu Manager data structure. */
@@ -33,6 +35,12 @@ typedef struct MacMenu {
* through. */
} MacMenu;
+typedef struct MenuEntryUserData {
+ Drawable mdefDrawable;
+ TkMenuEntry *mePtr;
+ Tk_Font tkfont;
+ Tk_FontMetrics *fmPtr;
+} MenuEntryUserData;
/*
* Various geometry definitions:
*/
@@ -203,6 +211,14 @@ static RgnHandle utilRgn = NULL;/* Used when creating the region that is to
static TopLevelMenubarList *windowListPtr;
/* A list of windows that have menubars set. */
+static MenuItemDrawingUPP tkThemeMenuItemDrawingUPP;
+ /* Points to the UPP for theme Item drawing. */
+
+static GC appearanceGC = NULL; /* The fake appearance GC. If you
+ pass the foreground of this to TkMacSetColor,
+ it will return false, so you will know
+ not to set the foreground color */
+
/*
* Forward declarations for procedures defined later in this file:
@@ -211,6 +227,8 @@ static TopLevelMenubarList *windowListPtr;
static void CompleteIdlers _ANSI_ARGS_((TkMenu *menuPtr));
static void DrawMenuBarWhenIdle _ANSI_ARGS_((
ClientData clientData));
+static void DrawMenuBackground _ANSI_ARGS_((
+ Rect *menuRectPtr, Drawable d, ThemeMenuType type));
static void DrawMenuEntryAccelerator _ANSI_ARGS_((
TkMenu *menuPtr, TkMenuEntry *mePtr,
Drawable d, GC gc, Tk_Font tkfont,
@@ -286,6 +304,13 @@ static void RecursivelyInsertMenu _ANSI_ARGS_((
static void SetDefaultMenubar _ANSI_ARGS_((void));
static int SetMenuCascade _ANSI_ARGS_((TkMenu *menuPtr));
static void SetMenuIndicator _ANSI_ARGS_((TkMenuEntry *mePtr));
+static void AppearanceEntryDrawWrapper _ANSI_ARGS_((TkMenuEntry *mePtr,
+ Rect * menuRectPtr, TkMenuLowMemGlobals *globalsPtr,
+ Drawable d, Tk_FontMetrics *fmPtr, Tk_Font tkfont,
+ int x, int y, int width, int height));
+pascal void tkThemeMenuItemDrawingProc _ANSI_ARGS_ ((const Rect *inBounds,
+ SInt16 inDepth, Boolean inIsColorDevice,
+ SInt32 inUserData));
/*
@@ -1094,10 +1119,15 @@ ReconfigureIndividualMenu(
->menuPtr->platformData)->menuHdl;
}
if (childMenuHdl != NULL) {
+ if (TkMacHaveAppearance() > 1) {
+ SetMenuItemHierarchicalID(macMenuHdl, base + index,
+ (*childMenuHdl)->menuID);
+ } else {
SetItemMark(macMenuHdl, base + index,
(*childMenuHdl)->menuID);
SetItemCmd(macMenuHdl, base + index, CASCADE_CMD);
}
+ }
/*
* If we changed the highligthing of this menu, its
* children all have to be reconfigured so that
@@ -2162,8 +2192,16 @@ GetMenuSeparatorGeometry(
int *widthPtr, /* The resulting width */
int *heightPtr) /* The resulting height */
{
- *widthPtr = 0;
- *heightPtr = fmPtr->linespace;
+ if (TkMacHaveAppearance() > 1) {
+ SInt16 outHeight;
+
+ GetThemeMenuSeparatorHeight(&outHeight);
+ *widthPtr = 0;
+ *heightPtr = outHeight;
+ } else {
+ *widthPtr = 0;
+ *heightPtr = fmPtr->linespace;
+ }
}
/*
@@ -2219,6 +2257,46 @@ DrawMenuEntryIndicator(
/*
*----------------------------------------------------------------------
*
+ * DrawMenuBackground --
+ *
+ * If Appearance is present, draws the Appearance background
+ *
+ * Results:
+ * Nothing
+ *
+ * Side effects:
+ * Commands are output to X to display the menu in its
+ * current mode.
+ *
+ *----------------------------------------------------------------------
+ */
+static void
+DrawMenuBackground(
+ Rect *menuRectPtr, /* The menu rect */
+ Drawable d, /* What we are drawing into */
+ ThemeMenuType type /* Type of menu */
+ )
+{
+ if (!TkMacHaveAppearance()) {
+ return;
+ } else {
+ CGrafPtr saveWorld;
+ GDHandle saveDevice;
+ GWorldPtr destPort;
+
+ destPort = TkMacGetDrawablePort(d);
+ GetGWorld(&saveWorld, &saveDevice);
+ SetGWorld(destPort, NULL);
+ TkMacSetUpClippingRgn(d);
+ DrawThemeMenuBackground (menuRectPtr, type);
+ SetGWorld(saveWorld, saveDevice);
+ return;
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* DrawSICN --
*
* Given a resource id and an index, loads the appropriate SICN
@@ -2324,6 +2402,11 @@ DrawMenuEntryAccelerator(
int drawArrow) /* Whether or not to draw cascade arrow */
{
if (mePtr->type == CASCADE_ENTRY) {
+ /*
+ * Under Appearance, we let the Appearance Manager draw the icon
+ */
+
+ if (!TkMacHaveAppearance()) {
if (0 == DrawSICN(SICN_RESOURCE_NUMBER, CASCADE_ARROW, d, gc,
x + width - SICN_HEIGHT, (y + (height / 2))
- (SICN_HEIGHT / 2))) {
@@ -2342,6 +2425,7 @@ DrawMenuEntryAccelerator(
3, DECORATION_BORDER_WIDTH, TK_RELIEF_FLAT);
}
}
+ }
} else if (mePtr->accelLength != 0) {
int leftEdge = x + width;
int baseline = y + (height + fmPtr->ascent - fmPtr->descent) / 2;
@@ -2429,7 +2513,15 @@ DrawMenuSeparator(
GetGWorld(&saveWorld, &saveDevice);
SetGWorld(destPort, NULL);
TkMacSetUpClippingRgn(d);
-
+ if (TkMacHaveAppearance() > 1) {
+ Rect r;
+ r.top = y;
+ r.left = x;
+ r.bottom = y + height;
+ r.right = x + width;
+
+ DrawThemeMenuSeparator(&r);
+ } else {
/*
* We don't want to use the text GC for drawing the separator. It
* needs to be the same color as disabled items.
@@ -2443,6 +2535,7 @@ DrawMenuSeparator(
SetGWorld(saveWorld, saveDevice);
}
+}
/*
*----------------------------------------------------------------------
@@ -2561,10 +2654,29 @@ MenuDefProc(
SetEmptyRgn(utilRgn);
/*
+ * Now draw the background if Appearance is present...
+ */
+
+ GetGWorld(&macMDEFDrawable.portPtr, &device);
+ if (TkMacHaveAppearance() > 1) {
+ ThemeMenuType menuType;
+
+ if (menuPtr->menuRefPtr->topLevelListPtr != NULL) {
+ menuType = kThemeMenuTypePullDown;
+ } else if (menuPtr->menuRefPtr->parentEntryPtr != NULL) {
+ menuType = kThemeMenuTypeHierarchical;
+ } else {
+ menuType = kThemeMenuTypePopUp;
+ }
+
+ DrawMenuBackground(menuRectPtr, (Drawable) &macMDEFDrawable,
+ menuType);
+ }
+
+ /*
* Next, figure out scrolling information.
*/
- GetGWorld(&macMDEFDrawable.portPtr, &device);
menuClipRect = *menuRectPtr;
if ((menuClipRect.bottom - menuClipRect.top)
< menuPtr->totalHeight) {
@@ -2606,7 +2718,7 @@ MenuDefProc(
> menuClipRect.bottom) {
continue;
}
- ClipRect(&menuClipRect);
+ /* ClipRect(&menuClipRect); */
if (mePtr->tkfont == NULL) {
fmPtr = &fontMetrics;
tkfont = menuPtr->tkfont;
@@ -2615,12 +2727,13 @@ MenuDefProc(
Tk_GetFontMetrics(tkfont, &entryMetrics);
fmPtr = &entryMetrics;
}
- TkpDrawMenuEntry(mePtr, (Drawable) &macMDEFDrawable,
- tkfont, fmPtr, menuRectPtr->left + mePtr->x,
- globalsPtr->menuTop + mePtr->y,
- (mePtr->entryFlags & ENTRY_LAST_COLUMN) ?
- menuPtr->totalWidth - mePtr->x : mePtr->width,
- menuPtr->entries[i]->height, 0, 1);
+ AppearanceEntryDrawWrapper(mePtr, menuRectPtr, globalsPtr,
+ (Drawable) &macMDEFDrawable, fmPtr, tkfont,
+ menuRectPtr->left + mePtr->x,
+ globalsPtr->menuTop + mePtr->y,
+ (mePtr->entryFlags & ENTRY_LAST_COLUMN) ?
+ menuPtr->totalWidth - mePtr->x : mePtr->width,
+ menuPtr->entries[i]->height);
}
globalsPtr->menuBottom = globalsPtr->menuTop
+ menuPtr->totalHeight;
@@ -2646,11 +2759,15 @@ MenuDefProc(
if (TkSetMacColor(menuPtr->textGC->foreground,
&foreColor) == true) {
- RGBForeColor(&foreColor);
+ if (!TkMacHaveAppearance()) {
+ RGBForeColor(&foreColor);
+ }
}
if (TkSetMacColor(menuPtr->textGC->background,
&backColor) == true) {
- RGBBackColor(&backColor);
+ if (!TkMacHaveAppearance()) {
+ RGBBackColor(&backColor);
+ }
}
/*
@@ -2745,13 +2862,13 @@ MenuDefProc(
mePtr = menuPtr->entries[oldItem];
tkfont = mePtr->tkfont ? mePtr->tkfont : menuPtr->tkfont;
Tk_GetFontMetrics(tkfont, &fontMetrics);
- TkpDrawMenuEntry(mePtr, (Drawable) &macMDEFDrawable,
- tkfont, &fontMetrics,
- menuRectPtr->left + mePtr->x,
- globalsPtr->menuTop + mePtr->y,
- (mePtr->entryFlags & ENTRY_LAST_COLUMN)
- ? menuPtr->totalWidth - mePtr->x
- : mePtr->width, mePtr->height, 0, 1);
+ AppearanceEntryDrawWrapper(mePtr, menuRectPtr, globalsPtr,
+ (Drawable) &macMDEFDrawable, &fontMetrics, tkfont,
+ menuRectPtr->left + mePtr->x,
+ globalsPtr->menuTop + mePtr->y,
+ (mePtr->entryFlags & ENTRY_LAST_COLUMN) ?
+ menuPtr->totalWidth - mePtr->x : mePtr->width,
+ mePtr->height);
}
if (newItem != -1) {
int oldActiveItem = menuPtr->active;
@@ -2762,14 +2879,13 @@ MenuDefProc(
}
tkfont = mePtr->tkfont ? mePtr->tkfont : menuPtr->tkfont;
Tk_GetFontMetrics(tkfont, &fontMetrics);
- TkpDrawMenuEntry(mePtr, (Drawable) &macMDEFDrawable,
- tkfont, &fontMetrics,
- menuRectPtr->left + mePtr->x,
- globalsPtr->menuTop + mePtr->y,
- (mePtr->entryFlags & ENTRY_LAST_COLUMN)
- ? menuPtr->totalWidth - mePtr->x
- : mePtr->width, mePtr->height,
- 0, 1);
+ AppearanceEntryDrawWrapper(mePtr, menuRectPtr, globalsPtr,
+ (Drawable) &macMDEFDrawable, &fontMetrics, tkfont,
+ menuRectPtr->left + mePtr->x,
+ globalsPtr->menuTop + mePtr->y,
+ (mePtr->entryFlags & ENTRY_LAST_COLUMN) ?
+ menuPtr->totalWidth - mePtr->x : mePtr->width,
+ mePtr->height);
}
tkUseMenuCascadeRgn = 1;
@@ -2853,12 +2969,13 @@ MenuDefProc(
Tk_GetFontMetrics(tkfont, &entryMetrics);
fmPtr = &entryMetrics;
}
- TkpDrawMenuEntry(mePtr, (Drawable) &macMDEFDrawable,
- tkfont, fmPtr, menuRectPtr->left + mePtr->x,
- globalsPtr->menuTop + mePtr->y,
- (mePtr->entryFlags & ENTRY_LAST_COLUMN) ?
- menuPtr->totalWidth - mePtr->x : mePtr->width,
- menuPtr->entries[i]->height, 0, 1);
+ AppearanceEntryDrawWrapper(mePtr, menuRectPtr, globalsPtr,
+ (Drawable) &macMDEFDrawable, fmPtr, tkfont,
+ menuRectPtr->left + mePtr->x,
+ globalsPtr->menuTop + mePtr->y,
+ (mePtr->entryFlags & ENTRY_LAST_COLUMN) ?
+ menuPtr->totalWidth - mePtr->x : mePtr->width,
+ menuPtr->entries[i]->height);
}
}
@@ -2997,6 +3114,108 @@ MenuDefProc(
/*
*----------------------------------------------------------------------
*
+ * AppearanceEntryDrawWrapper --
+ *
+ * This routine wraps the TkpDrawMenuEntry function. Under Appearance,
+ * it routes to the Appearance Managers DrawThemeEntry, otherwise it
+ * just goes straight to TkpDrawMenuEntry.
+ *
+ * Results:
+ * A menu entry is drawn
+ *
+ * Side effects:
+ * None
+ *
+ *----------------------------------------------------------------------
+ */
+static void
+AppearanceEntryDrawWrapper(
+ TkMenuEntry *mePtr,
+ Rect *menuRectPtr,
+ TkMenuLowMemGlobals *globalsPtr,
+ Drawable d,
+ Tk_FontMetrics *fmPtr,
+ Tk_Font tkfont,
+ int x,
+ int y,
+ int width,
+ int height)
+{
+ if (TkMacHaveAppearance() > 1) {
+ MenuEntryUserData meData;
+ Rect itemRect;
+ ThemeMenuState theState;
+ ThemeMenuItemType theType;
+
+ meData.mePtr = mePtr;
+ meData.mdefDrawable = d;
+ meData.fmPtr = fmPtr;
+ meData.tkfont = tkfont;
+
+ itemRect.top = y;
+ itemRect.left = x;
+ itemRect.bottom = itemRect.top + height;
+ itemRect.right = itemRect.left + width;
+
+ if (mePtr->state == tkActiveUid) {
+ theState = kThemeMenuSelected;
+ } else if (mePtr->state == tkDisabledUid) {
+ theState = kThemeMenuDisabled;
+ } else {
+ theState = kThemeMenuActive;
+ }
+
+ if (mePtr->type == CASCADE_ENTRY) {
+ theType = kThemeMenuItemHierarchical;
+ } else {
+ theType = kThemeMenuItemPlain;
+ }
+
+ DrawThemeMenuItem (menuRectPtr, &itemRect,
+ globalsPtr->menuTop, globalsPtr->menuBottom, theState,
+ theType, tkThemeMenuItemDrawingUPP,
+ (unsigned long) &meData);
+
+ } else {
+ TkpDrawMenuEntry(mePtr, d, tkfont, fmPtr,
+ x, y, width, height, 0, 1);
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * tkThemeMenuItemDrawingProc --
+ *
+ * This routine is called from the Appearance DrawThemeMenuEntry
+ *
+ * Results:
+ * A menu entry is drawn
+ *
+ * Side effects:
+ * None
+ *
+ *----------------------------------------------------------------------
+ */
+pascal void
+tkThemeMenuItemDrawingProc (
+ const Rect *inBounds,
+ SInt16 inDepth,
+ Boolean inIsColorDevice,
+ SInt32 inUserData)
+{
+ MenuEntryUserData *meData = (MenuEntryUserData *) inUserData;
+
+ TkpDrawMenuEntry(meData->mePtr, meData->mdefDrawable,
+ meData->tkfont, meData->fmPtr, inBounds->left,
+ inBounds->top, inBounds->right - inBounds->left,
+ inBounds->bottom - inBounds->top, 0, 1);
+
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TkMacHandleTearoffMenu() --
*
* This routine sees if the MDEF has set a menu and a mouse position
@@ -3127,7 +3346,7 @@ DrawTearoffEntry(
XPoint points[2];
int margin, segmentWidth, maxX;
- if ((menuPtr->menuType != MASTER_MENU) || (GetResource('MDEF', 591) != NULL)) {
+ if ((menuPtr->menuType != MASTER_MENU) || (FixMDEF() != NULL)) {
return;
}
@@ -3265,13 +3484,20 @@ TkpDrawMenuEntry(
/*
* Choose the gc for drawing the foreground part of the entry.
+ * Under Appearance, we pass a null (appearanceGC) to tell
+ * ourselves not to change whatever color the appearance manager has set.
*/
if ((mePtr->state == tkActiveUid)
&& !strictMotif) {
gc = mePtr->activeGC;
if (gc == NULL) {
- gc = menuPtr->activeGC;
+ if ((TkMacHaveAppearance() > 1) && (menuPtr->menuType != TEAROFF_MENU)) {
+ SetThemeTextColor(kThemeSelectedMenuItemTextColor,32,true);
+ gc = appearanceGC;
+ } else {
+ gc = menuPtr->activeGC;
+ }
}
} else {
TkMenuEntry *cascadeEntryPtr;
@@ -3293,15 +3519,26 @@ TkpDrawMenuEntry(
&& (menuPtr->disabledFg != NULL)) {
gc = mePtr->disabledGC;
if (gc == NULL) {
+ if ((TkMacHaveAppearance() > 1) && (mePtr->bitmap == NULL)) {
+ SetThemeTextColor(kThemeDisabledMenuItemTextColor,32,true);
+ gc = appearanceGC;
+ } else {
gc = menuPtr->disabledGC;
}
+ }
} else {
gc = mePtr->textGC;
if (gc == NULL) {
- gc = menuPtr->textGC;
+ if ((TkMacHaveAppearance() > 1) && (mePtr->bitmap == NULL)) {
+ SetThemeTextColor(kThemeActiveMenuItemTextColor,32,true);
+ gc = appearanceGC;
+ } else {
+ gc = menuPtr->textGC;
+ }
}
- }
+ }
}
+
indicatorGC = mePtr->indicatorGC;
if (indicatorGC == NULL) {
indicatorGC = menuPtr->indicatorGC;
@@ -3352,6 +3589,7 @@ TkpDrawMenuEntry(
DrawMenuEntryIndicator(menuPtr, mePtr, d, gc, indicatorGC, tkfont,
fmPtr, x, adjustedY, width, adjustedHeight);
}
+
}
}
@@ -3665,8 +3903,10 @@ DrawMenuEntryLabel(
if (mePtr->state == tkDisabledUid) {
if (menuPtr->disabledFg == NULL) {
- XFillRectangle(menuPtr->display, d, menuPtr->disabledGC, x, y,
- (unsigned) width, (unsigned) height);
+ if (!TkMacHaveAppearance()) {
+ XFillRectangle(menuPtr->display, d, menuPtr->disabledGC, x, y,
+ (unsigned) width, (unsigned) height);
+ }
} else if ((mePtr->image != NULL)
&& (menuPtr->disabledImageGC != None)) {
XFillRectangle(menuPtr->display, d, menuPtr->disabledImageGC,
@@ -3682,7 +3922,9 @@ DrawMenuEntryLabel(
*
* DrawMenuEntryBackground --
*
- * This procedure draws the background part of a menu.
+ * This procedure draws the background part of a menu entry.
+ * Under Appearance, we only draw the background if the entry's
+ * border is set, we DO NOT inherit it from the menu...
*
* Results:
* None.
@@ -3706,11 +3948,16 @@ DrawMenuEntryBackground(
int width, /* width of rectangle to draw */
int height) /* height of rectangle to draw */
{
- if (mePtr->state == tkActiveUid) {
- bgBorder = activeBorder;
+ if (!TkMacHaveAppearance()
+ || (menuPtr->menuType == TEAROFF_MENU)
+ || ((mePtr->state == tkActiveUid) && (mePtr->activeBorder != NULL))
+ || ((mePtr->state != tkActiveUid) && (mePtr->border != NULL))) {
+ if (mePtr->state == tkActiveUid) {
+ bgBorder = activeBorder;
+ }
+ Tk_Fill3DRectangle(menuPtr->tkwin, d, bgBorder,
+ x, y, width, height, 0, TK_RELIEF_FLAT);
}
- Tk_Fill3DRectangle(menuPtr->tkwin, d, bgBorder,
- x, y, width, height, 0, TK_RELIEF_FLAT);
}
/*
@@ -3916,8 +4163,7 @@ TkMacClearMenubarActive(void) {
if ((menuBarRefPtr != NULL) && (menuBarRefPtr->menuPtr != NULL)) {
TkMenu *menuPtr;
- for (menuPtr = menuBarRefPtr->menuPtr->masterMenuPtr;
- menuPtr != NULL;
+ for (menuPtr = menuBarRefPtr->menuPtr->masterMenuPtr; menuPtr != NULL;
menuPtr = menuPtr->nextInstancePtr) {
if (menuPtr->menuType == MENUBAR) {
RecursivelyClearActiveMenu(menuPtr);
@@ -4033,6 +4279,24 @@ TkpMenuInit(void)
currentMenuBarInterp = NULL;
currentMenuBarName = NULL;
windowListPtr = NULL;
+
+ /*
+ * Get the GC that we will use as the sign to the font
+ * routines that they should not muck with the foreground color...
+ */
+
+ if (TkMacHaveAppearance() > 1) {
+ XGCValues tmpValues;
+ TkColor *tmpColorPtr;
+
+ tmpColorPtr = TkpGetColor(NULL, "systemAppearanceColor");
+ tmpValues.foreground = tmpColorPtr->color.pixel;
+ tmpValues.background = tmpColorPtr->color.pixel;
+ appearanceGC = XCreateGC(NULL, NULL, GCForeground | GCBackground, &tmpValues);
+ ckfree((char *) tmpColorPtr);
+
+ tkThemeMenuItemDrawingUPP = NewMenuItemDrawingProc(tkThemeMenuItemDrawingProc);
+ }
FixMDEF();
}
diff --git a/mac/tkMacPort.h b/mac/tkMacPort.h
index ecd5a5b..6175364 100644
--- a/mac/tkMacPort.h
+++ b/mac/tkMacPort.h
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacPort.h,v 1.3 1998/09/30 19:01:21 rjohnson Exp $
+ * RCS: @(#) $Id: tkMacPort.h,v 1.4 1998/11/11 17:31:29 jingham Exp $
*/
#ifndef _TKMACPORT
@@ -142,5 +142,6 @@ extern int strncasecmp _ANSI_ARGS_((CONST char *s1,
#define MENU_BACKGROUND_PIXEL 47
#define MENU_DISABLED_PIXEL 49
#define MENU_TEXT_PIXEL 51
+#define APPEARANCE_PIXEL 52
#endif /* _TKMACPORT */
diff --git a/mac/tkMacWm.c b/mac/tkMacWm.c
index 2833553..ba32f5e 100644
--- a/mac/tkMacWm.c
+++ b/mac/tkMacWm.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacWm.c,v 1.4 1998/09/14 18:23:40 stanton Exp $
+ * RCS: @(#) $Id: tkMacWm.c,v 1.5 1998/11/11 17:31:51 jingham Exp $
*/
#include <Gestalt.h>
@@ -4196,10 +4196,13 @@ TkpWmSetState(winPtr, state)
* TkMacHaveAppearance --
*
* Determine if the appearance manager is available on this Mac.
- * We cache the result so future calls are fast.
+ * We cache the result so future calls are fast. Return a different
+ * value if 1.0.1 is present, since many interfaces were added in
+ * 1.0.1
*
* Results:
- * True if the appearance manager is present, false otherwise.
+ * 1 if the appearance manager is present, 2 if the appearance
+ * manager version is 1.0.1 or greater, 0 if it is not present.
*
* Side effects:
* Calls Gestalt to query system values.
@@ -4211,14 +4214,18 @@ int
TkMacHaveAppearance()
{
static initialized = false;
- static int TkMacHaveAppearance = false;
+ static int TkMacHaveAppearance = 0;
long response = 0;
OSErr err = noErr;
if (!initialized) {
err = Gestalt(gestaltAppearanceAttr, &response);
if (err == noErr) {
- TkMacHaveAppearance = true;
+ TkMacHaveAppearance = 1;
+ }
+ err = Gestalt(gestaltAppearanceVersion, &response);
+ if (err == noErr) {
+ TkMacHaveAppearance = 2;
}
}