1 # This file is a Tcl script to test the Unix specific behavior of
2 # labels, buttons, checkbuttons, and radiobuttons in Tk (i.e., all the
3 # widgets defined in tkUnixButton.c). It is organized in the standard
4 # fashion for Tcl tests.
6 # Copyright (c) 1994 The Regents of the University of California.
7 # Copyright (c) 1994-1997 Sun Microsystems, Inc.
8 # Copyright (c) 1998-1999 by Scriptics Corporation.
11 package require tcltest 2.2
12 eval tcltest::configure $argv
13 tcltest::loadTestedCommands
14 namespace import -force tcltest::test
17 # Create entries in the option database to be sure that geometry options
18 # like border width have predictable values.
20 option add *Label.borderWidth 2
21 option add *Label.highlightThickness 0
22 option add *Label.font {Helvetica -12 bold}
23 option add *Button.borderWidth 2
24 option add *Button.highlightThickness 2
25 option add *Button.font {Helvetica -12 bold}
26 option add *Checkbutton.borderWidth 2
27 option add *Checkbutton.highlightThickness 2
28 option add *Checkbutton.font {Helvetica -12 bold}
29 option add *Radiobutton.borderWidth 2
30 option add *Radiobutton.highlightThickness 2
31 option add *Radiobutton.font {Helvetica -12 bold}
34 proc bogusTrace args {
38 if {[tk windowingsystem] eq "aqua"} {
47 test unixbutton-1.1 {TkpComputeButtonGeometry procedure} -constraints {
53 image create test image1
54 image1 changed 0 0 0 0 60 40
55 label .b1 -image image1 -bd 4 -padx 0 -pady 2
56 button .b2 -image image1 -bd 4 -padx 0 -pady 2
57 checkbutton .b3 -image image1 -bd 4 -padx 1 -pady 1
58 radiobutton .b4 -image image1 -bd 4 -padx 2 -pady 0
61 list [winfo reqwidth .b1] [winfo reqheight .b1] \
62 [winfo reqwidth .b2] [winfo reqheight .b2] \
63 [winfo reqwidth .b3] [winfo reqheight .b3] \
64 [winfo reqwidth .b4] [winfo reqheight .b4]
68 } -result [list 68 48 \
70 [expr {72 + $bigIndicator}] 52 \
71 [expr {72 + $bigIndicator}] 52]
72 test unixbutton-1.2 {TkpComputeButtonGeometry procedure} -constraints {
77 label .b1 -bitmap question -bd 3 -padx 0 -pady 2
78 button .b2 -bitmap question -bd 3 -padx 0 -pady 2
79 checkbutton .b3 -bitmap question -bd 3 -padx 1 -pady 1
80 radiobutton .b4 -bitmap question -bd 3 -padx 2 -pady 0
83 list [winfo reqwidth .b1] [winfo reqheight .b1] \
84 [winfo reqwidth .b2] [winfo reqheight .b2] \
85 [winfo reqwidth .b3] [winfo reqheight .b3] \
86 [winfo reqwidth .b4] [winfo reqheight .b4]
89 } -result [list 23 33 \
91 [expr {27 + $smallIndicator}] 37 \
92 [expr {27 + $smallIndicator}] 37]
93 test unixbutton-1.3 {TkpComputeButtonGeometry procedure} -constraints {
98 label .b1 -bitmap question -bd 3 -highlightthickness 4
99 button .b2 -bitmap question -bd 3 -highlightthickness 0
100 checkbutton .b3 -bitmap question -bd 3 -highlightthickness 1 \
102 radiobutton .b4 -bitmap question -bd 3 -highlightthickness 1 \
106 list [winfo reqwidth .b1] [winfo reqheight .b1] \
107 [winfo reqwidth .b2] [winfo reqheight .b2] \
108 [winfo reqwidth .b3] [winfo reqheight .b3] \
109 [winfo reqwidth .b4] [winfo reqheight .b4]
112 } -result {31 41 25 35 25 35 25 35}
113 test unixbutton-1.4 {TkpComputeButtonGeometry procedure} -constraints {
114 unix nonPortable fonts
118 label .b1 -text Xagqpim -padx 0 -pady 2 -font {Helvetica -18 bold}
119 button .b2 -text Xagqpim -padx 0 -pady 2 -font {Helvetica -18 bold}
120 checkbutton .b3 -text Xagqpim -padx 1 -pady 1 -font {Helvetica -18 bold}
121 radiobutton .b4 -text Xagqpim -padx 2 -pady 0 -font {Helvetica -18 bold}
124 list [winfo reqwidth .b1] [winfo reqheight .b1] \
125 [winfo reqwidth .b2] [winfo reqheight .b2] \
126 [winfo reqwidth .b3] [winfo reqheight .b3] \
127 [winfo reqwidth .b4] [winfo reqheight .b4]
130 } -result {82 29 88 35 114 31 121 29}
131 test unixbutton-1.5 {TkpComputeButtonGeometry procedure} -constraints {
132 unix nonPortable fonts
136 label .l1 -text "This is a long string that will wrap around on several lines.\n\nIt also has a blank line (above)." -wraplength 1.5i -padx 0 -pady 0
139 list [winfo reqwidth .l1] [winfo reqheight .l1]
143 test unixbutton-1.6 {TkpComputeButtonGeometry procedure} -constraints {
144 unix nonPortable fonts
148 label .l1 -text "This is a long string without wrapping.\n\nIt also has a blank line (above)." -padx 0 -pady 0
151 list [winfo reqwidth .l1] [winfo reqheight .l1]
155 test unixbutton-1.7 {TkpComputeButtonGeometry procedure} -constraints {
156 unix nonPortable fonts
160 label .b1 -text Xagqpim -bd 2 -padx 0 -pady 2 -width 10
161 button .b2 -text Xagqpim -bd 2 -padx 0 -pady 2 -height 5
162 checkbutton .b3 -text Xagqpim -bd 2 -padx 1 -pady 1 -width 20 -height 2
163 radiobutton .b4 -text Xagqpim -bd 2 -padx 2 -pady 0 -width 4
166 list [winfo reqwidth .b1] [winfo reqheight .b1] \
167 [winfo reqwidth .b2] [winfo reqheight .b2] \
168 [winfo reqwidth .b3] [winfo reqheight .b3] \
169 [winfo reqwidth .b4] [winfo reqheight .b4]
172 } -result {74 22 60 84 168 38 61 22}
173 test unixbutton-1.8 {TkpComputeButtonGeometry procedure} -constraints {
174 unix nonPortable fonts
178 label .b1 -text Xagqpim -bd 2 -padx 0 -pady 2 \
179 -highlightthickness 4
180 button .b2 -text Xagqpim -bd 2 -padx 0 -pady 2 \
181 -highlightthickness 0
182 checkbutton .b3 -text Xagqpim -bd 2 -padx 1 -pady 1 \
183 -highlightthickness 1 -indicatoron no
184 radiobutton .b4 -text Xagqpim -bd 2 -padx 2 -pady 0 -indicatoron 0
187 list [winfo reqwidth .b1] [winfo reqheight .b1] \
188 [winfo reqwidth .b2] [winfo reqheight .b2] \
189 [winfo reqwidth .b3] [winfo reqheight .b3] \
190 [winfo reqwidth .b4] [winfo reqheight .b4]
193 } -result {62 30 56 24 58 22 62 22}
194 test unixbutton-1.9 {TkpComputeButtonGeometry procedure} -constraints {
199 button .b2 -bitmap question -default active
200 list [winfo reqwidth .b2] [winfo reqheight .b2]
203 } -result [list [expr {17 + $defaultBorder}] [expr {27 + $defaultBorder}]]
204 test unixbutton-1.10 {TkpComputeButtonGeometry procedure} -constraints {
209 button .b2 -bitmap question -default normal
210 list [winfo reqwidth .b2] [winfo reqheight .b2]
213 } -result [list [expr {17 + $defaultBorder}] [expr {27 + $defaultBorder}]]
214 test unixbutton-1.11 {TkpComputeButtonGeometry procedure} -constraints {
219 button .b2 -bitmap question -default disabled
220 list [winfo reqwidth .b2] [winfo reqheight .b2]
226 test unixbutton-2.1 {disabled coloring check, bug 669595} -constraints {
232 # this was just a visual bug, but at least this shows the visual
235 label .l -text "The following widgets should\
236 \nshow significant visible diffs\
237 \nfor selected vs unselected."
238 checkbutton .cb0 -anchor w -state disabled \
239 -text Unselected -variable off
240 checkbutton .cb1 -anchor w -state disabled \
241 -text Selected -variable on
242 checkbutton .cb2 -anchor w -state disabled \
243 -text Unselected -variable off -disabledforeground ""
244 checkbutton .cb3 -anchor w -state disabled \
245 -text Selected -variable on -disabledforeground ""
246 radiobutton .rb0 -anchor w -state disabled \
247 -text Unselected -variable off
248 radiobutton .rb1 -anchor w -state disabled \
249 -text Selected -variable on -value 1
250 radiobutton .rb2 -anchor w -state disabled \
251 -text Unselected -variable off -disabledforeground ""
252 radiobutton .rb3 -anchor w -state disabled \
253 -text Selected -variable on -value 1 -disabledforeground ""
254 pack .l .cb0 .cb1 .cb2 .cb3 .rb0 .rb1 .rb2 .rb3 -side top -fill x