summaryrefslogtreecommitdiffstats
path: root/generic/ttk/ttkButton.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/ttk/ttkButton.c')
-rw-r--r--generic/ttk/ttkButton.c143
1 files changed, 70 insertions, 73 deletions
diff --git a/generic/ttk/ttkButton.c b/generic/ttk/ttkButton.c
index bae3e6a..64c5d7e 100644
--- a/generic/ttk/ttkButton.c
+++ b/generic/ttk/ttkButton.c
@@ -1,4 +1,4 @@
-/* $Id: ttkButton.c,v 1.8 2007/12/13 15:26:24 dgp Exp $
+/* $Id: ttkButton.c,v 1.8.2.1 2010/08/26 02:06:09 hobbs Exp $
* Copyright (c) 2003, Joe English
*
* label, button, checkbutton, radiobutton, and menubutton widgets.
@@ -57,24 +57,24 @@ typedef struct
static Tk_OptionSpec BaseOptionSpecs[] =
{
{TK_OPTION_STRING, "-text", "text", "Text", "",
- Tk_Offset(Base,base.textObj), -1,
+ Tk_Offset(Base,base.textObj), -1,
0,0,GEOMETRY_CHANGED },
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable", "",
- Tk_Offset(Base,base.textVariableObj), -1,
+ Tk_Offset(Base,base.textVariableObj), -1,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_INT, "-underline", "underline", "Underline",
- "-1", Tk_Offset(Base,base.underlineObj), -1,
+ "-1", Tk_Offset(Base,base.underlineObj), -1,
0,0,0 },
/* SB: OPTION_INT, see <<NOTE-NULLOPTIONS>> */
{TK_OPTION_STRING, "-width", "width", "Width",
- NULL, Tk_Offset(Base,base.widthObj), -1,
+ NULL, Tk_Offset(Base,base.widthObj), -1,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
/*
* Image options
*/
{TK_OPTION_STRING, "-image", "image", "Image", NULL/*default*/,
- Tk_Offset(Base,base.imageObj), -1,
+ Tk_Offset(Base,base.imageObj), -1,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
/*
@@ -118,13 +118,12 @@ static void TextVariableChanged(void *clientData, const char *value)
TtkResizeWidget(&basePtr->core);
}
-static int
+static void
BaseInitialize(Tcl_Interp *interp, void *recordPtr)
{
Base *basePtr = recordPtr;
basePtr->base.textVariableTrace = 0;
basePtr->base.imageSpec = NULL;
- return TCL_OK;
}
static void
@@ -133,7 +132,7 @@ BaseCleanup(void *recordPtr)
Base *basePtr = recordPtr;
if (basePtr->base.textVariableTrace)
Ttk_UntraceVariable(basePtr->base.textVariableTrace);
- if (basePtr->base.imageSpec)
+ if (basePtr->base.imageSpec)
TtkFreeImageSpec(basePtr->base.imageSpec);
}
@@ -220,23 +219,23 @@ typedef struct
static Tk_OptionSpec LabelOptionSpecs[] =
{
- {TK_OPTION_BORDER, "-background", "frameColor", "FrameColor",
+ {TK_OPTION_BORDER, "-background", "frameColor", "FrameColor",
NULL, Tk_Offset(Label,label.backgroundObj), -1,
TK_OPTION_NULL_OK,0,0 },
- {TK_OPTION_COLOR, "-foreground", "textColor", "TextColor",
+ {TK_OPTION_COLOR, "-foreground", "textColor", "TextColor",
NULL, Tk_Offset(Label,label.foregroundObj), -1,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_FONT, "-font", "font", "Font",
NULL, Tk_Offset(Label,label.fontObj), -1,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
- {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
+ {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
NULL, Tk_Offset(Label,label.borderWidthObj), -1,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
NULL, Tk_Offset(Label,label.reliefObj), -1,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- NULL, Tk_Offset(Label,label.anchorObj), -1,
+ NULL, Tk_Offset(Label,label.anchorObj), -1,
TK_OPTION_NULL_OK, 0, GEOMETRY_CHANGED},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
NULL, Tk_Offset(Label, label.justifyObj), -1,
@@ -248,14 +247,13 @@ static Tk_OptionSpec LabelOptionSpecs[] =
WIDGET_INHERIT_OPTIONS(BaseOptionSpecs)
};
-static WidgetCommandSpec LabelCommands[] =
-{
- { "configure", TtkWidgetConfigureCommand },
- { "cget", TtkWidgetCgetCommand },
- { "instate", TtkWidgetInstateCommand },
- { "state", TtkWidgetStateCommand },
- { "identify", TtkWidgetIdentifyCommand },
- { NULL, NULL }
+static const Ttk_Ensemble LabelCommands[] = {
+ { "configure", TtkWidgetConfigureCommand,0 },
+ { "cget", TtkWidgetCgetCommand,0 },
+ { "instate", TtkWidgetInstateCommand,0 },
+ { "state", TtkWidgetStateCommand,0 },
+ { "identify", TtkWidgetIdentifyCommand,0 },
+ { 0,0,0 }
};
static WidgetSpec LabelWidgetSpec =
@@ -342,7 +340,7 @@ static int ButtonConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
*/
static int
ButtonInvokeCommand(
- Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr)
+ void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
Button *buttonPtr = recordPtr;
if (objc > 2) {
@@ -355,15 +353,14 @@ ButtonInvokeCommand(
return Tcl_EvalObjEx(interp, buttonPtr->button.commandObj, TCL_EVAL_GLOBAL);
}
-static WidgetCommandSpec ButtonCommands[] =
-{
- { "configure", TtkWidgetConfigureCommand },
- { "cget", TtkWidgetCgetCommand },
- { "invoke", ButtonInvokeCommand },
- { "instate", TtkWidgetInstateCommand },
- { "state", TtkWidgetStateCommand },
- { "identify", TtkWidgetIdentifyCommand },
- { NULL, NULL }
+static const Ttk_Ensemble ButtonCommands[] = {
+ { "configure", TtkWidgetConfigureCommand,0 },
+ { "cget", TtkWidgetCgetCommand,0 },
+ { "invoke", ButtonInvokeCommand,0 },
+ { "instate", TtkWidgetInstateCommand,0 },
+ { "state", TtkWidgetStateCommand,0 },
+ { "identify", TtkWidgetIdentifyCommand,0 },
+ { 0,0,0 }
};
static WidgetSpec ButtonWidgetSpec =
@@ -418,13 +415,17 @@ static Tk_OptionSpec CheckbuttonOptionSpecs[] =
WIDGET_TAKES_FOCUS,
{TK_OPTION_STRING, "-variable", "variable", "Variable",
- "", Tk_Offset(Checkbutton, checkbutton.variableObj), -1, 0,0,0},
+ "", Tk_Offset(Checkbutton, checkbutton.variableObj), -1,
+ TK_OPTION_DONT_SET_DEFAULT,0,0},
{TK_OPTION_STRING, "-onvalue", "onValue", "OnValue",
- "1", Tk_Offset(Checkbutton, checkbutton.onValueObj), -1, 0,0,0},
+ "1", Tk_Offset(Checkbutton, checkbutton.onValueObj), -1,
+ 0,0,0},
{TK_OPTION_STRING, "-offvalue", "offValue", "OffValue",
- "0", Tk_Offset(Checkbutton, checkbutton.offValueObj), -1, 0,0,0},
+ "0", Tk_Offset(Checkbutton, checkbutton.offValueObj), -1,
+ 0,0,0},
{TK_OPTION_STRING, "-command", "command", "Command",
- "", Tk_Offset(Checkbutton, checkbutton.commandObj), -1, 0,0,0},
+ "", Tk_Offset(Checkbutton, checkbutton.commandObj), -1,
+ 0,0,0},
WIDGET_INHERIT_OPTIONS(BaseOptionSpecs)
};
@@ -453,19 +454,18 @@ static void CheckbuttonVariableChanged(void *clientData, const char *value)
}
}
-static int CheckbuttonInitialize(Tcl_Interp *interp, void *recordPtr)
+static void
+CheckbuttonInitialize(Tcl_Interp *interp, void *recordPtr)
{
Checkbutton *checkPtr = recordPtr;
- Tcl_Obj *objPtr;
+ Tcl_Obj *variableObj;
/* default -variable is the widget name:
*/
- objPtr = Tcl_NewStringObj(Tk_PathName(checkPtr->core.tkwin), -1);
- Tcl_IncrRefCount(objPtr);
- Tcl_DecrRefCount(checkPtr->checkbutton.variableObj);
- checkPtr->checkbutton.variableObj = objPtr;
-
- return BaseInitialize(interp, recordPtr);
+ variableObj = Tcl_NewStringObj(Tk_PathName(checkPtr->core.tkwin), -1);
+ Tcl_IncrRefCount(variableObj);
+ checkPtr->checkbutton.variableObj = variableObj;
+ BaseInitialize(interp, recordPtr);
}
static void
@@ -519,7 +519,7 @@ CheckbuttonPostConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
*/
static int
CheckbuttonInvokeCommand(
- Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
+ void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
Checkbutton *checkPtr = recordPtr;
WidgetCore *corePtr = &checkPtr->core;
@@ -553,16 +553,15 @@ CheckbuttonInvokeCommand(
checkPtr->checkbutton.commandObj, TCL_EVAL_GLOBAL);
}
-static WidgetCommandSpec CheckbuttonCommands[] =
-{
- { "configure", TtkWidgetConfigureCommand },
- { "cget", TtkWidgetCgetCommand },
- { "invoke", CheckbuttonInvokeCommand },
- { "instate", TtkWidgetInstateCommand },
- { "state", TtkWidgetStateCommand },
- { "identify", TtkWidgetIdentifyCommand },
+static const Ttk_Ensemble CheckbuttonCommands[] = {
+ { "configure", TtkWidgetConfigureCommand,0 },
+ { "cget", TtkWidgetCgetCommand,0 },
+ { "invoke", CheckbuttonInvokeCommand,0 },
+ { "instate", TtkWidgetInstateCommand,0 },
+ { "state", TtkWidgetStateCommand,0 },
+ { "identify", TtkWidgetIdentifyCommand,0 },
/* MISSING: select, deselect, toggle */
- { NULL, NULL }
+ { 0,0,0 }
};
static WidgetSpec CheckbuttonWidgetSpec =
@@ -632,7 +631,7 @@ static Tk_OptionSpec RadiobuttonOptionSpecs[] =
/*
* Variable trace procedure for radiobuttons.
*/
-static void
+static void
RadiobuttonVariableChanged(void *clientData, const char *value)
{
Radiobutton *radioPtr = clientData;
@@ -705,7 +704,7 @@ RadiobuttonPostConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
*/
static int
RadiobuttonInvokeCommand(
- Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
+ void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
Radiobutton *radioPtr = recordPtr;
WidgetCore *corePtr = &radioPtr->core;
@@ -731,16 +730,15 @@ RadiobuttonInvokeCommand(
radioPtr->radiobutton.commandObj, TCL_EVAL_GLOBAL);
}
-static WidgetCommandSpec RadiobuttonCommands[] =
-{
- { "configure", TtkWidgetConfigureCommand },
- { "cget", TtkWidgetCgetCommand },
- { "invoke", RadiobuttonInvokeCommand },
- { "instate", TtkWidgetInstateCommand },
- { "state", TtkWidgetStateCommand },
- { "identify", TtkWidgetIdentifyCommand },
+static const Ttk_Ensemble RadiobuttonCommands[] = {
+ { "configure", TtkWidgetConfigureCommand,0 },
+ { "cget", TtkWidgetCgetCommand,0 },
+ { "invoke", RadiobuttonInvokeCommand,0 },
+ { "instate", TtkWidgetInstateCommand,0 },
+ { "state", TtkWidgetStateCommand,0 },
+ { "identify", TtkWidgetIdentifyCommand,0 },
/* MISSING: select, deselect */
- { NULL, NULL }
+ { 0,0,0 }
};
static WidgetSpec RadiobuttonWidgetSpec =
@@ -786,7 +784,7 @@ typedef struct
/*
* Option specifications:
*/
-static const char *directionStrings[] = {
+static const char *const directionStrings[] = {
"above", "below", "left", "right", "flush", NULL
};
static Tk_OptionSpec MenubuttonOptionSpecs[] =
@@ -802,14 +800,13 @@ static Tk_OptionSpec MenubuttonOptionSpecs[] =
WIDGET_INHERIT_OPTIONS(BaseOptionSpecs)
};
-static WidgetCommandSpec MenubuttonCommands[] =
-{
- { "configure", TtkWidgetConfigureCommand },
- { "cget", TtkWidgetCgetCommand },
- { "instate", TtkWidgetInstateCommand },
- { "state", TtkWidgetStateCommand },
- { "identify", TtkWidgetIdentifyCommand },
- { NULL, NULL }
+static const Ttk_Ensemble MenubuttonCommands[] = {
+ { "configure", TtkWidgetConfigureCommand,0 },
+ { "cget", TtkWidgetCgetCommand,0 },
+ { "instate", TtkWidgetInstateCommand,0 },
+ { "state", TtkWidgetStateCommand,0 },
+ { "identify", TtkWidgetIdentifyCommand,0 },
+ { 0,0,0 }
};
static WidgetSpec MenubuttonWidgetSpec =