summaryrefslogtreecommitdiffstats
path: root/generic/ttk/ttkScale.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2010-08-26 02:06:08 (GMT)
committerhobbs <hobbs>2010-08-26 02:06:08 (GMT)
commitb29adcfbfc2e03e058536524f1aa3378b948e7ed (patch)
treefa90e1e6d32590addfbb0a1599a40b1f7f99ea3b /generic/ttk/ttkScale.c
parent7dec1714e5d5efd6b7d095657c1434fa68af0f87 (diff)
downloadtk-b29adcfbfc2e03e058536524f1aa3378b948e7ed.zip
tk-b29adcfbfc2e03e058536524f1aa3378b948e7ed.tar.gz
tk-b29adcfbfc2e03e058536524f1aa3378b948e7ed.tar.bz2
Major backport of 8.6 Ttk for 8.5.9. Most changes were only being
committed to head (8.6), although they could apply for 8.5 as well. This re-sync makes future work easier to maintain and adds some useful work for 8.5 users. Notable changes: - Lots of code cleanup - Some bug fixes never backported - Addition of ttk::spinbox - minor color changes - Improved Vista/7 styling - Move to tile version 0.8.6 (pseudo-package) - ABI and API compatible (even $w identify) - minor new features (extended $w identify)
Diffstat (limited to 'generic/ttk/ttkScale.c')
-rw-r--r--generic/ttk/ttkScale.c55
1 files changed, 22 insertions, 33 deletions
diff --git a/generic/ttk/ttkScale.c b/generic/ttk/ttkScale.c
index 4c8d1eb..10ef3ce 100644
--- a/generic/ttk/ttkScale.c
+++ b/generic/ttk/ttkScale.c
@@ -1,4 +1,4 @@
-/* $Id: ttkScale.c,v 1.7 2007/12/13 15:26:26 dgp Exp $
+/* $Id: ttkScale.c,v 1.7.2.1 2010/08/26 02:06:09 hobbs Exp $
* Copyright (C) 2004 Pat Thoyts <patthoyts@users.sourceforge.net>
*
* ttk::scale widget.
@@ -100,12 +100,10 @@ static void ScaleVariableChanged(void *recordPtr, const char *value)
/* ScaleInitialize --
* Scale widget initialization hook.
*/
-static int ScaleInitialize(Tcl_Interp *interp, void *recordPtr)
+static void ScaleInitialize(Tcl_Interp *interp, void *recordPtr)
{
Scale *scalePtr = recordPtr;
-
TtkTrackElementState(&scalePtr->core);
- return TCL_OK;
}
static void ScaleCleanup(void *recordPtr)
@@ -189,15 +187,7 @@ ScaleGetLayout(Tcl_Interp *interp, Ttk_Theme theme, void *recordPtr)
*/
static Ttk_Box TroughBox(Scale *scalePtr)
{
- WidgetCore *corePtr = &scalePtr->core;
- Ttk_LayoutNode *node = Ttk_LayoutFindNode(corePtr->layout, "trough");
-
- if (node) {
- return Ttk_LayoutNodeInternalParcel(corePtr->layout, node);
- } else {
- return Ttk_MakeBox(
- 0,0, Tk_Width(corePtr->tkwin), Tk_Height(corePtr->tkwin));
- }
+ return Ttk_ClientRegion(scalePtr->core.layout, "trough");
}
/*
@@ -208,13 +198,13 @@ static Ttk_Box TroughBox(Scale *scalePtr)
static Ttk_Box TroughRange(Scale *scalePtr)
{
Ttk_Box troughBox = TroughBox(scalePtr);
- Ttk_LayoutNode *slider=Ttk_LayoutFindNode(scalePtr->core.layout,"slider");
+ Ttk_Element slider = Ttk_FindElement(scalePtr->core.layout,"slider");
/*
* If this is a scale widget, adjust range for slider:
*/
if (slider) {
- Ttk_Box sliderBox = Ttk_LayoutNodeParcel(slider);
+ Ttk_Box sliderBox = Ttk_ElementParcel(slider);
if (scalePtr->scale.orient == TTK_ORIENT_HORIZONTAL) {
troughBox.x += sliderBox.width / 2;
troughBox.width -= sliderBox.width;
@@ -252,7 +242,7 @@ static double ScaleFraction(Scale *scalePtr, double value)
*/
static int
ScaleGetCommand(
- Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
+ void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
Scale *scalePtr = recordPtr;
int x, y, r = TCL_OK;
@@ -280,7 +270,7 @@ ScaleGetCommand(
*/
static int
ScaleSetCommand(
- Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
+ void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
Scale *scalePtr = recordPtr;
double from = 0.0, to = 1.0, value;
@@ -348,7 +338,7 @@ ScaleSetCommand(
static int
ScaleCoordsCommand(
- Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
+ void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
Scale *scalePtr = recordPtr;
double value;
@@ -378,16 +368,16 @@ ScaleCoordsCommand(
static void ScaleDoLayout(void *clientData)
{
WidgetCore *corePtr = clientData;
- Ttk_LayoutNode *sliderNode = Ttk_LayoutFindNode(corePtr->layout, "slider");
+ Ttk_Element slider = Ttk_FindElement(corePtr->layout, "slider");
Ttk_PlaceLayout(corePtr->layout,corePtr->state,Ttk_WinBox(corePtr->tkwin));
/* Adjust the slider position:
*/
- if (sliderNode) {
+ if (slider) {
Scale *scalePtr = clientData;
Ttk_Box troughBox = TroughBox(scalePtr);
- Ttk_Box sliderBox = Ttk_LayoutNodeParcel(sliderNode);
+ Ttk_Box sliderBox = Ttk_ElementParcel(slider);
double value = 0.0;
double fraction;
int range;
@@ -402,7 +392,7 @@ static void ScaleDoLayout(void *clientData)
range = troughBox.height - sliderBox.height;
sliderBox.y += (int)(fraction * range);
}
- Ttk_PlaceLayoutNode(corePtr->layout, sliderNode, sliderBox);
+ Ttk_PlaceElement(corePtr->layout, slider, sliderBox);
}
}
@@ -472,17 +462,16 @@ ValueToPoint(Scale *scalePtr, double value)
return pt;
}
-static WidgetCommandSpec ScaleCommands[] =
-{
- { "configure", TtkWidgetConfigureCommand },
- { "cget", TtkWidgetCgetCommand },
- { "state", TtkWidgetStateCommand },
- { "instate", TtkWidgetInstateCommand },
- { "identify", TtkWidgetIdentifyCommand },
- { "set", ScaleSetCommand },
- { "get", ScaleGetCommand },
- { "coords", ScaleCoordsCommand },
- { 0, 0 }
+static const Ttk_Ensemble ScaleCommands[] = {
+ { "configure", TtkWidgetConfigureCommand,0 },
+ { "cget", TtkWidgetCgetCommand,0 },
+ { "state", TtkWidgetStateCommand,0 },
+ { "instate", TtkWidgetInstateCommand,0 },
+ { "identify", TtkWidgetIdentifyCommand,0 },
+ { "set", ScaleSetCommand,0 },
+ { "get", ScaleGetCommand,0 },
+ { "coords", ScaleCoordsCommand,0 },
+ { 0,0,0 }
};
static WidgetSpec ScaleWidgetSpec =