1 |
578 |
markom |
# This file is a Tcl script to test drawing of menus in Tk. It is
|
2 |
|
|
# organized in the standard fashion for Tcl tests.
|
3 |
|
|
#
|
4 |
|
|
# Copyright (c) 1996-1997 Sun Microsystems, Inc.
|
5 |
|
|
#
|
6 |
|
|
# See the file "license.terms" for information on usage and redistribution
|
7 |
|
|
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
8 |
|
|
#
|
9 |
|
|
# RCS: @(#) $Id: menuDraw.test,v 1.1.1.1 2002-01-16 10:25:59 markom Exp $
|
10 |
|
|
|
11 |
|
|
if {[lsearch [image types] test] < 0} {
|
12 |
|
|
puts "This application hasn't been compiled with the \"test\" image"
|
13 |
|
|
puts "type, so I can't run this test. Are you sure you're using"
|
14 |
|
|
puts "tktest instead of wish?"
|
15 |
|
|
return
|
16 |
|
|
}
|
17 |
|
|
|
18 |
|
|
if {[info procs test] != "test"} {
|
19 |
|
|
source defs
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
proc deleteWindows {} {
|
23 |
|
|
foreach i [winfo children .] {
|
24 |
|
|
catch [destroy $i]
|
25 |
|
|
}
|
26 |
|
|
}
|
27 |
|
|
|
28 |
|
|
deleteWindows
|
29 |
|
|
wm geometry . {}
|
30 |
|
|
raise .
|
31 |
|
|
|
32 |
|
|
if {$tcl_platform(platform) == "windows" && ![info exists INTERACTIVE]} {
|
33 |
|
|
puts " Some tests were skipped because they could not be performed"
|
34 |
|
|
puts " automatically on this platform. If you wish to execute them"
|
35 |
|
|
puts " interactively, set the TCL variable INTERACTIVE and re-run"
|
36 |
|
|
puts " the test."
|
37 |
|
|
set testConfig(menuInteractive) 0
|
38 |
|
|
} else {
|
39 |
|
|
set testConfig(menuInteractive) 1
|
40 |
|
|
}
|
41 |
|
|
|
42 |
|
|
test menuDraw-1.1 {TkMenuInitializeDrawingFields} {
|
43 |
|
|
catch {destroy .m1}
|
44 |
|
|
list [menu .m1] [destroy .m1]
|
45 |
|
|
} {.m1 {}}
|
46 |
|
|
|
47 |
|
|
test menuDraw-2.1 {TkIntializeMenuEntryDrawingFields} {
|
48 |
|
|
catch {destroy .m1}
|
49 |
|
|
menu .m1
|
50 |
|
|
list [.m1 add command] [destroy .m1]
|
51 |
|
|
} {{} {}}
|
52 |
|
|
|
53 |
|
|
test menuDraw-3.1 {TkMenuFreeDrawOptions} {
|
54 |
|
|
catch {destroy .m1}
|
55 |
|
|
menu .m1
|
56 |
|
|
list [destroy .m1]
|
57 |
|
|
} {{}}
|
58 |
|
|
|
59 |
|
|
test menuDraw-4.1 {TkMenuEntryFreeDrawOptions} {
|
60 |
|
|
catch {destroy .m1}
|
61 |
|
|
menu .m1
|
62 |
|
|
.m1 add command -label "This is a test"
|
63 |
|
|
list [destroy .m1]
|
64 |
|
|
} {{}}
|
65 |
|
|
test menuDraw-4.2 {TkMenuEntryFreeDrawOptions} {
|
66 |
|
|
catch {destroy .m1}
|
67 |
|
|
menu .m1
|
68 |
|
|
.m1 add checkbutton -label "This is a test." -font "Courier 12" -activeforeground red -background green -selectcolor purple
|
69 |
|
|
list [destroy .m1]
|
70 |
|
|
} {{}}
|
71 |
|
|
|
72 |
|
|
test menuDraw-5.1 {TkMenuConfigureDrawOptions - new menu} {
|
73 |
|
|
catch {destroy .m1}
|
74 |
|
|
list [menu .m1] [destroy .m1]
|
75 |
|
|
} {.m1 {}}
|
76 |
|
|
test menuDraw-5.2 {TkMenuConfigureDrawOptions - old menu} {
|
77 |
|
|
catch {destroy .m1}
|
78 |
|
|
menu .m1
|
79 |
|
|
list [.m1 configure -fg red] [destroy .m1]
|
80 |
|
|
} {{} {}}
|
81 |
|
|
test menuDraw-5.3 {TkMenuConfigureDrawOptions - no disabledFg} {
|
82 |
|
|
catch {destroy .m1}
|
83 |
|
|
list [menu .m1 -disabledforeground ""] [destroy .m1]
|
84 |
|
|
} {.m1 {}}
|
85 |
|
|
|
86 |
|
|
test menuDraw-6.1 {TkMenuConfigureEntryDrawOptions - no tkfont specified} {
|
87 |
|
|
catch {destroy .m1}
|
88 |
|
|
menu .m1
|
89 |
|
|
list [.m1 add command -label "foo"] [destroy .m1]
|
90 |
|
|
} {{} {}}
|
91 |
|
|
test menuDraw-6.2 {TkMenuConfigureEntryDrawOptions - tkfont specified} {
|
92 |
|
|
catch {destroy .m1}
|
93 |
|
|
menu .m1
|
94 |
|
|
list [.m1 add command -label "foo" -font "Courier 12"] [destroy .m1]
|
95 |
|
|
} {{} {}}
|
96 |
|
|
test menuDraw-6.3 {TkMenuConfigureEntryDrawOptions - active state - wrong entry} {
|
97 |
|
|
catch {destroy .m1}
|
98 |
|
|
menu .m1
|
99 |
|
|
.m1 add command -label "foo"
|
100 |
|
|
list [.m1 entryconfigure 1 -state active] [destroy .m1]
|
101 |
|
|
} {{} {}}
|
102 |
|
|
test menuDraw-6.4 {TkMenuConfigureEntryDrawOptions - active state - correct entry} {
|
103 |
|
|
catch {destroy .m1}
|
104 |
|
|
menu .m1
|
105 |
|
|
.m1 add command -label "foo"
|
106 |
|
|
.m1 activate 1
|
107 |
|
|
list [.m1 entryconfigure 1 -state active] [destroy .m1]
|
108 |
|
|
} {{} {}}
|
109 |
|
|
test menuDraw-6.5 {TkMenuConfigureEntryDrawOptions - deactivate entry} {
|
110 |
|
|
catch {destroy .m1}
|
111 |
|
|
menu .m1
|
112 |
|
|
.m1 add command -label "foo"
|
113 |
|
|
.m1 activate 1
|
114 |
|
|
list [.m1 entryconfigure 1 -state normal] [destroy .m1]
|
115 |
|
|
} {{} {}}
|
116 |
|
|
test menuDraw-6.6 {TkMenuConfigureEntryDrawOptions - bad state} {
|
117 |
|
|
catch {destroy .m1}
|
118 |
|
|
menu .m1
|
119 |
|
|
.m1 add command -label "foo"
|
120 |
|
|
list [catch {.m1 entryconfigure 1 -state foo} msg] $msg [destroy .m1]
|
121 |
|
|
} {1 {bad state value "foo": must be normal, active, or disabled} {}}
|
122 |
|
|
test menuDraw-6.7 {TkMenuConfigureEntryDrawOptions - tkfont specified} {
|
123 |
|
|
catch {destroy .m1}
|
124 |
|
|
menu .m1
|
125 |
|
|
list [.m1 add command -label "foo" -font "Courier 12"] [destroy .m1]
|
126 |
|
|
} {{} {}}
|
127 |
|
|
test menuDraw-6.8 {TkMenuConfigureEntryDrawOptions - border specified} {
|
128 |
|
|
catch {destroy .m1}
|
129 |
|
|
menu .m1
|
130 |
|
|
list [.m1 add command -label "foo" -background "red"] [destroy .m1]
|
131 |
|
|
} {{} {}}
|
132 |
|
|
test menuDraw-6.9 {TkMenuConfigureEntryDrawOptions - foreground specified} {
|
133 |
|
|
catch {destroy .m1}
|
134 |
|
|
menu .m1
|
135 |
|
|
list [.m1 add command -label "foo" -foreground "red"] [destroy .m1]
|
136 |
|
|
} {{} {}}
|
137 |
|
|
test menuDraw-6.10 {TkMenuConfigureEntryDrawOptions - activeBorder specified} {
|
138 |
|
|
catch {destroy .m1}
|
139 |
|
|
menu .m1
|
140 |
|
|
list [.m1 add command -label "foo" -activebackground "red"] [destroy .m1]
|
141 |
|
|
} {{} {}}
|
142 |
|
|
test menuDraw-6.11 {TkMenuConfigureEntryDrawOptions - activeforeground specified} {
|
143 |
|
|
catch {destroy .m1}
|
144 |
|
|
menu .m1
|
145 |
|
|
list [.m1 add command -label "foo" -activeforeground "red"] [destroy .m1]
|
146 |
|
|
} {{} {}}
|
147 |
|
|
test menuDraw-6.12 {TkMenuConfigureEntryDrawOptions - selectcolor specified} {
|
148 |
|
|
catch {destroy .m1}
|
149 |
|
|
menu .m1
|
150 |
|
|
list [.m1 add radiobutton -label "foo" -selectcolor "red"] [destroy .m1]
|
151 |
|
|
} {{} {}}
|
152 |
|
|
test menuDraw-6.13 {TkMenuConfigureEntryDrawOptions - textGC disposal} {
|
153 |
|
|
catch {destroy .m1}
|
154 |
|
|
menu .m1
|
155 |
|
|
.m1 add command -label "foo" -font "Helvetica 12"
|
156 |
|
|
list [.m1 entryconfigure 1 -font "Courier 12"] [destroy .m1]
|
157 |
|
|
} {{} {}}
|
158 |
|
|
test menuDraw-6.14 {TkMenuConfigureEntryDrawOptions - activeGC disposal} {
|
159 |
|
|
catch {destroy .m1}
|
160 |
|
|
menu .m1
|
161 |
|
|
.m1 add command -label "foo" -activeforeground "red"
|
162 |
|
|
list [.m1 entryconfigure 1 -activeforeground "green"] [destroy .m1]
|
163 |
|
|
} {{} {}}
|
164 |
|
|
test menuDraw-6.15 {TkMenuConfigureEntryDrawOptions - disabledGC disposal} {
|
165 |
|
|
catch {destroy .m1}
|
166 |
|
|
menu .m1 -disabledforeground "red"
|
167 |
|
|
.m1 add command -label "foo"
|
168 |
|
|
list [.m1 configure -disabledforeground "green"] [destroy .m1]
|
169 |
|
|
} {{} {}}
|
170 |
|
|
test menuDraw-6.16 {TkMenuConfigureEntryDrawOptions - indicatorGC disposal} {
|
171 |
|
|
catch {destroy .m1}
|
172 |
|
|
menu .m1
|
173 |
|
|
.m1 add radiobutton -label "foo" -selectcolor "red"
|
174 |
|
|
list [.m1 entryconfigure 1 -selectcolor "green"] [destroy .m1]
|
175 |
|
|
} {{} {}}
|
176 |
|
|
|
177 |
|
|
test menuDraw-7.1 {TkEventuallyRecomputeMenu} {
|
178 |
|
|
catch {destroy .m1}
|
179 |
|
|
menu .m1
|
180 |
|
|
.m1 add command -label "This is a long label"
|
181 |
|
|
set tearoff [tkTearOffMenu .m1]
|
182 |
|
|
update idletasks
|
183 |
|
|
list [.m1 entryconfigure 1 -label "foo"] [destroy .m1]
|
184 |
|
|
} {{} {}}
|
185 |
|
|
test menuDraw-7.2 {TkEventuallyRecomputeMenu - update pending} {
|
186 |
|
|
catch {destroy .m1}
|
187 |
|
|
menu .m1
|
188 |
|
|
.m1 add command -label "This is a long label"
|
189 |
|
|
set tearoff [tkTearOffMenu .m1]
|
190 |
|
|
list [.m1 entryconfigure 1 -label "foo"] [destroy .m1]
|
191 |
|
|
} {{} {}}
|
192 |
|
|
|
193 |
|
|
|
194 |
|
|
test menuDraw-8.1 {TkRecomputeMenu} {menuInteractive} {
|
195 |
|
|
catch {destroy .m1}
|
196 |
|
|
menu .m1
|
197 |
|
|
.m1 configure -postcommand [.m1 add command -label foo]
|
198 |
|
|
.m1 add command -label "Hit ESCAPE to make this menu go away."
|
199 |
|
|
list [.m1 post 0 0] [destroy .m1]
|
200 |
|
|
} {{} {}}
|
201 |
|
|
|
202 |
|
|
|
203 |
|
|
test menuDraw-9.1 {TkEventuallyRedrawMenu - entry test} {
|
204 |
|
|
catch {destroy .m1}
|
205 |
|
|
catch {unset foo}
|
206 |
|
|
menu .m1
|
207 |
|
|
set foo 0
|
208 |
|
|
.m1 add radiobutton -variable foo -label test
|
209 |
|
|
tkTearOffMenu .m1
|
210 |
|
|
update idletasks
|
211 |
|
|
list [set foo test] [destroy .m1] [unset foo]
|
212 |
|
|
} {test {} {}}
|
213 |
|
|
test menuDraw-9.2 {TkEventuallyRedrawMenu - whole menu} {
|
214 |
|
|
catch {destroy .m1}
|
215 |
|
|
menu .m1
|
216 |
|
|
list [catch {tkTearOffMenu .m1}] [destroy .m1]
|
217 |
|
|
} {0 {}}
|
218 |
|
|
|
219 |
|
|
# Don't know how to test when window has been deleted and ComputeMenuGeometry
|
220 |
|
|
# gets called.
|
221 |
|
|
test menuDraw-10.1 {ComputeMenuGeometry - menubar} {
|
222 |
|
|
catch {destroy .m1}
|
223 |
|
|
menu .m1
|
224 |
|
|
.m1 add command -label test
|
225 |
|
|
. configure -menu .m1
|
226 |
|
|
list [update idletasks] [. configure -menu ""] [destroy .m1]
|
227 |
|
|
} {{} {} {}}
|
228 |
|
|
test menuDraw-10.2 {ComputeMenuGeometry - non-menubar} {
|
229 |
|
|
catch {destroy .m1}
|
230 |
|
|
menu .m1
|
231 |
|
|
.m1 add command -label test
|
232 |
|
|
list [update idletasks] [destroy .m1]
|
233 |
|
|
} {{} {}}
|
234 |
|
|
test menuDraw-10.3 {ComputeMenuGeometry - Resize necessary} {
|
235 |
|
|
catch {destroy .m1}
|
236 |
|
|
menu .m1
|
237 |
|
|
.m1 add command -label test
|
238 |
|
|
list [update idletasks] [destroy .m1]
|
239 |
|
|
} {{} {}}
|
240 |
|
|
test menuDraw-10.4 {ComputeMenuGeometry - resize not necessary} {
|
241 |
|
|
catch {destroy .m1}
|
242 |
|
|
menu .m1
|
243 |
|
|
.m1 add command -label test
|
244 |
|
|
update idletasks
|
245 |
|
|
.m1 entryconfigure 1 -label test
|
246 |
|
|
list [update idletasks] [destroy .m1]
|
247 |
|
|
} {{} {}}
|
248 |
|
|
|
249 |
|
|
test menuDraw-11.1 {TkMenuSelectImageProc - entry selected; redraw not pending} {
|
250 |
|
|
catch {destroy .m1}
|
251 |
|
|
catch {eval image delete [image names]}
|
252 |
|
|
image create test image1
|
253 |
|
|
image create test image2
|
254 |
|
|
menu .m1
|
255 |
|
|
.m1 add checkbutton -image image1 -selectimage image2
|
256 |
|
|
.m1 invoke 1
|
257 |
|
|
set tearoff [tkTearOffMenu .m1 40 40]
|
258 |
|
|
update idletasks
|
259 |
|
|
list [image delete image2] [destroy .m1] [eval image delete [image names]]
|
260 |
|
|
} {{} {} {}}
|
261 |
|
|
test menuDraw-11.2 {TkMenuSelectImageProc - entry selected; redraw pending} {
|
262 |
|
|
catch {destroy .m1}
|
263 |
|
|
catch {eval image delete [image names]}
|
264 |
|
|
image create test image1
|
265 |
|
|
image create test image2
|
266 |
|
|
menu .m1
|
267 |
|
|
.m1 add checkbutton -image image1 -selectimage image2
|
268 |
|
|
.m1 invoke 1
|
269 |
|
|
set tearoff [tkTearOffMenu .m1 40 40]
|
270 |
|
|
list [image delete image2] [destroy .m1] [eval image delete [image names]]
|
271 |
|
|
} {{} {} {}}
|
272 |
|
|
test menuDraw-11.3 {TkMenuSelectImageProc - entry not selected} {
|
273 |
|
|
catch {destroy .m1}
|
274 |
|
|
catch {eval image delete [image names]}
|
275 |
|
|
image create test image1
|
276 |
|
|
image create test image2
|
277 |
|
|
menu .m1
|
278 |
|
|
.m1 add checkbutton -image image1 -selectimage image2
|
279 |
|
|
set tearoff [tkTearOffMenu .m1 40 40]
|
280 |
|
|
update idletasks
|
281 |
|
|
list [image delete image2] [destroy .m1] [eval image delete [image names]]
|
282 |
|
|
} {{} {} {}}
|
283 |
|
|
|
284 |
|
|
#Don't know how to test missing tkwin in DisplayMenu
|
285 |
|
|
test menuDraw-12.1 {DisplayMenu - menubar background} {unixOnly} {
|
286 |
|
|
catch {destroy .m1}
|
287 |
|
|
menu .m1
|
288 |
|
|
.m1 add cascade -label foo -menu .m2
|
289 |
|
|
. configure -menu .m1
|
290 |
|
|
list [update] [. configure -menu ""] [destroy .m1]
|
291 |
|
|
} {{} {} {}}
|
292 |
|
|
test menuDraw-12.2 {Display menu - no entries} {
|
293 |
|
|
catch {destroy .m1}
|
294 |
|
|
menu .m1
|
295 |
|
|
set tearoff [tkTearOffMenu .m1 40 40]
|
296 |
|
|
list [update] [destroy .m1]
|
297 |
|
|
} {{} {}}
|
298 |
|
|
test menuDraw-12.3 {DisplayMenu - one entry} {
|
299 |
|
|
catch {destroy .m1}
|
300 |
|
|
menu .m1
|
301 |
|
|
.m1 add command -label foo
|
302 |
|
|
set tearoff [tkTearOffMenu .m1 40 40]
|
303 |
|
|
list [update] [destroy .m1]
|
304 |
|
|
} {{} {}}
|
305 |
|
|
test menuDraw-12.4 {DisplayMenu - two entries} {
|
306 |
|
|
catch {destroy .m1}
|
307 |
|
|
menu .m1
|
308 |
|
|
.m1 add command -label "one"
|
309 |
|
|
.m1 add command -label "two"
|
310 |
|
|
set tearoff [tkTearOffMenu .m1 40 40]
|
311 |
|
|
list [update] [destroy .m1]
|
312 |
|
|
} {{} {}}
|
313 |
|
|
test menuDraw.12.5 {DisplayMenu - two columns - first bigger} {
|
314 |
|
|
catch {destroy .m1}
|
315 |
|
|
menu .m1
|
316 |
|
|
.m1 add command -label "one"
|
317 |
|
|
.m1 add command -label "two"
|
318 |
|
|
.m1 add command -label "three" -columnbreak 1
|
319 |
|
|
set tearoff [tkTearOffMenu .m1 40 40]
|
320 |
|
|
list [update] [destroy .m1]
|
321 |
|
|
} {{} {}}
|
322 |
|
|
test menuDraw-12.5 {DisplayMenu - two column - second bigger} {
|
323 |
|
|
catch {destroy .m1}
|
324 |
|
|
menu .m1
|
325 |
|
|
.m1 add command -label "one"
|
326 |
|
|
.m1 add command -label "two" -columnbreak 1
|
327 |
|
|
.m1 add command -label "three"
|
328 |
|
|
set tearoff [tkTearOffMenu .m1 40 40]
|
329 |
|
|
list [update] [destroy .m1]
|
330 |
|
|
} {{} {}}
|
331 |
|
|
test menuDraw.12.7 {DisplayMenu - three columns} {
|
332 |
|
|
catch {destroy .m1}
|
333 |
|
|
menu .m1
|
334 |
|
|
.m1 add command -label "one"
|
335 |
|
|
.m1 add command -label "two" -columnbreak 1
|
336 |
|
|
.m1 add command -label "three"
|
337 |
|
|
.m1 add command -label "four"
|
338 |
|
|
.m1 add command -label "five"
|
339 |
|
|
.m1 add command -label "six"
|
340 |
|
|
set tearoff [tkTearOffMenu .m1 40 40]
|
341 |
|
|
list [update] [destroy .m1]
|
342 |
|
|
} {{} {}}
|
343 |
|
|
test menuDraw-12.6 {Display menu - testing for extra space and menubars} {unixOnly} {
|
344 |
|
|
catch {destroy .m1}
|
345 |
|
|
menu .m1
|
346 |
|
|
.m1 add cascade -label foo
|
347 |
|
|
. configure -menu .m1
|
348 |
|
|
list [update] [. configure -menu ""] [destroy .m1]
|
349 |
|
|
} {{} {} {}}
|
350 |
|
|
test menuDraw-12.7 {Display menu - extra space at end of menu} {
|
351 |
|
|
catch {destroy .m1}
|
352 |
|
|
menu .m1
|
353 |
|
|
.m1 add cascade -label foo
|
354 |
|
|
set tearoff [tkTearOffMenu .m1 40 40]
|
355 |
|
|
wm geometry $tearoff 200x100
|
356 |
|
|
list [update] [destroy .m1]
|
357 |
|
|
} {{} {}}
|
358 |
|
|
|
359 |
|
|
test menuDraw-13.1 {TkMenuEventProc - Expose} {
|
360 |
|
|
catch {destroy .m1}
|
361 |
|
|
catch {destroy .m2}
|
362 |
|
|
menu .m1
|
363 |
|
|
.m1 add command -label "one"
|
364 |
|
|
menu .m2
|
365 |
|
|
.m2 add command -label "two"
|
366 |
|
|
set tearoff1 [tkTearOffMenu .m1 40 40]
|
367 |
|
|
set tearoff2 [tkTearOffMenu .m2 40 40]
|
368 |
|
|
list [raise $tearoff2] [update] [destroy .m1] [destroy .m2]
|
369 |
|
|
} {{} {} {} {}}
|
370 |
|
|
test menuDraw-13.2 {TkMenuEventProc - ConfigureNotify} {
|
371 |
|
|
catch {destroy .m1}
|
372 |
|
|
menu .m1
|
373 |
|
|
.m1 add command -label "foo"
|
374 |
|
|
set tearoff [tkTearOffMenu .m1 40 40]
|
375 |
|
|
list [wm geometry $tearoff 200x100] [update] [destroy .m1]
|
376 |
|
|
} {{} {} {}}
|
377 |
|
|
test menuDraw-13.3 {TkMenuEventProc - ActivateNotify} {macOnly} {
|
378 |
|
|
catch {destroy .t2}
|
379 |
|
|
toplevel .t2 -menu .t2.m1
|
380 |
|
|
menu .t2.m1
|
381 |
|
|
.t2.m1 add command -label foo
|
382 |
|
|
tkTearOffMenu .t2.m1 40 40
|
383 |
|
|
list [catch {update} msg] $msg [destroy .t2]
|
384 |
|
|
} {0 {} {}}
|
385 |
|
|
# Testing deletes is hard, and I am going to do my best. Don't know how
|
386 |
|
|
# to test the case where we have already cleared the tkwin field in the
|
387 |
|
|
# menuPtr.
|
388 |
|
|
test menuDraw-13.4 {TkMenuEventProc - simple delete} {
|
389 |
|
|
catch {destroy .m1}
|
390 |
|
|
menu .m1
|
391 |
|
|
list [destroy .m1]
|
392 |
|
|
} {{}}
|
393 |
|
|
test menuDraw-13.5 {TkMenuEventProc - nothing pending} {
|
394 |
|
|
catch {destroy .m1}
|
395 |
|
|
menu .m1
|
396 |
|
|
.m1 add command -label foo
|
397 |
|
|
update idletasks
|
398 |
|
|
list [destroy .m1]
|
399 |
|
|
} {{}}
|
400 |
|
|
|
401 |
|
|
test menuDraw-14.1 {TkMenuImageProc} {
|
402 |
|
|
catch {destroy .m1}
|
403 |
|
|
catch {image delete image1}
|
404 |
|
|
menu .m1
|
405 |
|
|
image create test image1
|
406 |
|
|
.m1 add command -image image1
|
407 |
|
|
update idletasks
|
408 |
|
|
list [image delete image1] [destroy .m1]
|
409 |
|
|
} {{} {}}
|
410 |
|
|
test menuDraw-14.2 {TkMenuImageProc} {
|
411 |
|
|
catch {destroy .m1}
|
412 |
|
|
catch {image delete image1}
|
413 |
|
|
menu .m1
|
414 |
|
|
image create test image1
|
415 |
|
|
.m1 add command -image image1
|
416 |
|
|
list [image delete image1] [destroy .m1]
|
417 |
|
|
} {{} {}}
|
418 |
|
|
|
419 |
|
|
test menuDraw-15.1 {TkPostTearoffMenu - Basic posting} {
|
420 |
|
|
catch {destroy .m1}
|
421 |
|
|
menu .m1
|
422 |
|
|
.m1 add command -label "foo"
|
423 |
|
|
list [catch {tkTearOffMenu .m1 40 40}] [destroy .m1]
|
424 |
|
|
} {0 {}}
|
425 |
|
|
test menuDraw-15.2 {TkPostTearoffMenu - Deactivation} {
|
426 |
|
|
catch {destroy .m1}
|
427 |
|
|
menu .m1
|
428 |
|
|
.m1 add command -label "foo" -state active
|
429 |
|
|
set tearoff [tkTearOffMenu .m1 40 40]
|
430 |
|
|
list [$tearoff index active] [destroy .m1]
|
431 |
|
|
} {none {}}
|
432 |
|
|
test menuDraw-15.3 {TkPostTearoffMenu - post command} {
|
433 |
|
|
catch {destroy .m1}
|
434 |
|
|
catch {unset foo}
|
435 |
|
|
menu .m1 -postcommand "set foo .m1"
|
436 |
|
|
.m1 add command -label "foo"
|
437 |
|
|
list [catch {tkTearOffMenu .m1 40 40}] [set foo] [unset foo] [destroy .m1]
|
438 |
|
|
} {0 .m1 {} {}}
|
439 |
|
|
test menuDraw-15.4 {TkPostTearoffMenu - post command deleting the menu} {
|
440 |
|
|
catch {destroy .m1}
|
441 |
|
|
menu .m1 -postcommand "destroy .m1"
|
442 |
|
|
.m1 add command -label "foo"
|
443 |
|
|
list [catch {tkTearOffMenu .m1 40 40} msg] $msg [winfo exists .m1]
|
444 |
|
|
} {0 {} 0}
|
445 |
|
|
test menuDraw-15.5 {TkPostTearoffMenu - tearoff at edge of screen} {
|
446 |
|
|
catch {destroy .m1}
|
447 |
|
|
menu .m1
|
448 |
|
|
.m1 add command -label "foo"
|
449 |
|
|
set height [winfo screenheight .m1]
|
450 |
|
|
list [catch {tkTearOffMenu .m1 40 $height}] [destroy .m1]
|
451 |
|
|
} {0 {}}
|
452 |
|
|
test menuDraw-15.6 {TkPostTearoffMenu - tearoff off right} {
|
453 |
|
|
catch {destroy .m1}
|
454 |
|
|
menu .m1
|
455 |
|
|
.m1 add command -label "foo"
|
456 |
|
|
set width [winfo screenwidth .m1]
|
457 |
|
|
list [catch {tkTearOffMenu .m1 $width 40}] [destroy .m1]
|
458 |
|
|
} {0 {}}
|
459 |
|
|
|
460 |
|
|
|
461 |
|
|
test menuDraw-16.1 {TkPostSubmenu} {unixOnly} {
|
462 |
|
|
catch {destroy .m1}
|
463 |
|
|
catch {destroy .m2}
|
464 |
|
|
menu .m1
|
465 |
|
|
.m1 add cascade -label test -menu .m2
|
466 |
|
|
menu .m2
|
467 |
|
|
.m2 add command -label "Hit ESCAPE to make this menu go away."
|
468 |
|
|
set tearoff [tkTearOffMenu .m1 40 40]
|
469 |
|
|
$tearoff postcascade 0
|
470 |
|
|
list [$tearoff postcascade 0] [destroy .m1] [destroy .m2]
|
471 |
|
|
} {{} {} {}}
|
472 |
|
|
test menuDraw-16.2 {TkPostSubMenu} {unixOnly} {
|
473 |
|
|
catch {destroy .m1}
|
474 |
|
|
catch {destroy .m2}
|
475 |
|
|
catch {destroy .m3}
|
476 |
|
|
menu .m1
|
477 |
|
|
.m1 add cascade -label "two" -menu .m2
|
478 |
|
|
.m1 add cascade -label "three" -menu .m3
|
479 |
|
|
menu .m2
|
480 |
|
|
.m2 add command -label "two"
|
481 |
|
|
menu .m3
|
482 |
|
|
.m3 add command -label "three"
|
483 |
|
|
set tearoff [tkTearOffMenu .m1 40 40]
|
484 |
|
|
$tearoff postcascade 0
|
485 |
|
|
list [$tearoff postcascade 1] [destroy .m1] [destroy .m2] [destroy .m3]
|
486 |
|
|
} {{} {} {} {}}
|
487 |
|
|
test menuDraw-16.3 {TkPostSubMenu} {
|
488 |
|
|
catch {destroy .m1}
|
489 |
|
|
menu .m1
|
490 |
|
|
.m1 add cascade -label test -menu .m2
|
491 |
|
|
list [.m1 postcascade 1] [destroy .m1]
|
492 |
|
|
} {{} {}}
|
493 |
|
|
test menuDraw-16.4 {TkPostSubMenu} {
|
494 |
|
|
catch {destroy .m1}
|
495 |
|
|
menu .m1
|
496 |
|
|
.m1 add cascade -label test
|
497 |
|
|
set tearoff [tkTearOffMenu .m1 40 40]
|
498 |
|
|
list [$tearoff postcascade 0] [destroy .m1]
|
499 |
|
|
} {{} {}}
|
500 |
|
|
test menuDraw-16.5 {TkPostSubMenu} {unixOnly} {
|
501 |
|
|
catch {destroy .m1}
|
502 |
|
|
catch {destroy .m2}
|
503 |
|
|
menu .m1
|
504 |
|
|
.m1 add cascade -label test -menu .m2
|
505 |
|
|
menu .m2 -postcommand "glorp"
|
506 |
|
|
set tearoff [tkTearOffMenu .m1 40 40]
|
507 |
|
|
list [catch {$tearoff postcascade test} msg] $msg [destroy .m1] [destroy .m2]
|
508 |
|
|
} {1 {invalid command name "glorp"} {} {}}
|
509 |
|
|
test menuDraw-16.6 {TkPostSubMenu} {menuInteractive} {
|
510 |
|
|
catch {destroy .m1}
|
511 |
|
|
catch {destroy .m2}
|
512 |
|
|
menu .m1
|
513 |
|
|
.m1 add cascade -label test -menu .m2
|
514 |
|
|
menu .m2
|
515 |
|
|
.m2 add command -label "Hit ESCAPE to get rid of this menu"
|
516 |
|
|
set tearoff [tkTearOffMenu .m1 40 40]
|
517 |
|
|
list [$tearoff postcascade 0] [destroy .m1] [destroy .m2]
|
518 |
|
|
} {{} {} {}}
|
519 |
|
|
|
520 |
|
|
test menuDraw-17.1 {AdjustMenuCoords - menubar} {unixOnly} {
|
521 |
|
|
catch {destroy .m1}
|
522 |
|
|
catch {destroy .m2}
|
523 |
|
|
menu .m1 -tearoff 0
|
524 |
|
|
.m1 add cascade -label test -menu .m2
|
525 |
|
|
menu .m2 -tearoff 0
|
526 |
|
|
.m2 add command -label foo
|
527 |
|
|
. configure -menu .m1
|
528 |
|
|
foreach w [winfo children .] {
|
529 |
|
|
if {[$w cget -type] == "menubar"} {
|
530 |
|
|
break
|
531 |
|
|
}
|
532 |
|
|
}
|
533 |
|
|
list [$w postcascade 0] [. configure -menu ""] [destroy .m1] [destroy .m2]
|
534 |
|
|
} {{} {} {} {}}
|
535 |
|
|
test menuDraw-17.2 {AdjustMenuCoords - menu} {menuInteractive} {
|
536 |
|
|
catch {destroy .m1}
|
537 |
|
|
catch {destroy .m2}
|
538 |
|
|
menu .m1
|
539 |
|
|
.m1 add cascade -label test -menu .m2
|
540 |
|
|
menu .m2
|
541 |
|
|
.m2 add command -label "Hit ESCAPE to make this menu go away"
|
542 |
|
|
set tearoff [tkTearOffMenu .m1 40 40]
|
543 |
|
|
list [$tearoff postcascade 0] [destroy .m1] [destroy .m2]
|
544 |
|
|
} {{} {} {}}
|
545 |
|
|
|
546 |
|
|
deleteWindows
|