summaryrefslogtreecommitdiffstats
path: root/generic/tkButton.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkButton.c')
-rw-r--r--generic/tkButton.c181
1 files changed, 95 insertions, 86 deletions
diff --git a/generic/tkButton.c b/generic/tkButton.c
index 4e3c06c..190165d 100644
--- a/generic/tkButton.c
+++ b/generic/tkButton.c
@@ -26,14 +26,14 @@ static Tcl_ThreadDataKey dataKey;
* tkButton.h.
*/
-static const char *classNames[] = {"Label", "Button", "Checkbutton", "Radiobutton"};
+static const char *const classNames[] = {"Label", "Button", "Checkbutton", "Radiobutton"};
/*
* The following table defines the legal values for the -default option. It is
* used together with the "enum defaultValue" declaration in tkButton.h.
*/
-static const char *defaultStrings[] = {
+static const char *const defaultStrings[] = {
"active", "disabled", "normal", NULL
};
@@ -42,7 +42,7 @@ static const char *defaultStrings[] = {
* It is used together with the "enum state" declaration in tkButton.h.
*/
-static const char *stateStrings[] = {
+static const char *const stateStrings[] = {
"active", "disabled", "normal", NULL
};
@@ -51,18 +51,24 @@ static const char *stateStrings[] = {
* It is used with the "enum compound" declaration in tkButton.h
*/
-static const char *compoundStrings[] = {
+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},
@@ -110,7 +116,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 +125,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},
@@ -144,10 +150,10 @@ static 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 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},
@@ -201,7 +207,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 +219,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 +254,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},
@@ -299,7 +305,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 +325,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 +367,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},
@@ -412,7 +418,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 +435,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 +484,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,
@@ -491,7 +497,7 @@ static 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(optionSpecs[type]);
+ 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;
}
}