From ee16a52044d53a25664ecc7f02b042e3fb638baf Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 18 Aug 2016 19:05:41 +0000 Subject: =?UTF-8?q?Implementation=20of=20TIP=20#442=20by=20Ren=C3=A9=20Zau?= =?UTF-8?q?mseil=20-=20Display=20text=20in=20progressbars?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- generic/ttk/ttkProgress.c | 27 ++++++++++++++++++++++++++- library/ttk/vistaTheme.tcl | 1 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/generic/ttk/ttkProgress.c b/generic/ttk/ttkProgress.c index eed90ec..bd0b814 100644 --- a/generic/ttk/ttkProgress.c +++ b/generic/ttk/ttkProgress.c @@ -30,6 +30,12 @@ typedef struct { Tcl_Obj *maximumObj; Tcl_Obj *valueObj; Tcl_Obj *phaseObj; + Tcl_Obj *textObj; + Tcl_Obj *fontObj; + Tcl_Obj *foregroundObj; + Tcl_Obj *anchorObj; + Tcl_Obj *justifyObj; + Tcl_Obj *wrapLengthObj; int mode; Ttk_TraceHandle *variableTrace; /* Trace handle for -variable option */ @@ -68,6 +74,24 @@ static Tk_OptionSpec ProgressbarOptionSpecs[] = {TK_OPTION_INT, "-phase", "phase", "Phase", "0", Tk_Offset(Progressbar,progress.phaseObj), -1, 0, 0, 0 }, + {TK_OPTION_STRING, "-text", "text", "Text", "", + Tk_Offset(Progressbar,progress.textObj), -1, + 0,0,GEOMETRY_CHANGED }, + {TK_OPTION_FONT, "-font", "font", "Font", + DEFAULT_FONT, Tk_Offset(Progressbar,progress.fontObj), -1, + TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, + {TK_OPTION_COLOR, "-foreground", "textColor", "TextColor", + "black", Tk_Offset(Progressbar,progress.foregroundObj), -1, + TK_OPTION_NULL_OK,0,0 }, + {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", + "w", Tk_Offset(Progressbar,progress.anchorObj), -1, + TK_OPTION_NULL_OK, 0, GEOMETRY_CHANGED}, + {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", + "left", Tk_Offset(Progressbar,progress.justifyObj), -1, + TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, + {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength", + "0", Tk_Offset(Progressbar, progress.wrapLengthObj), -1, + TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED}, WIDGET_TAKEFOCUS_FALSE, WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) @@ -522,7 +546,8 @@ TTK_END_LAYOUT TTK_BEGIN_LAYOUT(HorizontalProgressbarLayout) TTK_GROUP("Horizontal.Progressbar.trough", TTK_FILL_BOTH, - TTK_NODE("Horizontal.Progressbar.pbar", TTK_PACK_LEFT|TTK_FILL_Y)) + TTK_NODE("Horizontal.Progressbar.pbar", TTK_PACK_LEFT|TTK_FILL_Y) + TTK_NODE("Horizontal.Progressbar.text", TTK_PACK_LEFT)) TTK_END_LAYOUT /* diff --git a/library/ttk/vistaTheme.tcl b/library/ttk/vistaTheme.tcl index 1ec824a..c284a52 100644 --- a/library/ttk/vistaTheme.tcl +++ b/library/ttk/vistaTheme.tcl @@ -182,6 +182,7 @@ namespace eval ttk::theme::vista { ttk::style layout Horizontal.TProgressbar { Horizontal.Progressbar.trough -sticky nswe -children { Horizontal.Progressbar.pbar -side left -sticky ns + Horizontal.Progressbar.text -sticky nesw } } ttk::style element create Vertical.Progressbar.pbar vsapi \ -- cgit v0.12 From aa4022a388d07e718331f5a593fc2ed6e0572fa9 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 6 Mar 2017 18:30:38 +0000 Subject: =?UTF-8?q?Updated=20patch=20from=20Ren=C3=A9=20Zaumseil,=20now=20?= =?UTF-8?q?consistent=20with=20the=20proposed=20implementation=20at=20http?= =?UTF-8?q?://wiki.tcl.tk/20059?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- generic/ttk/ttkButton.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/generic/ttk/ttkButton.c b/generic/ttk/ttkButton.c index c00754b..ef55ec3 100644 --- a/generic/ttk/ttkButton.c +++ b/generic/ttk/ttkButton.c @@ -23,6 +23,7 @@ typedef struct * Text element resources: */ Tcl_Obj *textObj; + Tcl_Obj *justifyObj; Tcl_Obj *textVariableObj; Tcl_Obj *underlineObj; Tcl_Obj *widthObj; @@ -56,6 +57,9 @@ typedef struct static Tk_OptionSpec BaseOptionSpecs[] = { + {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", + "left", Tk_Offset(Base,base.justifyObj), -1, + TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, {TK_OPTION_STRING, "-text", "text", "Text", "", Tk_Offset(Base,base.textObj), -1, 0,0,GEOMETRY_CHANGED }, -- cgit v0.12 From b536633b39243893edda31138eec6653e484759b Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 7 Mar 2017 20:46:17 +0000 Subject: Document -justify for ttk::button --- doc/ttk_button.n | 2 +- doc/ttk_label.n | 7 +------ doc/ttk_widget.n | 5 +++++ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/ttk_button.n b/doc/ttk_button.n index 62ebe47..e7c88b2 100644 --- a/doc/ttk_button.n +++ b/doc/ttk_button.n @@ -17,7 +17,7 @@ A \fBttk::button\fR widget displays a textual label and/or image, and evaluates a command when pressed. .SO ttk_widget \-class \-compound \-cursor -\-image \-state \-style +\-image \-justify \-state \-style \-takefocus \-text \-textvariable \-underline \-width .SE diff --git a/doc/ttk_label.n b/doc/ttk_label.n index 6781b47..e891954 100644 --- a/doc/ttk_label.n +++ b/doc/ttk_label.n @@ -19,7 +19,7 @@ The label may be linked to a Tcl variable to automatically change the displayed text. .SO ttk_widget \-class \-compound \-cursor -\-image \-style \-takefocus +\-image \-justify \-style \-takefocus \-text \-textvariable \-underline \-width .SE @@ -38,11 +38,6 @@ Font to use for label text. .OP \-foreground textColor TextColor The widget's foreground color. If unspecified, the theme default is used. -.OP \-justify justify Justify -If there are multiple lines of text, specifies how -the lines are laid out relative to one another. -One of \fBleft\fR, \fBcenter\fR, or \fBright\fR. -See also \fB\-anchor\fR. .OP \-padding padding Padding Specifies the amount of extra space to allocate for the widget. The padding is a list of up to four length specifications diff --git a/doc/ttk_widget.n b/doc/ttk_widget.n index 2ecc29f..1ab3bc8 100644 --- a/doc/ttk_widget.n +++ b/doc/ttk_widget.n @@ -71,6 +71,11 @@ See the description of \fB\-xscrollcommand\fR above for details. .SH "LABEL OPTIONS" The following options are supported by labels, buttons, and other button-like widgets: +.OP \-justify justify Justify +If there are multiple lines of text, specifies how +the lines are laid out relative to one another. +One of \fBleft\fR, \fBcenter\fR, or \fBright\fR. +See also \fB\-anchor\fR (for widgets supporting this option). .OP \-text text Text Specifies a text string to be displayed inside the widget (unless overridden by \fB\-textvariable\fR). -- cgit v0.12 From 1b348a666d6104aa075165cdea1b1ce4bb12323b Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 7 Mar 2017 21:43:51 +0000 Subject: Document the new options for ttk::progressbar --- doc/ttk_label.n | 23 +++---------------- doc/ttk_progressbar.n | 35 +++++++++++++++++------------ doc/ttk_widget.n | 61 ++++++++++++++++++++++++++++++++------------------- 3 files changed, 62 insertions(+), 57 deletions(-) diff --git a/doc/ttk_label.n b/doc/ttk_label.n index e891954..a9e7f11 100644 --- a/doc/ttk_label.n +++ b/doc/ttk_label.n @@ -18,26 +18,18 @@ A \fBttk::label\fR widget displays a textual label and/or image. The label may be linked to a Tcl variable to automatically change the displayed text. .SO ttk_widget -\-class \-compound \-cursor +\-anchor \-class \-compound \-cursor +\-foreground \-image \-justify \-style \-takefocus \-text \-textvariable \-underline -\-width +\-width \-wraplength .SE .SH "WIDGET-SPECIFIC OPTIONS" -.OP \-anchor anchor Anchor -Specifies how the information in the widget is positioned -relative to the inner margins. Legal values are -\fBn\fR, \fBne\fR, \fBe\fR, \fBse\fR, -\fBs\fR, \fBsw\fR, \fBw\fR, \fBnw\fR, and \fBcenter\fR. -See also \fB\-justify\fR. .OP \-background frameColor FrameColor The widget's background color. If unspecified, the theme default is used. .OP \-font font Font Font to use for label text. -.OP \-foreground textColor TextColor -The widget's foreground color. -If unspecified, the theme default is used. .OP \-padding padding Padding Specifies the amount of extra space to allocate for the widget. The padding is a list of up to four length specifications @@ -52,15 +44,6 @@ Specifies the 3-D effect desired for the widget border. Valid values are \fBflat\fR, \fBgroove\fR, \fBraised\fR, \fBridge\fR, \fBsolid\fR, and \fBsunken\fR. -.OP \-text text Text -Specifies a text string to be displayed inside the widget -(unless overridden by \fB\-textvariable\fR). -.OP \-wraplength wrapLength WrapLength -Specifies the maximum line length (in pixels). -If this option is less than or equal to zero, -then automatic wrapping is not performed; otherwise -the text is split into lines such that no line is longer -than the specified value. .SH "WIDGET COMMAND" .PP Supports the standard widget commands diff --git a/doc/ttk_progressbar.n b/doc/ttk_progressbar.n index 1945f70..33da815 100644 --- a/doc/ttk_progressbar.n +++ b/doc/ttk_progressbar.n @@ -19,22 +19,36 @@ operation. They can operate in two modes: \fIdeterminate\fR mode shows the amount completed relative to the total amount of work to be done, and \fIindeterminate\fR mode provides an animated display to let the user know that something is happening. +.PP +If the value of \fB-orient\fR is \fBhorizontal\fR a text string can be +displayed inside the progressbar. This string can be configured using +the \fB-anchor\fR, \fB-text\fR, \fB-foreground\fR, \fB-justify\fR and +\fB-wraplength\fR options. If the value of \fB-orient\fR is \fBvertical\fR +then these options are ignored. .SO ttk_widget -\-class \-cursor \-takefocus -\-style +\-anchor \-class \-cursor +\-foreground \-justify \-style +\-takefocus \-text \-wraplength .SE .SH "WIDGET-SPECIFIC OPTIONS" -.OP \-orient orient Orient -One of \fBhorizontal\fR or \fBvertical\fR. -Specifies the orientation of the progress bar. .OP \-length length Length Specifies the length of the long axis of the progress bar (width if horizontal, height if vertical). -.OP \-mode mode Mode -One of \fBdeterminate\fR or \fBindeterminate\fR. .OP \-maximum maximum Maximum A floating point number specifying the maximum \fB\-value\fR. Defaults to 100. +.OP \-mode mode Mode +One of \fBdeterminate\fR or \fBindeterminate\fR. +.OP \-orient orient Orient +One of \fBhorizontal\fR or \fBvertical\fR. +Specifies the orientation of the progress bar. +.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. @@ -47,13 +61,6 @@ The name of a global Tcl variable which is linked to the \fB\-value\fR. If specified, the \fB\-value\fR of the progress bar is automatically set to the value of the variable whenever the latter is modified. -.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. .SH "WIDGET COMMAND" .PP .TP diff --git a/doc/ttk_widget.n b/doc/ttk_widget.n index 1ab3bc8..f8bf98b 100644 --- a/doc/ttk_widget.n +++ b/doc/ttk_widget.n @@ -71,29 +71,12 @@ See the description of \fB\-xscrollcommand\fR above for details. .SH "LABEL OPTIONS" The following options are supported by labels, buttons, and other button-like widgets: -.OP \-justify justify Justify -If there are multiple lines of text, specifies how -the lines are laid out relative to one another. -One of \fBleft\fR, \fBcenter\fR, or \fBright\fR. -See also \fB\-anchor\fR (for widgets supporting this option). -.OP \-text text Text -Specifies a text string to be displayed inside the widget -(unless overridden by \fB\-textvariable\fR). -.OP \-textvariable textVariable Variable -Specifies the name of a global variable whose value will be used -in place of the \fB\-text\fR resource. -.OP \-underline underline Underline -If set, specifies the integer index (0-based) of a character to underline -in the text string. -The underlined character is used for mnemonic activation. -.OP \-image image Image -Specifies an image to display. -This is a list of 1 or more elements. -The first element is the default image name. -The rest of the list is a sequence of \fIstatespec / value\fR pairs -as per \fBstyle map\fR, specifying different images to use when -the widget is in a particular state or combination of states. -All images in the list should have the same size. +.OP \-anchor anchor Anchor +Specifies how the information in the widget is positioned +relative to the inner margins. Legal values are +\fBn\fR, \fBne\fR, \fBe\fR, \fBse\fR, +\fBs\fR, \fBsw\fR, \fBw\fR, \fBnw\fR, and \fBcenter\fR. +See also \fB\-justify\fR (for widgets supporting this option). .OP \-compound compound Compound Specifies how to display the image relative to the text, in the case both \fB\-text\fR and \fB\-image\fR are present. @@ -113,11 +96,43 @@ Display image above, below, left of, or right of the text, respectively. .IP none The default; display the image if present, otherwise the text. .RE +.OP \-foreground textColor TextColor +The widget's foreground color. +If unspecified, the theme default is used. +.OP \-image image Image +Specifies an image to display. +This is a list of 1 or more elements. +The first element is the default image name. +The rest of the list is a sequence of \fIstatespec / value\fR pairs +as per \fBstyle map\fR, specifying different images to use when +the widget is in a particular state or combination of states. +All images in the list should have the same size. +.OP \-justify justify Justify +If there are multiple lines of text, specifies how +the lines are laid out relative to one another. +One of \fBleft\fR, \fBcenter\fR, or \fBright\fR. +See also \fB\-anchor\fR (for widgets supporting this option). +.OP \-text text Text +Specifies a text string to be displayed inside the widget +(unless overridden by \fB\-textvariable\fR for the widgets supporting this option). +.OP \-textvariable textVariable Variable +Specifies the name of a global variable whose value will be used +in place of the \fB\-text\fR resource. +.OP \-underline underline Underline +If set, specifies the integer index (0-based) of a character to underline +in the text string. +The underlined character is used for mnemonic activation. .OP \-width width Width If greater than zero, specifies how much space, in character widths, to allocate for the text label. If less than zero, specifies a minimum width. If zero or unspecified, the natural width of the text label is used. +.OP \-wraplength wrapLength WrapLength +Specifies the maximum line length (in pixels). +If this option is less than or equal to zero, +then automatic wrapping is not performed; otherwise +the text is split into lines such that no line is longer +than the specified value. .SH "COMPATIBILITY OPTIONS" .OP \-state state State May be set to \fBnormal\fR or \fBdisabled\fR -- cgit v0.12 From eddcfed96bcaffb3ba5a2ced5b3c826943e0c51b Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 7 Mar 2017 22:00:03 +0000 Subject: Remove duplicate documentation of -width in ttk::button --- doc/ttk_button.n | 7 ------- doc/ttk_widget.n | 2 ++ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/doc/ttk_button.n b/doc/ttk_button.n index e7c88b2..f76de6c 100644 --- a/doc/ttk_button.n +++ b/doc/ttk_button.n @@ -39,13 +39,6 @@ The default is \fBnormal\fR. Depending on the theme, the default button may be displayed with an extra highlight ring, or with a different border color. .RE -.OP \-width width Width -If greater than zero, specifies how much space, in character widths, -to allocate for the text label. -If less than zero, specifies a minimum width. -If zero or unspecified, the natural width of the text label is used. -Note that some themes may specify a non-zero \fB\-width\fR -in the style. .\" Not documented -- may go away .\" .OP \-padding padding Padding .\" .OP \-foreground foreground Foreground diff --git a/doc/ttk_widget.n b/doc/ttk_widget.n index f8bf98b..3d3d52e 100644 --- a/doc/ttk_widget.n +++ b/doc/ttk_widget.n @@ -127,6 +127,8 @@ If greater than zero, specifies how much space, in character widths, to allocate for the text label. If less than zero, specifies a minimum width. If zero or unspecified, the natural width of the text label is used. +Note that some themes may specify a non-zero \fB\-width\fR +in the style. .OP \-wraplength wrapLength WrapLength Specifies the maximum line length (in pixels). If this option is less than or equal to zero, -- cgit v0.12 From 2a9ec78640adf4771ef371035ab3d4bb5207acf2 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 11 Mar 2017 10:38:10 +0000 Subject: Add minimal testing of the ttk::progressbar options --- tests/ttk/progressbar.test | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/ttk/progressbar.test b/tests/ttk/progressbar.test index b9add86..bd53f2e 100644 --- a/tests/ttk/progressbar.test +++ b/tests/ttk/progressbar.test @@ -82,4 +82,19 @@ test progressbar-end "Cleanup" -body { destroy .pb } +# check existence and default value of each non-core option of the widget +test progressbar-3.1 "progressbar non-core options" -setup { + set res {} + ttk::progressbar .defaultpb +} -body { + foreach option {-anchor -foreground -justify -style -text -wraplength \ + -length -maximum -mode -orient -phase -value -variable} { + lappend res [.defaultpb cget $option] + } + set res +} -cleanup { + unset res + destroy .defaultpb +} -result {w black left {} {} 0 100 100 determinate horizontal 0 0.0 {}} + tcltest::cleanupTests -- cgit v0.12 From 11e3592a11d54f1f9be294b842a526a9c3c6ef67 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 13 Mar 2017 13:33:38 +0000 Subject: =?UTF-8?q?Add=20test=20progressbar-3.2=20(tweaked=20from=20a=20pr?= =?UTF-8?q?oposal=20from=20Ren=C3=A9=20Zaumseil)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/ttk/progressbar.test | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/ttk/progressbar.test b/tests/ttk/progressbar.test index bd53f2e..7c888c6 100644 --- a/tests/ttk/progressbar.test +++ b/tests/ttk/progressbar.test @@ -97,4 +97,28 @@ test progressbar-3.1 "progressbar non-core options" -setup { destroy .defaultpb } -result {w black left {} {} 0 100 100 determinate horizontal 0 0.0 {}} +test progressbar-3.2 "TIP #442 options are taken into account" -setup { + set res {} + pack [ttk::progressbar .p -value 0 -maximum 50 -orient horizontal -mode determinate -length 500] + set thefont [font actual {Arial 10}] +} -body { + .p configure -anchor c -foreground blue -justify right \ + -text "TIP #442\noptions are now tested" -wraplength 100 + update + .p step 10 + .p configure -anchor e -font $thefont -foreground green -justify center \ + -text "Changing the value of each option\nfrom TIP #442" -wraplength 250 + update + .p step 20 + .p configure -orient vertical -text "Cannot be seen" + update + foreach option {-anchor -foreground -justify -text -wraplength} { + lappend res [list $option [.p cget $option]] + } + set res +} -cleanup { + unset res thefont + destroy .p +} -result {{-anchor e} {-foreground green} {-justify center} {-text {Cannot be seen}} {-wraplength 250}} + tcltest::cleanupTests -- cgit v0.12 From 32b29153c1c63a7e08d4325c1fe68ae511a5ed36 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 13 Mar 2017 13:43:12 +0000 Subject: Reorder progressbar options alphabetically (to follow the standard convention in the source code) --- generic/ttk/ttkProgress.c | 64 +++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/generic/ttk/ttkProgress.c b/generic/ttk/ttkProgress.c index bd0b814..7787390 100644 --- a/generic/ttk/ttkProgress.c +++ b/generic/ttk/ttkProgress.c @@ -23,18 +23,18 @@ static const char *const ProgressbarModeStrings[] = { }; typedef struct { - Tcl_Obj *orientObj; + Tcl_Obj *anchorObj; + Tcl_Obj *fontObj; + Tcl_Obj *foregroundObj; + Tcl_Obj *justifyObj; Tcl_Obj *lengthObj; - Tcl_Obj *modeObj; - Tcl_Obj *variableObj; Tcl_Obj *maximumObj; - Tcl_Obj *valueObj; + Tcl_Obj *modeObj; + Tcl_Obj *orientObj; Tcl_Obj *phaseObj; Tcl_Obj *textObj; - Tcl_Obj *fontObj; - Tcl_Obj *foregroundObj; - Tcl_Obj *anchorObj; - Tcl_Obj *justifyObj; + Tcl_Obj *valueObj; + Tcl_Obj *variableObj; Tcl_Obj *wrapLengthObj; int mode; @@ -52,43 +52,43 @@ typedef struct { static Tk_OptionSpec ProgressbarOptionSpecs[] = { - {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", - "horizontal", Tk_Offset(Progressbar,progress.orientObj), -1, - 0, (ClientData)ttkOrientStrings, STYLE_CHANGED }, + {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", + "w", Tk_Offset(Progressbar,progress.anchorObj), -1, + TK_OPTION_NULL_OK, 0, GEOMETRY_CHANGED}, + {TK_OPTION_FONT, "-font", "font", "Font", + DEFAULT_FONT, Tk_Offset(Progressbar,progress.fontObj), -1, + TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, + {TK_OPTION_COLOR, "-foreground", "textColor", "TextColor", + "black", Tk_Offset(Progressbar,progress.foregroundObj), -1, + TK_OPTION_NULL_OK,0,0 }, + {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", + "left", Tk_Offset(Progressbar,progress.justifyObj), -1, + TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, {TK_OPTION_PIXELS, "-length", "length", "Length", DEF_PROGRESSBAR_LENGTH, Tk_Offset(Progressbar,progress.lengthObj), -1, 0, 0, GEOMETRY_CHANGED }, + {TK_OPTION_DOUBLE, "-maximum", "maximum", "Maximum", + "100", Tk_Offset(Progressbar,progress.maximumObj), -1, + 0, 0, 0 }, {TK_OPTION_STRING_TABLE, "-mode", "mode", "ProgressMode", "determinate", Tk_Offset(Progressbar,progress.modeObj), Tk_Offset(Progressbar,progress.mode), 0, (ClientData)ProgressbarModeStrings, 0 }, - {TK_OPTION_DOUBLE, "-maximum", "maximum", "Maximum", - "100", Tk_Offset(Progressbar,progress.maximumObj), -1, - 0, 0, 0 }, - {TK_OPTION_STRING, "-variable", "variable", "Variable", - NULL, Tk_Offset(Progressbar,progress.variableObj), -1, - TK_OPTION_NULL_OK, 0, 0 }, - {TK_OPTION_DOUBLE, "-value", "value", "Value", - "0.0", Tk_Offset(Progressbar,progress.valueObj), -1, - 0, 0, 0 }, + {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", + "horizontal", Tk_Offset(Progressbar,progress.orientObj), -1, + 0, (ClientData)ttkOrientStrings, STYLE_CHANGED }, {TK_OPTION_INT, "-phase", "phase", "Phase", "0", Tk_Offset(Progressbar,progress.phaseObj), -1, 0, 0, 0 }, {TK_OPTION_STRING, "-text", "text", "Text", "", Tk_Offset(Progressbar,progress.textObj), -1, 0,0,GEOMETRY_CHANGED }, - {TK_OPTION_FONT, "-font", "font", "Font", - DEFAULT_FONT, Tk_Offset(Progressbar,progress.fontObj), -1, - TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, - {TK_OPTION_COLOR, "-foreground", "textColor", "TextColor", - "black", Tk_Offset(Progressbar,progress.foregroundObj), -1, - TK_OPTION_NULL_OK,0,0 }, - {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", - "w", Tk_Offset(Progressbar,progress.anchorObj), -1, - TK_OPTION_NULL_OK, 0, GEOMETRY_CHANGED}, - {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", - "left", Tk_Offset(Progressbar,progress.justifyObj), -1, - TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, + {TK_OPTION_DOUBLE, "-value", "value", "Value", + "0.0", Tk_Offset(Progressbar,progress.valueObj), -1, + 0, 0, 0 }, + {TK_OPTION_STRING, "-variable", "variable", "Variable", + NULL, Tk_Offset(Progressbar,progress.variableObj), -1, + TK_OPTION_NULL_OK, 0, 0 }, {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength", "0", Tk_Offset(Progressbar, progress.wrapLengthObj), -1, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED}, -- cgit v0.12 From c1648c48e32da4bf83827f3a11abed72a94640c8 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 13 Mar 2017 13:59:57 +0000 Subject: Document units for -length and -wraplength --- doc/ttk_progressbar.n | 3 ++- doc/ttk_widget.n | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/ttk_progressbar.n b/doc/ttk_progressbar.n index 33da815..6967bd4 100644 --- a/doc/ttk_progressbar.n +++ b/doc/ttk_progressbar.n @@ -33,7 +33,8 @@ then these options are ignored. .SH "WIDGET-SPECIFIC OPTIONS" .OP \-length length Length Specifies the length of the long axis of the progress bar -(width if horizontal, height if vertical). +(width if horizontal, height if vertical). The value may have any of the forms +acceptable to \fBTk_GetPixels\fR. .OP \-maximum maximum Maximum A floating point number specifying the maximum \fB\-value\fR. Defaults to 100. diff --git a/doc/ttk_widget.n b/doc/ttk_widget.n index 3d3d52e..7a770cc 100644 --- a/doc/ttk_widget.n +++ b/doc/ttk_widget.n @@ -130,9 +130,9 @@ If zero or unspecified, the natural width of the text label is used. Note that some themes may specify a non-zero \fB\-width\fR in the style. .OP \-wraplength wrapLength WrapLength -Specifies the maximum line length (in pixels). -If this option is less than or equal to zero, -then automatic wrapping is not performed; otherwise +Specifies the maximum line length. The value may have any of the forms +acceptable to \fBTk_GetPixels\fR. If this option is less than or equal +to zero, then automatic wrapping is not performed; otherwise the text is split into lines such that no line is longer than the specified value. .SH "COMPATIBILITY OPTIONS" -- cgit v0.12 From f3cb1aadffad99fd9e2e5ecf33afefceb2b4efe1 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 13 Mar 2017 14:10:32 +0000 Subject: Document -font for ttk::progressbar --- doc/ttk_label.n | 4 +--- doc/ttk_progressbar.n | 8 ++++---- doc/ttk_widget.n | 2 ++ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/ttk_label.n b/doc/ttk_label.n index a9e7f11..c11240f 100644 --- a/doc/ttk_label.n +++ b/doc/ttk_label.n @@ -19,7 +19,7 @@ The label may be linked to a Tcl variable to automatically change the displayed text. .SO ttk_widget \-anchor \-class \-compound \-cursor -\-foreground +\-font \-foreground \-image \-justify \-style \-takefocus \-text \-textvariable \-underline \-width \-wraplength @@ -28,8 +28,6 @@ to automatically change the displayed text. .OP \-background frameColor FrameColor The widget's background color. If unspecified, the theme default is used. -.OP \-font font Font -Font to use for label text. .OP \-padding padding Padding Specifies the amount of extra space to allocate for the widget. The padding is a list of up to four length specifications diff --git a/doc/ttk_progressbar.n b/doc/ttk_progressbar.n index 6967bd4..74d9698 100644 --- a/doc/ttk_progressbar.n +++ b/doc/ttk_progressbar.n @@ -22,12 +22,12 @@ that something is happening. .PP If the value of \fB-orient\fR is \fBhorizontal\fR a text string can be displayed inside the progressbar. This string can be configured using -the \fB-anchor\fR, \fB-text\fR, \fB-foreground\fR, \fB-justify\fR and -\fB-wraplength\fR options. If the value of \fB-orient\fR is \fBvertical\fR -then these options are ignored. +the \fB-anchor\fR, \fB-font\fR, \fB-foreground\fR, \fB-justify\fR, +\fB-text\fR and \fB-wraplength\fR options. If the value of \fB-orient\fR +is \fBvertical\fR then these options are ignored. .SO ttk_widget \-anchor \-class \-cursor -\-foreground \-justify \-style +\-font \-foreground \-justify \-style \-takefocus \-text \-wraplength .SE .SH "WIDGET-SPECIFIC OPTIONS" diff --git a/doc/ttk_widget.n b/doc/ttk_widget.n index 7a770cc..d2916f1 100644 --- a/doc/ttk_widget.n +++ b/doc/ttk_widget.n @@ -96,6 +96,8 @@ Display image above, below, left of, or right of the text, respectively. .IP none The default; display the image if present, otherwise the text. .RE +.OP \-font font Font +Font to use for the text displayed by the widget. .OP \-foreground textColor TextColor The widget's foreground color. If unspecified, the theme default is used. -- cgit v0.12 From 1d6a2ca5b4916f5d7ebb7b024f55d24ccc2303fb Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 13 Mar 2017 14:18:42 +0000 Subject: Add minimal test of -justify for ttk::button --- tests/ttk/ttk.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ttk/ttk.test b/tests/ttk/ttk.test index 93dba34..6760b80 100644 --- a/tests/ttk/ttk.test +++ b/tests/ttk/ttk.test @@ -134,8 +134,8 @@ test ttk-selfdestruct-ok-1 "Intentional self-destruction" -body { # # Basic tests. # -test ttk-1.1 "Create button" -body { - pack [ttk::button .t] -expand true -fill both +test ttk-1.1 "Create multiline button showing justified text" -body { + pack [ttk::button .t -text "Hello\nWorld!!" -justify center] -expand true -fill both update } -- cgit v0.12