Attachment "tk-varind.patch" to
ticket [2996760f]
added by
russty1971
2010-06-09 05:14:34.
diff -rup tk8.5.8_base/generic/tkMenubutton.c tk8.5.8/generic/tkMenubutton.c
--- tk8.5.8_base/generic/tkMenubutton.c 2009-04-10 12:07:56.000000000 -0400
+++ tk8.5.8/generic/tkMenubutton.c 2010-06-08 17:44:14.627079775 -0400
@@ -141,6 +141,12 @@ static const Tk_OptionSpec optionSpecs[]
{TK_OPTION_STRING, "-width", "width", "Width",
DEF_MENUBUTTON_WIDTH, -1, Tk_Offset(TkMenuButton, widthString),
0, 0, 0},
+ {TK_OPTION_STRING, "-indwidth", "indWidth", "IndWidth",
+ DEF_MENUBUTTON_INDICATORWIDTH, -1, Tk_Offset(TkMenuButton, indicatorWidthString),
+ 0, 0, 0},
+ {TK_OPTION_STRING, "-indheight", "indHeight", "IndHeight",
+ DEF_MENUBUTTON_INDICATORHEIGHT, -1, Tk_Offset(TkMenuButton, indicatorHeightString),
+ 0, 0, 0},
{TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
DEF_MENUBUTTON_WRAP_LENGTH, -1, Tk_Offset(TkMenuButton, wrapLength),
0, 0, 0},
@@ -278,6 +284,8 @@ Tk_MenubuttonObjCmd(
mbPtr->rightBearing = 0;
mbPtr->widthString = NULL;
mbPtr->heightString = NULL;
+ mbPtr->indicatorWidthString = NULL;
+ mbPtr->indicatorHeightString = NULL;
mbPtr->width = 0;
mbPtr->width = 0;
mbPtr->wrapLength = 0;
@@ -287,8 +295,8 @@ Tk_MenubuttonObjCmd(
mbPtr->justify = TK_JUSTIFY_CENTER;
mbPtr->textLayout = NULL;
mbPtr->indicatorOn = 0;
- mbPtr->indicatorWidth = 0;
- mbPtr->indicatorHeight = 0;
+ mbPtr->indWidthStore = 0;
+ mbPtr->indHeightStore = 0;
mbPtr->direction = DIRECTION_FLUSH;
mbPtr->cursor = None;
mbPtr->takeFocus = NULL;
@@ -593,6 +601,18 @@ ConfigureMenuButton(
Tcl_AddErrorInfo(interp, "\n (processing -height option)");
continue;
}
+ if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->indicatorWidthString,
+ &mbPtr->indWidthStore) != TCL_OK) {
+ indicatorWidthError:
+ Tcl_AddErrorInfo(interp, "\n (processing -indicatorwidth option)");
+ continue;
+ }
+ if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->indicatorHeightString,
+ &mbPtr->indHeightStore) != TCL_OK) {
+ indicatorHeightError:
+ Tcl_AddErrorInfo(interp, "\n (processing -indicatorheight option)");
+ continue;
+ }
} else {
if (Tcl_GetInt(interp, mbPtr->widthString, &mbPtr->width)
!= TCL_OK) {
@@ -602,6 +622,14 @@ ConfigureMenuButton(
!= TCL_OK) {
goto heightError;
}
+ if (Tcl_GetInt(interp, mbPtr->indicatorWidthString, &mbPtr->indWidthStore)
+ != TCL_OK) {
+ goto indicatorWidthError;
+ }
+ if (Tcl_GetInt(interp, mbPtr->indicatorHeightString, &mbPtr->indHeightStore)
+ != TCL_OK) {
+ goto indicatorHeightError;
+ }
}
break;
}
diff -rup tk8.5.8_base/generic/tkMenubutton.h tk8.5.8/generic/tkMenubutton.h
--- tk8.5.8_base/generic/tkMenubutton.h 2007-12-13 10:24:16.000000000 -0500
+++ tk8.5.8/generic/tkMenubutton.h 2010-06-08 17:36:20.519089664 -0400
@@ -130,6 +130,8 @@ typedef struct {
* origin. */
char *widthString; /* Value of -width option. Malloc'ed. */
char *heightString; /* Value of -height option. Malloc'ed. */
+ char *indicatorWidthString; /* Value of -indicatorwidth option */
+ char *indicatorHeightString;/* Value of -indicatorheight 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
@@ -159,6 +161,8 @@ typedef struct {
int indicatorWidth; /* Width of indicator in pixels, including
* indicatorHeight in padding on each side. 0
* if no indicator. */
+ int indWidthStore; /* Unchanging indicator width */
+ int indHeightStore; /* Unchanging indicator height */
/*
* Miscellaneous information:
diff -rup tk8.5.8_base/unix/tkUnixDefault.h tk8.5.8/unix/tkUnixDefault.h
--- tk8.5.8_base/unix/tkUnixDefault.h 2007-12-13 10:28:50.000000000 -0500
+++ tk8.5.8/unix/tkUnixDefault.h 2010-06-07 12:41:11.837089349 -0400
@@ -330,6 +330,8 @@
#define DEF_MENUBUTTON_TEXT_VARIABLE ""
#define DEF_MENUBUTTON_UNDERLINE "-1"
#define DEF_MENUBUTTON_WIDTH "0"
+#define DEF_MENUBUTTON_INDICATORWIDTH "0"
+#define DEF_MENUBUTTON_INDICATORHEIGHT "0"
#define DEF_MENUBUTTON_WRAP_LENGTH "0"
/*
diff -rup tk8.5.8_base/unix/tkUnixMenubu.c tk8.5.8/unix/tkUnixMenubu.c
--- tk8.5.8_base/unix/tkUnixMenubu.c 2007-12-13 10:28:50.000000000 -0500
+++ tk8.5.8/unix/tkUnixMenubu.c 2010-06-08 17:44:12.011081212 -0400
@@ -464,9 +464,18 @@ TkpComputeMenuButtonGeometry(
if (mbPtr->indicatorOn) {
mm = WidthMMOfScreen(Tk_Screen(mbPtr->tkwin));
pixels = WidthOfScreen(Tk_Screen(mbPtr->tkwin));
- mbPtr->indicatorHeight= (INDICATOR_HEIGHT * pixels)/(10*mm);
- mbPtr->indicatorWidth = (INDICATOR_WIDTH * pixels)/(10*mm)
- + 2*mbPtr->indicatorHeight;
+ if (mbPtr->indHeightStore == 0) {
+ mbPtr->indicatorHeight = (INDICATOR_HEIGHT * pixels)/(10*mm);
+ } else {
+ mbPtr->indicatorHeight = (mbPtr->indHeightStore * pixels)/(10*mm);
+ }
+ if (mbPtr->indWidthStore == 0) {
+ mbPtr->indicatorWidth = (INDICATOR_WIDTH * pixels)/(10*mm)
+ + 2*mbPtr->indicatorHeight;
+ } else {
+ mbPtr->indicatorWidth = (mbPtr->indWidthStore * pixels)/(10*mm)
+ + 2*mbPtr->indicatorHeight;
+ }
width += mbPtr->indicatorWidth;
} else {
mbPtr->indicatorHeight = 0;