1
# This file is a Tcl script to test out Tk's "raise" and
2
# "lower" commands, plus associated code to manage window
3
# stacking order. It is organized in the standard fashion
6
# Copyright (c) 1993-1994 The Regents of the University of California.
7
# Copyright (c) 1994 Sun Microsystems, Inc.
9
# See the file "license.terms" for information on usage and redistribution
10
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12
# RCS: @(#) $Id: raise.test,v 1.2 1998/09/14 18:23:49 stanton Exp $
14
if {[info commands testmakeexist] == {}} {
15
puts "This application hasn't been compiled with the \"testmakeexist\""
16
puts "command, so I can't run this test. Are you sure you're using"
17
puts "tktest instead of wish?"
21
if {[string compare test [info procs test]] == 1} then \
24
# Procedure to create a bunch of overlapping windows, which should
25
# make it easy to detect differences in order.
28
foreach i [winfo child .raise] {
31
foreach i {a b c d e} {
32
label .raise.$i -text $i -relief raised -bd 2
34
place .raise.a -x 20 -y 60 -width 60 -height 80
35
place .raise.b -x 60 -y 60 -width 60 -height 80
36
place .raise.c -x 100 -y 60 -width 60 -height 80
37
place .raise.d -x 40 -y 20 -width 100 -height 60
38
place .raise.e -x 40 -y 120 -width 100 -height 60
41
# Procedure to return information about which windows are on top
42
# of which other windows.
44
proc raise_getOrder {} {
45
set x [winfo rootx .raise]
46
set y [winfo rooty .raise]
47
list [winfo name [winfo containing [expr $x+50] [expr $y+70]]] \
48
[winfo name [winfo containing [expr $x+90] [expr $y+70]]] \
49
[winfo name [winfo containing [expr $x+130] [expr $y+70]]] \
50
[winfo name [winfo containing [expr $x+70] [expr $y+100]]] \
51
[winfo name [winfo containing [expr $x+110] [expr $y+100]]] \
52
[winfo name [winfo containing [expr $x+50] [expr $y+130]]] \
53
[winfo name [winfo containing [expr $x+90] [expr $y+130]]] \
54
[winfo name [winfo containing [expr $x+130] [expr $y+130]]]
57
# Procedure to set up a collection of top-level windows
59
proc raise_makeToplevels {} {
60
foreach i [winfo child .] {
63
foreach i {.raise1 .raise2 .raise3} {
65
wm geom $i 150x100+0+0
70
foreach i [winfo child .] {
74
wm geom .raise 250x200+0+0
76
test raise-1.1 {preserve creation order} {
81
test raise-1.2 {preserve creation order} {
83
testmakeexist .raise.a
87
test raise-1.3 {preserve creation order} {
89
testmakeexist .raise.c
93
test raise-1.4 {preserve creation order} {
95
testmakeexist .raise.e
99
test raise-1.5 {preserve creation order} {
101
testmakeexist .raise.d .raise.c .raise.b
106
test raise-2.1 {raise internal windows before creation} {
112
test raise-2.2 {raise internal windows before creation} {
118
test raise-2.3 {raise internal windows before creation} {
124
test raise-2.4 {raise internal windows before creation} {
126
raise .raise.e .raise.a
130
test raise-2.5 {raise internal windows before creation} {
132
raise .raise.a .raise.d
137
test raise-3.1 {raise internal windows after creation} {
140
raise .raise.a .raise.d
143
test raise-3.2 {raise internal windows after creation} {
145
testmakeexist .raise.a .raise.b
146
raise .raise.a .raise.b
150
test raise-3.3 {raise internal windows after creation} {
152
testmakeexist .raise.a .raise.d
153
raise .raise.a .raise.b
157
test raise-3.4 {raise internal windows after creation} {
159
testmakeexist .raise.a .raise.c .raise.d
160
raise .raise.a .raise.b
165
test raise-4.1 {raise relative to nephews} {
169
raise .raise.a .raise.d.child
172
test raise-4.2 {raise relative to nephews} {
176
list [catch {raise .raise.a .raise2} msg] $msg
177
} {1 {can't raise ".raise.a" above ".raise2"}}
178
catch {destroy .raise2}
180
test raise-5.1 {lower internal windows} {
186
test raise-5.2 {lower internal windows} {
189
lower .raise.d .raise.b
192
test raise-5.3 {lower internal windows} {
195
lower .raise.a .raise.e
198
test raise-5.4 {lower internal windows} {
202
list [catch {lower .raise.a .raise2} msg] $msg
203
} {1 {can't lower ".raise.a" below ".raise2"}}
204
catch {destroy .raise2}
206
test raise-6.1 {raise/lower toplevel windows} {nonPortable} {
210
winfo containing [winfo rootx .raise1] [winfo rooty .raise1]
212
test raise-6.2 {raise/lower toplevel windows} {nonPortable} {
216
winfo containing [winfo rootx .raise1] [winfo rooty .raise1]
218
test raise-6.3 {raise/lower toplevel windows} {nonPortable} {
223
raise .raise1 .raise3
224
set result [winfo containing [winfo rootx .raise1] \
225
[winfo rooty .raise1]]
229
list $result [winfo containing [winfo rootx .raise1] \
230
[winfo rooty .raise1]]
232
test raise-6.4 {raise/lower toplevel windows} {nonPortable} {
237
lower .raise3 .raise1
238
set result [winfo containing [winfo rootx .raise1] \
239
[winfo rooty .raise1]]
240
wm geometry .raise2 +30+30
241
wm geometry .raise1 +60+60
245
list $result [winfo containing [winfo rootx .raise2] \
246
[winfo rooty .raise2]]
248
test raise-6.5 {raise/lower toplevel windows} {nonPortable} {
251
set time [lindex [time {raise .raise1}] 0]
252
expr {$time < 2000000}
254
test raise-6.6 {raise/lower toplevel windows} {nonPortable} {
262
lower .raise3 .raise1.f1.f2
263
set result [winfo containing [winfo rootx .raise1] \
264
[winfo rooty .raise1]]
268
list $result [winfo containing [winfo rootx .raise2] \
269
[winfo rooty .raise2]]
272
test raise-7.1 {errors in raise/lower commands} {
273
list [catch {raise} msg] $msg
274
} {1 {wrong # args: should be "raise window ?aboveThis?"}}
275
test raise-7.2 {errors in raise/lower commands} {
276
list [catch {raise a b c} msg] $msg
277
} {1 {wrong # args: should be "raise window ?aboveThis?"}}
278
test raise-7.3 {errors in raise/lower commands} {
279
list [catch {raise badName} msg] $msg
280
} {1 {bad window path name "badName"}}
281
test raise-7.4 {errors in raise/lower commands} {
282
list [catch {raise . badName2} msg] $msg
283
} {1 {bad window path name "badName2"}}
284
test raise-7.5 {errors in raise/lower commands} {
285
list [catch {lower} msg] $msg
286
} {1 {wrong # args: should be "lower window ?belowThis?"}}
287
test raise-7.6 {errors in raise/lower commands} {
288
list [catch {lower a b c} msg] $msg
289
} {1 {wrong # args: should be "lower window ?belowThis?"}}
290
test raise-7.7 {errors in raise/lower commands} {
291
list [catch {lower badName3} msg] $msg
292
} {1 {bad window path name "badName3"}}
293
test raise-7.8 {errors in raise/lower commands} {
294
list [catch {lower . badName4} msg] $msg
295
} {1 {bad window path name "badName4"}}
297
foreach i [winfo child .] {