summaryrefslogtreecommitdiffstats
path: root/generic/tkButton.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkButton.c')
-rw-r--r--generic/tkButton.c54
1 files changed, 31 insertions, 23 deletions
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;
}