diff options
Diffstat (limited to 'generic/tkButton.c')
-rw-r--r-- | generic/tkButton.c | 233 |
1 files changed, 121 insertions, 112 deletions
diff --git a/generic/tkButton.c b/generic/tkButton.c index 9e3a08d..e2c754e 100644 --- a/generic/tkButton.c +++ b/generic/tkButton.c @@ -55,7 +55,13 @@ 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 @@ -65,19 +71,19 @@ char tkDefButtonBorderWidth[TCL_INTEGER_SPACE] = DEF_BUTTON_BORDER_WIDTH; 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}, + 0, DEF_BUTTON_ACTIVE_BG_MONO, 0}, {TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background", DEF_BUTTON_ACTIVE_FG_COLOR, -1, Tk_Offset(TkButton, activeFg), - TK_OPTION_NULL_OK, (ClientData) DEF_BUTTON_ACTIVE_FG_MONO, 0}, + TK_OPTION_NULL_OK, DEF_BUTTON_ACTIVE_FG_MONO, 0}, {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", DEF_BUTTON_ANCHOR, -1, Tk_Offset(TkButton, anchor), 0, 0, 0}, {TK_OPTION_BORDER, "-background", "background", "Background", DEF_BUTTON_BG_COLOR, -1, Tk_Offset(TkButton, normalBorder), - 0, (ClientData) DEF_BUTTON_BG_MONO, 0}, + 0, DEF_BUTTON_BG_MONO, 0}, {TK_OPTION_SYNONYM, "-bd", NULL, NULL, - NULL, 0, -1, 0, (ClientData) "-borderwidth", 0}, + NULL, 0, -1, 0, "-borderwidth", 0}, {TK_OPTION_SYNONYM, "-bg", NULL, NULL, - NULL, 0, -1, 0, (ClientData) "-background", 0}, + NULL, 0, -1, 0, "-background", 0}, {TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap", DEF_BUTTON_BITMAP, -1, Tk_Offset(TkButton, bitmap), TK_OPTION_NULL_OK, 0, 0}, @@ -86,7 +92,7 @@ static const Tk_OptionSpec labelOptionSpecs[] = { Tk_Offset(TkButton, borderWidth), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkButton, compound), 0, - (ClientData) compoundStrings, 0}, + compoundStrings, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_BUTTON_CURSOR, -1, Tk_Offset(TkButton, cursor), TK_OPTION_NULL_OK, 0, 0}, @@ -95,7 +101,7 @@ static const Tk_OptionSpec labelOptionSpecs[] = { -1, Tk_Offset(TkButton, disabledFg), TK_OPTION_NULL_OK, (ClientData) DEF_BUTTON_DISABLED_FG_MONO, 0}, {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, - NULL, 0, -1, 0, (ClientData) "-foreground", 0}, + NULL, 0, -1, 0, "-foreground", 0}, {TK_OPTION_FONT, "-font", "font", "Font", DEF_BUTTON_FONT, -1, Tk_Offset(TkButton, tkfont), 0, 0, 0}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", @@ -110,7 +116,7 @@ static const 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,16 +125,16 @@ static const 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}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", DEF_BUTTON_STATE, -1, Tk_Offset(TkButton, state), - 0, (ClientData) stateStrings, 0}, + 0, stateStrings, 0}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", DEF_LABEL_TAKE_FOCUS, Tk_Offset(TkButton, takeFocusPtr), -1, TK_OPTION_NULL_OK, 0, 0}, @@ -144,25 +150,25 @@ static const Tk_OptionSpec labelOptionSpecs[] = { {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength", DEF_BUTTON_WRAP_LENGTH, Tk_Offset(TkButton, wrapLengthPtr), Tk_Offset(TkButton, wrapLength), 0, 0, 0}, - {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0} + {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0} }; 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}, + 0, DEF_BUTTON_ACTIVE_BG_MONO, 0}, {TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background", DEF_BUTTON_ACTIVE_FG_COLOR, -1, Tk_Offset(TkButton, activeFg), - TK_OPTION_NULL_OK, (ClientData) DEF_BUTTON_ACTIVE_FG_MONO, 0}, + TK_OPTION_NULL_OK, DEF_BUTTON_ACTIVE_FG_MONO, 0}, {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", DEF_BUTTON_ANCHOR, -1, Tk_Offset(TkButton, anchor), 0, 0, 0}, {TK_OPTION_BORDER, "-background", "background", "Background", DEF_BUTTON_BG_COLOR, -1, Tk_Offset(TkButton, normalBorder), - 0, (ClientData) DEF_BUTTON_BG_MONO, 0}, + 0, DEF_BUTTON_BG_MONO, 0}, {TK_OPTION_SYNONYM, "-bd", NULL, NULL, - NULL, 0, -1, 0, (ClientData) "-borderwidth", 0}, + NULL, 0, -1, 0, "-borderwidth", 0}, {TK_OPTION_SYNONYM, "-bg", NULL, NULL, - NULL, 0, -1, 0, (ClientData) "-background", 0}, + NULL, 0, -1, 0, "-background", 0}, {TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap", DEF_BUTTON_BITMAP, -1, Tk_Offset(TkButton, bitmap), TK_OPTION_NULL_OK, 0, 0}, @@ -174,19 +180,19 @@ static const Tk_OptionSpec buttonOptionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkButton, compound), 0, - (ClientData) compoundStrings, 0}, + compoundStrings, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_BUTTON_CURSOR, -1, Tk_Offset(TkButton, cursor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-default", "default", "Default", DEF_BUTTON_DEFAULT, -1, Tk_Offset(TkButton, defaultState), - 0, (ClientData) defaultStrings, 0}, + 0, defaultStrings, 0}, {TK_OPTION_COLOR, "-disabledforeground", "disabledForeground", "DisabledForeground", DEF_BUTTON_DISABLED_FG_COLOR, -1, Tk_Offset(TkButton, disabledFg), TK_OPTION_NULL_OK, (ClientData) DEF_BUTTON_DISABLED_FG_MONO, 0}, {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, - NULL, 0, -1, 0, (ClientData) "-foreground", 0}, + NULL, 0, -1, 0, "-foreground", 0}, {TK_OPTION_FONT, "-font", "font", "Font", DEF_BUTTON_FONT, -1, Tk_Offset(TkButton, tkfont), 0, 0, 0}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", @@ -201,7 +207,7 @@ static const 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 +219,10 @@ static const 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), @@ -229,7 +235,7 @@ static const Tk_OptionSpec buttonOptionSpecs[] = { 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", DEF_BUTTON_STATE, -1, Tk_Offset(TkButton, state), - 0, (ClientData) stateStrings, 0}, + 0, stateStrings, 0}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", DEF_BUTTON_TAKE_FOCUS, Tk_Offset(TkButton, takeFocusPtr), -1, TK_OPTION_NULL_OK, 0, 0}, @@ -251,19 +257,19 @@ static const Tk_OptionSpec buttonOptionSpecs[] = { 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}, + 0, DEF_BUTTON_ACTIVE_BG_MONO, 0}, {TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background", DEF_CHKRAD_ACTIVE_FG_COLOR, -1, Tk_Offset(TkButton, activeFg), - TK_OPTION_NULL_OK, (ClientData) DEF_BUTTON_ACTIVE_FG_MONO, 0}, + TK_OPTION_NULL_OK, DEF_BUTTON_ACTIVE_FG_MONO, 0}, {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", DEF_BUTTON_ANCHOR, -1, Tk_Offset(TkButton, anchor), 0, 0, 0}, {TK_OPTION_BORDER, "-background", "background", "Background", DEF_BUTTON_BG_COLOR, -1, Tk_Offset(TkButton, normalBorder), - 0, (ClientData) DEF_BUTTON_BG_MONO, 0}, + 0, DEF_BUTTON_BG_MONO, 0}, {TK_OPTION_SYNONYM, "-bd", NULL, NULL, - NULL, 0, -1, 0, (ClientData) "-borderwidth", 0}, + NULL, 0, -1, 0, "-borderwidth", 0}, {TK_OPTION_SYNONYM, "-bg", NULL, NULL, - NULL, 0, -1, 0, (ClientData) "-background", 0}, + NULL, 0, -1, 0, "-background", 0}, {TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap", DEF_BUTTON_BITMAP, -1, Tk_Offset(TkButton, bitmap), TK_OPTION_NULL_OK, 0, 0}, @@ -275,7 +281,7 @@ static const Tk_OptionSpec checkbuttonOptionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkButton, compound), 0, - (ClientData) compoundStrings, 0}, + compoundStrings, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_BUTTON_CURSOR, -1, Tk_Offset(TkButton, cursor), TK_OPTION_NULL_OK, 0, 0}, @@ -284,7 +290,7 @@ static const Tk_OptionSpec checkbuttonOptionSpecs[] = { -1, Tk_Offset(TkButton, disabledFg), TK_OPTION_NULL_OK, (ClientData) DEF_BUTTON_DISABLED_FG_MONO, 0}, {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, - NULL, 0, -1, 0, (ClientData) "-foreground", 0}, + NULL, 0, -1, 0, "-foreground", 0}, {TK_OPTION_FONT, "-font", "font", "Font", DEF_BUTTON_FONT, -1, Tk_Offset(TkButton, tkfont), 0, 0, 0}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", @@ -299,7 +305,7 @@ static const 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,22 +325,22 @@ static const 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}, {TK_OPTION_BORDER, "-selectcolor", "selectColor", "Background", DEF_BUTTON_SELECT_COLOR, -1, Tk_Offset(TkButton, selectBorder), - TK_OPTION_NULL_OK, (ClientData) DEF_BUTTON_SELECT_MONO, 0}, + TK_OPTION_NULL_OK, DEF_BUTTON_SELECT_MONO, 0}, {TK_OPTION_STRING, "-selectimage", "selectImage", "SelectImage", DEF_BUTTON_SELECT_IMAGE, Tk_Offset(TkButton, selectImagePtr), -1, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", DEF_BUTTON_STATE, -1, Tk_Offset(TkButton, state), - 0, (ClientData) stateStrings, 0}, + 0, stateStrings, 0}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", DEF_BUTTON_TAKE_FOCUS, Tk_Offset(TkButton, takeFocusPtr), -1, TK_OPTION_NULL_OK, 0, 0}, @@ -364,19 +370,19 @@ static const Tk_OptionSpec checkbuttonOptionSpecs[] = { 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}, + 0, DEF_BUTTON_ACTIVE_BG_MONO, 0}, {TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background", DEF_CHKRAD_ACTIVE_FG_COLOR, -1, Tk_Offset(TkButton, activeFg), - TK_OPTION_NULL_OK, (ClientData) DEF_BUTTON_ACTIVE_FG_MONO, 0}, + TK_OPTION_NULL_OK, DEF_BUTTON_ACTIVE_FG_MONO, 0}, {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", DEF_BUTTON_ANCHOR, -1, Tk_Offset(TkButton, anchor), 0, 0, 0}, {TK_OPTION_BORDER, "-background", "background", "Background", DEF_BUTTON_BG_COLOR, -1, Tk_Offset(TkButton, normalBorder), - 0, (ClientData) DEF_BUTTON_BG_MONO, 0}, + 0, DEF_BUTTON_BG_MONO, 0}, {TK_OPTION_SYNONYM, "-bd", NULL, NULL, - NULL, 0, -1, 0, (ClientData) "-borderwidth", 0}, + NULL, 0, -1, 0, "-borderwidth", 0}, {TK_OPTION_SYNONYM, "-bg", NULL, NULL, - NULL, 0, -1, 0, (ClientData) "-background", 0}, + NULL, 0, -1, 0, "-background", 0}, {TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap", DEF_BUTTON_BITMAP, -1, Tk_Offset(TkButton, bitmap), TK_OPTION_NULL_OK, 0, 0}, @@ -388,7 +394,7 @@ static const Tk_OptionSpec radiobuttonOptionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkButton, compound), 0, - (ClientData) compoundStrings, 0}, + compoundStrings, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_BUTTON_CURSOR, -1, Tk_Offset(TkButton, cursor), TK_OPTION_NULL_OK, 0, 0}, @@ -397,7 +403,7 @@ static const Tk_OptionSpec radiobuttonOptionSpecs[] = { -1, Tk_Offset(TkButton, disabledFg), TK_OPTION_NULL_OK, (ClientData) DEF_BUTTON_DISABLED_FG_MONO, 0}, {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, - NULL, 0, -1, 0, (ClientData) "-foreground", 0}, + NULL, 0, -1, 0, "-foreground", 0}, {TK_OPTION_FONT, "-font", "font", "Font", DEF_BUTTON_FONT, -1, Tk_Offset(TkButton, tkfont), 0, 0, 0}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", @@ -412,7 +418,7 @@ static const 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,22 +435,22 @@ static const 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}, {TK_OPTION_BORDER, "-selectcolor", "selectColor", "Background", DEF_BUTTON_SELECT_COLOR, -1, Tk_Offset(TkButton, selectBorder), - TK_OPTION_NULL_OK, (ClientData) DEF_BUTTON_SELECT_MONO, 0}, + TK_OPTION_NULL_OK, DEF_BUTTON_SELECT_MONO, 0}, {TK_OPTION_STRING, "-selectimage", "selectImage", "SelectImage", DEF_BUTTON_SELECT_IMAGE, Tk_Offset(TkButton, selectImagePtr), -1, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", DEF_BUTTON_STATE, -1, Tk_Offset(TkButton, state), - 0, (ClientData) stateStrings, 0}, + 0, stateStrings, 0}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", DEF_BUTTON_TAKE_FOCUS, Tk_Offset(TkButton, takeFocusPtr), -1, TK_OPTION_NULL_OK, 0, 0}, @@ -491,7 +497,7 @@ static const Tk_OptionSpec *const optionSpecs[] = { * enumerated type used to dispatch the widget command. */ -static const char *commandNames[][8] = { +static const char *const commandNames[][8] = { {"cget", "configure", NULL}, {"cget", "configure", "flash", "invoke", NULL}, {"cget", "configure", "deselect", "flash", "invoke", "select", @@ -502,7 +508,7 @@ enum command { COMMAND_CGET, COMMAND_CONFIGURE, COMMAND_DESELECT, COMMAND_FLASH, COMMAND_INVOKE, COMMAND_SELECT, COMMAND_TOGGLE }; -static enum command map[][8] = { +static const enum command map[][8] = { {COMMAND_CGET, COMMAND_CONFIGURE}, {COMMAND_CGET, COMMAND_CONFIGURE, COMMAND_FLASH, COMMAND_INVOKE}, {COMMAND_CGET, COMMAND_CONFIGURE, COMMAND_DESELECT, COMMAND_FLASH, @@ -633,16 +639,16 @@ ButtonCreate( TkButton *butPtr; Tk_OptionTable optionTable; Tk_Window tkwin; - ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (!tsdPtr->defaultsInitialized) { - TkpButtonSetDefaults(NULL); + TkpButtonSetDefaults(); tsdPtr->defaultsInitialized = 1; } if (objc < 2) { - Tcl_WrongNumArgs(interp, 1, objv, "pathName ?options?"); + Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?"); return TCL_ERROR; } @@ -666,7 +672,7 @@ ButtonCreate( Tk_SetClass(tkwin, classNames[type]); butPtr = TkpCreateButton(tkwin); - Tk_SetClassProcs(tkwin, &tkpButtonProcs, (ClientData) butPtr); + Tk_SetClassProcs(tkwin, &tkpButtonProcs, butPtr); /* * Initialize the data structure for the button. @@ -676,7 +682,7 @@ ButtonCreate( butPtr->display = Tk_Display(tkwin); butPtr->interp = interp; butPtr->widgetCmd = Tcl_CreateObjCommand(interp, Tk_PathName(tkwin), - ButtonWidgetObjCmd, (ClientData) butPtr, ButtonCmdDeletedProc); + ButtonWidgetObjCmd, butPtr, ButtonCmdDeletedProc); butPtr->type = type; butPtr->optionTable = optionTable; butPtr->textPtr = NULL; @@ -741,7 +747,7 @@ ButtonCreate( Tk_CreateEventHandler(butPtr->tkwin, ExposureMask|StructureNotifyMask|FocusChangeMask, - ButtonEventProc, (ClientData) butPtr); + ButtonEventProc, butPtr); if (Tk_InitOptions(interp, (char *) butPtr, optionTable, tkwin) != TCL_OK) { @@ -753,8 +759,7 @@ ButtonCreate( return TCL_ERROR; } - Tcl_SetStringObj(Tcl_GetObjResult(interp), Tk_PathName(butPtr->tkwin), - -1); + Tcl_SetObjResult(interp, TkNewWindowObj(butPtr->tkwin)); return TCL_OK; } @@ -783,13 +788,13 @@ ButtonWidgetObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument values. */ { - TkButton *butPtr = (TkButton *) clientData; + TkButton *butPtr = clientData; int index; int result; Tcl_Obj *objPtr; if (objc < 2) { - Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg ...?"); + Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; } result = Tcl_GetIndexFromObj(interp, objv[1], commandNames[butPtr->type], @@ -797,7 +802,7 @@ ButtonWidgetObjCmd( if (result != TCL_OK) { return result; } - Tcl_Preserve((ClientData) butPtr); + Tcl_Preserve(butPtr); switch (map[butPtr->type][index]) { case COMMAND_CGET: @@ -809,9 +814,8 @@ ButtonWidgetObjCmd( butPtr->optionTable, objv[2], butPtr->tkwin); if (objPtr == NULL) { goto error; - } else { - Tcl_SetObjResult(interp, objPtr); } + Tcl_SetObjResult(interp, objPtr); break; case COMMAND_CONFIGURE: @@ -821,9 +825,8 @@ ButtonWidgetObjCmd( butPtr->tkwin); if (objPtr == NULL) { goto error; - } else { - Tcl_SetObjResult(interp, objPtr); } + Tcl_SetObjResult(interp, objPtr); } else { result = ConfigureButton(interp, butPtr, objc-2, objv+2); } @@ -866,7 +869,7 @@ ButtonWidgetObjCmd( Tk_SetBackgroundFromBorder(butPtr->tkwin, butPtr->normalBorder); } - TkpDisplayButton((ClientData) butPtr); + TkpDisplayButton(butPtr); /* * Special note: must cancel any existing idle handler for @@ -874,7 +877,7 @@ ButtonWidgetObjCmd( * TkpDisplayButton cleared the REDRAW_PENDING flag. */ - Tcl_CancelIdleCall(TkpDisplayButton, (ClientData) butPtr); + Tcl_CancelIdleCall(TkpDisplayButton, butPtr); XFlush(butPtr->display); Tcl_Sleep(50); } @@ -916,11 +919,11 @@ ButtonWidgetObjCmd( } break; } - Tcl_Release((ClientData) butPtr); + Tcl_Release(butPtr); return result; error: - Tcl_Release((ClientData) butPtr); + Tcl_Release(butPtr); return TCL_ERROR; } @@ -949,7 +952,7 @@ DestroyButton( TkpDestroyButton(butPtr); if (butPtr->flags & REDRAW_PENDING) { - Tcl_CancelIdleCall(TkpDisplayButton, (ClientData) butPtr); + Tcl_CancelIdleCall(TkpDisplayButton, butPtr); } /* @@ -961,7 +964,7 @@ DestroyButton( if (butPtr->textVarNamePtr != NULL) { Tcl_UntraceVar(butPtr->interp, Tcl_GetString(butPtr->textVarNamePtr), TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - ButtonTextVarProc, (ClientData) butPtr); + ButtonTextVarProc, butPtr); } if (butPtr->image != NULL) { Tk_FreeImage(butPtr->image); @@ -996,12 +999,12 @@ DestroyButton( if (butPtr->selVarNamePtr != NULL) { Tcl_UntraceVar(butPtr->interp, Tcl_GetString(butPtr->selVarNamePtr), TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - ButtonVarProc, (ClientData) butPtr); + ButtonVarProc, butPtr); } Tk_FreeConfigOptions((char *) butPtr, butPtr->optionTable, butPtr->tkwin); butPtr->tkwin = NULL; - Tcl_EventuallyFree((ClientData) butPtr, TCL_DYNAMIC); + Tcl_EventuallyFree(butPtr, TCL_DYNAMIC); } /* @@ -1044,12 +1047,12 @@ ConfigureButton( if (butPtr->textVarNamePtr != NULL) { Tcl_UntraceVar(interp, Tcl_GetString(butPtr->textVarNamePtr), TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - ButtonTextVarProc, (ClientData) butPtr); + ButtonTextVarProc, butPtr); } if (butPtr->selVarNamePtr != NULL) { Tcl_UntraceVar(interp, Tcl_GetString(butPtr->selVarNamePtr), TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - ButtonVarProc, (ClientData) butPtr); + ButtonVarProc, butPtr); } /* @@ -1181,7 +1184,7 @@ ConfigureButton( if (butPtr->imagePtr != NULL) { image = Tk_GetImage(butPtr->interp, butPtr->tkwin, Tcl_GetString(butPtr->imagePtr), ButtonImageProc, - (ClientData) butPtr); + butPtr); if (image == NULL) { continue; } @@ -1195,7 +1198,7 @@ ConfigureButton( if (butPtr->selectImagePtr != NULL) { image = Tk_GetImage(butPtr->interp, butPtr->tkwin, Tcl_GetString(butPtr->selectImagePtr), - ButtonSelectImageProc, (ClientData) butPtr); + ButtonSelectImageProc, butPtr); if (image == NULL) { continue; } @@ -1209,7 +1212,7 @@ ConfigureButton( if (butPtr->tristateImagePtr != NULL) { image = Tk_GetImage(butPtr->interp, butPtr->tkwin, Tcl_GetString(butPtr->tristateImagePtr), - ButtonTristateImageProc, (ClientData) butPtr); + ButtonTristateImageProc, butPtr); if (image == NULL) { continue; } @@ -1296,15 +1299,15 @@ ConfigureButton( if (butPtr->textVarNamePtr != NULL) { Tcl_TraceVar(interp, Tcl_GetString(butPtr->textVarNamePtr), TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - ButtonTextVarProc, (ClientData) butPtr); + ButtonTextVarProc, butPtr); } if (butPtr->selVarNamePtr != NULL) { Tcl_TraceVar(interp, Tcl_GetString(butPtr->selVarNamePtr), TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - ButtonVarProc, (ClientData) butPtr); + ButtonVarProc, butPtr); } - TkButtonWorldChanged((ClientData) butPtr); + TkButtonWorldChanged(butPtr); if (error) { Tcl_SetObjResult(interp, errorResult); Tcl_DecrRefCount(errorResult); @@ -1339,9 +1342,7 @@ TkButtonWorldChanged( XGCValues gcValues; GC newGC; unsigned long mask; - TkButton *butPtr; - - butPtr = (TkButton *) instanceData; + TkButton *butPtr = instanceData; /* * Recompute GCs. @@ -1424,7 +1425,7 @@ TkButtonWorldChanged( */ if (Tk_IsMapped(butPtr->tkwin) && !(butPtr->flags & REDRAW_PENDING)) { - Tcl_DoWhenIdle(TkpDisplayButton, (ClientData) butPtr); + Tcl_DoWhenIdle(TkpDisplayButton, butPtr); butPtr->flags |= REDRAW_PENDING; } } @@ -1452,7 +1453,7 @@ ButtonEventProc( ClientData clientData, /* Information about window. */ XEvent *eventPtr) /* Information about event. */ { - TkButton *butPtr = (TkButton *) clientData; + TkButton *butPtr = clientData; if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) { goto redraw; } else if (eventPtr->type == ConfigureNotify) { @@ -1483,7 +1484,7 @@ ButtonEventProc( redraw: if ((butPtr->tkwin != NULL) && !(butPtr->flags & REDRAW_PENDING)) { - Tcl_DoWhenIdle(TkpDisplayButton, (ClientData) butPtr); + Tcl_DoWhenIdle(TkpDisplayButton, butPtr); butPtr->flags |= REDRAW_PENDING; } } @@ -1510,7 +1511,7 @@ static void ButtonCmdDeletedProc( ClientData clientData) /* Pointer to widget record for widget. */ { - TkButton *butPtr = (TkButton *) clientData; + TkButton *butPtr = clientData; /* * This function could be invoked either because the window was destroyed @@ -1605,22 +1606,19 @@ ButtonVarProc( const char *name2, /* Second part of variable name. */ int flags) /* Information about what happened. */ { - register TkButton *butPtr = (TkButton *) clientData; - char *name, *value; + register TkButton *butPtr = clientData; + const char *value; Tcl_Obj *valuePtr; - name = Tcl_GetString(butPtr->selVarNamePtr); - /* * If the variable is being unset, then just re-establish the trace unless * the whole interpreter is going away. */ if (flags & TCL_TRACE_UNSETS) { - butPtr->flags &= ~SELECTED; - butPtr->flags &= ~TRISTATED; + butPtr->flags &= ~(SELECTED | TRISTATED); if ((flags & TCL_TRACE_DESTROYED) && !(flags & TCL_INTERP_DESTROYED)) { - Tcl_TraceVar(interp, name, + Tcl_TraceVar(interp, Tcl_GetString(butPtr->selVarNamePtr), TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, ButtonVarProc, clientData); } @@ -1632,7 +1630,8 @@ ButtonVarProc( * button. */ - valuePtr = Tcl_GetVar2Ex(interp, name, NULL, TCL_GLOBAL_ONLY); + valuePtr = Tcl_ObjGetVar2(interp, butPtr->selVarNamePtr, NULL, + TCL_GLOBAL_ONLY); if (valuePtr == NULL) { value = Tcl_GetString(butPtr->tristateValuePtr); } else { @@ -1665,7 +1664,7 @@ ButtonVarProc( redisplay: if ((butPtr->tkwin != NULL) && Tk_IsMapped(butPtr->tkwin) && !(butPtr->flags & REDRAW_PENDING)) { - Tcl_DoWhenIdle(TkpDisplayButton, (ClientData) butPtr); + Tcl_DoWhenIdle(TkpDisplayButton, butPtr); butPtr->flags |= REDRAW_PENDING; } return NULL; @@ -1697,16 +1696,13 @@ ButtonTextVarProc( const char *name2, /* Not used. */ int flags) /* Information about what happened. */ { - TkButton *butPtr = (TkButton *) clientData; - char *name; + TkButton *butPtr = clientData; Tcl_Obj *valuePtr; if (butPtr->flags & BUTTON_DELETED) { return NULL; } - name = Tcl_GetString(butPtr->textVarNamePtr); - /* * If the variable is unset, then immediately recreate it unless the whole * interpreter is going away. @@ -1714,16 +1710,17 @@ ButtonTextVarProc( if (flags & TCL_TRACE_UNSETS) { if ((flags & TCL_TRACE_DESTROYED) && !(flags & TCL_INTERP_DESTROYED)) { - Tcl_SetVar2Ex(interp, name, NULL, butPtr->textPtr, - TCL_GLOBAL_ONLY); - Tcl_TraceVar(interp, name, + Tcl_ObjSetVar2(interp, butPtr->textVarNamePtr, NULL, + butPtr->textPtr, TCL_GLOBAL_ONLY); + Tcl_TraceVar(interp, Tcl_GetString(butPtr->textVarNamePtr), TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, ButtonTextVarProc, clientData); } return NULL; } - valuePtr = Tcl_GetVar2Ex(interp, name, NULL, TCL_GLOBAL_ONLY); + valuePtr = Tcl_ObjGetVar2(interp, butPtr->textVarNamePtr, NULL, + TCL_GLOBAL_ONLY); if (valuePtr == NULL) { valuePtr = Tcl_NewObj(); } @@ -1734,7 +1731,7 @@ ButtonTextVarProc( if ((butPtr->tkwin != NULL) && Tk_IsMapped(butPtr->tkwin) && !(butPtr->flags & REDRAW_PENDING)) { - Tcl_DoWhenIdle(TkpDisplayButton, (ClientData) butPtr); + Tcl_DoWhenIdle(TkpDisplayButton, butPtr); butPtr->flags |= REDRAW_PENDING; } return NULL; @@ -1767,12 +1764,12 @@ ButtonImageProc( * <= 0). */ int imgWidth, int imgHeight)/* New dimensions of image. */ { - register TkButton *butPtr = (TkButton *) clientData; + register TkButton *butPtr = clientData; if (butPtr->tkwin != NULL) { TkpComputeButtonGeometry(butPtr); if (Tk_IsMapped(butPtr->tkwin) && !(butPtr->flags & REDRAW_PENDING)) { - Tcl_DoWhenIdle(TkpDisplayButton, (ClientData) butPtr); + Tcl_DoWhenIdle(TkpDisplayButton, butPtr); butPtr->flags |= REDRAW_PENDING; } } @@ -1805,16 +1802,22 @@ ButtonSelectImageProc( * <= 0). */ int imgWidth, int imgHeight)/* New dimensions of image. */ { - register TkButton *butPtr = (TkButton *) clientData; + register TkButton *butPtr = clientData; +#ifdef MAC_OSX_TK + if (butPtr->tkwin != NULL) { + TkpComputeButtonGeometry(butPtr); + } +#else /* * Don't recompute geometry: it's controlled by the primary image. */ +#endif if ((butPtr->flags & SELECTED) && (butPtr->tkwin != NULL) && Tk_IsMapped(butPtr->tkwin) && !(butPtr->flags & REDRAW_PENDING)) { - Tcl_DoWhenIdle(TkpDisplayButton, (ClientData) butPtr); + Tcl_DoWhenIdle(TkpDisplayButton, butPtr); butPtr->flags |= REDRAW_PENDING; } } @@ -1846,16 +1849,22 @@ ButtonTristateImageProc( * <= 0). */ int imgWidth, int imgHeight)/* New dimensions of image. */ { - register TkButton *butPtr = (TkButton *) clientData; + register TkButton *butPtr = clientData; +#ifdef MAC_OSX_TK + if (butPtr->tkwin != NULL) { + TkpComputeButtonGeometry(butPtr); + } +#else /* * Don't recompute geometry: it's controlled by the primary image. */ +#endif if ((butPtr->flags & TRISTATED) && (butPtr->tkwin != NULL) && Tk_IsMapped(butPtr->tkwin) && !(butPtr->flags & REDRAW_PENDING)) { - Tcl_DoWhenIdle(TkpDisplayButton, (ClientData) butPtr); + Tcl_DoWhenIdle(TkpDisplayButton, butPtr); butPtr->flags |= REDRAW_PENDING; } } |