diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-10-03 15:38:13 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-10-03 15:38:13 (GMT) |
commit | a2a3a745beab7473aa65caea2e2a8d5d690f2955 (patch) | |
tree | 90d20aa42376939c6f7d1f4b5bfcec4773b616b3 | |
parent | 41f77fa32efa1d674dd4cc7c956d5e39e2f0a387 (diff) | |
parent | 562f881e83203969ee65ee1aa682742c9bc3555b (diff) | |
download | tk-a2a3a745beab7473aa65caea2e2a8d5d690f2955.zip tk-a2a3a745beab7473aa65caea2e2a8d5d690f2955.tar.gz tk-a2a3a745beab7473aa65caea2e2a8d5d690f2955.tar.bz2 |
More progress
-rw-r--r-- | README.md | 21 | ||||
-rw-r--r-- | generic/tkText.c | 73 | ||||
-rw-r--r-- | generic/tkText.h | 67 | ||||
-rw-r--r-- | generic/tkTextDisp.c | 74 | ||||
-rw-r--r-- | generic/tkTextImage.c | 27 | ||||
-rw-r--r-- | generic/tkTextTag.c | 51 | ||||
-rw-r--r-- | generic/tkTextWind.c | 29 | ||||
-rw-r--r-- | unix/tkUnixButton.c | 90 | ||||
-rw-r--r-- | unix/tkUnixMenubu.c | 61 | ||||
-rw-r--r-- | win/tkWinButton.c | 99 |
10 files changed, 293 insertions, 299 deletions
@@ -5,20 +5,15 @@ This is the **Tk 9.0.1** source distribution. You can get any source release of Tk from [our distribution site](https://sourceforge.net/projects/tcl/files/Tcl/). -8.6 (production release, daily build) -[![Build Status](https://github.com/tcltk/tk/workflows/Linux/badge.svg?branch=core-8-6-branch)](https://github.com/tcltk/tk/actions?query=workflow%3A%22Linux%22+branch%3Acore-8-6-branch) -[![Build Status](https://github.com/tcltk/tk/workflows/Windows/badge.svg?branch=core-8-6-branch)](https://github.com/tcltk/tk/actions?query=workflow%3A%22Windows%22+branch%3Acore-8-6-branch) -[![Build Status](https://github.com/tcltk/tk/workflows/macOS/badge.svg?branch=core-8-6-branch)](https://github.com/tcltk/tk/actions?query=workflow%3A%22macOS%22+branch%3Acore-8-6-branch) +9.0 (production release, daily build) +[![Build Status](https://github.com/tcltk/tk/actions/workflows/linux-build.yml/badge.svg?branch=main)](https://github.com/tcltk/tk/actions/workflows/linux-build.yml?query=branch%3Amain) +[![Build Status](https://github.com/tcltk/tk/actions/workflows/win-build.yml/badge.svg?branch=main)](https://github.com/tcltk/tk/actions/workflows/win-build.yml?query=branch%3Amain) +[![Build Status](https://github.com/tcltk/tk/actions/workflows/mac-build.yml/badge.svg?branch=main)](https://github.com/tcltk/tk/actions/workflows/mac-build.yml?query=branch%3Amain) <br> -8.7 (in development, daily build)) -[![Build Status](https://github.com/tcltk/tk/workflows/Linux/badge.svg?branch=core-8-branch)](https://github.com/tcltk/tk/actions?query=workflow%3A%22Linux%22+branch%3Acore-8-branch) -[![Build Status](https://github.com/tcltk/tk/workflows/Windows/badge.svg?branch=core-8-branch)](https://github.com/tcltk/tk/actions?query=workflow%3A%22Windows%22+branch%3Acore-8-branch) -[![Build Status](https://github.com/tcltk/tk/workflows/macOS/badge.svg?branch=core-8-branch)](https://github.com/tcltk/tk/actions?query=workflow%3A%22macOS%22+branch%3Acore-8-branch) -<br> -9.0 (in development, daily build)) -[![Build Status](https://github.com/tcltk/tk/workflows/Linux/badge.svg?branch=main)](https://github.com/tcltk/tk/actions?query=workflow%3A%22Linux%22+branch%3Amain) -[![Build Status](https://github.com/tcltk/tk/workflows/Windows/badge.svg?branch=main)](https://github.com/tcltk/tk/actions?query=workflow%3A%22Windows%22+branch%3Amain) -[![Build Status](https://github.com/tcltk/tk/workflows/macOS/badge.svg?branch=main)](https://github.com/tcltk/tk/actions?query=workflow%3A%22macOS%22+branch%3Amain) +8.7 (in development, daily build) +[![Build Status](https://github.com/tcltk/tk/actions/workflows/linux-build.yml/badge.svg?branch=core-8-branch)](https://github.com/tcltk/tk/actions/workflows/linux-build.yml?query=branch%3Acore-8-branch) +[![Build Status](https://github.com/tcltk/tk/actions/workflows/win-build.yml/badge.svg?branch=core-8-branch)](https://github.com/tcltk/tk/actions/workflows/win-build.yml?query=branch%3Acore-8-branch) +[![Build Status](https://github.com/tcltk/tk/actions/workflows/mac-build.yml/badge.svg?branch=core-8-branch)](https://github.com/tcltk/tk/actions/workflows/mac-build.yml?query=branch%3Acore-8-branch) ## <a id="intro">1.</a> Introduction diff --git a/generic/tkText.c b/generic/tkText.c index 57059d7..ba35e83 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -181,10 +181,10 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_TEXT_MAX_UNDO, TCL_INDEX_NONE, offsetof(TkText, maxUndo), TK_OPTION_DONT_SET_DEFAULT, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", - DEF_TEXT_PADX, offsetof(TkText, padXObj), offsetof(TkText, padX), 0, 0, + DEF_TEXT_PADX, offsetof(TkText, padXObj), TCL_INDEX_NONE, 0, 0, TK_TEXT_LINE_GEOMETRY}, {TK_OPTION_PIXELS, "-pady", "padY", "Pad", - DEF_TEXT_PADY, offsetof(TkText, padYObj), offsetof(TkText, padY), 0, 0, 0}, + DEF_TEXT_PADY, offsetof(TkText, padYObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_TEXT_RELIEF, TCL_INDEX_NONE, offsetof(TkText, relief), 0, 0, 0}, {TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground", @@ -192,7 +192,7 @@ static const Tk_OptionSpec optionSpecs[] = { 0, DEF_TEXT_SELECT_MONO, 0}, {TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth", "BorderWidth", DEF_TEXT_SELECT_BD_COLOR, - offsetof(TkText, selBorderWidthObj), offsetof(TkText, selBorderWidth), + offsetof(TkText, selBorderWidthObj), TCL_INDEX_NONE, 0, DEF_TEXT_SELECT_BD_MONO, 0}, {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background", DEF_TEXT_SELECT_FG_COLOR, TCL_INDEX_NONE, offsetof(TkText, selFgColorPtr), @@ -200,13 +200,13 @@ static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_BOOLEAN, "-setgrid", "setGrid", "SetGrid", DEF_TEXT_SET_GRID, TCL_INDEX_NONE, offsetof(TkText, setGrid), 0, 0, 0}, {TK_OPTION_PIXELS, "-spacing1", "spacing1", "Spacing", - DEF_TEXT_SPACING1, offsetof(TkText, spacing1Obj), offsetof(TkText, spacing1), + DEF_TEXT_SPACING1, offsetof(TkText, spacing1Obj), TCL_INDEX_NONE, 0, 0, TK_TEXT_LINE_GEOMETRY }, {TK_OPTION_PIXELS, "-spacing2", "spacing2", "Spacing", - DEF_TEXT_SPACING2, offsetof(TkText, spacing2Obj), offsetof(TkText, spacing2), + DEF_TEXT_SPACING2, offsetof(TkText, spacing2Obj), TCL_INDEX_NONE, 0, 0, TK_TEXT_LINE_GEOMETRY }, {TK_OPTION_PIXELS, "-spacing3", "spacing3", "Spacing", - DEF_TEXT_SPACING3, offsetof(TkText, spacing3Obj), offsetof(TkText, spacing3), + DEF_TEXT_SPACING3, offsetof(TkText, spacing3Obj), TCL_INDEX_NONE, 0, 0, TK_TEXT_LINE_GEOMETRY }, {TK_OPTION_CUSTOM, "-startline", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkText, start), TK_OPTION_NULL_OK, @@ -602,7 +602,6 @@ CreateWidget( textPtr->selBorder = NULL; textPtr->inactiveSelBorder = NULL; - textPtr->selBorderWidth = 0; textPtr->selBorderWidthObj = NULL; textPtr->selFgColorPtr = NULL; @@ -2064,6 +2063,7 @@ ConfigureText( Tk_SavedOptions savedOptions; int oldExport = (textPtr->exportSelection) && (!Tcl_IsSafe(textPtr->interp)); int mask = 0; + int selBorderWidth, spacing1, spacing2, spacing3; if (Tk_SetOptions(interp, (char *) textPtr, textPtr->optionTable, objc, objv, textPtr->tkwin, &savedOptions, &mask) != TCL_OK) { @@ -2203,27 +2203,24 @@ ConfigureText( * Don't allow negative spacings. */ - if (textPtr->spacing1 < 0) { - textPtr->spacing1 = 0; - if (textPtr->spacing1Obj) { - Tcl_DecrRefCount(textPtr->spacing1Obj); - } + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->spacing1Obj, &spacing1); + if (spacing1 < 0) { + spacing1 = 0; + Tcl_DecrRefCount(textPtr->spacing1Obj); textPtr->spacing1Obj = Tcl_NewIntObj(0); Tcl_IncrRefCount(textPtr->spacing1Obj); } - if (textPtr->spacing2 < 0) { - textPtr->spacing2 = 0; - if (textPtr->spacing2Obj) { - Tcl_DecrRefCount(textPtr->spacing2Obj); - } + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->spacing2Obj, &spacing2); + if (spacing2 < 0) { + spacing2 = 0; + Tcl_DecrRefCount(textPtr->spacing2Obj); textPtr->spacing2Obj = Tcl_NewIntObj(0); Tcl_IncrRefCount(textPtr->spacing2Obj); } - if (textPtr->spacing3 < 0) { - textPtr->spacing3 = 0; - if (textPtr->spacing3Obj) { - Tcl_DecrRefCount(textPtr->spacing3Obj); - } + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->spacing3Obj, &spacing3); + if (spacing3 < 0) { + spacing3 = 0; + Tcl_DecrRefCount(textPtr->spacing3Obj); textPtr->spacing3Obj = Tcl_NewIntObj(0); Tcl_IncrRefCount(textPtr->spacing3Obj); } @@ -2243,11 +2240,10 @@ ConfigureText( textPtr->insertWidthObj = Tcl_NewIntObj(0); Tcl_IncrRefCount(textPtr->insertWidthObj); } - if (textPtr->selBorderWidth < 0) { - textPtr->selBorderWidth = 0; - if (textPtr->selBorderWidthObj) { - Tcl_DecrRefCount(textPtr->selBorderWidthObj); - } + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->selBorderWidthObj, &selBorderWidth); + if (selBorderWidth < 0) { + selBorderWidth = 0; + Tcl_DecrRefCount(textPtr->selBorderWidthObj); textPtr->selBorderWidthObj = Tcl_NewIntObj(0); Tcl_IncrRefCount(textPtr->selBorderWidthObj); } @@ -2285,7 +2281,6 @@ ConfigureText( } if (textPtr->selTagPtr->borderWidthObj != textPtr->selBorderWidthObj) { textPtr->selTagPtr->borderWidthObj = textPtr->selBorderWidthObj; - textPtr->selTagPtr->borderWidth = textPtr->selBorderWidth; } if (textPtr->selTagPtr->selFgColor == NULL) { textPtr->selTagPtr->fgColor = textPtr->selFgColorPtr; @@ -2301,9 +2296,9 @@ ConfigureText( || (textPtr->selTagPtr->lMargin2 != INT_MIN) || (textPtr->selTagPtr->offset != INT_MIN) || (textPtr->selTagPtr->rMargin != INT_MIN) - || (textPtr->selTagPtr->spacing1 != INT_MIN) - || (textPtr->selTagPtr->spacing2 != INT_MIN) - || (textPtr->selTagPtr->spacing3 != INT_MIN) + || (textPtr->selTagPtr->spacing1Obj != NULL) + || (textPtr->selTagPtr->spacing2Obj != NULL) + || (textPtr->selTagPtr->spacing3Obj != NULL) || (textPtr->selTagPtr->tabStringPtr != NULL) || (textPtr->selTagPtr->tabStyle == TK_TEXT_TABSTYLE_TABULAR) || (textPtr->selTagPtr->tabStyle == TK_TEXT_TABSTYLE_WORDPROCESSOR) @@ -2437,6 +2432,8 @@ TextWorldChanged( Tk_FontMetrics fm; int border; int oldCharHeight = textPtr->charHeight; + int padX, padY; + int spacing1, spacing3; textPtr->charWidth = Tk_TextWidth(textPtr->tkfont, "0", 1); if (textPtr->charWidth <= 0) { @@ -2451,15 +2448,18 @@ TextWorldChanged( if (textPtr->charHeight != oldCharHeight) { TkBTreeClientRangeChanged(textPtr, textPtr->charHeight); } + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->padXObj, &padX); + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->padYObj, &padY); + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->spacing1Obj, &spacing1); + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->spacing3Obj, &spacing3); border = textPtr->borderWidth + textPtr->highlightWidth; Tk_GeometryRequest(textPtr->tkwin, - textPtr->width * textPtr->charWidth + 2*textPtr->padX + 2*border, - textPtr->height*(fm.linespace+textPtr->spacing1+textPtr->spacing3) - + 2*textPtr->padY + 2*border); + textPtr->width * textPtr->charWidth + 2 * padX + 2 * border, + textPtr->height * (fm.linespace + spacing1 + spacing3) + + 2 * padY + 2*border); Tk_SetInternalBorderEx(textPtr->tkwin, - border + textPtr->padX, border + textPtr->padX, - border + textPtr->padY, border + textPtr->padY); + border + padX, border + padX, border + padY, border + padY); if (textPtr->setGrid) { Tk_SetGrid(textPtr->tkwin, textPtr->width, textPtr->height, textPtr->charWidth, textPtr->charHeight); @@ -2524,7 +2524,6 @@ TextEventProc( textPtr->selBorder = NULL; textPtr->selBorderWidthObj = NULL; - textPtr->selBorderWidth = 0; textPtr->selFgColorPtr = NULL; if (textPtr->setGrid) { Tk_UnsetGrid(textPtr->tkwin); diff --git a/generic/tkText.h b/generic/tkText.h index 713d7fc..58f8b61 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -130,10 +130,6 @@ typedef struct TkTextEmbWindow { TkTextEmbWindowClient *clients; /* Linked list of peer-widget specific * information for this embedded window. */ -#if defined(BUILD_tk) - int padX, padY; /* Padding to leave around each side of - * window, in pixels. */ -#endif } TkTextEmbWindow; /* @@ -167,10 +163,6 @@ typedef struct TkTextEmbImage { * image. */ Tk_OptionTable optionTable; /* Token representing the configuration * specifications. */ -#if defined(BUILD_tk) - int padX, padY; /* Padding to leave around each side of - * window, in pixels. */ -#endif } TkTextEmbImage; /* @@ -358,6 +350,9 @@ typedef struct TkTextTag { Tk_3DBorder border; /* Used for drawing background. NULL means no * value specified here. */ +#if TK_MAJOR_VERSION < 9 + int borderWidth; /* Width of 3-D border for background. */ +#endif Tcl_Obj *borderWidthObj; /* Width of 3-D border for background. */ #if TK_MAJOR_VERSION < 9 char *reliefString; /* -relief option string (malloc-ed). NULL @@ -379,33 +374,18 @@ typedef struct TkTextTag { #endif Tk_Justify justify; /* How to justify text: TK_JUSTIFY_CENTER, * TK_JUSTIFY_LEFT, or TK_JUSTIFY_RIGHT. */ -#if TK_MAJOR_VERSION > 8 Tcl_Obj *lMargin1Obj; /* -lmargin1 option object. NULL * means option not specified. */ -#else - char *lMargin1String; /* -lmargin1 option string (malloc-ed). NULL - * means option not specified. */ -#endif int lMargin1; /* Left margin for first display line of each * text line, in pixels. INT_MIN means option not specified. */ -#if TK_MAJOR_VERSION > 8 Tcl_Obj *lMargin2Obj; /* -lmargin2 option object. NULL * means option not specified. */ -#else - char *lMargin2String; /* -lmargin2 option string (malloc-ed). NULL - * means option not specified. */ -#endif int lMargin2; /* Left margin for second and later display lines * of each text line, in pixels. INT_MIN means option not specified. */ Tk_3DBorder lMarginColor; /* Used for drawing background in left margins. * This is used for both lmargin1 and lmargin2. * NULL means no value specified here. */ -#if TK_MAJOR_VERSION > 8 Tcl_Obj *offsetObj; /* -offset option. NULL means option not specified. */ -#else - char *offsetString; /* -offset option string (malloc-ed). NULL - * means option not specified. */ -#endif int offset; /* Vertical offset of text's baseline from * baseline of line. Used for superscripts and * subscripts. INT_MIN means option not specified. */ @@ -417,13 +397,8 @@ typedef struct TkTextTag { * middle of text. -1 means not specified. */ XColor *overstrikeColor; /* Color for the overstrike. NULL means same * color as foreground. */ -#if TK_MAJOR_VERSION > 8 Tcl_Obj *rMarginObj; /* -rmargin option object. NULL * means option not specified. */ -#else - char *rMarginString; /* -rmargin option string (malloc-ed). NULL - * means option not specified. */ -#endif int rMargin; /* Right margin for text, in pixels. INT_MIN means option not specified. */ Tk_3DBorder rMarginColor; /* Used for drawing background in right margin. * NULL means no value specified here. */ @@ -431,26 +406,20 @@ typedef struct TkTextTag { * NULL means no value specified here. */ XColor *selFgColor; /* Foreground color for selected text. NULL means * no value specified here. */ -#if TK_MAJOR_VERSION > 8 Tcl_Obj *spacing1Obj; /* -spacing1 option object. NULL * means option not specified. */ -#else - char *spacing1String; /* -spacing1 option string (malloc-ed). NULL - * means option not specified. */ +#if TK_MAJOR_VERSION < 9 + int spacing1; #endif -#if TK_MAJOR_VERSION > 8 Tcl_Obj *spacing2Obj; /* -spacing2 option object. NULL * means option not specified. */ -#else - char *spacing2String; /* -spacing2 option string (malloc-ed). NULL - * means option not specified. */ +#if TK_MAJOR_VERSION < 9 + int spacing2; #endif -#if TK_MAJOR_VERSION > 8 Tcl_Obj *spacing3Obj; /* -spacing3 option object. NULL * means option not specified. */ -#else - char *spacing3String; /* -spacing3 option string (malloc-ed). NULL - * means option not specified. */ +#if TK_MAJOR_VERSION < 9 + int spacing3; #endif Tcl_Obj *tabStringPtr; /* -tabs option string. NULL means option not * specified. */ @@ -489,15 +458,6 @@ typedef struct TkTextTag { * size with which information is displayed on * the screen (so need to recalculate line * dimensions if tag changes). */ -#ifdef BUILD_tk - int spacing1; /* Extra spacing above first display line for - * text line. INT_MIN means option not specified. */ - int spacing2; /* Extra spacing between display lines for the - * same text line. INT_MIN means option not specified. */ - int spacing3; /* Extra spacing below last display line for - * text line. INT_MIN means option not specified. */ - int borderWidth; /* Width of 3-D border for background. */ -#endif } TkTextTag; #define TK_TAG_AFFECTS_DISPLAY 0x1 @@ -841,7 +801,6 @@ typedef struct TkText { * Miscellaneous additional information: */ -#if TK_MAJOR_VERSION > 8 Tcl_Obj *takeFocusObj; /* Value of -takeFocus option; not used in the * C code, but used by keyboard traversal * scripts. May be NULL. */ @@ -849,11 +808,6 @@ typedef struct TkText { * horizontal scrollbar when view changes. May be NULL. */ Tcl_Obj *yScrollCmdObj; /* Prefix of command to issue to update * vertical scrollbar when view changes. May be NULL. */ -#else - char *takeFocus; - char *xScrollCmd; - char *yScrollCmd; -#endif int flags; /* Miscellaneous flags; see below for * definitions. */ Tk_OptionTable optionTable; /* Token representing the configuration @@ -878,11 +832,8 @@ typedef struct TkText { Tcl_Obj *afterSyncCmd; /* Command to be executed when lines are up to * date */ #ifdef BUILD_tk - int padX, padY; - int selBorderWidth; int highlightWidth; int borderWidth; - int spacing1, spacing2, spacing3; int height; int insertBorderWidth; int insertWidth; diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 50dead5..75b5e43 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -804,9 +804,9 @@ GetStyle( styleValues.overstrikeColor = textPtr->fgColor; styleValues.tkfont = textPtr->tkfont; styleValues.justify = TK_JUSTIFY_LEFT; - styleValues.spacing1 = textPtr->spacing1; - styleValues.spacing2 = textPtr->spacing2; - styleValues.spacing3 = textPtr->spacing3; + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->spacing1Obj, &styleValues.spacing1); + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->spacing2Obj, &styleValues.spacing2); + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->spacing3Obj, &styleValues.spacing3); styleValues.tabArrayPtr = textPtr->tabArrayPtr; styleValues.tabStyle = textPtr->tabStyle; styleValues.wrapMode = textPtr->wrapMode; @@ -861,7 +861,7 @@ GetStyle( if ((tagPtr->borderWidthObj != NULL) && (Tcl_GetString(tagPtr->borderWidthObj)[0] != '\0') && (tagPtr->priority > borderWidthPrio)) { - styleValues.borderWidth = tagPtr->borderWidth; + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, tagPtr->borderWidthObj, &styleValues.borderWidth); borderWidthPrio = tagPtr->priority; } if ((tagPtr->relief != TK_RELIEF_NULL) @@ -935,19 +935,19 @@ GetStyle( styleValues.rMarginColor = tagPtr->rMarginColor; rMarginColorPrio = tagPtr->priority; } - if ((tagPtr->spacing1 != INT_MIN) + if ((tagPtr->spacing1Obj != NULL) && (tagPtr->priority > spacing1Prio)) { - styleValues.spacing1 = tagPtr->spacing1; + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, tagPtr->spacing1Obj, &styleValues.spacing1); spacing1Prio = tagPtr->priority; } - if ((tagPtr->spacing2 != INT_MIN) + if ((tagPtr->spacing2Obj != NULL) && (tagPtr->priority > spacing2Prio)) { - styleValues.spacing2 = tagPtr->spacing2; + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, tagPtr->spacing2Obj, &styleValues.spacing2); spacing2Prio = tagPtr->priority; } - if ((tagPtr->spacing3 != INT_MIN) + if ((tagPtr->spacing3Obj != NULL) && (tagPtr->priority > spacing3Prio)) { - styleValues.spacing3 = tagPtr->spacing3; + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, tagPtr->spacing3Obj, &styleValues.spacing3); spacing3Prio = tagPtr->priority; } if ((tagPtr->tabStringPtr != NULL) @@ -4173,6 +4173,7 @@ DisplayText( int bottomY = 0; /* Initialization needed only to stop compiler * warnings. */ Tcl_Interp *interp; + int padX, padY; if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED)) { @@ -4366,6 +4367,9 @@ DisplayText( dInfoPtr->flags &= ~REDRAW_PENDING; + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->padXObj, &padX); + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->padYObj, &padY); + /* * Redraw the borders if that's needed. */ @@ -4405,28 +4409,28 @@ DisplayText( } } borders = textPtr->borderWidth + textPtr->highlightWidth; - if (textPtr->padY > 0) { + if (padY > 0) { Tk_Fill3DRectangle(textPtr->tkwin, Tk_WindowId(textPtr->tkwin), textPtr->border, borders, borders, - Tk_Width(textPtr->tkwin) - 2*borders, textPtr->padY, + Tk_Width(textPtr->tkwin) - 2 * borders, padY, 0, TK_RELIEF_FLAT); Tk_Fill3DRectangle(textPtr->tkwin, Tk_WindowId(textPtr->tkwin), textPtr->border, borders, - Tk_Height(textPtr->tkwin) - borders - textPtr->padY, - Tk_Width(textPtr->tkwin) - 2*borders, - textPtr->padY, 0, TK_RELIEF_FLAT); + Tk_Height(textPtr->tkwin) - borders - padY, + Tk_Width(textPtr->tkwin) - 2 * borders, + padY, 0, TK_RELIEF_FLAT); } - if (textPtr->padX > 0) { + if (padX > 0) { Tk_Fill3DRectangle(textPtr->tkwin, Tk_WindowId(textPtr->tkwin), - textPtr->border, borders, borders + textPtr->padY, - textPtr->padX, - Tk_Height(textPtr->tkwin) - 2*borders -2*textPtr->padY, + textPtr->border, borders, borders + padY, + padX, + Tk_Height(textPtr->tkwin) - 2 * borders -2 * padY, 0, TK_RELIEF_FLAT); Tk_Fill3DRectangle(textPtr->tkwin, Tk_WindowId(textPtr->tkwin), textPtr->border, - Tk_Width(textPtr->tkwin) - borders - textPtr->padX, - borders + textPtr->padY, textPtr->padX, - Tk_Height(textPtr->tkwin) - 2*borders -2*textPtr->padY, + Tk_Width(textPtr->tkwin) - borders - padX, + borders + padY, padX, + Tk_Height(textPtr->tkwin) - 2 * borders -2 * padY, 0, TK_RELIEF_FLAT); } dInfoPtr->flags &= ~REDRAW_BORDERS; @@ -4609,8 +4613,8 @@ DisplayText( } Tk_Fill3DRectangle(textPtr->tkwin, Tk_WindowId(textPtr->tkwin), - textPtr->border, dInfoPtr->x - textPtr->padX, bottomY, - dInfoPtr->maxX - (dInfoPtr->x - textPtr->padX), + textPtr->border, dInfoPtr->x - padX, bottomY, + dInfoPtr->maxX - (dInfoPtr->x - padX), dInfoPtr->topOfEof-bottomY, 0, TK_RELIEF_FLAT); } dInfoPtr->topOfEof = bottomY; @@ -4754,6 +4758,7 @@ TextInvalidateRegion( TextDInfo *dInfoPtr = textPtr->dInfoPtr; int maxY, inset; XRectangle rect; + int padX, padY; /* * Find all lines that overlap the given region and mark them for @@ -4774,12 +4779,14 @@ TextInvalidateRegion( dInfoPtr->topOfEof = maxY; } + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->padXObj, &padX); + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->padYObj, &padY); inset = textPtr->borderWidth + textPtr->highlightWidth; - if ((rect.x < (inset + textPtr->padX)) - || (rect.y < (inset + textPtr->padY)) + if ((rect.x < (inset + padX)) + || (rect.y < (inset + padY)) || ((int) (rect.x + rect.width) > (Tk_Width(textPtr->tkwin) - - inset - textPtr->padX)) - || (maxY > (Tk_Height(textPtr->tkwin) - inset - textPtr->padY))) { + - inset - padX)) + || (maxY > (Tk_Height(textPtr->tkwin) - inset - padY))) { dInfoPtr->flags |= REDRAW_BORDERS; } } @@ -5194,6 +5201,7 @@ TkTextRelayoutWindow( GC newGC; XGCValues gcValues; Bool inSync = 1; + int padX, padY; /* * Schedule the window redisplay. See TkTextChanged for the reason why @@ -5231,6 +5239,8 @@ TkTextRelayoutWindow( * it. */ + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->padXObj, &padX); + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->padYObj, &padY); if (textPtr->highlightWidthObj) { if (textPtr->highlightWidth < 0) { textPtr->highlightWidth = 0; @@ -5240,11 +5250,11 @@ TkTextRelayoutWindow( } } dInfoPtr->x = textPtr->highlightWidth + textPtr->borderWidth - + textPtr->padX; + + padX; dInfoPtr->y = textPtr->highlightWidth + textPtr->borderWidth - + textPtr->padY; + + padY; dInfoPtr->maxX = Tk_Width(textPtr->tkwin) - textPtr->highlightWidth - - textPtr->borderWidth - textPtr->padX; + - textPtr->borderWidth - padX; if (dInfoPtr->maxX <= dInfoPtr->x) { dInfoPtr->maxX = dInfoPtr->x + 1; } @@ -5254,7 +5264,7 @@ TkTextRelayoutWindow( */ dInfoPtr->maxY = Tk_Height(textPtr->tkwin) - textPtr->highlightWidth - - textPtr->borderWidth - textPtr->padY; + - textPtr->borderWidth - padY; if (dInfoPtr->maxY <= dInfoPtr->y) { dInfoPtr->maxY = dInfoPtr->y + 1; } diff --git a/generic/tkTextImage.c b/generic/tkTextImage.c index 5e24e09..1a1c431 100644 --- a/generic/tkTextImage.c +++ b/generic/tkTextImage.c @@ -86,9 +86,9 @@ static const Tk_OptionSpec optionSpecs[] = { "center", TCL_INDEX_NONE, offsetof(TkTextEmbImage, align), (TCL_MAJOR_VERSION > 8) ? TK_OPTION_ENUM_VAR : 0, alignStrings, 0}, {TK_OPTION_PIXELS, "-padx", NULL, NULL, - "0", offsetof(TkTextEmbImage, padXObj), offsetof(TkTextEmbImage, padX), 0, 0, 0}, + "0", offsetof(TkTextEmbImage, padXObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_PIXELS, "-pady", NULL, NULL, - "0", offsetof(TkTextEmbImage, padYObj), offsetof(TkTextEmbImage, padY), 0, 0, 0}, + "0", offsetof(TkTextEmbImage, padYObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_STRING, "-image", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextEmbImage, imageString), TK_OPTION_NULL_OK, 0, 0}, @@ -252,7 +252,6 @@ TkTextImageCmd( eiPtr->body.ei.name = NULL; eiPtr->body.ei.image = NULL; eiPtr->body.ei.align = TK_ALIGN_CENTER; - eiPtr->body.ei.padX = eiPtr->body.ei.padY = 0; eiPtr->body.ei.padXObj = eiPtr->body.ei.padYObj = NULL; eiPtr->body.ei.chunkCount = 0; eiPtr->body.ei.optionTable = Tk_CreateOptionTable(interp, optionSpecs); @@ -532,11 +531,14 @@ EmbImageLayoutProc( * set by the caller. */ { int width, height; + int padX, padY; if (offset != 0) { Tcl_Panic("Non-zero offset in EmbImageLayoutProc"); } + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, eiPtr->body.ei.padXObj, &padX); + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, eiPtr->body.ei.padYObj, &padY); /* * See if there's room for this image on this line. */ @@ -546,8 +548,8 @@ EmbImageLayoutProc( height = 0; } else { Tk_SizeOfImage(eiPtr->body.ei.image, &width, &height); - width += 2*eiPtr->body.ei.padX; - height += 2*eiPtr->body.ei.padY; + width += 2 * padX; + height += 2 * padY; } if ((width > (maxX - chunkPtr->x)) && !noCharsYet && (textPtr->wrapMode != TEXT_WRAPMODE_NONE)) { @@ -564,8 +566,8 @@ EmbImageLayoutProc( chunkPtr->bboxProc = EmbImageBboxProc; chunkPtr->numBytes = 1; if (eiPtr->body.ei.align == TK_ALIGN_BASELINE) { - chunkPtr->minAscent = height - eiPtr->body.ei.padY; - chunkPtr->minDescent = eiPtr->body.ei.padY; + chunkPtr->minAscent = height - padY; + chunkPtr->minDescent = padY; chunkPtr->minHeight = 0; } else { chunkPtr->minAscent = 0; @@ -695,7 +697,7 @@ EmbImageDisplayProc( static void EmbImageBboxProc( - TCL_UNUSED(TkText *), + TkText *textPtr, TkTextDispChunk *chunkPtr, /* Chunk containing desired char. */ TCL_UNUSED(Tcl_Size), /* Index of desired character within the * chunk. */ @@ -713,6 +715,7 @@ EmbImageBboxProc( { TkTextSegment *eiPtr = (TkTextSegment *)chunkPtr->clientData; Tk_Image image; + int padX, padY; image = eiPtr->body.ei.image; if (image != NULL) { @@ -722,17 +725,19 @@ EmbImageBboxProc( *heightPtr = 0; } - *xPtr = chunkPtr->x + eiPtr->body.ei.padX; + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, eiPtr->body.ei.padXObj, &padX); + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, eiPtr->body.ei.padYObj, &padY); + *xPtr = chunkPtr->x + padX; switch (eiPtr->body.ei.align) { case TK_ALIGN_BOTTOM: - *yPtr = y + (lineHeight - *heightPtr - eiPtr->body.ei.padY); + *yPtr = y + (lineHeight - *heightPtr - padY); break; case TK_ALIGN_CENTER: *yPtr = y + (lineHeight - *heightPtr)/2; break; case TK_ALIGN_TOP: - *yPtr = y + eiPtr->body.ei.padY; + *yPtr = y + padY; break; case TK_ALIGN_BASELINE: *yPtr = y + (baseline - *heightPtr); diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index 32a62ad..3008420 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -22,7 +22,7 @@ static const Tk_OptionSpec tagOptionSpecs[] = { {TK_OPTION_BITMAP, "-bgstipple", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, bgStipple), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", NULL, NULL, - NULL, offsetof(TkTextTag, borderWidthObj), offsetof(TkTextTag, borderWidth), + NULL, offsetof(TkTextTag, borderWidthObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BOOLEAN, "-elide", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, elide), @@ -60,11 +60,11 @@ static const Tk_OptionSpec tagOptionSpecs[] = { {TK_OPTION_COLOR, "-selectforeground", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, selFgColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-spacing1", NULL, NULL, - NULL, offsetof(TkTextTag, spacing1Obj), offsetof(TkTextTag, spacing1), TK_OPTION_NULL_OK,0,0}, + NULL, offsetof(TkTextTag, spacing1Obj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,0}, {TK_OPTION_PIXELS, "-spacing2", NULL, NULL, - NULL, offsetof(TkTextTag, spacing2Obj), offsetof(TkTextTag, spacing2), TK_OPTION_NULL_OK,0,0}, + NULL, offsetof(TkTextTag, spacing2Obj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,0}, {TK_OPTION_PIXELS, "-spacing3", NULL, NULL, - NULL, offsetof(TkTextTag, spacing3Obj), offsetof(TkTextTag, spacing3), TK_OPTION_NULL_OK,0,0}, + NULL, offsetof(TkTextTag, spacing3Obj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,0}, {TK_OPTION_STRING, "-tabs", NULL, NULL, NULL, offsetof(TkTextTag, tabStringPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-tabstyle", NULL, NULL, @@ -364,32 +364,40 @@ TkTextTagCmd( */ if (tagPtr->borderWidthObj) { - if (tagPtr->borderWidth < 0) { - tagPtr->borderWidth = 0; + int borderWidth; + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, tagPtr->borderWidthObj, &borderWidth); + if (borderWidth < 0) { + borderWidth = 0; Tcl_DecrRefCount(tagPtr->borderWidthObj); tagPtr->borderWidthObj = Tcl_NewIntObj(0); Tcl_IncrRefCount(tagPtr->borderWidthObj); } } if (tagPtr->spacing1Obj) { - if (tagPtr->spacing1 < 0) { - tagPtr->spacing1 = 0; + int spacing1; + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, tagPtr->spacing1Obj, &spacing1); + if (spacing1 < 0) { + spacing1 = 0; Tcl_DecrRefCount(tagPtr->spacing1Obj); tagPtr->spacing1Obj = Tcl_NewIntObj(0); Tcl_IncrRefCount(tagPtr->spacing1Obj); } } if (tagPtr->spacing2Obj) { - if (tagPtr->spacing2 < 0) { - tagPtr->spacing2 = 0; + int spacing2; + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, tagPtr->spacing1Obj, &spacing2); + if (spacing2 < 0) { + spacing2 = 0; Tcl_DecrRefCount(tagPtr->spacing2Obj); tagPtr->spacing2Obj = Tcl_NewIntObj(0); Tcl_IncrRefCount(tagPtr->spacing2Obj); } } if (tagPtr->spacing3Obj) { - if (tagPtr->spacing3 < 0) { - tagPtr->spacing3 = 0; + int spacing3; + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, tagPtr->spacing1Obj, &spacing3); + if (spacing3 < 0) { + spacing3 = 0; Tcl_DecrRefCount(tagPtr->spacing3Obj); tagPtr->spacing3Obj = Tcl_NewIntObj(0); Tcl_IncrRefCount(tagPtr->spacing3Obj); @@ -430,7 +438,6 @@ TkTextTagCmd( } else { textPtr->selBorder = tagPtr->selBorder; } - textPtr->selBorderWidth = tagPtr->borderWidth; textPtr->selBorderWidthObj = tagPtr->borderWidthObj; if (tagPtr->selFgColor == NULL) { textPtr->selFgColorPtr = tagPtr->fgColor; @@ -444,13 +451,13 @@ TkTextTagCmd( if ((tagPtr->elide >= 0) || (tagPtr->tkfont != NULL) || (tagPtr->justify != TK_JUSTIFY_NULL) - || (tagPtr->lMargin1 != INT_MIN) - || (tagPtr->lMargin2 != INT_MIN) - || (tagPtr->offset != INT_MIN) - || (tagPtr->rMargin != INT_MIN) - || (tagPtr->spacing1 != INT_MIN) - || (tagPtr->spacing2 != INT_MIN) - || (tagPtr->spacing3 != INT_MIN) + || (tagPtr->lMargin1Obj != NULL) + || (tagPtr->lMargin2Obj != NULL) + || (tagPtr->offsetObj != NULL) + || (tagPtr->rMarginObj != NULL) + || (tagPtr->spacing1Obj != NULL) + || (tagPtr->spacing2Obj != NULL) + || (tagPtr->spacing3Obj != NULL) || (tagPtr->tabStringPtr != NULL) || (tagPtr->tabStyle == TK_TEXT_TABSTYLE_TABULAR) || (tagPtr->tabStyle == TK_TEXT_TABSTYLE_WORDPROCESSOR) @@ -955,7 +962,6 @@ TkTextCreateTag( tagPtr->tagRootPtr = NULL; tagPtr->priority = textPtr->sharedTextPtr->numTags; tagPtr->border = NULL; - tagPtr->borderWidth = 0; tagPtr->borderWidthObj = NULL; tagPtr->relief = TK_RELIEF_NULL; tagPtr->bgStipple = None; @@ -978,11 +984,8 @@ TkTextCreateTag( tagPtr->selBorder = NULL; tagPtr->selFgColor = NULL; tagPtr->spacing1Obj = NULL; - tagPtr->spacing1 = INT_MIN; tagPtr->spacing2Obj = NULL; - tagPtr->spacing2 = INT_MIN; tagPtr->spacing3Obj = NULL; - tagPtr->spacing3 = INT_MIN; tagPtr->tabStringPtr = NULL; tagPtr->tabArrayPtr = NULL; tagPtr->tabStyle = TK_TEXT_TABSTYLE_NULL; diff --git a/generic/tkTextWind.c b/generic/tkTextWind.c index 4f47082..ba006a5 100644 --- a/generic/tkTextWind.c +++ b/generic/tkTextWind.c @@ -100,9 +100,9 @@ static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_STRING, "-create", NULL, NULL, NULL, offsetof(TkTextEmbWindow, createObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-padx", NULL, NULL, - "0", offsetof(TkTextEmbWindow, padXObj), offsetof(TkTextEmbWindow, padX), 0, 0, 0}, + "0", offsetof(TkTextEmbWindow, padXObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_PIXELS, "-pady", NULL, NULL, - "0", offsetof(TkTextEmbWindow, padYObj), offsetof(TkTextEmbWindow, padY), 0, 0, 0}, + "0", offsetof(TkTextEmbWindow, padYObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_BOOLEAN, "-stretch", NULL, NULL, "0", TCL_INDEX_NONE, offsetof(TkTextEmbWindow, stretch), 0, 0, 0}, {TK_OPTION_WINDOW, "-window", NULL, NULL, @@ -292,7 +292,6 @@ TkTextWindowCmd( ewPtr->body.ew.tkwin = NULL; ewPtr->body.ew.createObj = NULL; ewPtr->body.ew.align = TK_ALIGN_CENTER; - ewPtr->body.ew.padX = ewPtr->body.ew.padY = 0; ewPtr->body.ew.padXObj = ewPtr->body.ew.padYObj = NULL; ewPtr->body.ew.stretch = 0; ewPtr->body.ew.optionTable = Tk_CreateOptionTable(interp, optionSpecs); @@ -834,6 +833,7 @@ EmbWinLayoutProc( { int width, height; TkTextEmbWindowClient *client; + int padX, padY; if (offset != 0) { Tcl_Panic("Non-zero offset in EmbWinLayoutProc"); @@ -980,6 +980,8 @@ EmbWinLayoutProc( Tcl_SetHashValue(hPtr, ewPtr); } + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, ewPtr->body.ew.padXObj, &padX); + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, ewPtr->body.ew.padYObj, &padY); /* * See if there's room for this window on this line. */ @@ -989,8 +991,8 @@ EmbWinLayoutProc( width = 0; height = 0; } else { - width = Tk_ReqWidth(ewPtr->body.ew.tkwin) + 2*ewPtr->body.ew.padX; - height = Tk_ReqHeight(ewPtr->body.ew.tkwin) + 2*ewPtr->body.ew.padY; + width = Tk_ReqWidth(ewPtr->body.ew.tkwin) + 2 * padX; + height = Tk_ReqHeight(ewPtr->body.ew.tkwin) + 2 * padY; } if ((width > (maxX - chunkPtr->x)) && !noCharsYet && (textPtr->wrapMode != TEXT_WRAPMODE_NONE)) { @@ -1007,8 +1009,8 @@ EmbWinLayoutProc( chunkPtr->bboxProc = EmbWinBboxProc; chunkPtr->numBytes = 1; if (ewPtr->body.ew.align == TK_ALIGN_BASELINE) { - chunkPtr->minAscent = height - ewPtr->body.ew.padY; - chunkPtr->minDescent = ewPtr->body.ew.padY; + chunkPtr->minAscent = height - padY; + chunkPtr->minDescent = padY; chunkPtr->minHeight = 0; } else { chunkPtr->minAscent = 0; @@ -1239,6 +1241,7 @@ EmbWinBboxProc( Tk_Window tkwin; TkTextSegment *ewPtr = (TkTextSegment *)chunkPtr->clientData; TkTextEmbWindowClient *client = EmbWinGetClient(textPtr, ewPtr); + int padX, padY; if (client == NULL) { tkwin = NULL; @@ -1252,23 +1255,25 @@ EmbWinBboxProc( *widthPtr = 0; *heightPtr = 0; } - *xPtr = chunkPtr->x + ewPtr->body.ew.padX; + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, ewPtr->body.ew.padXObj, &padX); + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, ewPtr->body.ew.padYObj, &padY); + *xPtr = chunkPtr->x + padX; if (ewPtr->body.ew.stretch) { if (ewPtr->body.ew.align == TK_ALIGN_BASELINE) { - *heightPtr = baseline - ewPtr->body.ew.padY; + *heightPtr = baseline - padY; } else { - *heightPtr = lineHeight - 2*ewPtr->body.ew.padY; + *heightPtr = lineHeight - 2 * padY; } } switch (ewPtr->body.ew.align) { case TK_ALIGN_BOTTOM: - *yPtr = y + (lineHeight - *heightPtr - ewPtr->body.ew.padY); + *yPtr = y + (lineHeight - *heightPtr - padY); break; case TK_ALIGN_CENTER: *yPtr = y + (lineHeight - *heightPtr)/2; break; case TK_ALIGN_TOP: - *yPtr = y + ewPtr->body.ew.padY; + *yPtr = y + padY; break; case TK_ALIGN_BASELINE: *yPtr = y + (baseline - *heightPtr); diff --git a/unix/tkUnixButton.c b/unix/tkUnixButton.c index c0cc5f2..765ddb4 100644 --- a/unix/tkUnixButton.c +++ b/unix/tkUnixButton.c @@ -449,6 +449,7 @@ TkpDisplayButton( int imageXOffset = 0, imageYOffset = 0; /* image information that will be used to * restrict disabled pixmap as well */ + int padX, padY, borderWidth, highlightWidth; butPtr->flags &= ~REDRAW_PENDING; if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { @@ -533,10 +534,10 @@ TkpDisplayButton( imageWidth = width; imageHeight = height; - Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padXObj, &butPtr->padX); - Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padYObj, &butPtr->padY); - Tk_GetPixelsFromObj(NULL, tkwin, butPtr->borderWidthObj, &butPtr->borderWidth); - Tk_GetPixelsFromObj(NULL, tkwin, butPtr->highlightWidthObj, &butPtr->highlightWidth); + Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padXObj, &padX); + Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padYObj, &padY); + Tk_GetPixelsFromObj(NULL, tkwin, butPtr->borderWidthObj, &borderWidth); + Tk_GetPixelsFromObj(NULL, tkwin, butPtr->highlightWidthObj, &highlightWidth); haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0); @@ -554,11 +555,11 @@ TkpDisplayButton( */ if (butPtr->compound == COMPOUND_TOP) { - textYOffset = height + butPtr->padY; + textYOffset = height + padY; } else { - imageYOffset = butPtr->textHeight + butPtr->padY; + imageYOffset = butPtr->textHeight + padY; } - fullHeight = height + butPtr->textHeight + butPtr->padY; + fullHeight = height + butPtr->textHeight + padY; fullWidth = (width > butPtr->textWidth ? width : butPtr->textWidth); textXOffset = (fullWidth - butPtr->textWidth)/2; @@ -571,11 +572,11 @@ TkpDisplayButton( */ if (butPtr->compound == COMPOUND_LEFT) { - textXOffset = width + butPtr->padX; + textXOffset = width + padX; } else { - imageXOffset = butPtr->textWidth + butPtr->padX; + imageXOffset = butPtr->textWidth + padX; } - fullWidth = butPtr->textWidth + butPtr->padX + width; + fullWidth = butPtr->textWidth + padX + width; fullHeight = (height > butPtr->textHeight ? height : butPtr->textHeight); textYOffset = (fullHeight - butPtr->textHeight)/2; @@ -599,7 +600,7 @@ TkpDisplayButton( break; } - TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY, + TkComputeAnchor(butPtr->anchor, tkwin, padX, padY, butPtr->indicatorSpace + fullWidth, fullHeight, &x, &y); x += butPtr->indicatorSpace; @@ -709,7 +710,7 @@ TkpDisplayButton( } y += height/2; } else { - TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY, + TkComputeAnchor(butPtr->anchor, tkwin, padX, padY, butPtr->indicatorSpace + butPtr->textWidth, butPtr->textHeight, &x, &y); @@ -730,7 +731,7 @@ TkpDisplayButton( if ((butPtr->type == TYPE_CHECK_BUTTON || butPtr->type == TYPE_RADIO_BUTTON) && butPtr->indicatorOn - && butPtr->indicatorDiameter > 2 * butPtr->borderWidth) { + && butPtr->indicatorDiameter > 2 * borderWidth) { TkBorder *selBorder = (TkBorder *) butPtr->selectBorder; XColor *selColor = NULL; int btype = (butPtr->type == TYPE_CHECK_BUTTON ? @@ -792,7 +793,7 @@ TkpDisplayButton( */ if (relief != TK_RELIEF_FLAT) { - int inset = butPtr->highlightWidth; + int inset = highlightWidth; if (butPtr->defaultState == DEFAULT_ACTIVE) { /* @@ -833,9 +834,9 @@ TkpDisplayButton( Tk_Draw3DRectangle(tkwin, pixmap, border, inset, inset, Tk_Width(tkwin) - 2 * inset, Tk_Height(tkwin) - 2 * inset, - butPtr->borderWidth, relief); + borderWidth, relief); } - if (butPtr->highlightWidth > 0) { + if (highlightWidth > 0) { if (butPtr->flags & GOT_FOCUS) { gc = Tk_GCForColor(butPtr->highlightColorPtr, pixmap); } else { @@ -849,10 +850,10 @@ TkpDisplayButton( */ if (butPtr->defaultState == DEFAULT_NORMAL) { - TkDrawInsetFocusHighlight(tkwin, gc, butPtr->highlightWidth, + TkDrawInsetFocusHighlight(tkwin, gc, highlightWidth, pixmap, 5); } else { - Tk_DrawFocusHighlight(tkwin, gc, butPtr->highlightWidth, pixmap); + Tk_DrawFocusHighlight(tkwin, gc, highlightWidth, pixmap); } } @@ -892,13 +893,18 @@ TkpComputeButtonGeometry( int width, height, avgWidth, txtWidth, txtHeight; int haveImage = 0, haveText = 0; Tk_FontMetrics fm; + int padX, padY, borderWidth, highlightWidth, wrapLength; + int butPtrWidth, butPtrHeight; - Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthObj, &butPtr->highlightWidth); - Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->borderWidthObj, &butPtr->borderWidth); - Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padXObj, &butPtr->padX); - Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padYObj, &butPtr->padY); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthObj, &highlightWidth); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->borderWidthObj, &borderWidth); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padXObj, &padX); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padYObj, &padY); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->wrapLengthObj, &wrapLength); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->widthObj, &butPtrWidth); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->heightObj, &butPtrHeight); - butPtr->inset = butPtr->highlightWidth + butPtr->borderWidth; + butPtr->inset = highlightWidth + borderWidth; /* * Leave room for the default ring if needed. @@ -927,7 +933,7 @@ TkpComputeButtonGeometry( Tk_FreeTextLayout(butPtr->textLayout); butPtr->textLayout = Tk_ComputeTextLayout(butPtr->tkfont, - Tcl_GetString(butPtr->textPtr), TCL_INDEX_NONE, butPtr->wrapLength, + Tcl_GetString(butPtr->textPtr), TCL_INDEX_NONE, wrapLength, butPtr->justify, 0, &butPtr->textWidth, &butPtr->textHeight); txtWidth = butPtr->textWidth; @@ -952,7 +958,7 @@ TkpComputeButtonGeometry( * Image is above or below text. */ - height += txtHeight + butPtr->padY; + height += txtHeight + padY; width = (width > txtWidth ? width : txtWidth); break; case COMPOUND_LEFT: @@ -961,7 +967,7 @@ TkpComputeButtonGeometry( * Image is left or right of text. */ - width += txtWidth + butPtr->padX; + width += txtWidth + padX; height = (height > txtHeight ? height : txtHeight); break; case COMPOUND_CENTER: @@ -975,11 +981,11 @@ TkpComputeButtonGeometry( case COMPOUND_NONE: break; } - if (butPtr->width > 0) { - width = butPtr->width; + if (butPtrWidth > 0) { + width = butPtrWidth; } - if (butPtr->height > 0) { - height = butPtr->height; + if (butPtrHeight > 0) { + height = butPtrHeight; } if ((butPtr->type >= TYPE_CHECK_BUTTON) && butPtr->indicatorOn) { @@ -991,15 +997,15 @@ TkpComputeButtonGeometry( } } - width += 2 * butPtr->padX; - height += 2 * butPtr->padY; + width += 2 * padX; + height += 2 * padY; } else { if (haveImage) { - if (butPtr->width > 0) { - width = butPtr->width; + if (butPtrWidth > 0) { + width = butPtrWidth; } - if (butPtr->height > 0) { - height = butPtr->height; + if (butPtrHeight > 0) { + height = butPtrHeight; } if ((butPtr->type >= TYPE_CHECK_BUTTON) && butPtr->indicatorOn) { @@ -1014,11 +1020,11 @@ TkpComputeButtonGeometry( width = txtWidth; height = txtHeight; - if (butPtr->width > 0) { - width = butPtr->width * avgWidth; + if (butPtrWidth > 0) { + width = butPtrWidth * avgWidth; } - if (butPtr->height > 0) { - height = butPtr->height * fm.linespace; + if (butPtrHeight > 0) { + height = butPtrHeight * fm.linespace; } if ((butPtr->type >= TYPE_CHECK_BUTTON) && butPtr->indicatorOn) { butPtr->indicatorDiameter = fm.linespace; @@ -1035,8 +1041,8 @@ TkpComputeButtonGeometry( */ if ((butPtr->image == NULL) && (butPtr->bitmap == None)) { - width += 2 * butPtr->padX; - height += 2 * butPtr->padY; + width += 2 * padX; + height += 2 * padY; } if ((butPtr->type == TYPE_BUTTON) && !Tk_StrictMotif(butPtr->tkwin)) { width += 2; diff --git a/unix/tkUnixMenubu.c b/unix/tkUnixMenubu.c index a87bb5b..a1f3aa3 100644 --- a/unix/tkUnixMenubu.c +++ b/unix/tkUnixMenubu.c @@ -74,6 +74,8 @@ TkpDisplayMenuButton( /* Image information that will be used to * restrict disabled pixmap as well */ int haveImage = 0, haveText = 0; + int padX, padY; + int mbPtrBorderWidth, highlightWidth; mbPtr->flags &= ~REDRAW_PENDING; if ((mbPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { @@ -123,6 +125,8 @@ TkpDisplayMenuButton( fullWidth = 0; fullHeight = 0; + Tk_GetPixelsFromObj(NULL, mbPtr->tkwin, mbPtr->padXObj, &padX); + Tk_GetPixelsFromObj(NULL, mbPtr->tkwin, mbPtr->padYObj, &padY); if (mbPtr->compound != COMPOUND_NONE && haveImage && haveText) { switch ((enum compound) mbPtr->compound) { case COMPOUND_TOP: @@ -132,11 +136,11 @@ TkpDisplayMenuButton( */ if (mbPtr->compound == COMPOUND_TOP) { - textYOffset = height + mbPtr->padY; + textYOffset = height + padY; } else { - imageYOffset = mbPtr->textHeight + mbPtr->padY; + imageYOffset = mbPtr->textHeight + padY; } - fullHeight = height + mbPtr->textHeight + mbPtr->padY; + fullHeight = height + mbPtr->textHeight + padY; fullWidth = (width > mbPtr->textWidth ? width : mbPtr->textWidth); textXOffset = (fullWidth - mbPtr->textWidth)/2; imageXOffset = (fullWidth - width)/2; @@ -148,11 +152,11 @@ TkpDisplayMenuButton( */ if (mbPtr->compound == COMPOUND_LEFT) { - textXOffset = width + mbPtr->padX; + textXOffset = width + padX; } else { - imageXOffset = mbPtr->textWidth + mbPtr->padX; + imageXOffset = mbPtr->textWidth + padX; } - fullWidth = mbPtr->textWidth + mbPtr->padX + width; + fullWidth = mbPtr->textWidth + padX + width; fullHeight = (height > mbPtr->textHeight ? height : mbPtr->textHeight); textYOffset = (fullHeight - mbPtr->textHeight)/2; @@ -211,7 +215,7 @@ TkpDisplayMenuButton( XSetClipOrigin(mbPtr->display, gc, 0, 0); } } else { - TkComputeAnchor(mbPtr->anchor, tkwin, mbPtr->padX, mbPtr->padY, + TkComputeAnchor(mbPtr->anchor, tkwin, padX, padY, mbPtr->textWidth + mbPtr->indicatorWidth, mbPtr->textHeight, &x, &y); Tk_DrawTextLayout(mbPtr->display, pixmap, gc, mbPtr->textLayout, @@ -272,20 +276,22 @@ TkpDisplayMenuButton( * border. */ + Tk_GetPixelsFromObj(NULL, mbPtr->tkwin, mbPtr->borderWidthObj, &mbPtrBorderWidth); + Tk_GetPixelsFromObj(NULL, mbPtr->tkwin, mbPtr->highlightWidthObj, &highlightWidth); if (mbPtr->relief != TK_RELIEF_FLAT) { Tk_Draw3DRectangle(tkwin, pixmap, border, - mbPtr->highlightWidth, mbPtr->highlightWidth, - Tk_Width(tkwin) - 2*mbPtr->highlightWidth, - Tk_Height(tkwin) - 2*mbPtr->highlightWidth, - mbPtr->borderWidth, mbPtr->relief); + highlightWidth, highlightWidth, + Tk_Width(tkwin) - 2 * highlightWidth, + Tk_Height(tkwin) - 2 * highlightWidth, + mbPtrBorderWidth, mbPtr->relief); } - if (mbPtr->highlightWidth > 0) { + if (highlightWidth > 0) { if (mbPtr->flags & GOT_FOCUS) { gc = Tk_GCForColor(mbPtr->highlightColorPtr, pixmap); } else { gc = Tk_GCForColor(mbPtr->highlightBgColorPtr, pixmap); } - Tk_DrawFocusHighlight(tkwin, gc, mbPtr->highlightWidth, pixmap); + Tk_DrawFocusHighlight(tkwin, gc, highlightWidth, pixmap); } /* @@ -347,8 +353,15 @@ TkpComputeMenuButtonGeometry( int avgWidth, txtWidth, txtHeight; int haveImage = 0, haveText = 0; Tk_FontMetrics fm; + int borderWidth, highlightWidth, wrapLength; + int padX, padY; - mbPtr->inset = mbPtr->highlightWidth + mbPtr->borderWidth; + Tk_GetPixelsFromObj(NULL, mbPtr->tkwin, mbPtr->padXObj, &padX); + Tk_GetPixelsFromObj(NULL, mbPtr->tkwin, mbPtr->padYObj, &padY); + Tk_GetPixelsFromObj(NULL, mbPtr->tkwin, mbPtr->borderWidthObj, &borderWidth); + Tk_GetPixelsFromObj(NULL, mbPtr->tkwin, mbPtr->highlightWidthObj, &highlightWidth); + Tk_GetPixelsFromObj(NULL, mbPtr->tkwin, mbPtr->wrapLengthObj, &wrapLength); + mbPtr->inset = highlightWidth + borderWidth; width = 0; height = 0; @@ -368,7 +381,7 @@ TkpComputeMenuButtonGeometry( Tk_FreeTextLayout(mbPtr->textLayout); mbPtr->textLayout = Tk_ComputeTextLayout(mbPtr->tkfont, mbPtr->textObj ? Tcl_GetString(mbPtr->textObj) : "", - TCL_INDEX_NONE, mbPtr->wrapLength, mbPtr->justify, 0, &mbPtr->textWidth, + TCL_INDEX_NONE, wrapLength, mbPtr->justify, 0, &mbPtr->textWidth, &mbPtr->textHeight); txtWidth = mbPtr->textWidth; txtHeight = mbPtr->textHeight; @@ -392,7 +405,7 @@ TkpComputeMenuButtonGeometry( * Image is above or below text. */ - height += txtHeight + mbPtr->padY; + height += txtHeight + padY; width = (width > txtWidth ? width : txtWidth); break; case COMPOUND_LEFT: @@ -401,7 +414,7 @@ TkpComputeMenuButtonGeometry( * Image is left or right of text. */ - width += txtWidth + mbPtr->padX; + width += txtWidth + padX; height = (height > txtHeight ? height : txtHeight); break; case COMPOUND_CENTER: @@ -421,8 +434,8 @@ TkpComputeMenuButtonGeometry( if (mbPtr->height > 0) { height = mbPtr->height; } - width += 2*mbPtr->padX; - height += 2*mbPtr->padY; + width += 2 * padX; + height += 2 * padY; } else { if (haveImage) { if (mbPtr->width > 0) { @@ -444,8 +457,8 @@ TkpComputeMenuButtonGeometry( } if (! haveImage) { - width += 2*mbPtr->padX; - height += 2*mbPtr->padY; + width += 2 * padX; + height += 2 * padY; } if (mbPtr->indicatorOn) { @@ -453,15 +466,15 @@ TkpComputeMenuButtonGeometry( pixels = WidthOfScreen(Tk_Screen(mbPtr->tkwin)); mbPtr->indicatorHeight= (INDICATOR_HEIGHT * pixels)/(10*mm); mbPtr->indicatorWidth = (INDICATOR_WIDTH * pixels)/(10*mm) - + 2*mbPtr->indicatorHeight; + + 2 * mbPtr->indicatorHeight; width += mbPtr->indicatorWidth; } else { mbPtr->indicatorHeight = 0; mbPtr->indicatorWidth = 0; } - Tk_GeometryRequest(mbPtr->tkwin, (int) (width + 2*mbPtr->inset), - (int) (height + 2*mbPtr->inset)); + Tk_GeometryRequest(mbPtr->tkwin, (int) (width + 2 * mbPtr->inset), + (int) (height + 2 * mbPtr->inset)); Tk_SetInternalBorder(mbPtr->tkwin, mbPtr->inset); } diff --git a/win/tkWinButton.c b/win/tkWinButton.c index 943c9e6..2281423 100644 --- a/win/tkWinButton.c +++ b/win/tkWinButton.c @@ -555,6 +555,7 @@ TkpDisplayButton( int imageXOffset = 0, imageYOffset = 0; /* Image information that will be used to * restrict disabled pixmap as well. */ + int padX, padY, borderWidth, highlightWidth; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); @@ -564,10 +565,10 @@ TkpDisplayButton( return; } - Tk_GetPixelsFromObj(NULL, tkwin, butPtr->borderWidthObj, &butPtr->borderWidth); - Tk_GetPixelsFromObj(NULL, tkwin, butPtr->highlightWidthObj, &butPtr->highlightWidth); - Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padXObj, &butPtr->padX); - Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padYObj, &butPtr->padY); + Tk_GetPixelsFromObj(NULL, tkwin, butPtr->borderWidthObj, &borderWidth); + Tk_GetPixelsFromObj(NULL, tkwin, butPtr->highlightWidthObj, &highlightWidth); + Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padXObj, &padX); + Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padYObj, &padY); border = butPtr->normalBorder; if ((butPtr->state == STATE_DISABLED) && (butPtr->disabledFg != NULL)) { @@ -626,11 +627,11 @@ TkpDisplayButton( */ if (butPtr->type == TYPE_LABEL) { - defaultWidth = butPtr->highlightWidth; + defaultWidth = highlightWidth; offset = 0; } else if (butPtr->type == TYPE_BUTTON) { defaultWidth = ((butPtr->defaultState == DEFAULT_ACTIVE) - ? butPtr->highlightWidth : 0); + ? highlightWidth : 0); offset = 1; } else { defaultWidth = 0; @@ -680,11 +681,11 @@ TkpDisplayButton( */ if (butPtr->compound == COMPOUND_TOP) { - textYOffset = height + butPtr->padY; + textYOffset = height + padY; } else { - imageYOffset = butPtr->textHeight + butPtr->padY; + imageYOffset = butPtr->textHeight + padY; } - fullHeight = height + butPtr->textHeight + butPtr->padY; + fullHeight = height + butPtr->textHeight + padY; fullWidth = (width > butPtr->textWidth ? width : butPtr->textWidth); textXOffset = (fullWidth - butPtr->textWidth)/2; @@ -698,11 +699,11 @@ TkpDisplayButton( */ if (butPtr->compound == COMPOUND_LEFT) { - textXOffset = width + butPtr->padX; + textXOffset = width + padX; } else { - imageXOffset = butPtr->textWidth + butPtr->padX; + imageXOffset = butPtr->textWidth + padX; } - fullWidth = butPtr->textWidth + butPtr->padX + width; + fullWidth = butPtr->textWidth + padX + width; fullHeight = (height > butPtr->textHeight ? height : butPtr->textHeight); textYOffset = (fullHeight - butPtr->textHeight)/2; @@ -726,7 +727,7 @@ TkpDisplayButton( case COMPOUND_NONE: break; } - TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY, + TkComputeAnchor(butPtr->anchor, tkwin, padX, padY, butPtr->indicatorSpace + fullWidth, fullHeight, &x, &y); x += butPtr->indicatorSpace; @@ -811,7 +812,7 @@ TkpDisplayButton( XSetClipOrigin(butPtr->display, gc, 0, 0); } } else { - TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY, + TkComputeAnchor(butPtr->anchor, tkwin, padX, padY, butPtr->indicatorSpace + butPtr->textWidth, butPtr->textHeight, &x, &y); @@ -853,7 +854,7 @@ TkpDisplayButton( if (drawRing && butPtr->flags & GOT_FOCUS && butPtr->type != TYPE_LABEL) { if (butPtr->type == TYPE_BUTTON || !butPtr->indicatorOn) { - int dottedWidth = butPtr->borderWidth + 1 + defaultWidth; + int dottedWidth = borderWidth + 1 + defaultWidth; TkWinDrawDottedRect(butPtr->display, pixmap, gc->foreground, dottedWidth, dottedWidth, Tk_Width(tkwin) - 2*dottedWidth, @@ -925,7 +926,7 @@ TkpDisplayButton( defaultWidth, defaultWidth, Tk_Width(tkwin) - 2 * defaultWidth, Tk_Height(tkwin) - 2 * defaultWidth, - butPtr->borderWidth, relief); + borderWidth, relief); } if (defaultWidth != 0) { int highlightColor; @@ -995,14 +996,20 @@ TkpComputeButtonGeometry( /* Vertical and horizontal dialog units size in pixels. */ double vDLU, hDLU; Tk_FontMetrics fm; + int borderWidth, highlightWidth, wrapLength; + int butPtrWidth, butPtrHeight; + int padX, padY; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthObj, &butPtr->highlightWidth); - Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->borderWidthObj, &butPtr->borderWidth); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthObj, &highlightWidth); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->borderWidthObj, &borderWidth); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->wrapLengthObj, &wrapLength); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->widthObj, &butPtrWidth); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->heightObj, &butPtrHeight); - butPtr->inset = butPtr->highlightWidth + butPtr->borderWidth; + butPtr->inset = highlightWidth + borderWidth; butPtr->indicatorSpace = 0; if (!tsdPtr->initialized) { @@ -1033,7 +1040,7 @@ TkpComputeButtonGeometry( Tk_FreeTextLayout(butPtr->textLayout); butPtr->textLayout = Tk_ComputeTextLayout(butPtr->tkfont, - Tcl_GetString(butPtr->textPtr), TCL_INDEX_NONE, butPtr->wrapLength, + Tcl_GetString(butPtr->textPtr), TCL_INDEX_NONE, wrapLength, butPtr->justify, 0, &butPtr->textWidth, &butPtr->textHeight); txtWidth = butPtr->textWidth; @@ -1081,8 +1088,8 @@ TkpComputeButtonGeometry( * = 50 DLU. Therefore, width = -11 -> MWUE compliant buttons. */ - if (butPtr->width < 0) { - minWidth = -(butPtr->width); /* Min width in chars */ + if (butPtrWidth < 0) { + minWidth = -(butPtrWidth); /* Min width in chars */ width = avgWidth * minWidth; /* Allow for characters */ width += (int)(0.5 + (6 * hDLU)); /* Add for padding */ } @@ -1093,7 +1100,7 @@ TkpComputeButtonGeometry( * suit. */ - if (butPtr->width == 0 + if (butPtrWidth == 0 || (txtWidth + (int)(0.5 + (6 * hDLU)) > width)) { width = txtWidth + (int)(0.5 + (6 * hDLU)); } @@ -1194,8 +1201,8 @@ TkpComputeButtonGeometry( * because otherwise it is not really a compound button. */ - Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padXObj, &butPtr->padX); - Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padYObj, &butPtr->padY); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padXObj, &padX); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padYObj, &padY); if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) { switch ((enum compound) butPtr->compound) { @@ -1208,7 +1215,7 @@ TkpComputeButtonGeometry( if (imgWidth > width) { width = imgWidth; } - height += imgHeight + butPtr->padY; + height += imgHeight + padY; break; case COMPOUND_LEFT: @@ -1221,8 +1228,8 @@ TkpComputeButtonGeometry( * space of default button width */ - if ((imgWidth + txtWidth + butPtr->padX) > width) { - width = imgWidth + txtWidth + butPtr->padX; + if ((imgWidth + txtWidth + padX) > width) { + width = imgWidth + txtWidth + padX; } if (imgHeight > height) { @@ -1250,33 +1257,33 @@ TkpComputeButtonGeometry( * Fix up for minimum width. */ - if (butPtr->width < 0) { + if (butPtrWidth < 0) { /* * minWidth in pixels (because there's an image. */ - minWidth = -(butPtr->width); + minWidth = -(butPtrWidth); if (width < minWidth) { width = minWidth; } - } else if (butPtr->width > 0) { - width = butPtr->width; + } else if (butPtrWidth > 0) { + width = butPtrWidth; } - if (butPtr->height > 0) { - height = butPtr->height; + if (butPtrHeight > 0) { + height = butPtrHeight; } - width += 2 * butPtr->padX; - height += 2 * butPtr->padY; + width += 2 * padX; + height += 2 * padY; } else if (haveImage) { - if (butPtr->width > 0) { - width = butPtr->width; + if (butPtrWidth > 0) { + width = butPtrWidth; } else { width = imgWidth; } - if (butPtr->height > 0) { - height = butPtr->height; + if (butPtrHeight > 0) { + height = butPtrHeight; } else { height = imgHeight; } @@ -1290,8 +1297,8 @@ TkpComputeButtonGeometry( * characters on the face, not in the over-all button width */ - if (butPtr->width > 0) { - width = butPtr->width * avgWidth; + if (butPtrWidth > 0) { + width = butPtrWidth * avgWidth; } /* @@ -1299,8 +1306,8 @@ TkpComputeButtonGeometry( * lines on the face, not in the over-all button height. */ - if (butPtr->height > 0) { - height = butPtr->height * fm.linespace; + if (butPtrHeight > 0) { + height = butPtrHeight * fm.linespace; /* * Make the same adjustments as above to get same height for e.g. @@ -1320,8 +1327,8 @@ TkpComputeButtonGeometry( } } - width += 2 * butPtr->padX; - height += 2 * butPtr->padY; + width += 2 * padX; + height += 2 * padY; } /* |