summaryrefslogtreecommitdiffstats
path: root/generic/ttk/ttkScale.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/ttk/ttkScale.c')
-rw-r--r--generic/ttk/ttkScale.c68
1 files changed, 33 insertions, 35 deletions
diff --git a/generic/ttk/ttkScale.c b/generic/ttk/ttkScale.c
index a80d6e8..ec2343a 100644
--- a/generic/ttk/ttkScale.c
+++ b/generic/ttk/ttkScale.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004 Pat Thoyts <patthoyts@users.sourceforge.net>
+ * Copyright © 2004 Pat Thoyts <patthoyts@users.sourceforge.net>
*
* ttk::scale widget.
*/
@@ -50,31 +50,31 @@ typedef struct
ScalePart scale;
} Scale;
-static Tk_OptionSpec ScaleOptionSpecs[] =
+static const Tk_OptionSpec ScaleOptionSpecs[] =
{
{TK_OPTION_STRING, "-command", "command", "Command", "",
- Tk_Offset(Scale,scale.commandObj), -1,
+ offsetof(Scale,scale.commandObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0},
{TK_OPTION_STRING, "-variable", "variable", "Variable", "",
- Tk_Offset(Scale,scale.variableObj), -1,
+ offsetof(Scale,scale.variableObj), TCL_INDEX_NONE,
0, 0, 0},
{TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal",
- Tk_Offset(Scale,scale.orientObj),
- Tk_Offset(Scale,scale.orient),
+ offsetof(Scale,scale.orientObj),
+ offsetof(Scale,scale.orient),
0, ttkOrientStrings, STYLE_CHANGED },
- {TK_OPTION_DOUBLE, "-from", "from", "From", "0",
- Tk_Offset(Scale,scale.fromObj), -1, 0, 0, 0},
+ {TK_OPTION_DOUBLE, "-from", "from", "From", "0.0",
+ offsetof(Scale,scale.fromObj), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_DOUBLE, "-to", "to", "To", "1.0",
- Tk_Offset(Scale,scale.toObj), -1, 0, 0, 0},
- {TK_OPTION_DOUBLE, "-value", "value", "Value", "0",
- Tk_Offset(Scale,scale.valueObj), -1, 0, 0, 0},
+ offsetof(Scale,scale.toObj), TCL_INDEX_NONE, 0, 0, 0},
+ {TK_OPTION_DOUBLE, "-value", "value", "Value", "0.0",
+ offsetof(Scale,scale.valueObj), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_PIXELS, "-length", "length", "Length",
- DEF_SCALE_LENGTH, Tk_Offset(Scale,scale.lengthObj), -1, 0, 0,
+ DEF_SCALE_LENGTH, offsetof(Scale,scale.lengthObj), TCL_INDEX_NONE, 0, 0,
GEOMETRY_CHANGED},
{TK_OPTION_STRING, "-state", "state", "State",
- "normal", Tk_Offset(Scale,scale.stateObj), -1,
+ "normal", offsetof(Scale,scale.stateObj), TCL_INDEX_NONE,
0, 0, STATE_CHANGED},
WIDGET_TAKEFOCUS_TRUE,
@@ -261,19 +261,15 @@ static double ScaleFraction(Scale *scalePtr, double value)
*/
static int
ScaleGetCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Scale *scalePtr = (Scale *)recordPtr;
int x, y, r = TCL_OK;
double value = 0;
- if ((objc != 2) && (objc != 4)) {
- Tcl_WrongNumArgs(interp, 1, objv, "get ?x y?");
- return TCL_ERROR;
- }
if (objc == 2) {
Tcl_SetObjResult(interp, scalePtr->scale.valueObj);
- } else {
+ } else if (objc == 4) {
r = Tcl_GetIntFromObj(interp, objv[2], &x);
if (r == TCL_OK)
r = Tcl_GetIntFromObj(interp, objv[3], &y);
@@ -281,6 +277,9 @@ ScaleGetCommand(
value = PointToValue(scalePtr, x, y);
Tcl_SetObjResult(interp, Tcl_NewDoubleObj(value));
}
+ } else {
+ Tcl_WrongNumArgs(interp, 1, objv, "get ?x y?");
+ return TCL_ERROR;
}
return r;
}
@@ -289,7 +288,7 @@ ScaleGetCommand(
*/
static int
ScaleSetCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Scale *scalePtr = (Scale *)recordPtr;
double from = 0.0, to = 1.0, value;
@@ -357,28 +356,26 @@ ScaleSetCommand(
static int
ScaleCoordsCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Scale *scalePtr = (Scale *)recordPtr;
double value;
int r = TCL_OK;
- if (objc < 2 || objc > 3) {
- Tcl_WrongNumArgs(interp, 1, objv, "coords ?value?");
- return TCL_ERROR;
- }
-
if (objc == 3) {
r = Tcl_GetDoubleFromObj(interp, objv[2], &value);
- } else {
+ } else if (objc == 2) {
r = Tcl_GetDoubleFromObj(interp, scalePtr->scale.valueObj, &value);
+ } else {
+ Tcl_WrongNumArgs(interp, 1, objv, "coords ?value?");
+ return TCL_ERROR;
}
if (r == TCL_OK) {
Tcl_Obj *point[2];
XPoint pt = ValueToPoint(scalePtr, value);
- point[0] = Tcl_NewIntObj(pt.x);
- point[1] = Tcl_NewIntObj(pt.y);
+ point[0] = Tcl_NewWideIntObj(pt.x);
+ point[1] = Tcl_NewWideIntObj(pt.y);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, point));
}
return r;
@@ -482,18 +479,19 @@ ValueToPoint(Scale *scalePtr, double value)
}
static const Ttk_Ensemble ScaleCommands[] = {
- { "configure", TtkWidgetConfigureCommand,0 },
{ "cget", TtkWidgetCgetCommand,0 },
- { "state", TtkWidgetStateCommand,0 },
- { "instate", TtkWidgetInstateCommand,0 },
+ { "configure", TtkWidgetConfigureCommand,0 },
+ { "coords", ScaleCoordsCommand,0 },
+ { "get", ScaleGetCommand,0 },
{ "identify", TtkWidgetIdentifyCommand,0 },
+ { "instate", TtkWidgetInstateCommand,0 },
{ "set", ScaleSetCommand,0 },
- { "get", ScaleGetCommand,0 },
- { "coords", ScaleCoordsCommand,0 },
+ { "state", TtkWidgetStateCommand,0 },
+ { "style", TtkWidgetStyleCommand,0 },
{ 0,0,0 }
};
-static WidgetSpec ScaleWidgetSpec =
+static const WidgetSpec ScaleWidgetSpec =
{
"TScale", /* Class name */
sizeof(Scale), /* record size */