summaryrefslogtreecommitdiffstats
path: root/tests/geometry.test
blob: 615ccc715af60e3018ec9402c595145802f1ddd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# This file is a Tcl script to test the procedures in the file
# tkGeometry.c (generic support for geometry managers).  It is
# organized in the standard fashion for Tcl tests.
#
# Copyright (c) 1994 The Regents of the University of California.
# Copyright (c) 1994 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
# RCS: @(#) $Id: geometry.test,v 1.3 1999/04/16 01:51:37 stanton Exp $

if {[lsearch [namespace children] ::tcltest] == -1} {
    source [file join [pwd] [file dirname [info script]] defs.tcl]
}

foreach i [winfo children .] {
    destroy $i
}
wm geometry . 300x300
raise .
update

frame .f -bd 2 -relief raised
frame .f.f -bd 2 -relief sunken
frame .f.f.f -bd 2 -relief raised
button .b1 -text .b1
button .b2 -text .b2
button .b3 -text .b3
button .f.f.b4 -text .b4

test geometry-1.1 {Tk_ManageGeometry procedure} {
    place .b1 -x 120 -y 80
    update
    list [winfo x .b1] [winfo y .b1]
} {120 80}
test geometry-1.2 {Tk_ManageGeometry procedure} {
    foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
	place forget $w
    }
    place .f -x 20 -y 30 -width 200 -height 200
    place .b1 -in .f -x 40 -y 30
    update
    pack .b1 -side top -anchor w
    place .f -x 30 -y 40
    update
    list [winfo x .b1] [winfo y .b1]
} {0 0}

test geometry-2.1 {Tk_GeometryRequest procedure} {
    frame .f2
    set result [list [winfo reqwidth .f2] [winfo reqheight .f2]]
    .f2 configure -width 150 -height 300
    update
    lappend result [winfo reqwidth .f2] [winfo reqheight .f2] \
	    [winfo geom .f2]
    place .f2 -x 10 -y 20
    update
    lappend result [winfo geom .f2]
    .f2 configure -width 100 -height 80
    update
    lappend result [winfo geom .f2]
} {1 1 150 300 1x1+0+0 150x300+10+20 100x80+10+20}
catch {destroy .f2}

test geometry-3.1 {Tk_SetInternalBorder procedure} {
    foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
	place forget $w
    }
    place .f -x 20 -y 30 -width 200 -height 200
    place .b1 -in .f -x 50 -y 5
    update
    set x [list [winfo x .b1] [winfo y .b1]]
    .f configure -bd 5
    update
    lappend x [winfo x .b1] [winfo y .b1]
} {72 37 75 40}
.f configure -bd 2

test geometry-4.1 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
    foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
	place forget $w
    }
    place .f -x 20 -y 30 -width 200 -height 200
    place .f.f -x 15 -y 5 -width 150 -height 120
    place .f.f.f -width 100 -height 80
    place .b1 -in .f.f.f -x 50 -y 5
    update
    list [winfo x .b1] [winfo y .b1]
} {91 46}
test geometry-4.2 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
    foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
	place forget $w
    }
    place .f -x 20 -y 30 -width 200 -height 200
    place .f.f -x 15 -y 5 -width 150 -height 120
    place .f.f.f -width 100 -height 80
    place .b1 -in .f.f.f -x 50 -y 5
    place .b2 -in .f.f.f -x 10 -y 25
    place .b3 -in .f.f.f -x 50 -y 25
    update
    place .f -x 30 -y 25
    update
    list [winfo x .b1] [winfo y .b1] [winfo x .b2] [winfo y .b2] \
	    [winfo x .b3] [winfo y .b3]
} {101 41 61 61 101 61}
test geometry-4.3 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
    foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
	place forget $w
    }
    place .f -x 20 -y 30 -width 200 -height 200
    place .f.f -x 15 -y 5 -width 150 -height 120
    place .f.f.f -width 100 -height 80
    place .b1 -in .f.f.f -x 50 -y 5
    place .b2 -in .f.f.f -x 10 -y 25
    place .b3 -in .f.f.f -x 50 -y 25
    update
    destroy .b1
    button .b1 -text .b1
    place .f.f -x 10 -y 25
    update
    list [winfo x .b1] [winfo y .b1] [winfo x .b2] [winfo y .b2] \
	    [winfo x .b3] [winfo y .b3]
} {0 0 46 86 86 86}
test geometry-4.4 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
    foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
	place forget $w
    }
    place .f -x 20 -y 30 -width 200 -height 200
    place .f.f -x 15 -y 5 -width 150 -height 120
    place .f.f.f -width 100 -height 80
    place .b1 -in .f.f.f -x 50 -y 5
    place .b2 -in .f.f.f -x 10 -y 25
    place .b3 -in .f.f.f -x 50 -y 25
    update
    destroy .b2
    button .b2 -text .b2
    place .f.f.f -x 2 -y 3
    update
    list [winfo x .b1] [winfo y .b1] [winfo x .b2] [winfo y .b2] \
	    [winfo x .b3] [winfo y .b3]
} {93 49 0 0 93 69}
test geometry-4.5 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
    foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
	place forget $w
    }
    place .f -x 20 -y 30 -width 200 -height 200
    place .f.f -x 15 -y 5 -width 150 -height 120
    place .f.f.f -width 100 -height 80
    place .b1 -in .f.f.f -x 50 -y 5
    place .b2 -in .f.f.f -x 10 -y 25
    place .b3 -in .f.f.f -x 50 -y 25
    update
    destroy .b3
    button .b3 -text .b3
    place .f.f.f -x 2 -y 3
    update
    list [winfo x .b1] [winfo y .b1] [winfo x .b2] [winfo y .b2] \
	    [winfo x .b3] [winfo y .b3]
} {93 49 53 69 0 0}
test geometry-4.6 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
    foreach w {.f .f.f .f.f.f .b1 .b2 .b3 .f.f.b4} {
	place forget $w
    }
    place .f -x 20 -y 30 -width 200 -height 200
    place .f.f -x 15 -y 5 -width 150 -height 120
    place .f.f.f -width 100 -height 80
    place .f.f.b4 -in .f.f.f -x 50 -y 5
    place .b2 -in .f.f.f -x 10 -y 25
    update
    place .f -x 25 -y 35
    update
    list [winfo x .f.f.b4] [winfo y .f.f.b4] [winfo x .b2] [winfo y .b2]
} {54 9 56 71}
test geometry-4.7 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
    foreach w {.f .f.f .f.f.f .b1 .b2 .b3 .f.f.b4} {
	place forget $w
    }
    bind .b1 <Configure> {lappend x configure}
    place .f -x 20 -y 30 -width 200 -height 200
    place .f.f -x 15 -y 5 -width 150 -height 120
    place .f.f.f -width 100 -height 80
    place .f.f.b4 -in .f.f.f -x 50 -y 5
    place .b1 -in .f.f.f -x 10 -y 25
    update
    set x init
    place .f -x 25 -y 35
    update
    lappend x |
    place .f -x 30 -y 40
    place .f.f -x 10 -y 0
    update
    bind .b1 <Configure> {}
    set x
} {init configure |}
test geometry-4.8 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
    foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
	place forget $w
    }
    place .f -x 20 -y 30 -width 200 -height 200
    place .f.f -x 15 -y 5 -width 150 -height 120
    place .f.f.f -width 100 -height 80
    place .b1 -in .f.f.f -x 50 -y 5
    place .b2 -in .f.f.f -x 10 -y 25
    place .b3 -in .f.f.f -x 50 -y 25
    update
    destroy .f.f
    frame .f.f -bd 2 -relief raised
    frame .f.f.f -bd 2 -relief raised
    place .f -x 30 -y 25
    update
    list [winfo x .b1] [winfo y .b1] [winfo ismapped .b1] \
	    [winfo x .b2] [winfo y .b2] [winfo ismapped .b2] \
	    [winfo x .b3] [winfo y .b3] [winfo ismapped .b3]
} {91 46 0 51 66 0 91 66 0}
test geometry-4.9 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
    foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
	place forget $w
    }
    place .f -x 20 -y 30 -width 200 -height 200
    place .f.f -x 15 -y 5 -width 150 -height 120
    place .f.f.f -width 100 -height 80
    place .b1 -in .f.f.f -x 50 -y 5
    update
    set result [winfo ismapped .b1]
    place forget .f.f
    update
    lappend result [winfo ismapped .b1]
    place .f.f -x 15 -y 5 -width 150 -height 120
    update
    lappend result [winfo ismapped .b1]
} {1 0 1}
test geometry-4.10 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
    toplevel .t
    wm geometry .t +0+0
    tkwait visibility .t
    update
    frame .t.f 
    pack .t.f
    button .t.quit -text Quit -command exit
    pack .t.quit -in .t.f
    wm iconify .t
    set x 0
    after 500 {set x 1}
    tkwait variable x
    wm deiconify .t
    update
    winfo ismapped .t.quit
} {1}

catch {destroy .t}

# cleanup
::tcltest::cleanupTests
return