Tk Source Code

Changes On Branch rfe-71107a79fa
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch rfe-71107a79fa Excluding Merge-Ins

This is equivalent to a diff from 1711aa76 to fd244465

2019-12-01
18:14
Implement RFE [71107a79fa]: allow ttk::progressbar to grow in reverse direction Closed-Leaf check-in: fd244465 user: fvogel tags: rfe-71107a79fa
16:39
Merge 8.6. When compiling against Tcl 9.0 headers, don't allow Emoji escape sequences to be split into two surrugates any more. check-in: 0ec184f4 user: jan.nijtmans tags: trunk
2019-11-30
20:19
Implementation of TIP #556 (Add oo like widgets to Tk). Files committed on behalf of RenĂ© Zaumseil. check-in: d4bb7b69 user: fvogel tags: tip-556
2019-11-29
16:26
Merge 8.6 check-in: 1711aa76 user: jan.nijtmans tags: trunk
15:49
Fix [d4f5620f5d]: font-4.14 fails (font actual with unicode). Add another test-case for TCL_UTF_MAX>3 check-in: 2e2afd52 user: jan.nijtmans tags: core-8-6-branch
2019-11-27
12:37
Update to a (slightly) later version of X11R6 headers. check-in: 0c6bbf57 user: jan.nijtmans tags: trunk

Changes to doc/ttk_progressbar.n.
46
47
48
49
50
51
52






53
54
55
56
57
58
59
.OP \-phase phase Phase
Read-only option.
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 \-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
.QW cycle
when the \fB\-value\fR increases by \fB\-maximum\fR.







>
>
>
>
>
>







46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
.OP \-phase phase Phase
Read-only option.
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
.QW cycle
when the \fB\-value\fR increases by \fB\-maximum\fR.
Changes to generic/ttk/ttkProgress.c.
26
27
28
29
30
31
32

33
34
35
36
37
38
39
    Tcl_Obj 	*foregroundObj;
    Tcl_Obj 	*justifyObj;
    Tcl_Obj 	*lengthObj;
    Tcl_Obj 	*maximumObj;
    Tcl_Obj 	*modeObj;
    Tcl_Obj 	*orientObj;
    Tcl_Obj 	*phaseObj;

    Tcl_Obj 	*textObj;
    Tcl_Obj 	*valueObj;
    Tcl_Obj 	*variableObj;
    Tcl_Obj 	*wrapLengthObj;

    int 	mode;
    Ttk_TraceHandle *variableTrace;	/* Trace handle for -variable option */







>







26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
    Tcl_Obj 	*foregroundObj;
    Tcl_Obj 	*justifyObj;
    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;

    int 	mode;
    Ttk_TraceHandle *variableTrace;	/* Trace handle for -variable option */
74
75
76
77
78
79
80



81
82
83
84
85
86
87
	0, (ClientData)ProgressbarModeStrings, 0 },
    {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient",
	"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_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,
	0, 0, 0 },
    {TK_OPTION_STRING, "-variable", "variable", "Variable",







>
>
>







75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
	0, (ClientData)ProgressbarModeStrings, 0 },
    {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient",
	"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,
	0, 0, 0 },
    {TK_OPTION_STRING, "-variable", "variable", "Variable",
313
314
315
316
317
318
319
320

321
322
323
324
325
326




327
328

329

330
331
332
333
334
335
336
 */

static void ProgressbarDeterminateLayout(
    Progressbar *pb,
    Ttk_Element pbar,
    Ttk_Box parcel,
    double fraction,
    Ttk_Orient orient)

{
    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);




    } else {
	int newHeight = (int)(parcel.height * fraction);

	parcel.y += (parcel.height - newHeight);

	parcel.height = newHeight;
    }
    Ttk_PlaceElement(pb->core.layout, pbar, parcel);
}

static void ProgressbarIndeterminateLayout(
    Progressbar *pb,







|
>





|
>
>
>
>


>
|
>







317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
 */

static void ProgressbarDeterminateLayout(
    Progressbar *pb,
    Ttk_Element pbar,
    Ttk_Box parcel,
    double fraction,
    Ttk_Orient orient,
    int reverse)
{
    if (fraction < 0.0) fraction = 0.0;
    if (fraction > 1.0) fraction = 1.0;

    if (orient == TTK_ORIENT_HORIZONTAL) {
	int newWidth = (int)(parcel.width * fraction);
        if (reverse == 1) {
            parcel.x += (parcel.width - newWidth);
        }
        parcel.width = newWidth;
    } else {
	int newHeight = (int)(parcel.height * fraction);
        if (reverse == 0) {
	    parcel.y += (parcel.height - newHeight);
        }
	parcel.height = newHeight;
    }
    Ttk_PlaceElement(pb->core.layout, pbar, parcel);
}

static void ProgressbarIndeterminateLayout(
    Progressbar *pb,
357
358
359
360
361
362
363

364
365
366
367
368
369
370
371
372

373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
static void ProgressbarDoLayout(void *recordPtr)
{
    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;


    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);


    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);
	} else {
	    ProgressbarIndeterminateLayout(
		pb, pbar, parcel, fraction, orient);
	}
    }
}








>









>







|







368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
static void ProgressbarDoLayout(void *recordPtr)
{
    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, reverse);
	} else {
	    ProgressbarIndeterminateLayout(
		pb, pbar, parcel, fraction, orient);
	}
    }
}