summaryrefslogtreecommitdiffstats
path: root/mac/tkMacMenu.c
diff options
context:
space:
mode:
Diffstat (limited to 'mac/tkMacMenu.c')
-rw-r--r--mac/tkMacMenu.c546
1 files changed, 370 insertions, 176 deletions
diff --git a/mac/tkMacMenu.c b/mac/tkMacMenu.c
index 33bb82b..a44636c 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.
*
- * SCCS: @(#) tkMacMenu.c 1.107 97/11/20 18:33:09
+ * SCCS: @(#) tkMacMenu.c 1.111 98/01/21 22:04:59
*/
#include <Menus.h>
@@ -18,11 +18,11 @@
#include <string.h>
#include <ToolUtils.h>
#include <Balloons.h>
-#undef Status
-#include <Devices.h>
#include "tkMenu.h"
#include "tkMacInt.h"
-#include "tkMenuButton.h"
+#include "tkMenubutton.h"
+#undef Status
+#include <Devices.h>
typedef struct MacMenu {
MenuHandle menuHdl; /* The Menu Manager data structure. */
@@ -46,7 +46,7 @@ typedef struct MacMenu {
* The following are constants relating to the SICNs used for drawing the MDEF.
*/
-#define SICN_RESOURCE_NUMBER 128
+#define SICN_RESOURCE_NUMBER 128
#define SICN_HEIGHT 16
#define SICN_ROWS 2
@@ -139,6 +139,8 @@ typedef struct TopLevelMenubarList {
#define MENUBAR_REDRAW_PENDING 1
+static int gNoTkMenus = 0; /* This is used by Tk_MacTurnOffMenus as the
+ * flag that Tk is not to draw any menus. */
RgnHandle tkMenuCascadeRgn = NULL;
/* The region to clip drawing to when the
* MDEF is up. */
@@ -166,6 +168,9 @@ static char *currentMenuBarName;
* DString. */
static Tk_Window currentMenuBarOwner;
/* Which window owns the current menu bar. */
+static char elipsisString[TCL_UTF_MAX + 1];
+ /* The UTF representation of the elipsis (ƒ)
+ * character. */
static int helpItemCount; /* The number of items in the help menu.
* -1 means that the help menu is
* unavailable. This does not include
@@ -182,7 +187,8 @@ static MacDrawable macMDEFDrawable;
static MDEFScrollFlag = 0; /* Used so that popups don't scroll too soon. */
static int menuBarFlags; /* Used for whether the menu bar needs
* redrawing or not. */
-static TkMenuDefUPP menuDefProc;/* The routine descriptor to the MDEF proc.
+static TkMenuDefUPP menuDefProc = NULL ;
+ /* The routine descriptor to the MDEF proc.
* The MDEF is needed to draw menus with
* non-standard attributes and to support
* tearoff menus. */
@@ -240,6 +246,8 @@ static void DrawTearoffEntry _ANSI_ARGS_((TkMenu *menuPtr,
Tk_Font tkfont, CONST Tk_FontMetrics *fmPtr,
int x, int y, int width, int height));
static void FixMDEF _ANSI_ARGS_((void));
+static void GetEntryText _ANSI_ARGS_((TkMenuEntry *mePtr,
+ Tcl_DString *dStringPtr));
static void GetMenuAccelGeometry _ANSI_ARGS_((TkMenu *menuPtr,
TkMenuEntry *mePtr, Tk_Font tkfont,
CONST Tk_FontMetrics *fmPtr, int *modWidthPtr,
@@ -284,6 +292,8 @@ 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 SetMenuTitle _ANSI_ARGS_((MenuHandle menuHdl,
+ Tcl_Obj *titlePtr));
/*
@@ -308,7 +318,7 @@ static void SetMenuIndicator _ANSI_ARGS_((TkMenuEntry *mePtr));
int
TkMacUseMenuID(
- short macID) /* The id to take out of the table */
+ short macID) /* The id to take out of the table */
{
Tcl_HashEntry *commandEntryPtr;
int newEntry;
@@ -419,6 +429,7 @@ GetNewID(
*menuIDPtr = returnID;
return TCL_OK;
} else {
+ Tcl_ResetResult(interp);
Tcl_AppendResult(interp, "No more menus can be allocated.",
(char *) NULL);
return TCL_ERROR;
@@ -655,7 +666,8 @@ TkpDestroyMenuEntry(
*
* Given a menu entry, gives back the text that should go in it.
* Separators should be done by the caller, as they have to be
- * handled specially.
+ * handled specially. This is primarily used to do a substitution
+ * between "..." and "ƒ".
*
* Results:
* itemText points to the new text for the item.
@@ -669,36 +681,41 @@ TkpDestroyMenuEntry(
static void
GetEntryText(
TkMenuEntry *mePtr, /* A pointer to the menu entry. */
- Str255 itemText) /* The pascal string containing the text */
+ Tcl_DString *dStringPtr) /* The DString to put the text into. This
+ * will be initialized by this routine. */
{
+ Tcl_DStringInit(dStringPtr);
if (mePtr->type == TEAROFF_ENTRY) {
- strcpy((char *)itemText, (const char *)"\p(Tear-off)");
- } else if (mePtr->imageString != NULL) {
- strcpy((char *)itemText, (const char *)"\p(Image)");
- } else if (mePtr->bitmap != None) {
- strcpy((char *)itemText, (const char *)"\p(Pixmap)");
- } else if (mePtr->label == NULL || mePtr->labelLength == 0) {
+ Tcl_DStringAppend(dStringPtr, "(Tear-off)", -1);
+ } else if (mePtr->imagePtr != NULL) {
+ Tcl_DStringAppend(dStringPtr, "(Image)", -1);
+ } else if (mePtr->bitmapPtr != NULL) {
+ Tcl_DStringAppend(dStringPtr, "(Pixmap)", -1);
+ } else if (mePtr->labelPtr == NULL || mePtr->labelLength == 0) {
/*
* The Mac menu manager does not like null strings.
*/
- strcpy((char *)itemText, (const char *)"\p ");
+ Tcl_DStringAppend(dStringPtr, " ", -1);
} else {
- char *text = mePtr->label;
+ int length;
+ char *text = Tcl_GetStringFromObj(mePtr->labelPtr, &length);
+ char *dStringText;
int i;
- itemText[0] = 0;
- for (i = 1; (*text != '\0') && (i <= 230); i++, text++) {
+ for (i = 0; i < length; text++, i++) {
if ((*text == '.')
&& (*(text + 1) != '\0') && (*(text + 1) == '.')
&& (*(text + 2) != '\0') && (*(text + 2) == '.')) {
- itemText[i] = 'É';
- text += 2;
- } else {
- itemText[i] = *text;
+ Tcl_DStringAppend(dStringPtr, elipsisString, -1);
+ i += strlen(elipsisString) - 1;
+ } else {
+ Tcl_DStringSetLength(dStringPtr,
+ Tcl_DStringLength(dStringPtr) + 1);
+ dStringText = Tcl_DStringValue(dStringPtr);
+ dStringText[i] = *text;
}
- itemText[0] += 1;
}
}
}
@@ -715,10 +732,10 @@ GetEntryText(
* We try the following special mac characters. If none of them
* are present, just use the check mark.
* '' - Check mark character
- * '¥' - Bullet character
+ * '´' - Bullet character
* '' - Filled diamond
* '×' - Hollow diamond
- * 'Ñ' = Long dash ("em dash")
+ * '„' = Long dash ("em dash")
* '-' = short dash (minus, "en dash");
*
* Results:
@@ -736,19 +753,22 @@ FindMarkCharacter(
* for. */
{
char markChar;
- Tk_Font tkfont = (mePtr->tkfont == NULL) ? mePtr->menuPtr->tkfont
- : mePtr->tkfont;
+ Tk_Font tkfont;
+
+ tkfont = Tk_GetFontFromObj(mePtr->menuPtr->tkwin,
+ (mePtr->fontPtr == NULL) ? mePtr->menuPtr->fontPtr
+ : mePtr->fontPtr);
if (!TkMacIsCharacterMissing(tkfont, '')) {
markChar = '';
- } else if (!TkMacIsCharacterMissing(tkfont, '¥')) {
- markChar = '¥';
+ } else if (!TkMacIsCharacterMissing(tkfont, '´')) {
+ markChar = '´';
} else if (!TkMacIsCharacterMissing(tkfont, '')) {
markChar = '';
} else if (!TkMacIsCharacterMissing(tkfont, '×')) {
markChar = '×';
- } else if (!TkMacIsCharacterMissing(tkfont, 'Ñ')) {
- markChar = 'Ñ';
+ } else if (!TkMacIsCharacterMissing(tkfont, '„')) {
+ markChar = '„';
} else if (!TkMacIsCharacterMissing(tkfont, '-')) {
markChar = '-';
} else {
@@ -781,6 +801,7 @@ SetMenuIndicator(
TkMenu *menuPtr = mePtr->menuPtr;
MenuHandle macMenuHdl = ((MacMenu *) menuPtr->platformData)->menuHdl;
char markChar;
+ int indicatorOn;
/*
* There can be no indicators on menus that are not checkbuttons
@@ -795,14 +816,14 @@ SetMenuIndicator(
if (mePtr->type == CASCADE_ENTRY) {
return;
}
-
- if (((mePtr->type == RADIO_BUTTON_ENTRY)
- || (mePtr->type == CHECK_BUTTON_ENTRY))
- && (mePtr->indicatorOn)
- && (mePtr->entryFlags & ENTRY_SELECTED)) {
- markChar = FindMarkCharacter(mePtr);
- } else {
- markChar = 0;
+
+ markChar = 0;
+ if ((mePtr->type == RADIO_BUTTON_ENTRY)
+ || (mePtr->type == CHECK_BUTTON_ENTRY)) {
+ Tcl_GetBooleanFromObj(NULL, mePtr->indicatorOnPtr, &indicatorOn);
+ if (indicatorOn && (mePtr->entryFlags & ENTRY_SELECTED)) {
+ markChar = FindMarkCharacter(mePtr);
+ }
}
SetItemMark(macMenuHdl, mePtr->index + 1, markChar);
}
@@ -829,10 +850,12 @@ SetMenuIndicator(
static void
SetMenuTitle(
MenuHandle menuHdl, /* The menu we are setting the title of. */
- char *title) /* The C string to set the title to. */
+ Tcl_Obj *titlePtr) /* The C string to set the title to. */
{
int oldLength, newLength, oldHandleSize, dataLength;
Ptr menuDataPtr;
+ char *title = (titlePtr == NULL) ? ""
+ : Tcl_GetStringFromObj(titlePtr, NULL);
menuDataPtr = (Ptr) (*menuHdl)->menuData;
@@ -869,7 +892,7 @@ SetMenuTitle(
*
* Results:
* Returns standard TCL result. If TCL_ERROR is returned, then
- * interp->result contains an error message.
+ * the interp's result contains an error message.
*
* Side effects:
* Configuration information get set for mePtr; old resources
@@ -909,7 +932,7 @@ TkpConfigureMenuEntry(
}
if (menuPtr->menuType == MENUBAR) {
- SetMenuTitle(childMenuHdl, mePtr->label);
+ SetMenuTitle(childMenuHdl, mePtr->labelPtr);
}
}
}
@@ -925,7 +948,9 @@ TkpConfigureMenuEntry(
if (0 == mePtr->accelLength) {
((EntryGeometry *)mePtr->platformEntryData)->accelTextStart = -1;
} else {
- char *accelString = mePtr->accel;
+ char *accelString = (mePtr->accelPtr == NULL) ? ""
+ : Tcl_GetStringFromObj(mePtr->accelPtr, NULL);
+ char *accel = accelString;
mePtr->entryFlags |= ~ENTRY_ACCEL_MASK;
while (1) {
@@ -971,7 +996,7 @@ TkpConfigureMenuEntry(
}
((EntryGeometry *)mePtr->platformEntryData)->accelTextStart
- = ((long) accelString - (long) mePtr->accel);
+ = ((long) accelString - (long) accel);
}
if (!(menuPtr->menuFlags & MENU_RECONFIGURE_PENDING)) {
@@ -1018,11 +1043,17 @@ ReconfigureIndividualMenu(
TkMenuEntry *mePtr;
Str255 itemText;
int parentDisabled = 0;
+ int state;
for (mePtr = menuPtr->menuRefPtr->parentEntryPtr; mePtr != NULL;
mePtr = mePtr->nextCascadePtr) {
- if (strcmp(Tk_PathName(menuPtr->tkwin), mePtr->name) == 0) {
- if (mePtr->state == tkDisabledUid) {
+ char *name = (mePtr->namePtr == NULL) ? ""
+ : Tcl_GetStringFromObj(mePtr->namePtr, NULL);
+
+ if (strcmp(Tk_PathName(menuPtr->tkwin), name) == 0) {
+ Tcl_GetIndexFromObj(NULL, mePtr->statePtr, tkMenuStateStrings,
+ NULL, 0, &state);
+ if (state == ENTRY_DISABLED) {
parentDisabled = 1;
}
break;
@@ -1051,15 +1082,27 @@ ReconfigureIndividualMenu(
if (mePtr->type == SEPARATOR_ENTRY) {
AppendMenu(macMenuHdl, SEPARATOR_TEXT);
} else {
- GetEntryText(mePtr, itemText);
+ Tcl_DString itemTextDString;
+ int destWrote;
+
+ GetEntryText(mePtr, &itemTextDString);
+ Tcl_UtfToExternal(NULL, NULL, Tcl_DStringValue(&itemTextDString),
+ Tcl_DStringLength(&itemTextDString), 0, NULL,
+ (char *) &itemText[1],
+ 231, NULL, &destWrote, NULL);
+ itemText[0] = destWrote;
+
AppendMenu(macMenuHdl, "\px");
SetMenuItemText(macMenuHdl, base + index, itemText);
+ Tcl_DStringFree(&itemTextDString);
/*
* Set enabling and disabling correctly.
*/
- if (parentDisabled || (mePtr->state == tkDisabledUid)) {
+ Tcl_GetIndexFromObj(NULL, mePtr->statePtr, tkMenuStateStrings,
+ NULL, 0, &state);
+ if (parentDisabled || (state == ENTRY_DISABLED)) {
DisableItem(macMenuHdl, base + index);
} else {
EnableItem(macMenuHdl, base + index);
@@ -1072,9 +1115,13 @@ ReconfigureIndividualMenu(
SetItemMark(macMenuHdl, base + index, 0);
if ((mePtr->type == CHECK_BUTTON_ENTRY)
|| (mePtr->type == RADIO_BUTTON_ENTRY)) {
+ int indicatorOn;
+
+ Tcl_GetBooleanFromObj(NULL, mePtr->indicatorOnPtr,
+ &indicatorOn);
CheckItem(macMenuHdl, base + index, (mePtr->entryFlags
- & ENTRY_SELECTED) && (mePtr->indicatorOn));
- if ((mePtr->indicatorOn)
+ & ENTRY_SELECTED) && (indicatorOn));
+ if ((indicatorOn)
&& (mePtr->entryFlags & ENTRY_SELECTED)) {
SetItemMark(macMenuHdl, base + index,
FindMarkCharacter(mePtr));
@@ -1116,9 +1163,9 @@ ReconfigureIndividualMenu(
if ((mePtr->type != CASCADE_ENTRY)
&& (ENTRY_COMMAND_ACCEL
== (mePtr->entryFlags & ENTRY_ACCEL_MASK))) {
- SetItemCmd(macMenuHdl, index, mePtr
- ->accel[((EntryGeometry *)mePtr->platformEntryData)
- ->accelTextStart]);
+ char *accel = Tcl_GetStringFromObj(mePtr->accelPtr, NULL);
+ SetItemCmd(macMenuHdl, index, accel[((EntryGeometry *)
+ mePtr->platformEntryData)->accelTextStart]);
}
}
}
@@ -1396,6 +1443,31 @@ TkpMenuNewEntry(
*----------------------------------------------------------------------
*
*
+ * Tk_MacTurnOffMenus --
+ *
+ * Turns off all the menu drawing code. This is more than just disabling
+ * the "menu" command, this means that Tk will NEVER touch the menubar.
+ * It is needed in the Plugin, where Tk does not own the menubar.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * A flag is set which will disable all menu drawing.
+ *
+ *----------------------------------------------------------------------
+ */
+
+EXTERN void
+Tk_MacTurnOffMenus()
+{
+ gNoTkMenus = 1;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ *
* DrawMenuBarWhenIdle --
*
* Update the menu bar next time there is an idle event.
@@ -1419,6 +1491,14 @@ DrawMenuBarWhenIdle(
Tcl_HashEntry *hashEntryPtr;
/*
+ * If we have been turned off, exit.
+ */
+
+ if (gNoTkMenus) {
+ return;
+ }
+
+ /*
* We need to clear the apple and help menus of any extra items.
*/
@@ -1527,9 +1607,14 @@ DrawMenuBarWhenIdle(
if (menuBarPtr == NULL) {
SetDefaultMenubar();
- } else {
- if (menuBarPtr->tearOff != menuPtr->tearOff) {
- if (menuBarPtr->tearOff) {
+ } else {
+ int menuBarTearoff, menuTearoff;
+
+ Tcl_GetBooleanFromObj(NULL, menuBarPtr->tearoffPtr,
+ &menuBarTearoff);
+ Tcl_GetBooleanFromObj(NULL, menuPtr->tearoffPtr, &menuTearoff);
+ if (menuBarTearoff != menuTearoff) {
+ if (menuBarTearoff) {
appleIndex = (-1 == appleIndex) ? appleIndex
: appleIndex + 1;
helpIndex = (-1 == helpIndex) ? helpIndex
@@ -1577,7 +1662,12 @@ DrawMenuBarWhenIdle(
for (i = 0; i < menuBarPtr->numEntries; i++) {
if (i == appleIndex) {
- if (menuBarPtr->entries[i]->state == tkDisabledUid) {
+ int state;
+
+ Tcl_GetIndexFromObj(NULL,
+ menuBarPtr->entries[i]->statePtr,
+ tkMenuStateStrings, NULL, 0, &state);
+ if (state == ENTRY_DISABLED) {
DisableItem(((MacMenu *) menuBarPtr->entries[i]
->childMenuRefPtr->menuPtr
->platformData)->menuHdl,
@@ -1613,6 +1703,8 @@ DrawMenuBarWhenIdle(
if ((menuBarPtr->entries[i]->childMenuRefPtr != NULL)
&& menuBarPtr->entries[i]->childMenuRefPtr
->menuPtr != NULL) {
+ int state;
+
cascadeMenuPtr = menuBarPtr->entries[i]
->childMenuRefPtr->menuPtr;
macMenuHdl = ((MacMenu *) cascadeMenuPtr
@@ -1620,7 +1712,10 @@ DrawMenuBarWhenIdle(
DeleteMenu((*macMenuHdl)->menuID);
InsertMenu(macMenuHdl, 0);
RecursivelyInsertMenu(cascadeMenuPtr);
- if (menuBarPtr->entries[i]->state == tkDisabledUid) {
+ Tcl_GetIndexFromObj(NULL,
+ menuBarPtr->entries[i]->statePtr,
+ tkMenuStateStrings, NULL, 0, &state);
+ if (state == ENTRY_DISABLED) {
DisableItem(((MacMenu *) menuBarPtr->entries[i]
->childMenuRefPtr->menuPtr
->platformData)->menuHdl,
@@ -1675,7 +1770,8 @@ RecursivelyInsertMenu(
&& (menuPtr->entries[i]->childMenuRefPtr->menuPtr
!= NULL)) {
cascadeMenuPtr = menuPtr->entries[i]->childMenuRefPtr->menuPtr;
- macMenuHdl = ((MacMenu *) cascadeMenuPtr->platformData)->menuHdl;
+ macMenuHdl =
+ ((MacMenu *) cascadeMenuPtr->platformData)->menuHdl;
InsertMenu(macMenuHdl, -1);
RecursivelyInsertMenu(cascadeMenuPtr);
}
@@ -1716,7 +1812,8 @@ RecursivelyDeleteMenu(
&& (menuPtr->entries[i]->childMenuRefPtr->menuPtr
!= NULL)) {
cascadeMenuPtr = menuPtr->entries[i]->childMenuRefPtr->menuPtr;
- macMenuHdl = ((MacMenu *) cascadeMenuPtr->platformData)->menuHdl;
+ macMenuHdl =
+ ((MacMenu *) cascadeMenuPtr->platformData)->menuHdl;
DeleteMenu((*macMenuHdl)->menuID);
RecursivelyInsertMenu(cascadeMenuPtr);
}
@@ -1826,7 +1923,8 @@ TkpSetMainMenubar(
}
}
if (listPtr != NULL) {
- menuName = Tk_PathName(listPtr->menuPtr->masterMenuPtr->tkwin);
+ menuName = Tk_PathName(listPtr->menuPtr->masterMenuPtr
+ ->tkwin);
break;
}
}
@@ -2028,15 +2126,15 @@ GetMenuAccelGeometry (
} else if (0 == mePtr->accelLength) {
*textWidthPtr = 0;
} else {
+ char *accel = (mePtr->accelPtr == NULL) ? ""
+ : Tcl_GetStringFromObj(mePtr->accelPtr, NULL);
if (NULL == GetResource('SICN', SICN_RESOURCE_NUMBER)) {
- *textWidthPtr = Tk_TextWidth(tkfont, mePtr->accel,
- mePtr->accelLength);
+ *textWidthPtr = Tk_TextWidth(tkfont, accel, mePtr->accelLength);
} else {
int emWidth = Tk_TextWidth(tkfont, "W", 1) + 1;
if ((mePtr->entryFlags & ENTRY_ACCEL_MASK) == 0) {
- int width = Tk_TextWidth(tkfont, mePtr->accel,
- mePtr->accelLength);
+ int width = Tk_TextWidth(tkfont, accel, mePtr->accelLength);
*textWidthPtr = emWidth;
if (width < emWidth) {
*modWidthPtr = 0;
@@ -2061,7 +2159,7 @@ GetMenuAccelGeometry (
if (1 == (mePtr->accelLength - length)) {
*textWidthPtr = emWidth;
} else {
- *textWidthPtr += Tk_TextWidth(tkfont, mePtr->accel
+ *textWidthPtr += Tk_TextWidth(tkfont, accel
+ length, mePtr->accelLength - length);
}
}
@@ -2163,21 +2261,31 @@ DrawMenuEntryIndicator(
int width, /* width of entry */
int height) /* height of entry */
{
- if (((mePtr->type == CHECK_BUTTON_ENTRY) ||
- (mePtr->type == RADIO_BUTTON_ENTRY))
- && (mePtr->indicatorOn)
- && (mePtr->entryFlags & ENTRY_SELECTED)) {
- int baseline;
- short markShort;
- char markChar;
+ if ((mePtr->type == CHECK_BUTTON_ENTRY) ||
+ (mePtr->type == RADIO_BUTTON_ENTRY)) {
+ int indicatorOn;
+
+ Tcl_GetBooleanFromObj(NULL, mePtr->indicatorOnPtr, &indicatorOn);
+
+ if ((indicatorOn)
+ && (mePtr->entryFlags & ENTRY_SELECTED)) {
+ int baseline;
+ short markShort;
- baseline = y + (height + fmPtr->ascent - fmPtr->descent) / 2;
- GetItemMark(((MacMenu *) menuPtr->platformData)->menuHdl,
- mePtr->index + 1, &markShort);
- if (markShort != 0) {
- markChar = (char) markShort;
- Tk_DrawChars(menuPtr->display, d, gc, tkfont, &markChar, 1,
- x + 2, baseline);
+ baseline = y + (height + fmPtr->ascent - fmPtr->descent) / 2;
+ GetItemMark(((MacMenu *) menuPtr->platformData)->menuHdl,
+ mePtr->index + 1, &markShort);
+ if (markShort != 0) {
+ char markChar;
+ char markCharUTF[TCL_UTF_MAX + 1];
+ int dstWrote;
+
+ markChar = (char) markShort;
+ Tcl_ExternalToUtf(NULL, NULL, &markChar, 1, 0, NULL,
+ markCharUTF, TCL_UTF_MAX + 1, NULL, &dstWrote, NULL);
+ Tk_DrawChars(menuPtr->display, d, gc, tkfont, markCharUTF,
+ dstWrote, x + 2, baseline);
+ }
}
}
}
@@ -2289,6 +2397,10 @@ DrawMenuEntryAccelerator(
int height, /* The height of the entry */
int drawArrow) /* Whether or not to draw cascade arrow */
{
+ int activeBorderWidth;
+
+ Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->activeBorderWidthPtr,
+ &activeBorderWidth);
if (mePtr->type == CASCADE_ENTRY) {
if (0 == DrawSICN(SICN_RESOURCE_NUMBER, CASCADE_ARROW, d, gc,
x + width - SICN_HEIGHT, (y + (height / 2))
@@ -2297,7 +2409,7 @@ DrawMenuEntryAccelerator(
Tk_Window tkwin = menuPtr->tkwin;
if (mePtr->type == CASCADE_ENTRY) {
- points[0].x = width - menuPtr->activeBorderWidth
+ points[0].x = width - activeBorderWidth
- MAC_MARGIN_WIDTH - CASCADE_ARROW_WIDTH;
points[0].y = y + (height - CASCADE_ARROW_HEIGHT)/2;
points[1].x = points[0].x;
@@ -2311,11 +2423,14 @@ DrawMenuEntryAccelerator(
} else if (mePtr->accelLength != 0) {
int leftEdge = x + width;
int baseline = y + (height + fmPtr->ascent - fmPtr->descent) / 2;
+ char *accel;
+
+ accel = Tcl_GetStringFromObj(mePtr->accelPtr, NULL);
if (NULL == GetResource('SICN', SICN_RESOURCE_NUMBER)) {
leftEdge -= ((EntryGeometry *) mePtr->platformEntryData)
->accelTextWidth;
- Tk_DrawChars(menuPtr->display, d, gc, tkfont, mePtr->accel,
+ Tk_DrawChars(menuPtr->display, d, gc, tkfont, accel,
mePtr->accelLength, leftEdge, baseline);
} else {
EntryGeometry *geometryPtr =
@@ -2327,7 +2442,7 @@ DrawMenuEntryAccelerator(
leftEdge -= geometryPtr->modifierWidth;
}
- Tk_DrawChars(menuPtr->display, d, gc, tkfont, mePtr->accel
+ Tk_DrawChars(menuPtr->display, d, gc, tkfont, accel
+ geometryPtr->accelTextStart, length, leftEdge, baseline);
if (mePtr->entryFlags & ENTRY_COMMAND_ACCEL) {
@@ -2403,10 +2518,8 @@ DrawMenuSeparator(
TkMacSetUpGraphicsPort(mePtr->disabledGC != None ? mePtr->disabledGC
: menuPtr->disabledGC);
-
MoveTo(x, y + (height / 2));
Line(width, 0);
-
SetGWorld(saveWorld, saveDevice);
}
@@ -2447,7 +2560,7 @@ MenuDefProc(
TkMenuEntry *parentEntryPtr;
Tcl_HashEntry *commandEntryPtr;
GrafPtr windowMgrPort;
- Tk_Font tkfont;
+ Tk_Font tkfont, menuFont;
Tk_FontMetrics fontMetrics, entryMetrics;
Tk_FontMetrics *fmPtr;
TkMenuEntry *mePtr;
@@ -2562,7 +2675,8 @@ MenuDefProc(
* that are lower than the bottom.
*/
- Tk_GetFontMetrics(menuPtr->tkfont, &fontMetrics);
+ menuFont = Tk_GetFontFromObj(menuPtr->tkwin, menuPtr->fontPtr);
+ Tk_GetFontMetrics(menuFont, &fontMetrics);
for (i = 0; i < menuPtr->numEntries; i++) {
mePtr = menuPtr->entries[i];
if (globalsPtr->menuTop + mePtr->y + mePtr->height
@@ -2573,11 +2687,11 @@ MenuDefProc(
continue;
}
ClipRect(&menuClipRect);
- if (mePtr->tkfont == NULL) {
+ if (mePtr->fontPtr == NULL) {
fmPtr = &fontMetrics;
- tkfont = menuPtr->tkfont;
+ tkfont = menuFont;
} else {
- tkfont = mePtr->tkfont;
+ tkfont = Tk_GetFontFromObj(menuPtr->tkwin, mePtr->fontPtr);
Tk_GetFontMetrics(tkfont, &entryMetrics);
fmPtr = &entryMetrics;
}
@@ -2598,7 +2712,7 @@ MenuDefProc(
break;
case mChooseMsg: {
- int hasTopScroll, hasBottomScroll;
+ int hasTopScroll, hasBottomScroll, tearoff;
enum {
DONT_SCROLL, DOWN_SCROLL, UP_SCROLL
} scrollDirection;
@@ -2640,8 +2754,12 @@ MenuDefProc(
itemRect.bottom = itemRect.top
+ menuPtr->entries[i]->height;
if (PtInRect(hitPt, &itemRect)) {
+ int state;
+
+ Tcl_GetIndexFromObj(NULL, mePtr->statePtr,
+ tkMenuStateStrings, NULL, 0, &state);
if ((mePtr->type == SEPARATOR_ENTRY)
- || (mePtr->state == tkDisabledUid)) {
+ || (state == ENTRY_DISABLED)) {
newItem = -1;
} else {
TkMenuEntry *cascadeEntryPtr;
@@ -2652,10 +2770,17 @@ MenuDefProc(
cascadeEntryPtr != NULL;
cascadeEntryPtr
= cascadeEntryPtr->nextCascadePtr) {
- if (strcmp(cascadeEntryPtr->name,
- Tk_PathName(menuPtr->tkwin)) == 0) {
- if (cascadeEntryPtr->state
- == tkDisabledUid) {
+ char *name;
+
+ name = Tcl_GetStringFromObj(
+ cascadeEntryPtr->namePtr, NULL);
+ if (strcmp(name, Tk_PathName(menuPtr->tkwin))
+ == 0) {
+ Tcl_GetIndexFromObj(NULL,
+ cascadeEntryPtr->statePtr,
+ tkMenuStateStrings, NULL, 0,
+ &state);
+ if (state == ENTRY_DISABLED) {
parentDisabled = 1;
}
break;
@@ -2707,9 +2832,17 @@ MenuDefProc(
ClipRect(&menuClipRect);
if (oldItem != newItem) {
+ int state;
+
if (oldItem >= 0) {
mePtr = menuPtr->entries[oldItem];
- tkfont = mePtr->tkfont ? mePtr->tkfont : menuPtr->tkfont;
+ if (mePtr->fontPtr == NULL) {
+ tkfont = Tk_GetFontFromObj(menuPtr->tkwin,
+ menuPtr->fontPtr);
+ } else {
+ tkfont = Tk_GetFontFromObj(menuPtr->tkwin,
+ mePtr->fontPtr);
+ }
Tk_GetFontMetrics(tkfont, &fontMetrics);
TkpDrawMenuEntry(mePtr, (Drawable) &macMDEFDrawable,
tkfont, &fontMetrics,
@@ -2723,10 +2856,18 @@ MenuDefProc(
int oldActiveItem = menuPtr->active;
mePtr = menuPtr->entries[newItem];
- if (mePtr->state != tkDisabledUid) {
+ Tcl_GetIndexFromObj(NULL, mePtr->statePtr,
+ tkMenuStateStrings, NULL, 0, &state);
+ if (state != ENTRY_DISABLED) {
TkActivateMenuEntry(menuPtr, newItem);
}
- tkfont = mePtr->tkfont ? mePtr->tkfont : menuPtr->tkfont;
+ if (mePtr->fontPtr == NULL) {
+ tkfont = Tk_GetFontFromObj(menuPtr->tkwin,
+ menuPtr->fontPtr);
+ } else {
+ tkfont = Tk_GetFontFromObj(menuPtr->tkwin,
+ mePtr->fontPtr);
+ }
Tk_GetFontMetrics(tkfont, &fontMetrics);
TkpDrawMenuEntry(mePtr, (Drawable) &macMDEFDrawable,
tkfont, &fontMetrics,
@@ -2742,7 +2883,9 @@ MenuDefProc(
MenuSelectEvent(menuPtr);
Tcl_ServiceAll();
tkUseMenuCascadeRgn = 0;
- if (mePtr->state != tkDisabledUid) {
+ Tcl_GetIndexFromObj(NULL, mePtr->statePtr,
+ tkMenuStateStrings, NULL, 0, &state);
+ if (state != ENTRY_DISABLED) {
TkActivateMenuEntry(menuPtr, -1);
}
*whichItem = newItem + 1;
@@ -2755,7 +2898,8 @@ MenuDefProc(
- globalsPtr->menuBottom) {
scrollAmt = menuRectPtr->bottom - globalsPtr->menuBottom;
}
- if (!hasTopScroll && ((globalsPtr->menuTop + scrollAmt) < menuRectPtr->top)) {
+ if (!hasTopScroll && ((globalsPtr->menuTop + scrollAmt)
+ < menuRectPtr->top)) {
SetRect(&updateRect, menuRectPtr->left,
globalsPtr->menuTop, menuRectPtr->right,
globalsPtr->menuTop + SICN_HEIGHT);
@@ -2787,6 +2931,7 @@ MenuDefProc(
}
}
if (scrollDirection != DONT_SCROLL) {
+ Tk_Font menuFont;
RgnHandle updateRgn = NewRgn();
ScrollRect(&menuClipRect, 0, scrollAmt, updateRgn);
updateRect = (*updateRgn)->rgnBBox;
@@ -2801,7 +2946,8 @@ MenuDefProc(
}
ClipRect(&updateRect);
EraseRect(&updateRect);
- Tk_GetFontMetrics(menuPtr->tkfont, &fontMetrics);
+ menuFont = Tk_GetFontFromObj(menuPtr->tkwin, menuPtr->fontPtr);
+ Tk_GetFontMetrics(menuFont, &fontMetrics);
for (i = 0; i < menuPtr->numEntries; i++) {
mePtr = menuPtr->entries[i];
if (globalsPtr->menuTop + mePtr->y + mePtr->height
@@ -2811,11 +2957,12 @@ MenuDefProc(
> updateRect.bottom) {
continue;
}
- if (mePtr->tkfont == NULL) {
+ if (mePtr->fontPtr == NULL) {
fmPtr = &fontMetrics;
- tkfont = menuPtr->tkfont;
+ tkfont = menuFont;
} else {
- tkfont = mePtr->tkfont;
+ tkfont = Tk_GetFontFromObj(menuPtr->tkwin,
+ mePtr->fontPtr);
Tk_GetFontMetrics(tkfont, &entryMetrics);
fmPtr = &entryMetrics;
}
@@ -2844,18 +2991,24 @@ MenuDefProc(
menuRefPtr = TkFindMenuReferences(menuPtr->interp,
Tk_PathName(menuPtr->tkwin));
if ((menuRefPtr != NULL) && (menuRefPtr->parentEntryPtr != NULL)) {
+ char *name;
for (parentEntryPtr = menuRefPtr->parentEntryPtr;
- strcmp(parentEntryPtr->name,
- Tk_PathName(menuPtr->tkwin)) == 0;
- parentEntryPtr = parentEntryPtr->nextCascadePtr) {
+ parentEntryPtr != NULL
+ ; parentEntryPtr = parentEntryPtr->nextCascadePtr) {
+ name = Tcl_GetStringFromObj(parentEntryPtr->namePtr,
+ NULL);
+ if (strcmp(name, Tk_PathName(menuPtr->tkwin)) != 0) {
+ break;
+ }
}
if (parentEntryPtr != NULL) {
TkActivateMenuEntry(parentEntryPtr->menuPtr,
- parentEntryPtr->index);
+ parentEntryPtr->index);
}
}
- if (menuPtr->tearOff) {
+ Tcl_GetBooleanFromObj(NULL, menuPtr->tearoffPtr, &tearoff);
+ if (tearoff) {
scratchRect = *menuRectPtr;
if (tearoffStruct.menuPtr == NULL) {
scratchRect.top -= 10;
@@ -2982,7 +3135,7 @@ TkMacHandleTearoffMenu(void)
{
if (tearoffStruct.menuPtr != NULL) {
Tcl_DString tearoffCmdStr;
- char intString[20];
+ char intString[TCL_INTEGER_SPACE];
short windowPart;
WindowRef whichWindow;
@@ -3092,8 +3245,10 @@ DrawTearoffEntry(
{
XPoint points[2];
int margin, segmentWidth, maxX;
+ Tk_3DBorder border;
- if ((menuPtr->menuType != MASTER_MENU) || (GetResource('MDEF', 591) != NULL)) {
+ if ((menuPtr->menuType != MASTER_MENU)
+ || (GetResource('MDEF', 591) != NULL)) {
return;
}
@@ -3103,13 +3258,14 @@ DrawTearoffEntry(
points[1].y = points[0].y;
segmentWidth = 6;
maxX = width - 1;
+ border = Tk_Get3DBorderFromObj(menuPtr->tkwin, menuPtr->borderPtr);
while (points[0].x < maxX) {
points[1].x = points[0].x + segmentWidth;
if (points[1].x > maxX) {
points[1].x = maxX;
}
- Tk_Draw3DPolygon(menuPtr->tkwin, d, menuPtr->border, points, 2, 1,
+ Tk_Draw3DPolygon(menuPtr->tkwin, d, border, points, 2, 1,
TK_RELIEF_RAISED);
points[0].x += 2*segmentWidth;
}
@@ -3228,13 +3384,15 @@ TkpDrawMenuEntry(
int padY = (menuPtr->menuType == MENUBAR) ? 3 : 0;
int adjustedY = y + padY;
int adjustedHeight = height - 2 * padY;
+ int state;
/*
* Choose the gc for drawing the foreground part of the entry.
*/
- if ((mePtr->state == tkActiveUid)
- && !strictMotif) {
+ Tcl_GetIndexFromObj(NULL, mePtr->statePtr, tkMenuStateStrings, NULL,
+ 0, &state);
+ if ((state == ENTRY_ACTIVE) && !strictMotif) {
gc = mePtr->activeGC;
if (gc == NULL) {
gc = menuPtr->activeGC;
@@ -3246,17 +3404,23 @@ TkpDrawMenuEntry(
for (cascadeEntryPtr = menuPtr->menuRefPtr->parentEntryPtr;
cascadeEntryPtr != NULL;
cascadeEntryPtr = cascadeEntryPtr->nextCascadePtr) {
- if (strcmp(cascadeEntryPtr->name,
- Tk_PathName(menuPtr->tkwin)) == 0) {
- if (cascadeEntryPtr->state == tkDisabledUid) {
+ char *name = (cascadeEntryPtr->namePtr == NULL) ? ""
+ : Tcl_GetStringFromObj(cascadeEntryPtr->namePtr, NULL);
+
+ if (strcmp(name, Tk_PathName(menuPtr->tkwin)) == 0) {
+ int cascadeState;
+
+ Tcl_GetIndexFromObj(NULL, cascadeEntryPtr->statePtr,
+ tkMenuStateStrings, NULL, 0, &cascadeState);
+ if (cascadeState == ENTRY_DISABLED) {
parentDisabled = 1;
}
break;
}
}
- if (((parentDisabled || (mePtr->state == tkDisabledUid)))
- && (menuPtr->disabledFg != NULL)) {
+ if (((parentDisabled || (state == ENTRY_DISABLED)))
+ && (menuPtr->disabledFgPtr != NULL)) {
gc = mePtr->disabledGC;
if (gc == NULL) {
gc = menuPtr->disabledGC;
@@ -3272,24 +3436,22 @@ TkpDrawMenuEntry(
if (indicatorGC == NULL) {
indicatorGC = menuPtr->indicatorGC;
}
-
- bgBorder = mePtr->border;
- if (bgBorder == NULL) {
- bgBorder = menuPtr->border;
- }
+
+ bgBorder = Tk_Get3DBorderFromObj(menuPtr->tkwin,
+ (mePtr->borderPtr == NULL)
+ ? menuPtr->borderPtr : mePtr->borderPtr);
if (strictMotif) {
activeBorder = bgBorder;
} else {
- activeBorder = mePtr->activeBorder;
- if (activeBorder == NULL) {
- activeBorder = menuPtr->activeBorder;
- }
+ activeBorder = Tk_Get3DBorderFromObj(menuPtr->tkwin,
+ (mePtr->activeBorderPtr == NULL)
+ ? menuPtr->activeBorderPtr : mePtr->activeBorderPtr);
}
- if (mePtr->tkfont == NULL) {
+ if (mePtr->fontPtr == NULL) {
fmPtr = menuMetricsPtr;
} else {
- tkfont = mePtr->tkfont;
+ tkfont = Tk_GetFontFromObj(menuPtr->tkwin, mePtr->fontPtr);
Tk_GetFontMetrics(tkfont, &entryMetrics);
fmPtr = &entryMetrics;
}
@@ -3310,11 +3472,14 @@ TkpDrawMenuEntry(
DrawTearoffEntry(menuPtr, mePtr, d, gc, tkfont, fmPtr, x, adjustedY,
width, adjustedHeight);
} else {
+ int hideMargin;
+
DrawMenuEntryLabel(menuPtr, mePtr, d, gc, tkfont, fmPtr, x,
adjustedY, width, adjustedHeight);
DrawMenuEntryAccelerator(menuPtr, mePtr, d, gc, tkfont, fmPtr,
activeBorder, x, adjustedY, width, adjustedHeight, drawArrow);
- if (!mePtr->hideMargin) {
+ Tcl_GetBooleanFromObj(NULL, mePtr->hideMarginPtr, &hideMargin);
+ if (!hideMargin) {
DrawMenuEntryIndicator(menuPtr, mePtr, d, gc, indicatorGC, tkfont,
fmPtr, x, adjustedY, width, adjustedHeight);
}
@@ -3344,13 +3509,13 @@ void
TkpComputeStandardMenuGeometry(
TkMenu *menuPtr) /* Structure describing menu. */
{
- Tk_Font tkfont;
+ Tk_Font tkfont, menuFont;
Tk_FontMetrics menuMetrics, entryMetrics, *fmPtr;
int x, y, height, modifierWidth, labelWidth, indicatorSpace;
int windowWidth, windowHeight, accelWidth, maxAccelTextWidth;
int i, j, lastColumnBreak, maxModifierWidth, maxWidth, nonAccelMargin;
int maxNonAccelMargin, maxEntryWithAccelWidth, maxEntryWithoutAccelWidth;
- int entryWidth, maxIndicatorSpace;
+ int entryWidth, maxIndicatorSpace, borderWidth, activeBorderWidth;
TkMenuEntry *mePtr, *columnEntryPtr;
EntryGeometry *geometryPtr;
@@ -3358,7 +3523,11 @@ TkpComputeStandardMenuGeometry(
return;
}
- x = y = menuPtr->borderWidth;
+ Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthPtr,
+ &borderWidth);
+ Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->activeBorderWidthPtr,
+ &activeBorderWidth);
+ x = y = borderWidth;
indicatorSpace = labelWidth = accelWidth = maxAccelTextWidth = 0;
windowHeight = windowWidth = maxWidth = lastColumnBreak = 0;
maxModifierWidth = nonAccelMargin = maxNonAccelMargin = 0;
@@ -3376,20 +3545,24 @@ TkpComputeStandardMenuGeometry(
* give all of the geometry/drawing the entry's font and metrics.
*/
- Tk_GetFontMetrics(menuPtr->tkfont, &menuMetrics);
+ menuFont = Tk_GetFontFromObj(menuPtr->tkwin, menuPtr->fontPtr);
+ Tk_GetFontMetrics(menuFont, &menuMetrics);
for (i = 0; i < menuPtr->numEntries; i++) {
+ int columnBreak;
+
mePtr = menuPtr->entries[i];
- tkfont = mePtr->tkfont;
- if (tkfont == NULL) {
- tkfont = menuPtr->tkfont;
- fmPtr = &menuMetrics;
+ if (mePtr->fontPtr == NULL) {
+ tkfont = menuFont;
+ fmPtr = &menuMetrics;
} else {
+ tkfont = Tk_GetFontFromObj(menuPtr->tkwin, mePtr->fontPtr);
Tk_GetFontMetrics(tkfont, &entryMetrics);
fmPtr = &entryMetrics;
}
- if ((i > 0) && mePtr->columnBreak) {
+ Tcl_GetBooleanFromObj(NULL, mePtr->columnBreakPtr, &columnBreak);
+ if ((i > 0) && columnBreak) {
if (maxIndicatorSpace != 0) {
maxIndicatorSpace += 2;
}
@@ -3400,7 +3573,7 @@ TkpComputeStandardMenuGeometry(
columnEntryPtr->indicatorSpace = maxIndicatorSpace;
columnEntryPtr->width = maxIndicatorSpace + maxWidth
- + 2 * menuPtr->activeBorderWidth;
+ + 2 * activeBorderWidth;
geometryPtr->accelTextWidth = maxAccelTextWidth;
geometryPtr->modifierWidth = maxModifierWidth;
columnEntryPtr->x = x;
@@ -3415,13 +3588,13 @@ TkpComputeStandardMenuGeometry(
geometryPtr->nonAccelMargin = 0;
}
}
- x += maxIndicatorSpace + maxWidth + 2 * menuPtr->borderWidth;
+ x += maxIndicatorSpace + maxWidth + 2 * borderWidth;
windowWidth = x;
maxWidth = maxIndicatorSpace = maxAccelTextWidth = 0;
maxModifierWidth = maxNonAccelMargin = maxEntryWithAccelWidth = 0;
maxEntryWithoutAccelWidth = 0;
lastColumnBreak = i;
- y = menuPtr->borderWidth;
+ y = borderWidth;
}
if (mePtr->type == SEPARATOR_ENTRY) {
@@ -3433,6 +3606,9 @@ TkpComputeStandardMenuGeometry(
fmPtr, &entryWidth, &height);
mePtr->height = height;
} else {
+ int hideMargin;
+
+ Tcl_GetBooleanFromObj(NULL, mePtr->hideMarginPtr, &hideMargin);
/*
* For each entry, compute the height required by that
@@ -3453,7 +3629,7 @@ TkpComputeStandardMenuGeometry(
&modifierWidth, &accelWidth, &height);
nonAccelMargin = 0;
} else if (mePtr->accelLength == 0) {
- nonAccelMargin = mePtr->hideMargin ? 0
+ nonAccelMargin = hideMargin ? 0
: Tk_TextWidth(tkfont, "m", 1);
accelWidth = modifierWidth = 0;
} else {
@@ -3466,7 +3642,7 @@ TkpComputeStandardMenuGeometry(
nonAccelMargin = 0;
}
- if (!(mePtr->hideMargin)) {
+ if (!(hideMargin)) {
GetMenuIndicatorGeometry(menuPtr, mePtr, tkfont,
fmPtr, &indicatorSpace, &height);
if (height > mePtr->height) {
@@ -3506,10 +3682,10 @@ TkpComputeStandardMenuGeometry(
}
}
- mePtr->height += 2 * menuPtr->activeBorderWidth;
+ mePtr->height += 2 * activeBorderWidth;
}
mePtr->y = y;
- y += menuPtr->entries[i]->height + menuPtr->borderWidth;
+ y += menuPtr->entries[i]->height + borderWidth;
if (y > windowHeight) {
windowHeight = y;
}
@@ -3521,7 +3697,7 @@ TkpComputeStandardMenuGeometry(
columnEntryPtr->indicatorSpace = maxIndicatorSpace;
columnEntryPtr->width = maxIndicatorSpace + maxWidth
- + 2 * menuPtr->activeBorderWidth;
+ + 2 * activeBorderWidth;
geometryPtr->accelTextWidth = maxAccelTextWidth;
geometryPtr->modifierWidth = maxModifierWidth;
columnEntryPtr->x = x;
@@ -3537,8 +3713,8 @@ TkpComputeStandardMenuGeometry(
}
}
windowWidth = x + maxIndicatorSpace + maxWidth
- + 2 * menuPtr->activeBorderWidth + menuPtr->borderWidth;
- windowHeight += menuPtr->borderWidth;
+ + 2 * activeBorderWidth + borderWidth;
+ windowHeight += borderWidth;
/*
* The X server doesn't like zero dimensions, so round up to at least
@@ -3589,6 +3765,7 @@ DrawMenuEntryLabel(
int indicatorSpace = mePtr->indicatorSpace;
int leftEdge = x + indicatorSpace;
int imageHeight, imageWidth;
+ int state;
/*
* Draw label or bitmap or image for entry.
@@ -3607,30 +3784,31 @@ DrawMenuEntryLabel(
imageHeight, d, leftEdge,
(int) (y + (mePtr->height - imageHeight)/2));
}
- } else if (mePtr->bitmap != None) {
+ } else if (mePtr->bitmapPtr != NULL) {
int width, height;
-
+ Pixmap bitmap = Tk_GetBitmapFromObj(menuPtr->tkwin, mePtr->bitmapPtr);
Tk_SizeOfBitmap(menuPtr->display,
- mePtr->bitmap, &width, &height);
- XCopyPlane(menuPtr->display,
- mePtr->bitmap, d,
- gc, 0, 0, (unsigned) width, (unsigned) height, leftEdge,
+ bitmap, &width, &height);
+ XCopyPlane(menuPtr->display, bitmap, d, gc, 0, 0,
+ (unsigned) width, (unsigned) height, leftEdge,
(int) (y + (mePtr->height - height)/2), 1);
} else {
if (mePtr->labelLength > 0) {
- Str255 itemText;
+ Tcl_DString itemTextDString;
- GetEntryText(mePtr, itemText);
+ GetEntryText(mePtr, &itemTextDString);
Tk_DrawChars(menuPtr->display, d, gc,
- tkfont, (char *) itemText + 1, itemText[0],
+ tkfont, Tcl_DStringValue(&itemTextDString),
+ Tcl_DStringLength(&itemTextDString),
leftEdge, baseline);
-/* TkpDrawMenuUnderline(menuPtr, mePtr, d, gc, tkfont, fmPtr, x, y,
- width, height);*/
+ Tcl_DStringFree(&itemTextDString);
}
}
- if (mePtr->state == tkDisabledUid) {
- if (menuPtr->disabledFg == NULL) {
+ Tcl_GetIndexFromObj(NULL, mePtr->statePtr, tkMenuStateStrings, NULL,
+ 0, &state);
+ if (state == ENTRY_DISABLED) {
+ if (menuPtr->disabledFgPtr == NULL) {
XFillRectangle(menuPtr->display, d, menuPtr->disabledGC, x, y,
(unsigned) width, (unsigned) height);
} else if ((mePtr->image != NULL)
@@ -3672,7 +3850,11 @@ DrawMenuEntryBackground(
int width, /* width of rectangle to draw */
int height) /* height of rectangle to draw */
{
- if (mePtr->state == tkActiveUid) {
+ int state;
+
+ Tcl_GetIndexFromObj(NULL, mePtr->statePtr, tkMenuStateStrings, NULL,
+ 0, &state);
+ if (state == ENTRY_ACTIVE) {
bgBorder = activeBorder;
}
Tk_Fill3DRectangle(menuPtr->tkwin, d, bgBorder,
@@ -3710,17 +3892,20 @@ GetMenuLabelGeometry(
if (mePtr->image != NULL) {
Tk_SizeOfImage(mePtr->image, widthPtr, heightPtr);
- } else if (mePtr->bitmap != (Pixmap) NULL) {
- Tk_SizeOfBitmap(menuPtr->display, mePtr->bitmap, widthPtr, heightPtr);
+ } else if (mePtr->bitmapPtr != NULL) {
+ Pixmap bitmap = Tk_GetBitmapFromObj(menuPtr->tkwin, mePtr->bitmapPtr);
+ Tk_SizeOfBitmap(menuPtr->display, bitmap, widthPtr, heightPtr);
} else {
*heightPtr = fmPtr->linespace;
- if (mePtr->label != NULL) {
- Str255 itemText;
+ if (mePtr->labelPtr != NULL) {
+ Tcl_DString itemTextDString;
- GetEntryText(mePtr, itemText);
- *widthPtr = Tk_TextWidth(tkfont, (char *) itemText + 1,
- itemText[0]);
+ GetEntryText(mePtr, &itemTextDString);
+ *widthPtr = Tk_TextWidth(tkfont,
+ Tcl_DStringValue(&itemTextDString),
+ Tcl_DStringLength(&itemTextDString));
+ Tcl_DStringFree(&itemTextDString);
} else {
*widthPtr = 0;
}
@@ -3882,7 +4067,8 @@ 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);
@@ -3957,9 +4143,12 @@ FixMDEF(void)
if ((MDEFHandle != NULL) && (SICNHandle != NULL)) {
MoveHHi(MDEFHandle);
HLock(MDEFHandle);
- menuDefProc = TkNewMenuDefProc(MenuDefProc);
+ if ( menuDefProc == NULL) {
+ menuDefProc = TkNewMenuDefProc(MenuDefProc);
+ }
memmove((void *) (((long) (*MDEFHandle)) + 0x24), &menuDefProc, 4);
}
+
#endif
}
@@ -3974,7 +4163,7 @@ FixMDEF(void)
* None.
*
* Side effects:
- * Allcates a hash table.
+ * Allocates a hash table.
*
*----------------------------------------------------------------------
*/
@@ -3991,4 +4180,9 @@ TkpMenuInit(void)
currentMenuBarInterp = NULL;
currentMenuBarName = NULL;
windowListPtr = NULL;
+ FixMDEF();
+
+
+ Tcl_ExternalToUtf(NULL, NULL, "É", -1, 0, NULL, elipsisString,
+ TCL_UTF_MAX + 1, NULL, NULL, NULL);
}