Attachment "tk-varind.patch" to
ticket [2994285fff]
added by
russty1971
2010-04-30 00:48:54.
--- tk8.5.6/generic/tkMenubutton.h 2007-12-13 08:24:16.000000000 -0700
+++ tk8.5.6_ib/generic/tkMenubutton.h 2010-04-19 15:05:15.425675755 -0600
@@ -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
@@ -207,8 +209,8 @@ typedef struct {
* these options are 1/10 millimeters.
*/
-#define INDICATOR_WIDTH 40
-#define INDICATOR_HEIGHT 17
+#define INDICATOR_WIDTH 30
+#define INDICATOR_HEIGHT 10
/*
* Declaration of variables shared between the files in the button module.
--- tk8.5.6/generic/tkMenubutton.c 2007-12-13 16:08:43.000000000 -0700
+++ tk8.5.6_ib/generic/tkMenubutton.c 2010-04-20 11:26:57.335675393 -0600
@@ -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", "indicatorWidth", "IndicatorWidth",
+ DEF_MENUBUTTON_INDICATORWIDTH, -1, Tk_Offset(TkMenuButton, indicatorWidthString),
+ 0, 0, 0},
+ {TK_OPTION_STRING, "-indheight", "indicatorHeight", "IndicatorHeight",
+ 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;
@@ -593,6 +601,18 @@ ConfigureMenuButton(
Tcl_AddErrorInfo(interp, "\n (processing -height option)");
continue;
}
+ if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->indicatorWidthString,
+ &mbPtr->indicatorWidth) != TCL_OK) {
+ indicatorWidthError:
+ Tcl_AddErrorInfo(interp, "\n (processing -indicatorwidth option)");
+ continue;
+ }
+ if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->indicatorHeightString,
+ &mbPtr->indicatorHeight) != 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->indicatorWidth)
+ != TCL_OK) {
+ goto indicatorWidthError;
+ }
+ if (Tcl_GetInt(interp, mbPtr->indicatorHeightString, &mbPtr->indicatorHeight)
+ != TCL_OK) {
+ goto indicatorHeightError;
+ }
}
break;
}
--- tk8.5.6/unix/tkUnixDefault.h 2007-12-13 08:28:50.000000000 -0700
+++ tk8.5.6_ib/unix/tkUnixDefault.h 2010-04-19 15:05:15.427676270 -0600
@@ -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"
/*
--- tk8.5.6/unix/tkUnixMenubu.c 2007-12-13 08:28:50.000000000 -0700
+++ tk8.5.6_ib/unix/tkUnixMenubu.c 2010-04-21 16:18:41.728441742 -0600
@@ -271,10 +271,9 @@ TkpDisplayMenuButton(
/*y += mbPtr->textHeight / 2;*/
Tk_Fill3DRectangle(tkwin, pixmap, border,
Tk_Width(tkwin) - mbPtr->inset - mbPtr->indicatorWidth
- + mbPtr->indicatorHeight,
+ + (mbPtr->indicatorHeight/2) - (borderWidth*2.5),
((int) (Tk_Height(tkwin) - mbPtr->indicatorHeight))/2,
- mbPtr->indicatorWidth - 2*mbPtr->indicatorHeight,
- mbPtr->indicatorHeight, borderWidth, TK_RELIEF_RAISED);
+ mbPtr->indicatorWidth, mbPtr->indicatorHeight, borderWidth, TK_RELIEF_RAISED);
}
/*
@@ -464,9 +463,13 @@ 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->indicatorHeight == 0) {
+ mbPtr->indicatorHeight= (INDICATOR_HEIGHT * pixels)/(10*mm);
+ }
+ if (mbPtr->indicatorWidth == 0) {
+ mbPtr->indicatorWidth = (INDICATOR_WIDTH * pixels)/(10*mm)
+ + 2*mbPtr->indicatorHeight;
+ }
width += mbPtr->indicatorWidth;
} else {
mbPtr->indicatorHeight = 0;