summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2024-10-01 20:40:17 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2024-10-01 20:40:17 (GMT)
commitdf21e8d29c5c82e39c4280b1b71f4ebcbc9b23c5 (patch)
tree2d4d89daea79221ca4cde476242fc55747c2faa8
parent8eb1894369b5ad171605bee1beadec4208b4204b (diff)
parent018572a23afa95dc2893826a34f2f16d47b5cc0a (diff)
downloadtk-df21e8d29c5c82e39c4280b1b71f4ebcbc9b23c5.zip
tk-df21e8d29c5c82e39c4280b1b71f4ebcbc9b23c5.tar.gz
tk-df21e8d29c5c82e39c4280b1b71f4ebcbc9b23c5.tar.bz2
Fix [f91aa24bbe] for "menubutton". Simplify -activerelief for "menu"
-rw-r--r--generic/tkMenu.c4
-rw-r--r--generic/tkMenu.h2
-rw-r--r--generic/tkMenubutton.c50
-rw-r--r--generic/tkMenubutton.h4
-rw-r--r--macosx/tkMacOSXMenubutton.c7
-rw-r--r--unix/tkUnixMenu.c2
-rw-r--r--win/tkWinMenu.c2
7 files changed, 33 insertions, 38 deletions
diff --git a/generic/tkMenu.c b/generic/tkMenu.c
index 019a881..fb02a35 100644
--- a/generic/tkMenu.c
+++ b/generic/tkMenu.c
@@ -249,8 +249,8 @@ static const Tk_OptionSpec tkMenuConfigSpecs[] = {
offsetof(TkMenu, activeFgPtr), TCL_INDEX_NONE, 0,
DEF_MENU_ACTIVE_FG_MONO, 0},
{TK_OPTION_RELIEF, "-activerelief", "activeRelief", "Relief",
- DEF_MENU_ACTIVE_RELIEF, offsetof(TkMenu, activeReliefPtr),
- TCL_INDEX_NONE, 0, NULL, 0},
+ DEF_MENU_ACTIVE_RELIEF, TCL_INDEX_NONE,
+ offsetof(TkMenu, activeRelief), 0, NULL, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
DEF_MENU_BG_COLOR, offsetof(TkMenu, borderPtr), TCL_INDEX_NONE, 0,
DEF_MENU_BG_MONO, 0},
diff --git a/generic/tkMenu.h b/generic/tkMenu.h
index 5f77128..cbe524b 100644
--- a/generic/tkMenu.h
+++ b/generic/tkMenu.h
@@ -379,7 +379,7 @@ typedef struct TkMenu {
/* We actually have to allocate these because
* multiple menus get changed during one
* ConfigureMenu call. */
- Tcl_Obj *activeReliefPtr; /* 3-d effect for active element. */
+ int activeRelief; /* 3-d effect for active element. */
Tcl_HashTable items; /* Map: id -> entry */
int serial; /* Next item # for autogenerated ids */
} TkMenu;
diff --git a/generic/tkMenubutton.c b/generic/tkMenubutton.c
index a185b08..ce7df6f 100644
--- a/generic/tkMenubutton.c
+++ b/generic/tkMenubutton.c
@@ -81,8 +81,8 @@ static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
DEF_MENUBUTTON_FG, TCL_INDEX_NONE, offsetof(TkMenuButton, normalFg), 0, 0, 0},
{TK_OPTION_STRING, "-height", "height", "Height",
- DEF_MENUBUTTON_HEIGHT, TCL_INDEX_NONE, offsetof(TkMenuButton, heightString),
- 0, 0, 0},
+ DEF_MENUBUTTON_HEIGHT, offsetof(TkMenuButton, heightObj),
+ TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_COLOR, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_MENUBUTTON_HIGHLIGHT_BG_COLOR,
TCL_INDEX_NONE, offsetof(TkMenuButton, highlightBgColorPtr), 0, 0, 0},
@@ -129,11 +129,11 @@ static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_INDEX, "-underline", "underline", "Underline",
TK_OPTION_UNDERLINE_DEF(TkMenuButton, underline), 0},
{TK_OPTION_STRING, "-width", "width", "Width",
- DEF_MENUBUTTON_WIDTH, TCL_INDEX_NONE, offsetof(TkMenuButton, widthString),
- 0, 0, 0},
+ DEF_MENUBUTTON_WIDTH, offsetof(TkMenuButton, widthObj),
+ TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
- DEF_MENUBUTTON_WRAP_LENGTH, offsetof(TkMenuButton, wrapLengthObj), offsetof(TkMenuButton, wrapLength),
- 0, 0, 0},
+ DEF_MENUBUTTON_WRAP_LENGTH, offsetof(TkMenuButton, wrapLengthObj),
+ offsetof(TkMenuButton, wrapLength), 0, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
@@ -190,7 +190,7 @@ static void DestroyMenuButton(void *memPtr);
int
Tk_MenubuttonObjCmd(
- void *dummy, /* NULL. */
+ TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -198,7 +198,6 @@ Tk_MenubuttonObjCmd(
TkMenuButton *mbPtr;
Tk_OptionTable optionTable;
Tk_Window tkwin;
- (void)dummy;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
@@ -265,10 +264,10 @@ Tk_MenubuttonObjCmd(
mbPtr->stippleGC = NULL;
mbPtr->leftBearing = 0;
mbPtr->rightBearing = 0;
- mbPtr->widthString = NULL;
- mbPtr->heightString = NULL;
- mbPtr->width = 0;
+ mbPtr->widthObj = NULL;
+ mbPtr->heightObj = NULL;
mbPtr->width = 0;
+ mbPtr->height = 0;
mbPtr->wrapLength = 0;
mbPtr->padX = 0;
mbPtr->padY = 0;
@@ -536,6 +535,9 @@ ConfigureMenuButton(
Tk_SetBackgroundFromBorder(mbPtr->tkwin, mbPtr->normalBorder);
}
+ if (mbPtr->borderWidth < 0) {
+ mbPtr->borderWidth = 0;
+ }
if (mbPtr->highlightWidth < 0) {
mbPtr->highlightWidth = 0;
if (mbPtr->highlightWidthObj) {
@@ -544,7 +546,6 @@ ConfigureMenuButton(
mbPtr->highlightWidthObj = Tcl_NewIntObj(0);
Tcl_IncrRefCount(mbPtr->highlightWidthObj);
}
-
if (mbPtr->padX < 0) {
mbPtr->padX = 0;
if (mbPtr->padXObj) {
@@ -587,24 +588,24 @@ ConfigureMenuButton(
*/
if ((mbPtr->bitmap != None) || (mbPtr->image != NULL)) {
- if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->widthString,
+ if (Tk_GetPixelsFromObj(interp, mbPtr->tkwin, mbPtr->widthObj,
&mbPtr->width) != TCL_OK) {
widthError:
Tcl_AddErrorInfo(interp, "\n (processing \"-width\" option)");
continue;
}
- if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->heightString,
+ if (Tk_GetPixelsFromObj(interp, mbPtr->tkwin, mbPtr->heightObj,
&mbPtr->height) != TCL_OK) {
heightError:
Tcl_AddErrorInfo(interp, "\n (processing \"-height\" option)");
continue;
}
} else {
- if (Tcl_GetInt(interp, mbPtr->widthString, &mbPtr->width)
+ if (Tcl_GetIntFromObj(interp, mbPtr->widthObj, &mbPtr->width)
!= TCL_OK) {
goto widthError;
}
- if (Tcl_GetInt(interp, mbPtr->heightString, &mbPtr->height)
+ if (Tcl_GetIntFromObj(interp, mbPtr->heightObj, &mbPtr->height)
!= TCL_OK) {
goto heightError;
}
@@ -954,19 +955,14 @@ MenuButtonTextVarProc(
static void
MenuButtonImageProc(
void *clientData, /* Pointer to widget record. */
- int x, int y, /* Upper left pixel (within image) that must
- * be redisplayed. */
- int width, int height, /* Dimensions of area to redisplay (may be <=
- * 0). */
- int imgWidth, int imgHeight)/* New dimensions of image. */
+ TCL_UNUSED(int), /* x, Upper left pixel (within image) that must */
+ TCL_UNUSED(int), /* y, be redisplayed. */
+ TCL_UNUSED(int), /* width, Dimensions of area to redisplay (may be <= */
+ TCL_UNUSED(int), /* height, 0). */
+ TCL_UNUSED(int), /* imgWidth, New dimensions of image. */
+ TCL_UNUSED(int)) /* imgHeight) */
{
TkMenuButton *mbPtr = (TkMenuButton *)clientData;
- (void)x;
- (void)y;
- (void)width;
- (void)height;
- (void)imgWidth;
- (void)imgHeight;
if (mbPtr->tkwin != NULL) {
TkpComputeMenuButtonGeometry(mbPtr);
diff --git a/generic/tkMenubutton.h b/generic/tkMenubutton.h
index 06502df..1dd8f78 100644
--- a/generic/tkMenubutton.h
+++ b/generic/tkMenubutton.h
@@ -119,8 +119,8 @@ typedef struct {
* pixel (positive means to right). */
int rightBearing; /* Amount text sticks right from its
* origin. */
- char *widthString; /* Value of -width option. Malloc'ed. */
- char *heightString; /* Value of -height option. Malloc'ed. */
+ Tcl_Obj *widthObj; /* Value of -width option. */
+ Tcl_Obj *heightObj; /* Value of -height option. */
int width, height; /* If > 0, these specify dimensions to request
* for window, in characters for text and in
* pixels for bitmaps. In this case the actual
diff --git a/macosx/tkMacOSXMenubutton.c b/macosx/tkMacOSXMenubutton.c
index c50eaba..2b71bff 100644
--- a/macosx/tkMacOSXMenubutton.c
+++ b/macosx/tkMacOSXMenubutton.c
@@ -246,7 +246,6 @@ TkpComputeMenuButtonGeometry(
int width, height, avgWidth, haveImage = 0, haveText = 0;
int txtWidth, txtHeight;
Tk_FontMetrics fm;
- int highlightWidth = butPtr->highlightWidth > 0 ? butPtr->highlightWidth : 0;
/*
* First compute the size of the contents of the button.
@@ -336,15 +335,15 @@ TkpComputeMenuButtonGeometry(
width = txtWidth;
height = txtHeight;
if (butPtr->width > 0) {
- width = butPtr->width * avgWidth + 2*butPtr->padX;
+ width = butPtr->width * avgWidth + 2 * butPtr->padX;
}
if (butPtr->height > 0) {
- height = butPtr->height * fm.linespace + 2*butPtr->padY;
+ height = butPtr->height * fm.linespace + 2 * butPtr->padY;
}
}
}
- butPtr->inset = highlightWidth + butPtr->borderWidth;
+ butPtr->inset = butPtr->highlightWidth + butPtr->borderWidth;
width += LEFT_INSET + RIGHT_INSET + 2*butPtr->inset;
height += 2*butPtr->inset;
height = height < MIN_HEIGHT ? MIN_HEIGHT : height;
diff --git a/unix/tkUnixMenu.c b/unix/tkUnixMenu.c
index 717731d..3460840 100644
--- a/unix/tkUnixMenu.c
+++ b/unix/tkUnixMenu.c
@@ -444,7 +444,7 @@ DrawMenuEntryBackground(
|| (menuPtr->postedCascade != mePtr))) {
relief = TK_RELIEF_FLAT;
} else {
- Tk_GetReliefFromObj(NULL, menuPtr->activeReliefPtr, &relief);
+ relief = menuPtr->activeRelief;
}
Tk_GetPixelsFromObj(NULL, menuPtr->tkwin,
menuPtr->activeBorderWidthPtr, &activeBorderWidth);
diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c
index 22aadef..da00c02 100644
--- a/win/tkWinMenu.c
+++ b/win/tkWinMenu.c
@@ -2944,7 +2944,7 @@ DrawMenuEntryBackground(
|| (menuPtr->postedCascade != mePtr))) {
relief = TK_RELIEF_FLAT;
} else {
- Tk_GetReliefFromObj(NULL, menuPtr->activeReliefPtr, &relief);
+ relief = menuPtr->activeRelief);
}
Tk_GetPixelsFromObj(NULL, menuPtr->tkwin,
menuPtr->activeBorderWidthPtr, &activeBorderWidth);