Index: doc/ttk_progressbar.n ================================================================== --- doc/ttk_progressbar.n +++ doc/ttk_progressbar.n @@ -48,10 +48,16 @@ The widget periodically increments the value of this option whenever the \fB\-value\fR is greater than 0 and, in \fIdeterminate\fR mode, less than \fB\-maximum\fR. This option may be used by the current theme to provide additional animation effects. +.OP \-reverse reverse Reverse +A boolean specifying the direction the progress bar grows when its \fB\-value\fR +increases. If false, an horizontal progressbar grows from left to right and +a vertical progressbar grows from bottom to top. If true, the progressbar +grows in the reverse direction. This option defaults to false and is +only taken into account in \fIdeterminate\fR mode. .OP \-value value Value The current value of the progress bar. In \fIdeterminate\fR mode, this represents the amount of work completed. In \fIindeterminate\fR mode, it is interpreted modulo \fB\-maximum\fR; that is, the progress bar completes one Index: generic/ttk/ttkProgress.c ================================================================== --- generic/ttk/ttkProgress.c +++ generic/ttk/ttkProgress.c @@ -28,10 +28,11 @@ Tcl_Obj *lengthObj; Tcl_Obj *maximumObj; Tcl_Obj *modeObj; Tcl_Obj *orientObj; Tcl_Obj *phaseObj; + Tcl_Obj *reverseObj; Tcl_Obj *textObj; Tcl_Obj *valueObj; Tcl_Obj *variableObj; Tcl_Obj *wrapLengthObj; @@ -76,10 +77,13 @@ "horizontal", offsetof(Progressbar,progress.orientObj), -1, 0, (ClientData)ttkOrientStrings, STYLE_CHANGED }, {TK_OPTION_INT, "-phase", "phase", "Phase", "0", offsetof(Progressbar,progress.phaseObj), -1, 0, 0, 0 }, + {TK_OPTION_BOOLEAN, "-reverse", "reverse", "Reverse", + "0", offsetof(Progressbar,progress.reverseObj), -1, + 0, 0, GEOMETRY_CHANGED }, {TK_OPTION_STRING, "-text", "text", "Text", "", offsetof(Progressbar,progress.textObj), -1, 0,0,GEOMETRY_CHANGED }, {TK_OPTION_DOUBLE, "-value", "value", "Value", "0.0", offsetof(Progressbar,progress.valueObj), -1, @@ -315,20 +319,27 @@ static void ProgressbarDeterminateLayout( Progressbar *pb, Ttk_Element pbar, Ttk_Box parcel, double fraction, - Ttk_Orient orient) + Ttk_Orient orient, + int reverse) { if (fraction < 0.0) fraction = 0.0; if (fraction > 1.0) fraction = 1.0; if (orient == TTK_ORIENT_HORIZONTAL) { - parcel.width = (int)(parcel.width * fraction); + int newWidth = (int)(parcel.width * fraction); + if (reverse == 1) { + parcel.x += (parcel.width - newWidth); + } + parcel.width = newWidth; } else { int newHeight = (int)(parcel.height * fraction); - parcel.y += (parcel.height - newHeight); + if (reverse == 0) { + parcel.y += (parcel.height - newHeight); + } parcel.height = newHeight; } Ttk_PlaceElement(pb->core.layout, pbar, parcel); } @@ -359,27 +370,29 @@ Progressbar *pb = recordPtr; WidgetCore *corePtr = &pb->core; Ttk_Element pbar = Ttk_FindElement(corePtr->layout, "pbar"); double value = 0.0, maximum = 100.0; int orient = TTK_ORIENT_HORIZONTAL; + int reverse; Ttk_PlaceLayout(corePtr->layout,corePtr->state,Ttk_WinBox(corePtr->tkwin)); /* Adjust the bar size: */ Tcl_GetDoubleFromObj(NULL, pb->progress.valueObj, &value); Tcl_GetDoubleFromObj(NULL, pb->progress.maximumObj, &maximum); Ttk_GetOrientFromObj(NULL, pb->progress.orientObj, &orient); + Tcl_GetBooleanFromObj(NULL, pb->progress.reverseObj, &reverse); if (pbar) { double fraction = value / maximum; Ttk_Box parcel = Ttk_ClientRegion(corePtr->layout, "trough"); if (pb->progress.mode == TTK_PROGRESSBAR_DETERMINATE) { ProgressbarDeterminateLayout( - pb, pbar, parcel, fraction, orient); + pb, pbar, parcel, fraction, orient, reverse); } else { ProgressbarIndeterminateLayout( pb, pbar, parcel, fraction, orient); } }