summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--generic/tk.h7
-rw-r--r--generic/tkButton.c4
-rw-r--r--generic/tkMenubutton.c688
-rw-r--r--generic/tkMenubutton.h25
-rw-r--r--generic/tkScale.c10
-rw-r--r--generic/tkWindow.c4
-rw-r--r--mac/tkMacDefault.h5
-rw-r--r--mac/tkMacMenubutton.c15
-rw-r--r--tests/menubut.test14
-rw-r--r--win/tkWinDefault.h5
11 files changed, 442 insertions, 339 deletions
diff --git a/ChangeLog b/ChangeLog
index 4875712..c100f74 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,7 +3,11 @@
* generic/tkMenuButton.h:
* generic/tkMenuButton.c:
* mac/tkMacMenubutton.c:
+ * mac/tkMacDefault.h
* unix/tkUnixMenubu.c: Eliminated Tk_Uids used by -state option.
+ * unix/tkUnixDefault.h
+ * win/tkWinDefault.h
+
* generic/tk.h:
* generic/tkScale.h:
diff --git a/generic/tk.h b/generic/tk.h
index 7907c49..a8c1a99 100644
--- a/generic/tk.h
+++ b/generic/tk.h
@@ -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: tk.h,v 1.1.4.9 1999/02/13 05:09:35 lfb Exp $
+ * RCS: @(#) $Id: tk.h,v 1.1.4.10 1999/02/16 06:00:40 lfb Exp $
*/
#ifndef _TK
@@ -1747,8 +1747,9 @@ EXTERN int Tk_ListboxCmd _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, int argc, char **argv));
EXTERN int Tk_LowerCmd _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_MenubuttonCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
+EXTERN int Tk_MenubuttonObjCmd _ANSI_ARGS_((ClientData clientData,
+ Tcl_Interp *interp, int objc,
+ Tcl_Obj *CONST objv[]));
EXTERN int Tk_MessageBoxObjCmd _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *CONST objv[]));
diff --git a/generic/tkButton.c b/generic/tkButton.c
index d2549f9..7f6f297 100644
--- a/generic/tkButton.c
+++ b/generic/tkButton.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: tkButton.c,v 1.1.4.4 1999/02/11 04:13:45 stanton Exp $
+ * RCS: @(#) $Id: tkButton.c,v 1.1.4.5 1999/02/16 06:00:40 lfb Exp $
*/
#include "tkButton.h"
@@ -1027,7 +1027,7 @@ ConfigureButton(interp, butPtr, objc, objv)
/*
* A few options need special processing, such as setting the
* background from a 3-D border, or filling in complicated
- * defaults that couldn't be specified to Tk_ConfigureWidget.
+ * defaults that couldn't be specified to Tk_SetOptions.
*/
if ((butPtr->state == STATE_ACTIVE)
diff --git a/generic/tkMenubutton.c b/generic/tkMenubutton.c
index dfef406..64760b0 100644
--- a/generic/tkMenubutton.c
+++ b/generic/tkMenubutton.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMenubutton.c,v 1.1.4.5 1999/02/13 05:38:48 lfb Exp $
+ * RCS: @(#) $Id: tkMenubutton.c,v 1.1.4.6 1999/02/16 06:00:41 lfb Exp $
*/
#include "tkMenubutton.h"
@@ -18,118 +18,140 @@
#include "default.h"
/*
- * Uids internal to menubuttons.
+ * The following table defines the legal values for the -direction
+ * option. It is used together with the "enum direction" declaration
+ * in tkMenubutton.h.
*/
-static Tk_Uid aboveUid = NULL;
-static Tk_Uid belowUid = NULL;
-static Tk_Uid leftUid = NULL;
-static Tk_Uid rightUid = NULL;
-static Tk_Uid flushUid = NULL;
-TCL_DECLARE_MUTEX(menuButMutex)
+static char *directionStrings[] = {
+ "above", "below", "flush", "left", "right", (char *) NULL
+};
+
+/*
+ * The following table defines the legal values for the -state option.
+ * It is used together with the "enum state" declaration in tkMenubutton.h.
+ */
+
+static char *stateStrings[] = {
+ "active", "disabled", "normal", (char *) NULL
+};
/*
* Information used for parsing configuration specs:
*/
-static Tk_ConfigSpec configSpecs[] = {
- {TK_CONFIG_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_MENUBUTTON_ACTIVE_BG_COLOR, Tk_Offset(TkMenuButton, activeBorder),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_MENUBUTTON_ACTIVE_BG_MONO, Tk_Offset(TkMenuButton, activeBorder),
- TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_COLOR, "-activeforeground", "activeForeground", "Background",
- DEF_MENUBUTTON_ACTIVE_FG_COLOR, Tk_Offset(TkMenuButton, activeFg),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_COLOR, "-activeforeground", "activeForeground", "Background",
- DEF_MENUBUTTON_ACTIVE_FG_MONO, Tk_Offset(TkMenuButton, activeFg),
- TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_ANCHOR, "-anchor", "anchor", "Anchor",
- DEF_MENUBUTTON_ANCHOR, Tk_Offset(TkMenuButton, anchor), 0},
- {TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_MENUBUTTON_BG_COLOR, Tk_Offset(TkMenuButton, normalBorder),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_MENUBUTTON_BG_MONO, Tk_Offset(TkMenuButton, normalBorder),
- TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_SYNONYM, "-bd", "borderWidth", (char *) NULL,
- (char *) NULL, 0, 0},
- {TK_CONFIG_SYNONYM, "-bg", "background", (char *) NULL,
- (char *) NULL, 0, 0},
- {TK_CONFIG_BITMAP, "-bitmap", "bitmap", "Bitmap",
- DEF_MENUBUTTON_BITMAP, Tk_Offset(TkMenuButton, bitmap),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_MENUBUTTON_BORDER_WIDTH, Tk_Offset(TkMenuButton, borderWidth), 0},
- {TK_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_MENUBUTTON_CURSOR, Tk_Offset(TkMenuButton, cursor),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_UID, "-direction", "direction", "Direction",
- DEF_MENUBUTTON_DIRECTION, Tk_Offset(TkMenuButton, direction),
- 0},
- {TK_CONFIG_COLOR, "-disabledforeground", "disabledForeground",
+static Tk_OptionSpec optionSpecs[] = {
+ {TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
+ DEF_MENUBUTTON_ACTIVE_BG_COLOR, -1,
+ Tk_Offset(TkMenuButton, activeBorder), 0,
+ (ClientData) DEF_MENUBUTTON_ACTIVE_BG_MONO, 0},
+ {TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background",
+ DEF_MENUBUTTON_ACTIVE_FG_COLOR, -1,
+ Tk_Offset(TkMenuButton, activeFg),
+ 0, (ClientData) DEF_MENUBUTTON_ACTIVE_FG_MONO, 0},
+ {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
+ DEF_MENUBUTTON_ANCHOR, -1,
+ Tk_Offset(TkMenuButton, anchor), 0, 0, 0},
+ {TK_OPTION_BORDER, "-background", "background", "Background",
+ DEF_MENUBUTTON_BG_COLOR, -1, Tk_Offset(TkMenuButton, normalBorder),
+ 0, (ClientData) DEF_MENUBUTTON_BG_MONO, 0},
+ {TK_OPTION_SYNONYM, "-bd", (char *) NULL, (char *) NULL,
+ (char *) NULL, 0, -1, 0, (ClientData) "-borderwidth", 0},
+ {TK_OPTION_SYNONYM, "-bg", (char *) NULL, (char *) NULL,
+ (char *) NULL, 0, -1, 0, (ClientData) "-background", 0},
+ {TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap",
+ DEF_MENUBUTTON_BITMAP, -1, Tk_Offset(TkMenuButton, bitmap),
+ TK_OPTION_NULL_OK, 0, 0},
+ {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
+ DEF_MENUBUTTON_BORDER_WIDTH, -1,
+ Tk_Offset(TkMenuButton, borderWidth), 0, 0, 0},
+ {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
+ DEF_MENUBUTTON_CURSOR, -1, Tk_Offset(TkMenuButton, cursor),
+ TK_OPTION_NULL_OK, 0, 0},
+ {TK_OPTION_STRING_TABLE, "-direction", "direction", "Direction",
+ DEF_MENUBUTTON_DIRECTION, -1, Tk_Offset(TkMenuButton, direction),
+ 0, (ClientData) directionStrings, 0},
+ {TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
"DisabledForeground", DEF_MENUBUTTON_DISABLED_FG_COLOR,
- Tk_Offset(TkMenuButton, disabledFg),
- TK_CONFIG_COLOR_ONLY|TK_CONFIG_NULL_OK},
- {TK_CONFIG_COLOR, "-disabledforeground", "disabledForeground",
- "DisabledForeground", DEF_MENUBUTTON_DISABLED_FG_MONO,
- Tk_Offset(TkMenuButton, disabledFg),
- TK_CONFIG_MONO_ONLY|TK_CONFIG_NULL_OK},
- {TK_CONFIG_SYNONYM, "-fg", "foreground", (char *) NULL,
- (char *) NULL, 0, 0},
- {TK_CONFIG_FONT, "-font", "font", "Font",
- DEF_MENUBUTTON_FONT, Tk_Offset(TkMenuButton, tkfont), 0},
- {TK_CONFIG_COLOR, "-foreground", "foreground", "Foreground",
- DEF_MENUBUTTON_FG, Tk_Offset(TkMenuButton, normalFg), 0},
- {TK_CONFIG_STRING, "-height", "height", "Height",
- DEF_MENUBUTTON_HEIGHT, Tk_Offset(TkMenuButton, heightString), 0},
- {TK_CONFIG_COLOR, "-highlightbackground", "highlightBackground",
- "HighlightBackground", DEF_MENUBUTTON_HIGHLIGHT_BG,
- Tk_Offset(TkMenuButton, highlightBgColorPtr), 0},
- {TK_CONFIG_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_MENUBUTTON_HIGHLIGHT, Tk_Offset(TkMenuButton, highlightColorPtr),
- 0},
- {TK_CONFIG_PIXELS, "-highlightthickness", "highlightThickness",
+ -1, Tk_Offset(TkMenuButton, disabledFg), TK_OPTION_NULL_OK,
+ (ClientData) DEF_MENUBUTTON_DISABLED_FG_MONO, 0},
+ {TK_OPTION_SYNONYM, "-fg", "foreground", (char *) NULL,
+ (char *) NULL, 0, -1, 0, (ClientData) "-foreground", 0},
+ {TK_OPTION_FONT, "-font", "font", "Font",
+ DEF_MENUBUTTON_FONT, -1, Tk_Offset(TkMenuButton, tkfont), 0, 0, 0},
+ {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
+ DEF_MENUBUTTON_FG, -1, Tk_Offset(TkMenuButton, normalFg), 0, 0, 0},
+ {TK_OPTION_STRING, "-height", "height", "Height",
+ DEF_MENUBUTTON_HEIGHT, -1, Tk_Offset(TkMenuButton, heightString),
+ 0, 0, 0},
+ {TK_OPTION_COLOR, "-highlightbackground", "highlightBackground",
+ "HighlightBackground", DEF_MENUBUTTON_HIGHLIGHT_BG_COLOR,
+ -1, Tk_Offset(TkMenuButton, highlightBgColorPtr), 0, 0, 0},
+ {TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
+ DEF_MENUBUTTON_HIGHLIGHT, -1,
+ Tk_Offset(TkMenuButton, highlightColorPtr), 0, 0, 0},
+ {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
"HighlightThickness", DEF_MENUBUTTON_HIGHLIGHT_WIDTH,
- Tk_Offset(TkMenuButton, highlightWidth), 0},
- {TK_CONFIG_STRING, "-image", "image", "Image",
- DEF_MENUBUTTON_IMAGE, Tk_Offset(TkMenuButton, imageString),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_BOOLEAN, "-indicatoron", "indicatorOn", "IndicatorOn",
- DEF_MENUBUTTON_INDICATOR, Tk_Offset(TkMenuButton, indicatorOn), 0},
- {TK_CONFIG_JUSTIFY, "-justify", "justify", "Justify",
- DEF_MENUBUTTON_JUSTIFY, Tk_Offset(TkMenuButton, justify), 0},
- {TK_CONFIG_STRING, "-menu", "menu", "Menu",
- DEF_MENUBUTTON_MENU, Tk_Offset(TkMenuButton, menuName),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_PIXELS, "-padx", "padX", "Pad",
- DEF_MENUBUTTON_PADX, Tk_Offset(TkMenuButton, padX), 0},
- {TK_CONFIG_PIXELS, "-pady", "padY", "Pad",
- DEF_MENUBUTTON_PADY, Tk_Offset(TkMenuButton, padY), 0},
- {TK_CONFIG_RELIEF, "-relief", "relief", "Relief",
- DEF_MENUBUTTON_RELIEF, Tk_Offset(TkMenuButton, relief), 0},
- {TK_CONFIG_STRING, "-state", "state", "State",
- DEF_MENUBUTTON_STATE, Tk_Offset(TkMenuButton, state), 0},
- {TK_CONFIG_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_MENUBUTTON_TAKE_FOCUS, Tk_Offset(TkMenuButton, takeFocus),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_STRING, "-text", "text", "Text",
- DEF_MENUBUTTON_TEXT, Tk_Offset(TkMenuButton, text), 0},
- {TK_CONFIG_STRING, "-textvariable", "textVariable", "Variable",
- DEF_MENUBUTTON_TEXT_VARIABLE, Tk_Offset(TkMenuButton, textVarName),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_INT, "-underline", "underline", "Underline",
- DEF_MENUBUTTON_UNDERLINE, Tk_Offset(TkMenuButton, underline), 0},
- {TK_CONFIG_STRING, "-width", "width", "Width",
- DEF_MENUBUTTON_WIDTH, Tk_Offset(TkMenuButton, widthString), 0},
- {TK_CONFIG_PIXELS, "-wraplength", "wrapLength", "WrapLength",
- DEF_MENUBUTTON_WRAP_LENGTH, Tk_Offset(TkMenuButton, wrapLength), 0},
- {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
+ -1, Tk_Offset(TkMenuButton, highlightWidth), 0, 0, 0},
+ {TK_OPTION_STRING, "-image", "image", "Image",
+ DEF_MENUBUTTON_IMAGE, -1, Tk_Offset(TkMenuButton, imageString),
+ TK_OPTION_NULL_OK, 0, 0},
+ {TK_OPTION_BOOLEAN, "-indicatoron", "indicatorOn", "IndicatorOn",
+ DEF_MENUBUTTON_INDICATOR, -1, Tk_Offset(TkMenuButton, indicatorOn),
+ 0, 0, 0},
+ {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
+ DEF_BUTTON_JUSTIFY, -1, Tk_Offset(TkMenuButton, justify), 0, 0, 0},
+ {TK_OPTION_STRING, "-menu", "menu", "Menu",
+ DEF_MENUBUTTON_MENU, -1, Tk_Offset(TkMenuButton, menuName),
+ TK_OPTION_NULL_OK, 0, 0},
+ {TK_OPTION_PIXELS, "-padx", "padX", "Pad",
+ DEF_MENUBUTTON_PADX, -1, Tk_Offset(TkMenuButton, padX),
+ 0, 0, 0},
+ {TK_OPTION_PIXELS, "-pady", "padY", "Pad",
+ DEF_MENUBUTTON_PADY, -1, Tk_Offset(TkMenuButton, padY),
+ 0, 0, 0},
+ {TK_OPTION_RELIEF, "-relief", "relief", "Relief",
+ DEF_MENUBUTTON_RELIEF, -1, Tk_Offset(TkMenuButton, relief),
+ 0, 0, 0},
+ {TK_OPTION_STRING_TABLE, "-state", "state", "State",
+ DEF_MENUBUTTON_STATE, -1, Tk_Offset(TkMenuButton, state),
+ 0, (ClientData) stateStrings, 0},
+ {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
+ DEF_MENUBUTTON_TAKE_FOCUS, -1,
+ Tk_Offset(TkMenuButton, takeFocus), TK_OPTION_NULL_OK, 0, 0},
+ {TK_OPTION_STRING, "-text", "text", "Text",
+ DEF_MENUBUTTON_TEXT, -1, Tk_Offset(TkMenuButton, text), 0, 0, 0},
+ {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
+ DEF_MENUBUTTON_TEXT_VARIABLE, -1,
+ Tk_Offset(TkMenuButton, textVarName), TK_OPTION_NULL_OK, 0, 0},
+ {TK_OPTION_INT, "-underline", "underline", "Underline",
+ DEF_MENUBUTTON_UNDERLINE, -1, Tk_Offset(TkMenuButton, underline),
+ 0, 0, 0},
+ {TK_OPTION_STRING, "-width", "width", "Width",
+ DEF_MENUBUTTON_WIDTH, -1, Tk_Offset(TkMenuButton, widthString),
+ 0, 0, 0},
+ {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
+ DEF_MENUBUTTON_WRAP_LENGTH, -1, Tk_Offset(TkMenuButton, wrapLength),
+ 0, 0, 0},
+ {TK_OPTION_END, (char *) NULL, (char *) NULL, (char *) NULL,
(char *) NULL, 0, 0}
};
/*
+ * The following tables define the menubutton widget commands and map the
+ * indexes into the string tables into a single enumerated type used
+ * to dispatch the scale widget command.
+ */
+
+static char *commandNames[] = {
+ "cget", "configure", (char *) NULL
+};
+
+enum command {
+ COMMAND_CGET, COMMAND_CONFIGURE,
+};
+
+/*
* Forward declarations for procedures defined later in this file:
*/
@@ -143,17 +165,18 @@ static void MenuButtonImageProc _ANSI_ARGS_((ClientData clientData,
static char * MenuButtonTextVarProc _ANSI_ARGS_((
ClientData clientData, Tcl_Interp *interp,
char *name1, char *name2, int flags));
-static int MenuButtonWidgetCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
+static int MenuButtonWidgetObjCmd _ANSI_ARGS_((
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]));
static int ConfigureMenuButton _ANSI_ARGS_((Tcl_Interp *interp,
- TkMenuButton *mbPtr, int argc, char **argv,
- int flags));
+ TkMenuButton *mbPtr, int objc,
+ Tcl_Obj *CONST objv[]));
static void DestroyMenuButton _ANSI_ARGS_((char *memPtr));
/*
*--------------------------------------------------------------
*
- * Tk_MenubuttonCmd --
+ * Tk_MenubuttonObjCmd --
*
* This procedure is invoked to process the "button", "label",
* "radiobutton", and "checkbutton" Tcl commands. See the
@@ -169,20 +192,38 @@ static void DestroyMenuButton _ANSI_ARGS_((char *memPtr));
*/
int
-Tk_MenubuttonCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
+Tk_MenubuttonObjCmd(clientData, interp, objc, objv)
+ ClientData clientData; /* Either NULL or pointer to
+ * option table. */
Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
+ int objc; /* Number of arguments. */
+ Tcl_Obj *CONST objv[]; /* Argument objects. */
{
register TkMenuButton *mbPtr;
- Tk_Window tkwin = (Tk_Window) clientData;
- Tk_Window new;
+ Tk_OptionTable optionTable;
+ Tk_Window tkwin;
+
+ optionTable = (Tk_OptionTable) clientData;
+ if (optionTable == NULL) {
+ Tcl_CmdInfo info;
+ char *name;
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " pathName ?options?\"", (char *) NULL);
+ /*
+ * We haven't created the option table for this widget class
+ * yet. Do it now and save the table as the clientData for
+ * the command, so we'll have access to it in future
+ * invocations of the command.
+ */
+
+ optionTable = Tk_CreateOptionTable(interp, optionSpecs);
+ name = Tcl_GetString(objv[0]);
+ Tcl_GetCommandInfo(interp, name, &info);
+ info.objClientData = (ClientData) optionTable;
+ Tcl_SetCommandInfo(interp, name, &info);
+ }
+
+ if (objc < 2) {
+ Tcl_WrongNumArgs(interp, 1, objv, "pathName ?options?");
return TCL_ERROR;
}
@@ -190,25 +231,28 @@ Tk_MenubuttonCmd(clientData, interp, argc, argv)
* Create the new window.
*/
- new = Tk_CreateWindowFromPath(interp, tkwin, argv[1], (char *) NULL);
- if (new == NULL) {
+ tkwin = Tk_CreateWindowFromPath(interp,
+ Tk_MainWindow(interp), Tcl_GetString(objv[1]), (char *) NULL);
+ if (tkwin == NULL) {
return TCL_ERROR;
}
- Tk_SetClass(new, "Menubutton");
- mbPtr = TkpCreateMenuButton(new);
+ Tk_SetClass(tkwin, "Menubutton");
+ mbPtr = TkpCreateMenuButton(tkwin);
- TkSetClassProcs(new, &tkpMenubuttonClass, (ClientData) mbPtr);
+ TkSetClassProcs(tkwin, &tkpMenubuttonClass, (ClientData) mbPtr);
/*
* Initialize the data structure for the button.
*/
- mbPtr->tkwin = new;
- mbPtr->display = Tk_Display (new);
+ mbPtr->tkwin = tkwin;
+ mbPtr->display = Tk_Display (tkwin);
mbPtr->interp = interp;
- mbPtr->widgetCmd = Tcl_CreateCommand(interp, Tk_PathName(mbPtr->tkwin),
- MenuButtonWidgetCmd, (ClientData) mbPtr, MenuButtonCmdDeletedProc);
+ mbPtr->widgetCmd = Tcl_CreateObjCommand(interp,
+ Tk_PathName(mbPtr->tkwin), MenuButtonWidgetObjCmd,
+ (ClientData) mbPtr, MenuButtonCmdDeletedProc);
+ mbPtr->optionTable = optionTable;
mbPtr->menuName = NULL;
mbPtr->text = NULL;
mbPtr->underline = -1;
@@ -216,7 +260,7 @@ Tk_MenubuttonCmd(clientData, interp, argc, argv)
mbPtr->bitmap = None;
mbPtr->imageString = NULL;
mbPtr->image = NULL;
- mbPtr->state = "normal";
+ mbPtr->state = STATE_NORMAL;
mbPtr->normalBorder = NULL;
mbPtr->activeBorder = NULL;
mbPtr->borderWidth = 0;
@@ -248,38 +292,35 @@ Tk_MenubuttonCmd(clientData, interp, argc, argv)
mbPtr->indicatorOn = 0;
mbPtr->indicatorWidth = 0;
mbPtr->indicatorHeight = 0;
+ mbPtr->direction = DIRECTION_FLUSH;
mbPtr->cursor = None;
mbPtr->takeFocus = NULL;
mbPtr->flags = 0;
- if (flushUid == NULL) {
- Tcl_MutexLock(&menuButMutex);
- if (flushUid == NULL) {
- aboveUid = Tk_GetUid("above");
- belowUid = Tk_GetUid("below");
- leftUid = Tk_GetUid("left");
- rightUid = Tk_GetUid("right");
- flushUid = Tk_GetUid("flush");
- }
- Tcl_MutexUnlock(&menuButMutex);
- }
- mbPtr->direction = flushUid;
Tk_CreateEventHandler(mbPtr->tkwin,
ExposureMask|StructureNotifyMask|FocusChangeMask,
MenuButtonEventProc, (ClientData) mbPtr);
- if (ConfigureMenuButton(interp, mbPtr, argc-2, argv+2, 0) != TCL_OK) {
+
+ if (Tk_InitOptions(interp, (char *) mbPtr, optionTable, tkwin)
+ != TCL_OK) {
+ Tk_DestroyWindow(mbPtr->tkwin);
+ return TCL_ERROR;
+ }
+
+ if (ConfigureMenuButton(interp, mbPtr, objc-2, objv+2) != TCL_OK) {
Tk_DestroyWindow(mbPtr->tkwin);
return TCL_ERROR;
}
- Tcl_SetResult(interp, Tk_PathName(mbPtr->tkwin), TCL_STATIC);
+ Tcl_SetStringObj(Tcl_GetObjResult(interp), Tk_PathName(mbPtr->tkwin),
+ -1);
return TCL_OK;
}
/*
*--------------------------------------------------------------
*
- * MenuButtonWidgetCmd --
+ * MenuButtonWidgetObjCmd --
*
* This procedure is invoked to process the Tcl command
* that corresponds to a widget managed by this module.
@@ -295,56 +336,68 @@ Tk_MenubuttonCmd(clientData, interp, argc, argv)
*/
static int
-MenuButtonWidgetCmd(clientData, interp, argc, argv)
+MenuButtonWidgetObjCmd(clientData, interp, objc, objv)
ClientData clientData; /* Information about button widget. */
Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
+ int objc; /* Number of arguments. */
+ Tcl_Obj *CONST objv[]; /* Argument objects. */
{
register TkMenuButton *mbPtr = (TkMenuButton *) clientData;
- int result;
- size_t length;
- int c;
+ int result, index;
+ Tcl_Obj *objPtr;
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " option ?arg arg ...?\"", (char *) NULL);
+ if (objc < 2) {
+ Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg ...?");
return TCL_ERROR;
}
+ result = Tcl_GetIndexFromObj(interp, objv[1],
+ commandNames, "option", 0, &index);
+ if (result != TCL_OK) {
+ return result;
+ }
Tcl_Preserve((ClientData) mbPtr);
- c = argv[1][0];
- length = strlen(argv[1]);
- if ((c == 'c') && (strncmp(argv[1], "cget", length) == 0)
- && (length >= 2)) {
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " cget option\"",
- (char *) NULL);
- result = TCL_ERROR;
- } else {
- result = Tk_ConfigureValue(interp, mbPtr->tkwin, configSpecs,
- (char *) mbPtr, argv[2], 0);
+
+ switch (index) {
+ case COMMAND_CGET: {
+ if (objc != 3) {
+ Tcl_WrongNumArgs(interp, 1, objv, "cget option");
+ goto error;
+ }
+
+ objPtr = Tk_GetOptionValue(interp, (char *) mbPtr,
+ mbPtr->optionTable, objv[2], mbPtr->tkwin);
+ if (objPtr == NULL) {
+ goto error;
+ } else {
+ Tcl_SetObjResult(interp, objPtr);
+ }
+ break;
}
- } else if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0)
- && (length >= 2)) {
- if (argc == 2) {
- result = Tk_ConfigureInfo(interp, mbPtr->tkwin, configSpecs,
- (char *) mbPtr, (char *) NULL, 0);
- } else if (argc == 3) {
- result = Tk_ConfigureInfo(interp, mbPtr->tkwin, configSpecs,
- (char *) mbPtr, argv[2], 0);
- } else {
- result = ConfigureMenuButton(interp, mbPtr, argc-2, argv+2,
- TK_CONFIG_ARGV_ONLY);
+
+ case COMMAND_CONFIGURE: {
+ if (objc <= 3) {
+ objPtr = Tk_GetOptionInfo(interp, (char *) mbPtr,
+ mbPtr->optionTable,
+ (objc == 3) ? objv[2] : (Tcl_Obj *) NULL,
+ mbPtr->tkwin);
+ if (objPtr == NULL) {
+ goto error;
+ } else {
+ Tcl_SetObjResult(interp, objPtr);
+ }
+ } else {
+ result = ConfigureMenuButton(interp, mbPtr, objc-2,
+ objv+2);
+ }
+ break;
}
- } else {
- Tcl_AppendResult(interp, "bad option \"", argv[1],
- "\": must be cget or configure",
- (char *) NULL);
- result = TCL_ERROR;
}
Tcl_Release((ClientData) mbPtr);
return result;
+
+ error:
+ Tcl_Release((ClientData) mbPtr);
+ return TCL_ERROR;
}
/*
@@ -353,9 +406,9 @@ MenuButtonWidgetCmd(clientData, interp, argc, argv)
* DestroyMenuButton --
*
* This procedure is invoked to recycle all of the resources
- * associated with a button widget. It is invoked as a
+ * associated with a menubutton widget. It is invoked as a
* when-idle handler in order to make sure that there is no
- * other use of the button pending at the time of the deletion.
+ * other use of the menubutton pending at the time of the deletion.
*
* Results:
* None.
@@ -371,6 +424,11 @@ DestroyMenuButton(memPtr)
char *memPtr; /* Info about button widget. */
{
register TkMenuButton *mbPtr = (TkMenuButton *) memPtr;
+ TkpDestroyMenuButton(mbPtr);
+
+ if (mbPtr->flags & REDRAW_PENDING) {
+ Tcl_CancelIdleCall(TkpDisplayMenuButton, (ClientData) mbPtr);
+ }
/*
* Free up all the stuff that requires special handling, then
@@ -378,6 +436,7 @@ DestroyMenuButton(memPtr)
* stuff.
*/
+ Tcl_DeleteCommandFromToken(mbPtr->interp, mbPtr->widgetCmd);
if (mbPtr->textVarName != NULL) {
Tcl_UntraceVar(mbPtr->interp, mbPtr->textVarName,
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
@@ -392,15 +451,19 @@ DestroyMenuButton(memPtr)
if (mbPtr->activeTextGC != None) {
Tk_FreeGC(mbPtr->display, mbPtr->activeTextGC);
}
+ if (mbPtr->disabledGC != None) {
+ Tk_FreeGC(mbPtr->display, mbPtr->disabledGC);
+ }
if (mbPtr->gray != None) {
Tk_FreeBitmap(mbPtr->display, mbPtr->gray);
}
- if (mbPtr->disabledGC != None) {
- Tk_FreeGC(mbPtr->display, mbPtr->disabledGC);
+ if (mbPtr->textLayout != NULL) {
+ Tk_FreeTextLayout(mbPtr->textLayout);
}
- Tk_FreeTextLayout(mbPtr->textLayout);
- Tk_FreeOptions(configSpecs, (char *) mbPtr, mbPtr->display, 0);
- ckfree((char *) mbPtr);
+ Tk_FreeConfigOptions((char *) mbPtr, mbPtr->optionTable,
+ mbPtr->tkwin);
+ mbPtr->tkwin = NULL;
+ Tcl_EventuallyFree((ClientData) mbPtr, TCL_DYNAMIC);
}
/*
@@ -425,152 +488,174 @@ DestroyMenuButton(memPtr)
*/
static int
-ConfigureMenuButton(interp, mbPtr, argc, argv, flags)
+ConfigureMenuButton(interp, mbPtr, objc, objv)
Tcl_Interp *interp; /* Used for error reporting. */
- register TkMenuButton *mbPtr; /* Information about widget; may or may
- * not already have values for some fields. */
- int argc; /* Number of valid entries in argv. */
- char **argv; /* Arguments. */
- int flags; /* Flags to pass to Tk_ConfigureWidget. */
+ register TkMenuButton *mbPtr;
+ /* Information about widget; may or may
+ * not already have values for some
+ * fields. */
+ int objc; /* Number of valid entries in objv. */
+ Tcl_Obj *CONST objv[]; /* Arguments. */
{
- int result;
+ Tk_SavedOptions savedOptions;
+ Tcl_Obj *errorResult;
+ int error;
Tk_Image image;
/*
- * Eliminate any existing trace on variables monitored by the menubutton.
+ * Eliminate any existing trace on variables monitored by the
+ * menubutton.
*/
if (mbPtr->textVarName != NULL) {
- Tcl_UntraceVar(interp, mbPtr->textVarName,
+ Tcl_UntraceVar(interp, mbPtr->textVarName,
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
MenuButtonTextVarProc, (ClientData) mbPtr);
}
- result = Tk_ConfigureWidget(interp, mbPtr->tkwin, configSpecs,
- argc, argv, (char *) mbPtr, flags);
- if (result != TCL_OK) {
- return TCL_ERROR;
- }
-
/*
- * A few options need special processing, such as setting the
- * background from a 3-D border, or filling in complicated
- * defaults that couldn't be specified to Tk_ConfigureWidget.
+ * The following loop is potentially executed twice. During the
+ * first pass configuration options get set to their new values.
+ * If there is an error in this pass, we execute a second pass
+ * to restore all the options to their previous values.
*/
- if ((mbPtr->state[0] == 'a') && (strcmp(mbPtr->state, "active") == 0)
- && !Tk_StrictMotif(mbPtr->tkwin)) {
- Tk_SetBackgroundFromBorder(mbPtr->tkwin, mbPtr->activeBorder);
- } else {
- Tk_SetBackgroundFromBorder(mbPtr->tkwin, mbPtr->normalBorder);
- if ((mbPtr->state[0] != 'a')
- && (strcmp(mbPtr->state, "active") != 0)
- && (mbPtr->state[0] != 'd')
- && (strcmp(mbPtr->state, "disabled") != 0)
- && (mbPtr->state[0] != 'n')
- && (strcmp(mbPtr->state, "normal") != 0)) {
- Tcl_AppendResult(interp, "bad state value \"", mbPtr->state,
- "\": must be normal, active, or disabled", (char *) NULL);
- mbPtr->state = "normal";
- return TCL_ERROR;
+ for (error = 0; error <= 1; error++) {
+ if (!error) {
+ /*
+ * First pass: set options to new values.
+ */
+
+ if (Tk_SetOptions(interp, (char *) mbPtr,
+ mbPtr->optionTable, objc, objv,
+ mbPtr->tkwin, &savedOptions, (int *) NULL) != TCL_OK) {
+ continue;
+ }
+ } else {
+ /*
+ * Second pass: restore options to old values.
+ */
+
+ errorResult = Tcl_GetObjResult(interp);
+ Tcl_IncrRefCount(errorResult);
+ Tk_RestoreSavedOptions(&savedOptions);
}
- }
- if ((mbPtr->direction != aboveUid) && (mbPtr->direction != belowUid)
- && (mbPtr->direction != leftUid) && (mbPtr->direction != rightUid)
- && (mbPtr->direction != flushUid)) {
- Tcl_AppendResult(interp, "bad direction value \"", mbPtr->direction,
- "\": must be above, below, left, right, or flush",
- (char *) NULL);
- mbPtr->direction = belowUid;
- return TCL_ERROR;
- }
-
- if (mbPtr->highlightWidth < 0) {
- mbPtr->highlightWidth = 0;
- }
+ /*
+ * A few options need special processing, such as setting the
+ * background from a 3-D border, or filling in complicated
+ * defaults that couldn't be specified to Tk_SetOptions.
+ */
- if (mbPtr->padX < 0) {
- mbPtr->padX = 0;
- }
- if (mbPtr->padY < 0) {
- mbPtr->padY = 0;
- }
+ if ((mbPtr->state == STATE_ACTIVE)
+ && !Tk_StrictMotif(mbPtr->tkwin)) {
+ Tk_SetBackgroundFromBorder(mbPtr->tkwin, mbPtr->activeBorder);
+ } else {
+ Tk_SetBackgroundFromBorder(mbPtr->tkwin, mbPtr->normalBorder);
+ }
- /*
- * Get the image for the widget, if there is one. Allocate the
- * new image before freeing the old one, so that the reference
- * count doesn't go to zero and cause image data to be discarded.
- */
+ if (mbPtr->highlightWidth < 0) {
+ mbPtr->highlightWidth = 0;
+ }
- if (mbPtr->imageString != NULL) {
- image = Tk_GetImage(mbPtr->interp, mbPtr->tkwin,
- mbPtr->imageString, MenuButtonImageProc, (ClientData) mbPtr);
- if (image == NULL) {
- return TCL_ERROR;
+ if (mbPtr->padX < 0) {
+ mbPtr->padX = 0;
+ }
+ if (mbPtr->padY < 0) {
+ mbPtr->padY = 0;
}
- } else {
- image = NULL;
- }
- if (mbPtr->image != NULL) {
- Tk_FreeImage(mbPtr->image);
- }
- mbPtr->image = image;
- if ((mbPtr->image == NULL) && (mbPtr->bitmap == None)
- && (mbPtr->textVarName != NULL)) {
/*
- * The menubutton displays a variable. Set up a trace to watch
- * for any changes in it.
+ * Get the image for the widget, if there is one. Allocate the
+ * new image before freeing the old one, so that the reference
+ * count doesn't go to zero and cause image data to be discarded.
*/
- char *value;
+ if (mbPtr->imageString != NULL) {
+ image = Tk_GetImage(mbPtr->interp, mbPtr->tkwin,
+ mbPtr->imageString, MenuButtonImageProc,
+ (ClientData) mbPtr);
+ if (image == NULL) {
+ return TCL_ERROR;
+ }
+ } else {
+ image = NULL;
+ }
+ if (mbPtr->image != NULL) {
+ Tk_FreeImage(mbPtr->image);
+ }
+ mbPtr->image = image;
- value = Tcl_GetVar(interp, mbPtr->textVarName, TCL_GLOBAL_ONLY);
- if (value == NULL) {
- Tcl_SetVar(interp, mbPtr->textVarName, mbPtr->text,
- TCL_GLOBAL_ONLY);
+ /*
+ * Recompute the geometry for the button.
+ */
+
+ if ((mbPtr->bitmap != None) || (mbPtr->image != NULL)) {
+ if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->widthString,
+ &mbPtr->width) != TCL_OK) {
+ widthError:
+ Tcl_AddErrorInfo(interp, "\n (processing -width option)");
+ continue;
+ }
+ if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->heightString,
+ &mbPtr->height) != TCL_OK) {
+ heightError:
+ Tcl_AddErrorInfo(interp, "\n (processing -height option)");
+ continue;
+ }
} else {
- if (mbPtr->text != NULL) {
- ckfree(mbPtr->text);
+ if (Tcl_GetInt(interp, mbPtr->widthString, &mbPtr->width)
+ != TCL_OK) {
+ goto widthError;
+ }
+ if (Tcl_GetInt(interp, mbPtr->heightString, &mbPtr->height)
+ != TCL_OK) {
+ goto heightError;
}
- mbPtr->text = (char *) ckalloc((unsigned) (strlen(value) + 1));
- strcpy(mbPtr->text, value);
}
- Tcl_TraceVar(interp, mbPtr->textVarName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- MenuButtonTextVarProc, (ClientData) mbPtr);
+ break;
}
- /*
- * Recompute the geometry for the button.
- */
+ if (!error) {
+ Tk_FreeSavedOptions(&savedOptions);
+ }
- if ((mbPtr->bitmap != None) || (mbPtr->image != NULL)) {
- if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->widthString,
- &mbPtr->width) != TCL_OK) {
- widthError:
- Tcl_AddErrorInfo(interp, "\n (processing -width option)");
- return TCL_ERROR;
- }
- if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->heightString,
- &mbPtr->height) != TCL_OK) {
- heightError:
- Tcl_AddErrorInfo(interp, "\n (processing -height option)");
- return TCL_ERROR;
- }
- } else {
- if (Tcl_GetInt(interp, mbPtr->widthString, &mbPtr->width)
- != TCL_OK) {
- goto widthError;
- }
- if (Tcl_GetInt(interp, mbPtr->heightString, &mbPtr->height)
- != TCL_OK) {
- goto heightError;
- }
+ if ((mbPtr->image == NULL) && (mbPtr->bitmap == None)
+ && (mbPtr->textVarName != NULL)) {
+
+ /*
+ * The menubutton displays the value of a variable.
+ * Set up a trace to watch for any changes in it, create
+ * the variable if it doesn't exist, and fetch its
+ * current value.
+ */
+
+ char *value;
+
+ value = Tcl_GetVar(interp, mbPtr->textVarName, TCL_GLOBAL_ONLY);
+ if (value == NULL) {
+ Tcl_SetVar(interp, mbPtr->textVarName, mbPtr->text,
+ TCL_GLOBAL_ONLY);
+ } else {
+ if (mbPtr->text != NULL) {
+ ckfree(mbPtr->text);
+ }
+ mbPtr->text = (char *) ckalloc((unsigned) (strlen(value) + 1));
+ strcpy(mbPtr->text, value);
+ }
+ Tcl_TraceVar(interp, mbPtr->textVarName,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ MenuButtonTextVarProc, (ClientData) mbPtr);
}
+
TkMenuButtonWorldChanged((ClientData) mbPtr);
- return TCL_OK;
+ if (error) {
+ Tcl_SetObjResult(interp, errorResult);
+ Tcl_DecrRefCount(errorResult);
+ return TCL_ERROR;
+ } else {
+ return TCL_OK;
+ }
}
/*
@@ -700,15 +785,7 @@ MenuButtonEventProc(clientData, eventPtr)
goto redraw;
} else if (eventPtr->type == DestroyNotify) {
- TkpDestroyMenuButton(mbPtr);
- if (mbPtr->tkwin != NULL) {
- mbPtr->tkwin = NULL;
- Tcl_DeleteCommandFromToken(mbPtr->interp, mbPtr->widgetCmd);
- }
- if (mbPtr->flags & REDRAW_PENDING) {
- Tcl_CancelIdleCall(TkpDisplayMenuButton, (ClientData) mbPtr);
- }
- Tcl_EventuallyFree((ClientData) mbPtr, DestroyMenuButton);
+ DestroyMenuButton((char *) mbPtr);
} else if (eventPtr->type == FocusIn) {
if (eventPtr->xfocus.detail != NotifyInferior) {
mbPtr->flags |= GOT_FOCUS;
@@ -766,7 +843,6 @@ MenuButtonCmdDeletedProc(clientData)
*/
if (tkwin != NULL) {
- mbPtr->tkwin = NULL;
Tk_DestroyWindow(tkwin);
}
}
diff --git a/generic/tkMenubutton.h b/generic/tkMenubutton.h
index f934b51..606e0bc 100644
--- a/generic/tkMenubutton.h
+++ b/generic/tkMenubutton.h
@@ -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: tkMenubutton.h,v 1.1.4.3 1999/02/13 05:38:49 lfb Exp $
+ * RCS: @(#) $Id: tkMenubutton.h,v 1.1.4.4 1999/02/16 06:00:41 lfb Exp $
*/
#ifndef _TKMENUBUTTON
@@ -25,6 +25,23 @@
#endif
/*
+ * Legal values for the "orient" field of TkMenubutton records.
+ */
+
+enum direction {
+ DIRECTION_ABOVE, DIRECTION_BELOW, DIRECTION_FLUSH,
+ DIRECTION_LEFT, DIRECTION_RIGHT
+};
+
+/*
+ * Legal values for the "state" field of TkMenubutton records.
+ */
+
+enum state {
+ STATE_ACTIVE, STATE_DISABLED, STATE_NORMAL
+};
+
+/*
* A data structure of the following type is kept for each
* widget managed by this file:
*/
@@ -39,6 +56,8 @@ typedef struct {
* freed up even after tkwin has gone away. */
Tcl_Interp *interp; /* Interpreter associated with menubutton. */
Tcl_Command widgetCmd; /* Token for menubutton's widget command. */
+ Tk_OptionTable optionTable; /* Table that defines configuration options
+ * available for this widget. */
char *menuName; /* Name of menu associated with widget.
* Malloc-ed. */
@@ -65,7 +84,7 @@ typedef struct {
* Information used when displaying widget:
*/
- char * state; /* State of button for display purposes:
+ enum state state; /* State of button for display purposes:
* normal, active, or disabled. */
Tk_3DBorder normalBorder; /* Structure used to draw 3-D
* border and background when window
@@ -143,7 +162,7 @@ typedef struct {
* Miscellaneous information:
*/
- Tk_Uid direction; /* Direction for where to pop the menu.
+ enum direction direction; /* Direction for where to pop the menu.
* Valid directions are "above", "below",
* "left", "right", and "flush". "flush"
* means that the upper left corner of the
diff --git a/generic/tkScale.c b/generic/tkScale.c
index 6588fb8..f742627 100644
--- a/generic/tkScale.c
+++ b/generic/tkScale.c
@@ -17,7 +17,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkScale.c,v 1.1.4.4 1999/02/13 05:09:35 lfb Exp $
+ * RCS: @(#) $Id: tkScale.c,v 1.1.4.5 1999/02/16 06:00:41 lfb Exp $
*/
#include "tkPort.h"
@@ -46,7 +46,7 @@ static char *stateStrings[] = {
static Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_BUTTON_ACTIVE_BG_COLOR, -1, Tk_Offset(TkScale, activeBorder),
+ DEF_SCALE_ACTIVE_BG_COLOR, -1, Tk_Offset(TkScale, activeBorder),
0, (ClientData) DEF_SCALE_ACTIVE_BG_MONO, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
DEF_SCALE_BG_COLOR, -1, Tk_Offset(TkScale, bgBorder),
@@ -75,7 +75,8 @@ static Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_FONT, "-font", "font", "Font",
DEF_SCALE_FONT, -1, Tk_Offset(TkScale, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_BUTTON_FG, -1, Tk_Offset(TkScale, textColorPtr), 0, 0, 0},
+ DEF_SCALE_FG_COLOR, -1, Tk_Offset(TkScale, textColorPtr), 0,
+ (ClientData) DEF_SCALE_FG_MONO, 0},
{TK_OPTION_DOUBLE, "-from", "from", "From", DEF_SCALE_FROM, -1,
Tk_Offset(TkScale, fromValue), 0, 0, 0},
{TK_OPTION_BORDER, "-highlightbackground", "highlightBackground",
@@ -246,6 +247,8 @@ Tk_ScaleObjCmd(clientData, interp, objc, objv)
if (tkwin == NULL) {
return TCL_ERROR;
}
+
+ Tk_SetClass(tkwin, "Scale");
scalePtr = TkpCreateScale(tkwin);
/*
@@ -307,7 +310,6 @@ Tk_ScaleObjCmd(clientData, interp, objc, objv)
scalePtr->takeFocusPtr = NULL;
scalePtr->flags = NEVER_SET;
- Tk_SetClass(scalePtr->tkwin, "Scale");
TkSetClassProcs(scalePtr->tkwin, &scaleClass, (ClientData) scalePtr);
Tk_CreateEventHandler(scalePtr->tkwin,
ExposureMask|StructureNotifyMask|FocusChangeMask,
diff --git a/generic/tkWindow.c b/generic/tkWindow.c
index f571819..f9ead85 100644
--- a/generic/tkWindow.c
+++ b/generic/tkWindow.c
@@ -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: tkWindow.c,v 1.1.4.6 1999/02/13 05:09:35 lfb Exp $
+ * RCS: @(#) $Id: tkWindow.c,v 1.1.4.7 1999/02/16 06:00:41 lfb Exp $
*/
#include "tkPort.h"
@@ -135,7 +135,7 @@ static TkCmd commands[] = {
{"frame", Tk_FrameCmd, NULL, 1, 1},
{"label", NULL, Tk_LabelObjCmd, 1, 0},
{"listbox", Tk_ListboxCmd, NULL, 1, 1},
- {"menubutton", Tk_MenubuttonCmd, NULL, 1, 1},
+ {"menubutton", NULL, Tk_MenubuttonObjCmd, 1, 0},
{"message", Tk_MessageCmd, NULL, 1, 1},
{"radiobutton", NULL, Tk_RadiobuttonObjCmd, 1, 0},
{"scale", NULL, Tk_ScaleObjCmd, 1, 0},
diff --git a/mac/tkMacDefault.h b/mac/tkMacDefault.h
index d26014f..eeb4c1f 100644
--- a/mac/tkMacDefault.h
+++ b/mac/tkMacDefault.h
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacDefault.h,v 1.1.4.3 1999/02/13 05:09:36 lfb Exp $
+ * RCS: @(#) $Id: tkMacDefault.h,v 1.1.4.4 1999/02/16 06:00:42 lfb Exp $
*/
#ifndef _TKMACDEFAULT
@@ -289,7 +289,8 @@
#define DEF_MENUBUTTON_FONT "system"
#define DEF_MENUBUTTON_FG BLACK
#define DEF_MENUBUTTON_HEIGHT "0"
-#define DEF_MENUBUTTON_HIGHLIGHT_BG NORMAL_BG
+#define DEF_MENUBUTTON_HIGHLIGHT_BG_COLOR DEF_MENUBUTTON_BG_COLOR
+#define DEF_MENUBUTTON_HIGHLIGHT_BG_MONO DEF_MENUBUTTON_BG_MONO
#define DEF_MENUBUTTON_HIGHLIGHT BLACK
#define DEF_MENUBUTTON_HIGHLIGHT_WIDTH "0"
#define DEF_MENUBUTTON_IMAGE (char *) NULL
diff --git a/mac/tkMacMenubutton.c b/mac/tkMacMenubutton.c
index 49bdb94..2b11e5f 100644
--- a/mac/tkMacMenubutton.c
+++ b/mac/tkMacMenubutton.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: tkMacMenubutton.c,v 1.1.4.3 1999/02/13 05:38:49 lfb Exp $
+ * RCS: @(#) $Id: tkMacMenubutton.c,v 1.1.4.4 1999/02/16 06:00:42 lfb Exp $
*/
#include "tkMenubutton.h"
@@ -110,10 +110,9 @@ TkpDisplayMenuButton(
SetGWorld(destPort, NULL);
macDraw = (MacDrawable *) Tk_WindowId(tkwin);
- if ((mbPtr->state[0] == 'd') && (strcmp(mbPtr->state, "disabled"))
- && (mbPtr->disabledFg != NULL)) {
+ if ((mbPtr->state == STATE_DISABLED) && (mbPtr->disabledFg != NULL)) {
gc = mbPtr->disabledGC;
- } else if ((mbPtr->state[0] == 'a') && (strcmp(mbPtr->state, "active"))
+ } else if ((mbPtr->state == STATE_ACTIVE)
&& !Tk_StrictMotif(mbPtr->tkwin)) {
gc = mbPtr->activeTextGC;
} else {
@@ -164,10 +163,10 @@ TkpDisplayMenuButton(
* foreground color, generate the stippled effect.
*/
- if ((mbPtr->state[0] == 'd') && (strcmp(mbPtr->state, "disabled"))
- && ((mbPtr->disabledFg == NULL) || (mbPtr->image != NULL))) {
- XFillRectangle(mbPtr->display, Tk_WindowId(tkwin), mbPtr->disabledGC,
- mbPtr->inset, mbPtr->inset,
+ if (mbPtr->state == STATE_DISABLED && mbPtr->disabledFg != NULL) {
+ || (mbPtr->image != NULL))) {
+ XFillRectangle(mbPtr->display, Tk_WindowId(tkwin),
+ mbPtr->disabledGC, mbPtr->inset, mbPtr->inset,
(unsigned) (Tk_Width(tkwin) - 2*mbPtr->inset),
(unsigned) (Tk_Height(tkwin) - 2*mbPtr->inset));
}
diff --git a/tests/menubut.test b/tests/menubut.test
index a0054ba..35e43c9 100644
--- a/tests/menubut.test
+++ b/tests/menubut.test
@@ -7,7 +7,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: menubut.test,v 1.1.4.1 1998/09/30 02:18:49 stanton Exp $
+# RCS: @(#) $Id: menubut.test,v 1.1.4.2 1999/02/16 06:00:42 lfb Exp $
# XXX This test file is woefully incomplete right now. If any part
# XXX of a procedure has tests then the whole procedure has tests,
@@ -51,7 +51,7 @@ foreach test {
{unknown color name "non-existent"}}
{-activeforeground #ff0000 #ff0000 non-existent
{unknown color name "non-existent"}}
- {-anchor nw nw bogus {bad anchor position "bogus": must be n, ne, e, se, s, sw, w, nw, or center}}
+ {-anchor nw nw bogus {bad anchor "bogus": must be n, ne, e, se, s, sw, w, nw, or center}}
{-background #ff0000 #ff0000 non-existent
{unknown color name "non-existent"}}
{-bd 4 4 badValue {bad screen distance "badValue"}}
@@ -59,7 +59,7 @@ foreach test {
{-bitmap questhead questhead badValue {bitmap "badValue" not defined}}
{-borderwidth 1.3 1 badValue {bad screen distance "badValue"}}
{-cursor arrow arrow badValue {bad cursor spec "badValue"}}
- {-direction below below badValue {bad direction value "badValue": must be above, below, left, right, or flush}}
+ {-direction below below badValue {bad direction "badValue": must be above, below, flush, left, or right}}
{-disabledforeground #00ff00 #00ff00 xyzzy {unknown color name "xyzzy"}}
{-fg #110022 #110022 bogus {unknown color name "bogus"}}
{-font {Helvetica 12} {Helvetica 12} {} {font "" doesn't exist}}
@@ -74,8 +74,8 @@ foreach test {
{-menu "any old string" "any old string" {} {}}
{-padx 12 12 420x {bad screen distance "420x"}}
{-pady 12 12 420x {bad screen distance "420x"}}
- {-relief groove groove 1.5 {bad relief type "1.5": must be flat, groove, raised, ridge, solid, or sunken}}
- {-state normal normal bogus {bad state value "bogus": must be normal, active, or disabled}}
+ {-relief groove groove 1.5 {bad relief "1.5": must be flat, groove, raised, ridge, solid, or sunken}}
+ {-state normal normal bogus {bad state "bogus": must be active, disabled, or normal}}
{-takefocus "any string" "any string" {} {}}
{-text "Sample text" {Sample text} {} {}}
{-textvariable i i {} {}}
@@ -122,7 +122,7 @@ test menubutton-3.1 {MenuButtonWidgetCmd procedure} {
} {1 {wrong # args: should be ".mb option ?arg arg ...?"}}
test menubutton-3.2 {ButtonWidgetCmd procedure, "cget" option} {
list [catch {.mb c} msg] $msg
-} {1 {bad option "c": must be cget or configure}}
+} {1 {ambiguous option "c": must be cget or configure}}
test menubutton-3.3 {ButtonWidgetCmd procedure, "cget" option} {
list [catch {.mb cget} msg] $msg
} {1 {wrong # args: should be ".mb cget option"}}
@@ -204,7 +204,7 @@ test menubutton-4.6 {ConfigureMenuButton procedure - bad direction} {
menubutton .mb -text "Test"
list [catch {.mb configure -direction badValue} msg] $msg \
[.mb cget -direction] [destroy .mb]
-} {1 {bad direction value "badValue": must be above, below, left, right, or flush} below {}}
+} {1 {bad direction "badValue": must be above, below, flush, left, or right} below {}}
# XXX Need to add tests for several procedures here. XXX
diff --git a/win/tkWinDefault.h b/win/tkWinDefault.h
index d395aec..c4458e2 100644
--- a/win/tkWinDefault.h
+++ b/win/tkWinDefault.h
@@ -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: tkWinDefault.h,v 1.1.4.3 1999/02/13 05:09:37 lfb Exp $
+ * RCS: @(#) $Id: tkWinDefault.h,v 1.1.4.4 1999/02/16 06:00:43 lfb Exp $
*/
#ifndef _TKWINDEFAULT
@@ -289,7 +289,8 @@
#define DEF_MENUBUTTON_FONT CTL_FONT
#define DEF_MENUBUTTON_FG NORMAL_FG
#define DEF_MENUBUTTON_HEIGHT "0"
-#define DEF_MENUBUTTON_HIGHLIGHT_BG NORMAL_BG
+#define DEF_MENUBUTTON_HIGHLIGHT_BG_COLOR DEF_MENUBUTTON_BG_COLOR
+#define DEF_MENUBUTTON_HIGHLIGHT_BG_MONO DEF_MENUBUTTON_BG_MONO
#define DEF_MENUBUTTON_HIGHLIGHT HIGHLIGHT
#define DEF_MENUBUTTON_HIGHLIGHT_WIDTH "0"
#define DEF_MENUBUTTON_IMAGE (char *) NULL