diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-27 18:44:31 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-27 18:44:31 +0000 |
commit | ee695fb164796dc203306f1585c4f6dd74f06806 (patch) | |
tree | 278f46cf1b6a9afafd3391af2b29e8a2ecf31dd4 /ext/tk/sample/tkextlib/tile | |
parent | 4dd9fd71b34cd21613404a2900085868dfac5cd4 (diff) | |
download | ruby-ee695fb164796dc203306f1585c4f6dd74f06806.tar.gz |
* ext/tk/lib/tk.rb, ext/tk/lib/*: make default widget set
switchable between Tk (standard Tcl/Tk widget set) and
Ttk (Tile). Initial default widget set is Tk. Now, toplevel
widget classes are removed and defined as aliases.
For example, "TkButton" is an alias of the "Tk::Button" class.
Those aliases are replaced when switching default widget set.
"Tk.default_widget_set=" is the method for switching default
widget set. "Tk.default_widget_set = :Ttk" defines Ttk (Tile)
widget set as default. It means that "TkButton" denotes
"Tk::Tile::Button" class. And then, "TkButton.new" creates
a Tk::Tile::Button widget. Of course, you can back to use
standard Tk widgets as the default widget set by calling
"Tk.default_widget_set = :Tk", whenever you want. Based on
thie feature, you can use Ttk widget styling engine on your
old Ruby/Tk application without modifying its source, if you
don'tuse widget options unsupported on Ttk widgets (At first,
call "Tk.default_widget_set = :Ttk", and next load and run
your application).
This is one step for supporting Tcl/Tk8.5 features.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/sample/tkextlib/tile')
-rw-r--r-- | ext/tk/sample/tkextlib/tile/toolbutton.tcl | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/ext/tk/sample/tkextlib/tile/toolbutton.tcl b/ext/tk/sample/tkextlib/tile/toolbutton.tcl index 4e08034e31..2656fff6d8 100644 --- a/ext/tk/sample/tkextlib/tile/toolbutton.tcl +++ b/ext/tk/sample/tkextlib/tile/toolbutton.tcl @@ -4,6 +4,18 @@ # Demonstration of custom widget styles. # +set tile_ver [package require tile] +if {[package vcompare $tile_ver 0.8] >= 0} { + set style ::ttk::style +} { + set style style +} +if {[package vcompare $tile_ver 0.7] >= 0} { + set conf_subcmd configure +} { + set conf_subcmd default +} + # # ~ BACKGROUND # @@ -42,7 +54,8 @@ # style; see demo.tcl.) # -style theme settings "step" { +#$style theme settings "step" { +$style theme settings "alt" { # # First, we use [style layout] to define what elements to @@ -51,7 +64,7 @@ style theme settings "step" { # and a label. (See also the TScrollbar layout definition # in demos/blue.tcl for a more complicated layout spec.) # - style layout Toolbutton { + $style layout Toolbutton { Toolbutton.background Toolbutton.border -children { Toolbutton.padding -children { @@ -68,7 +81,7 @@ style theme settings "step" { # For many options (like -background), the defaults # inherited from the parent style are sufficient. # - style default Toolbutton -width 0 -padding 1 -relief flat -borderwidth 2 + $style $conf_subcmd Toolbutton -width 0 -padding 1 -relief flat -borderwidth 2 # # Finally, use [style map] to specify state-specific @@ -78,7 +91,7 @@ style theme settings "step" { # over the widget). Each state-value pair is checked # in order, and the first matching state takes precedence. # - style map Toolbutton -relief { + $style map Toolbutton -relief { disabled flat selected sunken pressed sunken @@ -93,19 +106,19 @@ style theme settings "step" { # design decisions from an aesthetic standpoint.) # if {![catch {package require tile::theme::blue}]} { -style theme settings "blue" { +$style theme settings "blue" { # # Default values: # - style default Toolbutton \ + $style $conf_subcmd Toolbutton \ -width 0 -relief flat -borderwidth 2 \ -background #6699CC -foreground #000000 ; # # Configure state-specific values for -relief, as before: # - style map Toolbutton -relief { + $style map Toolbutton -relief { disabled flat selected sunken pressed sunken @@ -116,8 +129,8 @@ style theme settings "blue" { # Adjust the -padding at the same time, to enhance # the raised/sunken illusion: # - style default Toolbutton -padding 4 - style map Toolbutton -padding { + $style $conf_subcmd Toolbutton -padding 4 + $style map Toolbutton -padding { disabled {4} selected {6 6 2 2} pressed {6 6 2 2} @@ -128,7 +141,7 @@ style theme settings "blue" { # ... and change the foreground and background colors # when the mouse cursor is over the widget: # - style map Toolbutton -background { + $style map Toolbutton -background { active #008800 } -foreground { active #FFFFFF |