~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to ext/tk/sample/tkextlib/tile/toolbutton.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2011-09-24 19:16:17 UTC
  • mfrom: (1.1.8 upstream) (13.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20110924191617-o1qz4rcmqjot8zuy
Tags: 1.9.3~rc1-1
* New upstream release: 1.9.3 RC1.
  + Includes load.c fixes. Closes: #639959.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#
2
 
# $Id: toolbutton.tcl 25189 2009-10-02 12:04:37Z akr $
 
2
# $Id: toolbutton.tcl 31689 2011-05-22 09:26:02Z nobu $
3
3
#
4
4
# Demonstration of custom widget styles.
5
5
#
7
7
#
8
8
# ~ BACKGROUND
9
9
#
10
 
# Checkbuttons in toolbars have a very different appearance 
 
10
# Checkbuttons in toolbars have a very different appearance
11
11
# than regular checkbuttons: there's no indicator, they
12
12
# "pop up" when the mouse is over them, and they appear sunken
13
13
# when selected.
14
 
15
 
# Tk added partial support for toolbar-style buttons in 8.4 
 
14
#
 
15
# Tk added partial support for toolbar-style buttons in 8.4
16
16
# with the "-overrelief" option, and TIP #82 added further
17
 
# support with the "-offrelief" option.  So to get a toolbar-style 
 
17
# support with the "-offrelief" option.  So to get a toolbar-style
18
18
# checkbutton, you can configure it with:
19
19
#
20
20
# checkbutton .cb \
34
34
#
35
35
# ~ DEMONSTRATION
36
36
#
37
 
# The tile built-in themes (default, "alt", windows, and XP) 
 
37
# The tile built-in themes (default, "alt", windows, and XP)
38
38
# already include Toolbutton styles.  This script will add
39
39
# them to the "step" and "blue" themes as a demonstration.
40
40
#
41
 
# (Note: Pushbuttons and radiobuttons can also use the "Toolbutton" 
 
41
# (Note: Pushbuttons and radiobuttons can also use the "Toolbutton"
42
42
# style; see demo.tcl.)
43
43
#
44
44
 
48
48
# First, we use [style layout] to define what elements to
49
49
# use and how they're arranged.  Toolbuttons are pretty
50
50
# simple, consisting of a border, some internal padding,
51
 
# and a label.  (See also the TScrollbar layout definition 
 
51
# and a label.  (See also the TScrollbar layout definition
52
52
# in demos/blue.tcl for a more complicated layout spec.)
53
53
#
54
54
    style layout Toolbutton {
60
60
        }
61
61
    }
62
62
 
63
 
# (Actually the above isn't strictly necessary, since the same layout 
64
 
# is defined in the default theme; we could have inherited it 
 
63
# (Actually the above isn't strictly necessary, since the same layout
 
64
# is defined in the default theme; we could have inherited it
65
65
# instead.)
66
66
#
67
67
# Next, specify default values for element options.
71
71
    style default Toolbutton -width 0 -padding 1 -relief flat -borderwidth 2
72
72
 
73
73
#
74
 
# Finally, use [style map] to specify state-specific 
 
74
# Finally, use [style map] to specify state-specific
75
75
# resource values.  We want a flat relief if the widget is
76
 
# disabled, sunken if it's selected (on) or pressed, 
 
76
# disabled, sunken if it's selected (on) or pressed,
77
77
# and raised when it's active (the mouse pointer is
78
78
# over the widget).  Each state-value pair is checked
79
79
# in order, and the first matching state takes precedence.
80
80
#
81
81
    style map Toolbutton -relief {
82
82
        disabled        flat
83
 
        selected        sunken  
84
 
        pressed         sunken  
 
83
        selected        sunken
 
84
        pressed         sunken
85
85
        active          raised
86
86
    }
87
87
}
107
107
    #
108
108
    style map Toolbutton -relief {
109
109
        disabled        flat
110
 
        selected        sunken  
111
 
        pressed         sunken  
 
110
        selected        sunken
 
111
        pressed         sunken
112
112
        active          raised
113
 
    } 
 
113
    }
114
114
 
115
115
    #
116
116
    # Adjust the -padding at the same time, to enhance
138
138
}
139
139
 
140
140
#
141
 
# ~ A final note:  
 
141
# ~ A final note:
142
142
#
143
143
# TIP #82 also says: "When -indicatoron is off and the button itself
144
144
# is on, the relief continues to be hard-coded to sunken. For symmetry,