summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--carbon/tkMacOSXPort.h4
-rw-r--r--generic/tkButton.c54
-rw-r--r--generic/tkButton.h14
-rw-r--r--macosx/tkMacOSXButton.c27
-rw-r--r--unix/tkUnixPort.h4
-rw-r--r--win/tkWinButton.c64
7 files changed, 68 insertions, 108 deletions
diff --git a/ChangeLog b/ChangeLog
index f65795f..c49dd13 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-02-18 Jan Nijtmans <nijtmans@users.sf.net>
+
+ * generic/tkButton.h Put all Tk_OptionSpec for buttons and labels
+ * generic/tkButton.c in const memory. With some changes to win32
+ * win/tkWinButton.c and macosx, preventing direct writes to
+ * unix/tkUnixPort.h read-only memory.
+ * carbon/tkMacOSXPort.h
+ * macosx/tkMacOSXButton.c
+
2010-02-17 Joe English <jenglish@users.sourceforge.net>
* generic/tkMenu.c: Defer TkMenuOptionTables cleanup
diff --git a/carbon/tkMacOSXPort.h b/carbon/tkMacOSXPort.h
index ad4e81e..afc59f5 100644
--- a/carbon/tkMacOSXPort.h
+++ b/carbon/tkMacOSXPort.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: tkMacOSXPort.h,v 1.1 2009/06/26 01:42:47 das Exp $
+ * RCS: @(#) $Id: tkMacOSXPort.h,v 1.2 2010/02/18 22:31:31 nijtmans Exp $
*/
#ifndef _TKMACPORT
@@ -125,7 +125,7 @@
* The following functions are not used on the Mac, so we stub them out.
*/
-#define TkpButtonSetDefaults(specPtr) {}
+#define TkpButtonSetDefaults() {}
#define TkpCmapStressed(tkwin,colormap) (0)
#define TkpFreeColor(tkColPtr)
#define TkSetPixmapColormap(p,c) {}
diff --git a/generic/tkButton.c b/generic/tkButton.c
index 1ad493a..10b36fb 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.38 2010/02/13 13:47:49 nijtmans Exp $
+ * RCS: @(#) $Id: tkButton.c,v 1.39 2010/02/18 22:31:31 nijtmans Exp $
*/
#include "tkInt.h"
@@ -57,12 +57,20 @@ static const char *const compoundStrings[] = {
"bottom", "center", "left", "none", "right", "top", NULL
};
+char tkDefButtonHighlightWidth[TCL_INTEGER_SPACE] = DEF_BUTTON_HIGHLIGHT_WIDTH;
+char tkDefButtonPadx[TCL_INTEGER_SPACE] = DEF_BUTTON_PADX;
+char tkDefButtonPady[TCL_INTEGER_SPACE] = DEF_BUTTON_PADY;
+char tkDefButtonBorderWidth[TCL_INTEGER_SPACE] = DEF_BUTTON_BORDER_WIDTH;
+char tkDefLabelHighlightWidth[TCL_INTEGER_SPACE] = DEF_LABEL_HIGHLIGHT_WIDTH;
+char tkDefLabelPadx[TCL_INTEGER_SPACE] = DEF_LABCHKRAD_PADX;
+char tkDefLabelPady[TCL_INTEGER_SPACE] = DEF_LABCHKRAD_PADY;
+
/*
* Information used for parsing configuration options. There is a
* separate table for each of the four widget classes.
*/
-static Tk_OptionSpec labelOptionSpecs[] = {
+static const Tk_OptionSpec labelOptionSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
DEF_BUTTON_ACTIVE_BG_COLOR, -1, Tk_Offset(TkButton, activeBorder),
0, (ClientData) DEF_BUTTON_ACTIVE_BG_MONO, 0},
@@ -82,7 +90,7 @@ static Tk_OptionSpec labelOptionSpecs[] = {
DEF_BUTTON_BITMAP, -1, Tk_Offset(TkButton, bitmap),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_BUTTON_BORDER_WIDTH, Tk_Offset(TkButton, borderWidthPtr),
+ tkDefButtonBorderWidth, Tk_Offset(TkButton, borderWidthPtr),
Tk_Offset(TkButton, borderWidth), 0, 0, 0},
{TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkButton, compound), 0,
@@ -110,7 +118,7 @@ static Tk_OptionSpec labelOptionSpecs[] = {
DEF_BUTTON_HIGHLIGHT, -1, Tk_Offset(TkButton, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_LABEL_HIGHLIGHT_WIDTH,
+ "HighlightThickness", tkDefLabelHighlightWidth,
Tk_Offset(TkButton, highlightWidthPtr),
Tk_Offset(TkButton, highlightWidth), 0, 0, 0},
{TK_OPTION_STRING, "-image", "image", "Image",
@@ -119,10 +127,10 @@ static Tk_OptionSpec labelOptionSpecs[] = {
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
DEF_BUTTON_JUSTIFY, -1, Tk_Offset(TkButton, justify), 0, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- DEF_LABCHKRAD_PADX, Tk_Offset(TkButton, padXPtr),
+ tkDefLabelPadx, Tk_Offset(TkButton, padXPtr),
Tk_Offset(TkButton, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- DEF_LABCHKRAD_PADY, Tk_Offset(TkButton, padYPtr),
+ tkDefLabelPady, Tk_Offset(TkButton, padYPtr),
Tk_Offset(TkButton, padY), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
DEF_LABCHKRAD_RELIEF, -1, Tk_Offset(TkButton, relief), 0, 0, 0},
@@ -147,7 +155,7 @@ static Tk_OptionSpec labelOptionSpecs[] = {
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
-static Tk_OptionSpec buttonOptionSpecs[] = {
+static const Tk_OptionSpec buttonOptionSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
DEF_BUTTON_ACTIVE_BG_COLOR, -1, Tk_Offset(TkButton, activeBorder),
0, (ClientData) DEF_BUTTON_ACTIVE_BG_MONO, 0},
@@ -167,7 +175,7 @@ static Tk_OptionSpec buttonOptionSpecs[] = {
DEF_BUTTON_BITMAP, -1, Tk_Offset(TkButton, bitmap),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_BUTTON_BORDER_WIDTH, Tk_Offset(TkButton, borderWidthPtr),
+ tkDefButtonBorderWidth, Tk_Offset(TkButton, borderWidthPtr),
Tk_Offset(TkButton, borderWidth), 0, 0, 0},
{TK_OPTION_STRING, "-command", "command", "Command",
DEF_BUTTON_COMMAND, Tk_Offset(TkButton, commandPtr), -1,
@@ -201,7 +209,7 @@ static Tk_OptionSpec buttonOptionSpecs[] = {
DEF_BUTTON_HIGHLIGHT, -1, Tk_Offset(TkButton, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_BUTTON_HIGHLIGHT_WIDTH,
+ "HighlightThickness", tkDefButtonHighlightWidth,
Tk_Offset(TkButton, highlightWidthPtr),
Tk_Offset(TkButton, highlightWidth), 0, 0, 0},
{TK_OPTION_STRING, "-image", "image", "Image",
@@ -213,10 +221,10 @@ static Tk_OptionSpec buttonOptionSpecs[] = {
DEF_BUTTON_OVER_RELIEF, -1, Tk_Offset(TkButton, overRelief),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- DEF_BUTTON_PADX, Tk_Offset(TkButton, padXPtr),
+ tkDefButtonPadx, Tk_Offset(TkButton, padXPtr),
Tk_Offset(TkButton, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- DEF_BUTTON_PADY, Tk_Offset(TkButton, padYPtr),
+ tkDefButtonPady, Tk_Offset(TkButton, padYPtr),
Tk_Offset(TkButton, padY), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
DEF_BUTTON_RELIEF, -1, Tk_Offset(TkButton, relief),
@@ -248,7 +256,7 @@ static Tk_OptionSpec buttonOptionSpecs[] = {
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
};
-static Tk_OptionSpec checkbuttonOptionSpecs[] = {
+static const Tk_OptionSpec checkbuttonOptionSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
DEF_BUTTON_ACTIVE_BG_COLOR, -1, Tk_Offset(TkButton, activeBorder),
0, (ClientData) DEF_BUTTON_ACTIVE_BG_MONO, 0},
@@ -268,7 +276,7 @@ static Tk_OptionSpec checkbuttonOptionSpecs[] = {
DEF_BUTTON_BITMAP, -1, Tk_Offset(TkButton, bitmap),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_BUTTON_BORDER_WIDTH, Tk_Offset(TkButton, borderWidthPtr),
+ tkDefButtonBorderWidth, Tk_Offset(TkButton, borderWidthPtr),
Tk_Offset(TkButton, borderWidth), 0, 0, 0},
{TK_OPTION_STRING, "-command", "command", "Command",
DEF_BUTTON_COMMAND, Tk_Offset(TkButton, commandPtr), -1,
@@ -299,7 +307,7 @@ static Tk_OptionSpec checkbuttonOptionSpecs[] = {
DEF_BUTTON_HIGHLIGHT, -1, Tk_Offset(TkButton, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_BUTTON_HIGHLIGHT_WIDTH,
+ "HighlightThickness", tkDefButtonHighlightWidth,
Tk_Offset(TkButton, highlightWidthPtr),
Tk_Offset(TkButton, highlightWidth), 0, 0, 0},
{TK_OPTION_STRING, "-image", "image", "Image",
@@ -319,10 +327,10 @@ static Tk_OptionSpec checkbuttonOptionSpecs[] = {
DEF_BUTTON_OVER_RELIEF, -1, Tk_Offset(TkButton, overRelief),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- DEF_LABCHKRAD_PADX, Tk_Offset(TkButton, padXPtr),
+ tkDefLabelPadx, Tk_Offset(TkButton, padXPtr),
Tk_Offset(TkButton, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- DEF_LABCHKRAD_PADY, Tk_Offset(TkButton, padYPtr),
+ tkDefLabelPady, Tk_Offset(TkButton, padYPtr),
Tk_Offset(TkButton, padY), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
DEF_LABCHKRAD_RELIEF, -1, Tk_Offset(TkButton, relief), 0, 0, 0},
@@ -361,7 +369,7 @@ static Tk_OptionSpec checkbuttonOptionSpecs[] = {
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
};
-static Tk_OptionSpec radiobuttonOptionSpecs[] = {
+static const Tk_OptionSpec radiobuttonOptionSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
DEF_BUTTON_ACTIVE_BG_COLOR, -1, Tk_Offset(TkButton, activeBorder),
0, (ClientData) DEF_BUTTON_ACTIVE_BG_MONO, 0},
@@ -381,7 +389,7 @@ static Tk_OptionSpec radiobuttonOptionSpecs[] = {
DEF_BUTTON_BITMAP, -1, Tk_Offset(TkButton, bitmap),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_BUTTON_BORDER_WIDTH, Tk_Offset(TkButton, borderWidthPtr),
+ tkDefButtonBorderWidth, Tk_Offset(TkButton, borderWidthPtr),
Tk_Offset(TkButton, borderWidth), 0, 0, 0},
{TK_OPTION_STRING, "-command", "command", "Command",
DEF_BUTTON_COMMAND, Tk_Offset(TkButton, commandPtr), -1,
@@ -412,7 +420,7 @@ static Tk_OptionSpec radiobuttonOptionSpecs[] = {
DEF_BUTTON_HIGHLIGHT, -1, Tk_Offset(TkButton, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_BUTTON_HIGHLIGHT_WIDTH,
+ "HighlightThickness", tkDefButtonHighlightWidth,
Tk_Offset(TkButton, highlightWidthPtr),
Tk_Offset(TkButton, highlightWidth), 0, 0, 0},
{TK_OPTION_STRING, "-image", "image", "Image",
@@ -429,10 +437,10 @@ static Tk_OptionSpec radiobuttonOptionSpecs[] = {
DEF_BUTTON_OVER_RELIEF, -1, Tk_Offset(TkButton, overRelief),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- DEF_LABCHKRAD_PADX, Tk_Offset(TkButton, padXPtr),
+ tkDefLabelPadx, Tk_Offset(TkButton, padXPtr),
Tk_Offset(TkButton, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- DEF_LABCHKRAD_PADY, Tk_Offset(TkButton, padYPtr),
+ tkDefLabelPady, Tk_Offset(TkButton, padYPtr),
Tk_Offset(TkButton, padY), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
DEF_LABCHKRAD_RELIEF, -1, Tk_Offset(TkButton, relief), 0, 0, 0},
@@ -478,7 +486,7 @@ static Tk_OptionSpec radiobuttonOptionSpecs[] = {
* such as TYPE_LABEL, to the option template for that class of widgets.
*/
-static Tk_OptionSpec *const optionSpecs[] = {
+static const Tk_OptionSpec *const optionSpecs[] = {
labelOptionSpecs,
buttonOptionSpecs,
checkbuttonOptionSpecs,
@@ -637,7 +645,7 @@ ButtonCreate(
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!tsdPtr->defaultsInitialized) {
- TkpButtonSetDefaults(optionSpecs[type]);
+ TkpButtonSetDefaults();
tsdPtr->defaultsInitialized = 1;
}
diff --git a/generic/tkButton.h b/generic/tkButton.h
index 6eb1ce5..2211255 100644
--- a/generic/tkButton.h
+++ b/generic/tkButton.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: tkButton.h,v 1.17 2010/01/13 23:08:07 nijtmans Exp $
+ * RCS: @(#) $Id: tkButton.h,v 1.18 2010/02/18 22:31:31 nijtmans Exp $
*/
#ifndef _TKBUTTON
@@ -295,17 +295,25 @@ typedef struct {
#define TRISTATED (1 << 4)
/*
- * Declaration of variables shared between the files in the button module.
+ * Declaration of button class functions structure
+ * and button/label defaults, for use in optionSpecs.
*/
MODULE_SCOPE const Tk_ClassProcs tkpButtonProcs;
+MODULE_SCOPE char tkDefButtonHighlightWidth[TCL_INTEGER_SPACE];
+MODULE_SCOPE char tkDefButtonPadx[TCL_INTEGER_SPACE];
+MODULE_SCOPE char tkDefButtonPady[TCL_INTEGER_SPACE];
+MODULE_SCOPE char tkDefButtonBorderWidth[TCL_INTEGER_SPACE];
+MODULE_SCOPE char tkDefLabelHighlightWidth[TCL_INTEGER_SPACE];
+MODULE_SCOPE char tkDefLabelPadx[TCL_INTEGER_SPACE];
+MODULE_SCOPE char tkDefLabelPady[TCL_INTEGER_SPACE];
/*
* Declaration of functions used in the implementation of the button widget.
*/
#ifndef TkpButtonSetDefaults
-MODULE_SCOPE void TkpButtonSetDefaults(Tk_OptionSpec *specPtr);
+MODULE_SCOPE void TkpButtonSetDefaults();
#endif
MODULE_SCOPE void TkButtonWorldChanged(ClientData instanceData);
MODULE_SCOPE void TkpComputeButtonGeometry(TkButton *butPtr);
diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c
index 5f26135..41edd9b 100644
--- a/macosx/tkMacOSXButton.c
+++ b/macosx/tkMacOSXButton.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: tkMacOSXButton.c,v 1.36 2010/01/13 23:08:12 nijtmans Exp $
+ * RCS: @(#) $Id: tkMacOSXButton.c,v 1.37 2010/02/18 22:31:31 nijtmans Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -247,27 +247,16 @@ TkpComputeButtonGeometry(
*/
void
-TkpButtonSetDefaults(
- Tk_OptionSpec *specPtr) /* Points to an array of option specs,
- * terminated by one with type
- * TK_OPTION_END. */
+TkpButtonSetDefaults()
{
#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
if (!tkMacOSXUseCompatibilityMetrics) {
- while (specPtr->type != TK_CONFIG_END) {
- switch (specPtr->internalOffset) {
- case Tk_Offset(TkButton, highlightWidth):
- specPtr->defValue = DEF_BUTTON_HIGHLIGHT_WIDTH_NOCM;
- break;
- case Tk_Offset(TkButton, padX):
- specPtr->defValue = DEF_BUTTON_PADX_NOCM;
- break;
- case Tk_Offset(TkButton, padY):
- specPtr->defValue = DEF_BUTTON_PADY_NOCM;
- break;
- }
- specPtr++;
- }
+ strcpy(tkDefButtonHighlightWidth, DEF_BUTTON_HIGHLIGHT_WIDTH_NOCM);
+ strcpy(tkDefLabelHighlightWidth, DEF_BUTTON_HIGHLIGHT_WIDTH_NOCM);
+ strcpy(tkDefButtonPadx, DEF_BUTTON_PADX_NOCM);
+ strcpy(tkDefLabelPadx, DEF_BUTTON_PADX_NOCM);
+ strcpy(tkDefButtonPady, DEF_BUTTON_PADY_NOCM);
+ strcpy(tkDefLabelPady, DEF_BUTTON_PADY_NOCM);
}
#endif
}
diff --git a/unix/tkUnixPort.h b/unix/tkUnixPort.h
index b360450..d8d19ab 100644
--- a/unix/tkUnixPort.h
+++ b/unix/tkUnixPort.h
@@ -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: tkUnixPort.h,v 1.16 2008/12/17 22:51:25 nijtmans Exp $
+ * RCS: @(#) $Id: tkUnixPort.h,v 1.17 2010/02/18 22:31:31 nijtmans Exp $
*/
#ifndef _UNIXPORT
@@ -167,7 +167,7 @@
* These functions do nothing under Unix, so we just eliminate calls to them.
*/
-#define TkpButtonSetDefaults(specPtr) {}
+#define TkpButtonSetDefaults() {}
#define TkpDestroyButton(butPtr) {}
#define TkSelUpdateClipboard(a,b) {}
#define TkSetPixmapColormap(p,c) {}
diff --git a/win/tkWinButton.c b/win/tkWinButton.c
index e17244b..1a89abf 100644
--- a/win/tkWinButton.c
+++ b/win/tkWinButton.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: tkWinButton.c,v 1.39 2010/01/13 23:08:11 nijtmans Exp $
+ * RCS: @(#) $Id: tkWinButton.c,v 1.40 2010/02/18 22:31:31 nijtmans Exp $
*/
#define OEMRESOURCE
@@ -71,7 +71,6 @@ typedef struct ThreadSpecificData {
LPSTR boxesBits; /* Pointer to bitmap data. */
DWORD boxHeight; /* Height of each sub-image. */
DWORD boxWidth; /* Width of each sub-image. */
- char defWidth[TCL_INTEGER_SPACE];
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
@@ -168,40 +167,6 @@ InitBoxes(void)
/*
*----------------------------------------------------------------------
*
- * ButtonDefaultsExitHandler --
- *
- * Frees the defaults for the buttons.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ButtonDefaultsExitHandler(
- ClientData clientData) /* Points to an array of option specs,
- * terminated by one with type
- * TK_OPTION_END. */
-{
- Tk_OptionSpec *specPtr = (Tk_OptionSpec *)clientData;
-
- for ( ; specPtr->type != TK_OPTION_END; specPtr++) {
- if (specPtr->internalOffset == Tk_Offset(TkButton, borderWidth)) {
- if (specPtr->defValue != NULL) {
- ckfree((char *) specPtr->defValue);
- specPtr->defValue = NULL;
- }
- }
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
* TkpButtonSetDefaults --
*
* This procedure is invoked before option tables are created for
@@ -218,31 +183,12 @@ ButtonDefaultsExitHandler(
*/
void
-TkpButtonSetDefaults(
- Tk_OptionSpec *specPtr) /* Points to an array of option specs,
- * terminated by one with type
- * TK_OPTION_END. */
+TkpButtonSetDefaults()
{
- int width;
- Tk_OptionSpec *savedSpecPtr = specPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
- Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
-
- if (tsdPtr->defWidth[0] == 0) {
- width = GetSystemMetrics(SM_CXEDGE);
- if (width == 0) {
- width = 1;
+ int width = GetSystemMetrics(SM_CXEDGE);
+ if (width > 0) {
+ sprintf(tkDefButtonBorderWidth, "%d", width);
}
- sprintf(tsdPtr->defWidth, "%d", width);
- }
- for ( ; specPtr->type != TK_OPTION_END; specPtr++) {
- if (specPtr->internalOffset == Tk_Offset(TkButton, borderWidth)) {
- char *defValue = (char *) ckalloc(strlen(tsdPtr->defWidth) + 1);
- strcpy(defValue, tsdPtr->defWidth);
- specPtr->defValue = defValue;
- }
- }
- TkCreateExitHandler(ButtonDefaultsExitHandler, (ClientData) savedSpecPtr);
}
/*