1# This file is a Tcl script to test entry widgets in Tk.  It is
2# organized in the standard fashion for Tcl tests.
3#
4# Copyright (c) 1994 The Regents of the University of California.
5# Copyright (c) 1994-1997 Sun Microsystems, Inc.
6# Copyright (c) 1998-1999 by Scriptics Corporation.
7# All rights reserved.
8
9package require tcltest 2.1
10eval tcltest::configure $argv
11tcltest::loadTestedCommands
12
13set i 1
14panedwindow .p
15foreach {testName testData} {
16    panedwindow-1.1 {-background
17	"#ff0000" "#ff0000" non-existent {unknown color name "non-existent"}}
18    panedwindow-1.2 {-bd
19	4 4 badValue {bad screen distance "badValue"}}
20    panedwindow-1.3 {-bg
21	"#ff0000" "#ff0000" non-existent {unknown color name "non-existent"}}
22    panedwindow-1.4 {-borderwidth
23	1.3 1 badValue {bad screen distance "badValue"}}
24    panedwindow-1.5 {-cursor
25	arrow arrow badValue {bad cursor spec "badValue"}}
26    panedwindow-1.6 {-handlesize
27	20 20 badValue {bad screen distance "badValue"}}
28    panedwindow-1.7 {-height
29	20 20 badValue {bad screen distance "badValue"}}
30    panedwindow-1.8 {-opaqueresize
31	true 1 foo {expected boolean value but got "foo"}}
32    panedwindow-1.9 {-proxybackground
33	"#f0a0a0" "#f0a0a0" non-existent {unknown color name "non-existent"}}
34    panedwindow-1.10 {-proxyborderwidth
35	1.3 1.3 badValue {bad screen distance "badValue"}}
36    panedwindow-1.11 {-proxyrelief
37	groove groove
38	1.5 {bad relief "1.5": must be flat, groove, raised, ridge, solid, or sunken}}
39    panedwindow-1.12 {-orient
40	horizontal horizontal
41	badValue {bad orient "badValue": must be horizontal or vertical}}
42    panedwindow-1.13 {-relief
43	groove groove
44	1.5 {bad relief "1.5": must be flat, groove, raised, ridge, solid, or sunken}}
45    panedwindow-1.14 {-sashcursor
46	arrow arrow badValue {bad cursor spec "badValue"}}
47    panedwindow-1.15 {-sashpad
48	1.3 1 badValue {bad screen distance "badValue"}}
49    panedwindow-1.16 {-sashrelief
50	groove groove
51	1.5 {bad relief "1.5": must be flat, groove, raised, ridge, solid, or sunken}}
52    panedwindow-1.17 {-sashwidth
53	10 10 badValue {bad screen distance "badValue"}}
54    panedwindow-1.18 {-showhandle
55	true 1 foo {expected boolean value but got "foo"}}
56    panedwindow-1.19 {-width
57	402 402 badValue {bad screen distance "badValue"}}
58} {
59    lassign $testData optionName goodIn goodOut badIn badOut
60    test ${testName}(good) "configuration options: $optionName" {
61	.p configure $optionName $goodIn
62	list [lindex [.p configure $optionName] 4] [.p cget $optionName]
63    } [list $goodOut $goodOut]
64    test ${testName}(bad) "configuration options: $optionName" -body {
65	.p configure $optionName $badIn
66    } -returnCodes error -result $badOut
67    # Reset to default
68    .p configure $optionName [lindex [.p configure $optionName] 3]
69}
70.p add [button .b]
71.p add [button .c]
72foreach {testName testData} {
73    panedwindow-1a.1 {-after .c .c badValue {bad window path name "badValue"}}
74    panedwindow-1a.2 {-before .c .c badValue {bad window path name "badValue"}}
75    panedwindow-1a.3 {-height 10 10 badValue {bad screen distance "badValue"}}
76    panedwindow-1a.4 {-hide false 0 foo {expected boolean value but got "foo"}}
77    panedwindow-1a.5 {-minsize 10 10 badValue {bad screen distance "badValue"}}
78    panedwindow-1a.6 {-padx 1.3 1 badValue {bad screen distance "badValue"}}
79    panedwindow-1a.7 {-pady 1.3 1 badValue {bad screen distance "badValue"}}
80    panedwindow-1a.8 {-sticky nsew nesw abcd {bad stickyness value "abcd": must be a string containing zero or more of n, e, s, and w}}
81    panedwindow-1a.9 {-stretch alw always foo {bad stretch "foo": must be always, first, last, middle, or never}}
82    panedwindow-1a.10 {-width 10 10 badValue {bad screen distance "badValue"}}
83} {
84    lassign $testData optionName goodIn goodOut badIn badOut
85    test ${testName}(good) "configuration options: $optionName" {
86	.p paneconfigure .b $optionName $goodIn
87	list [lindex [.p paneconfigure .b $optionName] 4] \
88	    [.p panecget .b $optionName]
89    } [list $goodOut $goodOut]
90    test ${testName}(bad) "configuration options: $optionName" -body {
91	.p paneconfigure .b $optionName $badIn
92    } -returnCodes error -result $badOut
93    # Reset to default
94    .p paneconfig .b $optionName [lindex [.p paneconfig .b $optionName] 3]
95}
96destroy .p .b .c
97
98test panedwindow-2.1 {panedwindow widget command} {
99    panedwindow .p
100    set result [list [catch {.p foo} msg] $msg]
101    destroy .p
102    set result
103} {1 {bad command "foo": must be add, cget, configure, forget, identify, panecget, paneconfigure, panes, proxy, or sash}}
104
105test panedwindow-3.1 {panedwindow panes subcommand} {
106    panedwindow .p
107    .p add [button .b]
108    .p add [button .c]
109    set result [list [.p panes]]
110    .p forget .b
111    lappend result [.p panes]
112    destroy .p .b .c
113    set result
114} [list [list .b .c] [list .c]]
115
116test panedwindow-4.1 {forget subcommand} {
117    panedwindow .p
118    set result [list [catch {.p forget} msg] $msg]
119    destroy .p
120    set result
121} [list 1 "wrong # args: should be \".p forget widget ?widget ...?\""]
122test panedwindow-4.2 {forget subcommand, forget one from start} {
123    panedwindow .p
124    .p add [button .b]
125    .p add [button .c]
126    set result [list [.p panes]]
127    .p forget .b
128    lappend result [.p panes]
129    destroy .p .b .c
130    set result
131} [list {.b .c} .c]
132test panedwindow-4.3 {forget subcommand, forget one from end} {
133    panedwindow .p
134    .p add [button .b]
135    .p add [button .c]
136    .p add [button .d]
137    set result [list [.p panes]]
138    .p forget .d
139    update
140    lappend result [.p panes]
141    destroy .p .b .c .d
142    set result
143} [list {.b .c .d} {.b .c}]
144test panedwindow-4.4 {forget subcommand, forget multiple} {
145    panedwindow .p
146    .p add [button .b]
147    .p add [button .c]
148    .p add [button .d]
149    set result [list [.p panes]]
150    .p forget .b .c
151    update
152    lappend result [.p panes]
153    destroy .p .b .c .d
154    set result
155} [list {.b .c .d} .d]
156test panedwindow-4.5 {forget subcommand, panes are unmapped} {
157    panedwindow .p
158    .p add [button .b]
159    .p add [button .c]
160    pack .p
161    update
162
163    set result [list [winfo ismapped .b] [winfo ismapped .c]]
164    .p forget .b
165    update
166
167    lappend result [winfo ismapped .b] [winfo ismapped .c]
168    destroy .p .b .c
169
170    set result
171} [list 1 1 0 1]
172test panedwindow-4.6 {forget subcommand, changes reqsize of panedwindow} {
173    panedwindow .p -borderwidth 0 -sashpad 0 -sashwidth 4 -showhandle false
174    .p add [frame .f -width 20 -height 20] [frame .g -width 20 -height 20]
175    set result [list [winfo reqwidth .p]]
176    .p forget .f
177    lappend result [winfo reqwidth .p]
178    destroy .p .f .g
179    set result
180} [list 44 20]
181
182test panedwindow-5.1 {sash subcommand} {
183    panedwindow .p
184    set result [list [catch {.p sash} msg] $msg]
185    destroy .p
186    set result
187} [list 1 "wrong # args: should be \".p sash option ?arg ...?\""]
188test panedwindow-5.2 {sash subcommand} {
189    panedwindow .p
190    set result [list [catch {.p sash foo} msg] $msg]
191    destroy .p
192    set result
193} [list 1 "bad option \"foo\": must be coord, dragto, mark, or place"]
194
195test panedwindow-6.1 {sash coord subcommand, errors} {
196    panedwindow .p
197    set result [list [catch {.p sash coord} msg] $msg]
198    destroy .p
199    set result
200} [list 1 "wrong # args: should be \".p sash coord index\""]
201test panedwindow-6.2 {sash coord subcommand, errors} {
202    panedwindow .p -borderwidth 0 -sashpad 0 -sashwidth 4
203    set result [list [catch {.p sash coord 0} msg] $msg]
204    destroy .p
205    set result
206} [list 1 "invalid sash index"]
207test panedwindow-6.3 {sash coord subcommand, errors} {
208    panedwindow .p
209    set result [list [catch {.p sash coord foo} msg] $msg]
210    destroy .p
211    set result
212} [list 1 "expected integer but got \"foo\""]
213test panedwindow-6.4 {sash coord subcommand sashes correctly placed} {
214    panedwindow .p -borderwidth 0 -sashpad 2 -sashwidth 4 -showhandle false
215    .p add [frame .p.f -width 20 -height 20] \
216	    [frame .p.f2 -width 20 -height 20] \
217	    [frame .p.f3 -width 20 -height 20]
218    set result [.p sash coord 0]
219    destroy .p .p.f .p.f2 .p.f3
220    set result
221} [list 22 0]
222test panedwindow-6.5 {sash coord subcommand sashes correctly placed} {
223    panedwindow .p -borderwidth 0 -sashpad 2 -sashwidth 4 -showhandle false
224    .p add [frame .p.f -width 20 -height 20] \
225	    [frame .p.f2 -width 20 -height 20] \
226	    [frame .p.f3 -width 20 -height 20]
227    set result [.p sash coord 1]
228    destroy .p .p.f .p.f2 .p.f3
229    set result
230} [list 50 0]
231test panedwindow-6.6 {sash coord subcommand, sashes correctly placed} {
232    panedwindow .p -borderwidth 0 -sashpad 2 -sashwidth 4 -orient vertical \
233            -showhandle false
234    .p add [frame .p.f -width 20 -height 20] \
235	    [frame .p.f2 -width 20 -height 20] \
236	    [frame .p.f3 -width 20 -height 20]
237    set result [.p sash coord 0]
238    destroy .p .p.f .p.f2 .p.f3
239    set result
240} [list 0 22]
241test panedwindow-6.7 {sash coord subcommand, sashes correctly placed} {
242    panedwindow .p -borderwidth 0 -sashpad 2 -sashwidth 4 -orient vertical \
243            -showhandle false
244    .p add [frame .p.f -width 20 -height 20] \
245	    [frame .p.f2 -width 20 -height 20] \
246	    [frame .p.f3 -width 20 -height 20]
247    set result [.p sash coord 1]
248    destroy .p .p.f .p.f2 .p.f3
249    set result
250} [list 0 50]
251test panedwindow-6.8 {sash coord subcommand, errors} {
252    panedwindow .p
253    set result [list \
254	    [catch {.p sash coord -1} msg] $msg \
255	    [catch {.p sash coord  0} msg] $msg \
256	    [catch {.p sash coord  1} msg] $msg \
257	    ]
258    destroy .p
259    set result
260} [list 1 "invalid sash index" 1 "invalid sash index" 1 "invalid sash index"]
261test panedwindow-6.9 {sash coord subcommand, errors} {
262    # There are no sashes until you have 2 panes
263    panedwindow .p
264    .p add [frame .p.f]
265    set result [list \
266	    [catch {.p sash coord -1} msg] $msg \
267	    [catch {.p sash coord  0} msg] $msg \
268	    [catch {.p sash coord  1} msg] $msg \
269	    ]
270    destroy .p
271    set result
272} [list 1 "invalid sash index" 1 "invalid sash index" 1 "invalid sash index"]
273test panedwindow-6.10 {sash coord subcommand, errors} {
274    # There are no sashes until you have 2 panes
275    panedwindow .p
276    .p add [frame .p.f] [frame .p.f2]
277    set result [list \
278	    [catch {.p sash coord -1} msg] $msg \
279	    [catch {.p sash coord  0} msg] \
280	    [catch {.p sash coord  1} msg] $msg \
281	    [catch {.p sash coord  2} msg] $msg \
282	    ]
283    destroy .p
284    set result
285} [list 1 "invalid sash index" 0 1 "invalid sash index" 1 "invalid sash index"]
286
287test panedwindow-8.1 {sash mark subcommand, errors} {
288    panedwindow .p
289    set result [list [catch {.p sash mark} msg] $msg]
290    destroy .p
291    set result
292} [list 1 "wrong # args: should be \".p sash mark index ?x y?\""]
293test panedwindow-8.2 {sash mark subcommand, errors} {
294    panedwindow .p
295    set result [list [catch {.p sash mark foo} msg] $msg]
296    destroy .p
297    set result
298} [list 1 "expected integer but got \"foo\""]
299test panedwindow-8.3 {sash mark subcommand, errors} {
300    panedwindow .p
301    set result [list [catch {.p sash mark 0 foo bar} msg] $msg]
302    destroy .p
303    set result
304} [list 1 "invalid sash index"]
305test panedwindow-8.4 {sash mark subcommand, errors} {
306    panedwindow .p
307    .p add [button .b] [button .c]
308    set result [list [catch {.p sash mark 0 foo bar} msg] $msg]
309    destroy .p .b .c
310    set result
311} [list 1 "expected integer but got \"foo\""]
312test panedwindow-8.5 {sash mark subcommand, errors} {
313    panedwindow .p
314    .p add [button .b] [button .c]
315    set result [list [catch {.p sash mark 0 0 bar} msg] $msg]
316    destroy .p .b .c
317    set result
318} [list 1 "expected integer but got \"bar\""]
319test panedwindow-8.6 {sash mark subcommand, mark defaults to 0 0} {
320    panedwindow .p
321    .p add [button .b] [button .c]
322    set result [.p sash mark 0]
323    destroy .p .b .c
324    set result
325} [list 0 0]
326test panedwindow-8.7 {sash mark subcommand, set mark} {
327    panedwindow .p
328    .p add [button .b] [button .c]
329    .p sash mark 0 10 10
330    set result [.p sash mark 0]
331    destroy .p .b .c
332    set result
333} [list 10 10]
334
335test panedwindow-9.1 {sash dragto subcommand, errors} {
336    panedwindow .p
337    set result [list [catch {.p sash dragto} msg] $msg]
338    destroy .p
339    set result
340} [list 1 "wrong # args: should be \".p sash dragto index x y\""]
341test panedwindow-9.2 {sash dragto subcommand, errors} {
342    panedwindow .p
343    set result [list [catch {.p sash dragto foo bar baz} msg] $msg]
344    destroy .p
345    set result
346} [list 1 "expected integer but got \"foo\""]
347test panedwindow-9.3 {sash dragto subcommand, errors} {
348    panedwindow .p
349    set result [list [catch {.p sash dragto 0 foo bar} msg] $msg]
350    destroy .p
351    set result
352} [list 1 "invalid sash index"]
353test panedwindow-9.4 {sash dragto subcommand, errors} {
354    panedwindow .p
355    .p add [button .b] [button .c]
356    set result [list [catch {.p sash dragto 0 foo bar} msg] $msg]
357    destroy .p .b .c
358    set result
359} [list 1 "expected integer but got \"foo\""]
360test panedwindow-9.5 {sash dragto subcommand, errors} {
361    panedwindow .p
362    .p add [button .b] [button .c]
363    set result [list [catch {.p sash dragto 0 0 bar} msg] $msg]
364    destroy .p .b .c
365    set result
366} [list 1 "expected integer but got \"bar\""]
367
368test panedwindow-10.1 {sash mark/sash dragto interaction} {
369    panedwindow .p -borderwidth 0 -sashpad 0 -sashwidth 4 -showhandle false
370    .p add [frame .f -width 20 -height 20] [button .c -text foobar]
371    .p sash mark 0 10 10
372    .p sash dragto 0 20 10
373    set result [.p sash coord 0]
374    destroy .p .f .c
375    set result
376} [list 30 0]
377test panedwindow-10.2 {sash mark/sash dragto interaction} {
378    panedwindow .p -borderwidth 0 -sashpad 0 -sashwidth 4 -orient vertical \
379            -showhandle false
380    .p add [frame .p.f -width 20 -height 20] [button .p.c -text foobar]
381    .p sash mark 0 10 10
382    .p sash dragto 0 10 20
383    set result [.p sash coord 0]
384    destroy .p .p.f .p.c
385    set result
386} [list 0 30]
387test panedwindow-10.3 {sash mark/sash dragto, respects minsize}  {
388    panedwindow .p -borderwidth 0 -sashpad 0 -sashwidth 4 -showhandle false
389    .p add [frame .f -width 20 -height 20] [button .c] -minsize 15
390    .p sash mark 0 20 10
391    .p sash dragto 0 10 10
392    set result [.p sash coord 0]
393    destroy .p .f .c
394    set result
395} [list 15 0]
396
397test panedwindow-11.1 {sash place subcommand, errors} {
398    panedwindow .p
399    set result [list [catch {.p sash place} msg] $msg]
400    destroy .p
401    set result
402} [list 1 "wrong # args: should be \".p sash place index x y\""]
403test panedwindow-11.2 {sash place subcommand, errors} {
404    destroy .p
405    panedwindow .p
406    list [catch {.p sash place foo bar baz} msg] $msg
407} [list 1 "expected integer but got \"foo\""]
408test panedwindow-11.3 {sash place subcommand, errors} {
409    destroy .p
410    panedwindow .p
411    list [catch {.p sash place 0 foo bar} msg] $msg
412} [list 1 "invalid sash index"]
413test panedwindow-11.4 {sash place subcommand, errors} {
414    destroy .p .b .c
415    panedwindow .p
416    .p add [button .b] [button .c]
417    list [catch {.p sash place 0 foo bar} msg] $msg
418} [list 1 "expected integer but got \"foo\""]
419test panedwindow-11.5 {sash place subcommand, errors} {
420    destroy .p .f .c .b
421    panedwindow .p
422    .p add [button .b] [button .c]
423    list [catch {.p sash place 0 0 bar} msg] $msg
424} [list 1 "expected integer but got \"bar\""]
425test panedwindow-11.6 {sash place subcommand, moves sash} {
426    destroy .p .f .c .b
427    panedwindow .p -borderwidth 0 -sashpad 0 -sashwidth 4
428    .p add [frame .f -width 20 -height 20] [button .c]
429    .p sash place 0 10 0
430    .p sash coord 0
431} [list 10 0]
432test panedwindow-11.7 {sash place subcommand, moves sash} {
433    destroy .p .f .c
434    panedwindow .p -borderwidth 0 -sashpad 0 -sashwidth 4 -orient vertical
435    .p add [frame .f -width 20 -height 20] [button .c]
436    .p sash place 0 0 10
437    .p sash coord 0
438} [list 0 10]
439test panedwindow-11.8 {sash place subcommand, respects minsize} {
440    destroy .p .f .c
441    panedwindow .p -borderwidth 0 -sashpad 0 -sashwidth 4 -showhandle false
442    .p add [frame .f -width 20 -height 20] [button .c] -minsize 15
443    .p sash place 0 10 0
444    .p sash coord 0
445} [list 15 0]
446test panedwindow-11.9 {sash place subcommand, respects minsize} {
447    destroy .p .f .c
448    panedwindow .p
449    .p add [frame .f -width 20 -height 20 -bg pink]
450    list [catch {.p sash place 0 2 0} msg] $msg
451} [list 1 {invalid sash index}]
452
453test panedwindow-12.1 {moving sash changes size of pane to left} {
454    destroy .p .f .c
455    panedwindow .p -borderwidth 0 -sashpad 0 -sashwidth 4 -showhandle false
456    .p add [frame .f -width 20 -height 20] [button .c -text foobar] -sticky nsew
457    .p sash place 0 30 0
458    pack .p
459    update
460    winfo width .f
461} 30
462test panedwindow-12.2 {moving sash changes size of pane to right} {
463    destroy .p .f .f2
464    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 4
465    .p add [frame .f -width 20 -height 20] [frame .f2 -width 20 -height 20]
466    pack .p
467    update
468    set result [winfo width .f2]
469    .p sash place 0 30 0
470    update
471    lappend result [winfo width .f2]
472} {20 10}
473test panedwindow-12.3 {moving sash does not change reqsize of panedwindow} {
474    destroy .p .f .f2
475    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 4
476    .p add [frame .f -width 20 -height 20] [frame .f2 -width 20 -height 20]
477    .p sash place 0 30 0
478    winfo reqwidth .p
479} 44
480test panedwindow-12.4 {moving sash changes size of pane above} {
481    destroy .p .f .c
482    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 4 \
483            -orient vertical
484    .p add [frame .f -width 20 -height 10] [button .c -text foobar] -sticky nsew
485    .p sash place 0 0 20
486    pack .p
487    update
488    set result [winfo height .f]
489    destroy .p .f .c
490    set result
491} 20
492test panedwindow-12.5 {moving sash changes size of pane below} {
493    destroy .p .f .f2
494    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 4 \
495            -orient vertical
496    .p add [frame .f -width 20 -height 10] [frame .f2 -width 20 -height 10]
497    pack .p
498    update
499    set result [winfo height .f2]
500    .p sash place 0 0 15
501    update
502    lappend result [winfo height .f2]
503    destroy .p .f .f2
504    set result
505} {10 5}
506test panedwindow-12.6 {moving sash does not change reqsize of panedwindow} {
507    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 4 \
508            -orient vertical
509    .p add [frame .f -width 20 -height 10] [frame .f2 -width 20 -height 10]
510    set result [winfo reqheight .p]
511    .p sash place 0 0 20
512    lappend result [winfo reqheight .p]
513    destroy .p .f .f2
514    set result
515} [list 24 24]
516test panedwindow-12.7 {moving sash does not alter reqsize of widget} {
517    destroy .p .f .f2
518    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 4 \
519            -orient vertical
520    .p add [frame .f -width 20 -height 10] [frame .f2 -width 20 -height 10]
521    set result [winfo reqheight .f]
522    .p sash place 0 0 20
523    lappend result [winfo reqheight .f]
524    destroy .p .f .f2
525    set result
526} [list 10 10]
527test panedwindow-12.8 {moving sash restricted to minsize} {
528    destroy .p .f .c
529    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 4
530    .p add [frame .f -width 20 -height 20] [button .c] -minsize 15
531    .p sash place 0 10 0
532    pack .p
533    update
534    set result [winfo width .f]
535    destroy .p .f .c
536    set result
537} 15
538test panedwindow-12.10 {moving sash restricted to minsize} {
539    destroy .p .f .c
540    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 4 \
541            -orient vertical
542    .p add [frame .f -width 20 -height 30] [button .c] -minsize 10
543    .p sash place 0 0 5
544    pack .p
545    update
546    set result [winfo height .f]
547    destroy .p .f .c
548    set result
549} 10
550test panedwindow-12.12 {moving sash in unmapped window restricted to reqsize} {
551    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 4
552    .p add [frame .f -width 20 -height 30] [frame .f2 -width 20 -height 20]
553    set result [list [.p sash coord 0]]
554    .p sash place 0 100 0
555    lappend result [.p sash coord 0]
556    destroy .p .f .f2
557    set result
558} [list {20 0} {40 0}]
559test panedwindow-12.13 {moving sash right pushes other sashes} {
560    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 4
561    .p add [frame .f -width 20 -height 30] [frame .f2 -width 20 -height 20] \
562	    [frame .f3 -width 20 -height 30]
563    .p sash place 0 80 0
564    set result [list [.p sash coord 0] [.p sash coord 1]]
565    destroy .p .f .f2 .f3
566    set result
567} {{60 0} {64 0}}
568test panedwindow-12.14 {moving sash left pushes other sashes} {
569    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 4
570    .p add [frame .f -width 20 -height 30] [frame .f2 -width 20 -height 20] \
571	    [frame .f3 -width 20 -height 30]
572    .p sash place 1 0 0
573    set result [list [.p sash coord 0] [.p sash coord 1]]
574    destroy .p .f .f2 .f3
575    set result
576} {{0 0} {4 0}}
577test panedwindow-12.15 {move sash in mapped window restricted to visible win} {
578    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 4
579    .p add [frame .f -width 20 -height 30] [frame .f2 -width 20 -height 20] \
580	    [frame .f3 -width 20 -height 30]
581    place .p -width 50
582    update
583    .p sash place 1 100 0
584    update
585    set result [.p sash coord 1]
586    destroy .p .f .f2 .f3
587    set result
588} {46 0}
589test panedwindow-12.16 {move sash in mapped window restricted to visible win} {
590    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 4
591    .p add [frame .f -width 20 -height 30] [frame .f2 -width 20 -height 20] \
592	    [frame .f3 -width 20 -height 30]
593    place .p -width 100
594    update
595    .p sash place 1 200 0
596    update
597    set result [.p sash coord 1]
598    destroy .p .f .f2 .f3
599    set result
600} {96 0}
601test panedwindow-12.17 {moving sash into "virtual" space on \
602	last pane increases reqsize} {
603    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 4
604    .p add [frame .f -width 20 -height 30] [frame .f2 -width 20 -height 20] \
605	    [frame .f3 -width 20 -height 30]
606    place .p -width 100
607    set result [winfo reqwidth .p]
608    update
609    .p sash place 1 200 0
610    update
611    lappend result [winfo reqwidth .p]
612    destroy .p .f .f2 .f3
613    set result
614} {68 100}
615
616test panedwindow-13.1 {horizontal panedwindow lays out widgets properly} {
617    panedwindow .p -showhandle false -borderwidth 2 -sashpad 2 -sashwidth 2
618    foreach win {.p.f .p.f2 .p.f3} {.p add [frame $win -width 20 -height 10]}
619    pack .p
620    update
621    set result {}
622    foreach w [.p panes] {lappend result [winfo x $w] [winfo y $w]}
623    destroy .p .p.f .p.f2 .p.f3
624    set result
625} [list 2 2 28 2 54 2]
626test panedwindow-13.2 {vertical panedwindow lays out widgets properly} {
627    panedwindow .p -showhandle false -borderwidth 2 -sashpad 2 -sashwidth 2 \
628            -orient vertical
629    foreach win {.p.f .p.f2 .p.f3} {.p add [frame $win -width 20 -height 10]}
630    pack .p
631    update
632    set result {}
633    foreach w [.p panes] {lappend result [winfo x $w] [winfo y $w]}
634    destroy .p .p.f .p.f2 .p.f3
635    set result
636} [list 2 2 2 18 2 34]
637test panedwindow-13.3 {horizontal panedwindow lays out widgets properly} {
638    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 0
639    foreach {win color} {.p.f blue .p.f2 green} {
640	.p add [frame $win -width 20 -height 20 -bg $color] -padx 10 -pady 5 \
641                -sticky ""
642    }
643    pack .p
644    update
645    set result [list [winfo reqwidth .p] [winfo reqheight .p]]
646    foreach win {.p.f .p.f2} {lappend result [winfo x $win] [winfo y $win]}
647    .p paneconfigure .p.f -padx 0 -pady 0
648    update
649    lappend result [winfo reqwidth .p] [winfo reqheight .p]
650    foreach win {.p.f .p.f2} {lappend result [winfo x $win] [winfo y $win]}
651    destroy .p .p.f .p.f2
652    set result
653} [list 80 30 10 5 50 5 60 30 0 5 30 5]
654test panedwindow-13.4 {vertical panedwindow lays out widgets properly} {
655    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 0 \
656            -orient vertical
657    foreach win {.p.f .p.f2} {
658	.p add [frame $win -width 20 -height 20] -padx 10 -pady 5 -sticky ""
659    }
660    pack .p
661    update
662    set result [list [winfo reqwidth .p] [winfo reqheight .p]]
663    foreach win {.p.f .p.f2} {lappend result [winfo x $win] [winfo y $win]}
664    .p paneconfigure .p.f -padx 0 -pady 0
665    update
666    lappend result [winfo reqwidth .p] [winfo reqheight .p]
667    foreach win {.p.f .p.f2} {lappend result [winfo x $win] [winfo y $win]}
668    destroy .p .p.f .p.f2
669    set result
670} [list 40 60 10 5 10 35 40 50 10 0 10 25]
671test panedwindow-13.5 {panedwindow respects reqsize of panes when possible} {
672    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 0
673    .p add [frame .p.f -width 20 -height 20] -sticky ""
674    place .p -width 40
675    update
676    set result [list [winfo width .p.f]]
677    .p.f configure -width 30
678    update
679    lappend result [winfo width .p.f]
680    destroy .p .p.f
681    set result
682} [list 20 30]
683test panedwindow-13.6 {panedwindow takes explicit widget width over reqwidth} {
684    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 0
685    .p add [frame .p.f -width 20 -height 20] -width 20 -sticky ""
686    place .p -width 40
687    update
688    set result [list [winfo width .p.f]]
689    .p.f configure -width 30
690    update
691    lappend result [winfo width .p.f]
692    destroy .p .p.f
693    set result
694} [list 20 20]
695test panedwindow-13.7 {horizontal panedwindow reqheight is max slave height} {
696    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 4
697    .p add [frame .p.f -width 20 -height 20] [frame .p.f2 -width 20 -height 20]
698    set result [winfo reqheight .p]
699    .p.f config -height 40
700    lappend result [winfo reqheight .p]
701    destroy .p .p.f .p.f2
702    set result
703} {20 40}
704test panedwindow-13.8 {horizontal panedwindow reqheight is max slave height} {
705    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 4
706    foreach win {.p.f .p.f2} {.p add [frame $win -width 20 -height 20]}
707    .p paneconfigure .p.f -height 15
708    set result [winfo reqheight .p]
709    .p.f config -height 40
710    lappend result [winfo reqheight .p]
711    destroy .p .p.f .p.f2
712    set result
713} {20 20}
714test panedwindow-13.9 {panedwindow pane width overrides widget width} {
715    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 4
716    foreach win {.p.f .p.f2} {.p add [frame $win -width 20 -height 20]}
717    .p sash place 0 10 0
718    pack .p
719    update
720    set result [winfo width .p.f]
721    .p paneconfigure .p.f -width 30
722    lappend result [winfo width .p.f]
723    destroy .p .p.f .p.f2
724    set result
725} [list 10 10]
726test panedwindow-13.10 {panedwindow respects reqsize of panes when possible} {
727    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 0
728    .p add [frame .p.f -width 20 -height 20] -sticky ""
729    place .p -height 40
730    update
731    set result [list [winfo height .p.f]]
732    .p.f configure -height 30
733    update
734    lappend result [winfo height .p.f]
735    destroy .p .p.f
736    set result
737} [list 20 30]
738test panedwindow-13.11 {panedwindow takes explicit height over reqheight} {
739    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 0
740    .p add [frame .p.f -width 20 -height 20] -height 20 -sticky ""
741    place .p -height 40
742    update
743    set result [list [winfo height .p.f]]
744    .p.f configure -height 30
745    update
746    lappend result [winfo height .p.f]
747    destroy .p .p.f
748    set result
749} [list 20 20]
750test panedwindow-13.12 {vertical panedwindow reqwidth is max slave width} {
751    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 4 \
752            -orient vertical
753    .p add [frame .p.f -width 20 -height 20] [frame .p.f2 -width 20 -height 20]
754    set result [winfo reqwidth .p]
755    .p.f config -width 40
756    lappend result [winfo reqwidth .p]
757    destroy .p .p.f .p.f2
758    set result
759} {20 40}
760test panedwindow-13.13 {vertical panedwindow reqwidth is max slave width} {
761    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 4 \
762            -orient vertical
763    foreach win {.p.f .p.f2} {.p add [frame $win -width 20 -height 20]}
764    .p paneconfigure .p.f -width 15
765    set result [winfo reqwidth .p]
766    .p.f config -width 40
767    lappend result [winfo reqwidth .p]
768    destroy .p .p.f .p.f2
769    set result
770} {20 20}
771test panedwindow-13.14 {panedwindow pane height overrides widget width} {
772    destroy .p
773    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 4 \
774            -orient vertical
775    foreach win {.p.f .p.f2} {.p add [frame $win -width 20 -height 20]}
776    .p sash place 0 0 10
777    pack .p
778    update
779    set result [winfo height .p.f]
780    .p paneconfigure .p.f -height 30
781    lappend result [winfo height .p.f]
782    destroy .p
783    set result
784} [list 10 10]
785
786
787test panedwindow-14.1 {PanestructureProc, widget yields managements} {
788    # Check that the panedwindow correctly yields geometry management of
789    # a slave when the slave is destroyed.
790
791    # This test should not cause a core dump, and it should not cause
792    # a memory leak.
793    destroy .p .b
794    panedwindow .p
795    .p add [button .b]
796    destroy .p
797    pack .b
798    destroy .b
799    set result ""
800} ""
801test panedwindow-14.2 {PanedWindowLostSlaveProc, widget yields management} {
802    # Check that the paned window correctly yields geometry management of
803    # a slave when some other geometry manager steals the slave from us.
804
805    # This test should not cause a core dump, and it should not cause a
806    # memory leak.
807    destroy .p .b
808    panedwindow .p
809    .p add [button .b]
810    pack .p
811    update
812    pack .b
813    update
814    set result [.p panes]
815    destroy .p .b
816    set result
817} {}
818
819set stickysets [list n s e w sn ns en ne wn nw esn nse nsw nsew ""]
820set stickygets [list n s e w ns ns ne ne nw nw nes nes nsw nesw ""]
821set i 0
822foreach s $stickysets g $stickygets {
823    test panedwindow-15.[incr i] {panedwindow sticky settings} {
824	destroy .p .b
825	panedwindow .p -showhandle false
826	.p add [button .b]
827	.p paneconfigure .b -sticky $s
828	set result [.p panecget .b -sticky]
829	destroy .p .b
830	set result
831    } $g
832}
833
834set i 0
835foreach s [list {}  n  s  e  w ns ew nw ne se sw nse nsw sew new news] \
836	x [list 10 10 10 20  0 10  0  0 20 20  0  20   0   0   0    0] \
837	y [list 10  0 20 10 10  0 10  0  0 20 20   0   0  20   0    0] \
838	w [list 20 20 20 20 20 20 40 20 20 20 20  20  20  40  40   40] \
839	h [list 20 20 20 20 20 40 20 20 20 20 20  40  40  20  20   40] {
840    test panedwindow-16.[incr i] {panedwindow sticky works} {
841	panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 0
842	.p add [frame .p.f -height 20 -width 20 -bg red] -sticky $s
843	place .p -width 40 -height 40
844	update
845	set result [list $s [winfo x .p.f] [winfo y .p.f] \
846		[winfo width .p.f] [winfo height .p.f]]
847	destroy .p .p.f
848	set result
849    } [list $s $x $y $w $h]
850}
851
852test panedwindow-17.1 {setting minsize when pane is too small snaps width} {
853    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
854    .p add [frame .p.f -height 20 -width 20 -bg red]
855    set result [winfo reqwidth .p]
856    .p paneconfigure .p.f -minsize 40
857    lappend result [winfo reqwidth .p]
858    destroy .p .p.f .p.f2
859    set result
860} [list 20 40]
861
862test panedwindow-18.1 {MoveSash, move right} {
863    set result {}
864    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
865    foreach w {.f1 .f2} c {red blue} {
866	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew
867    }
868
869    # Get the requested width of the paned window
870    lappend result [winfo reqwidth .p]
871
872    .p sash place 0 30 0
873
874    # Get the reqwidth again, to make sure it hasn't changed
875    lappend result [winfo reqwidth .p]
876
877    # Check that the sash moved
878    lappend result [.p sash coord 0]
879
880    # Cleanup
881    destroy .p .f1 .f2
882
883    set result
884} [list 42 42 {30 0}]
885test panedwindow-18.2 {MoveSash, move right (unmapped) clipped by reqwidth} {
886    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
887    foreach w {.f1 .f2} c {red blue} {
888	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew
889    }
890
891    .p sash place 0 100 0
892
893    # Get the new sash coord; it should be clipped by the reqwidth of
894    # the panedwindow.
895    set result [.p sash coord 0]
896
897    # Cleanup
898    destroy .p .f1 .f2
899
900    set result
901} [list 40 0]
902test panedwindow-18.3 {MoveSash, move right (mapped, width < reqwidth) clipped by width} {
903    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
904    foreach w {.f1 .f2} c {red blue} {
905	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew
906    }
907
908    # Put the panedwindow up on the display and give it a width < reqwidth
909    place .p -x 0 -y 0 -width 32
910    update
911
912    .p sash place 0 100 0
913
914    # Get the new sash coord; it should be clipped by the visible width of
915    # the panedwindow.
916    set result [.p sash coord 0]
917
918    # Cleanup
919    destroy .p .f1 .f2
920
921    set result
922} [list 30 0]
923test panedwindow-18.4 {MoveSash, move right (mapped, width > reqwidth) clipped by width} {
924    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
925    foreach w {.f1 .f2} c {red blue} {
926	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew
927    }
928
929    # Put the panedwindow up on the display and give it a width > reqwidth
930    place .p -x 0 -y 0 -width 102
931    update
932
933    .p sash place 0 200 0
934
935    # Get the new sash coord; it should be clipped by the visible width of
936    # the panedwindow.
937    set result [.p sash coord 0]
938
939    # Cleanup
940    destroy .p .f1 .f2
941
942    set result
943} [list 100 0]
944test panedwindow-18.5 {MoveSash, move right respects minsize} {
945    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
946    foreach w {.f1 .f2} c {red blue} {
947	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew -minsize 10
948    }
949
950    .p sash place 0 100 0
951
952    # Get the new sash coord; it should have moved as far as possible while
953    # respecting minsizes.
954    set result [.p sash coord 0]
955
956    # Cleanup
957    destroy .p .f1 .f2
958
959    set result
960} [list 30 0]
961test panedwindow-18.6 {MoveSash, move right respects minsize} {
962    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
963    foreach w {.f1 .f2 .f3} c {red blue} {
964	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew -minsize 10
965    }
966
967    .p sash place 0 100 0
968
969    # Get the new sash coord; it should have moved as far as possible.
970    set result [.p sash coord 0]
971
972    # Cleanup
973    destroy .p .f1 .f2 .f3
974
975    set result
976} [list 40 0]
977test panedwindow-18.7 {MoveSash, move right pushes other sashes} {
978    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
979    foreach w {.f1 .f2 .f3} c {red blue} {
980	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew
981    }
982
983    .p sash place 0 100 0
984
985    # Get the new sash coord; it should have moved as far as possible while
986    # respecting minsizes.
987    set result [.p sash coord 1]
988
989    # Cleanup
990    destroy .p .f1 .f2 .f3
991
992    set result
993} [list 62 0]
994test panedwindow-18.8 {MoveSash, move right pushes other sashes, respects minsize} {
995    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
996    foreach w {.f1 .f2 .f3} c {red blue} {
997	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew -minsize 10
998    }
999
1000    .p sash place 0 100 0
1001
1002    # Get the new sash coord; it should have moved as far as possible while
1003    # respecting minsizes.
1004    set result [.p sash coord 1]
1005
1006    # Cleanup
1007    destroy .p .f1 .f2 .f3
1008
1009    set result
1010} [list 52 0]
1011test panedwindow-18.9 {MoveSash, move right respects minsize, exludes pad} {
1012    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
1013    foreach w {.f1 .f2 .f3} c {red blue} {
1014	.p add [frame $w -height 20 -width 20 -bg $c] \
1015		-sticky nsew -minsize 10 -padx 5
1016    }
1017
1018    .p sash place 0 100 0
1019
1020    # Get the new sash coord; it should have moved as far as possible,
1021    # respecting minsizes.
1022    set result [.p sash coord 0]
1023
1024    # Cleanup
1025    destroy .p .f1 .f2 .f3
1026
1027    set result
1028} [list 50 0]
1029test panedwindow-18.10 {MoveSash, move right, negative minsize becomes 0} {
1030    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
1031    foreach w {.f1 .f2 .f3} c {red blue} {
1032	.p add [frame $w -height 20 -width 20 -bg $c] \
1033		-sticky nsew -minsize -50
1034    }
1035
1036    .p sash place 0 50 0
1037
1038    # Get the new sash coord; it should have moved as far as possible,
1039    # respecting minsizes.
1040    set result [list [.p sash coord 0] [.p sash coord 1]]
1041
1042    # Cleanup
1043    destroy .p .f1 .f2 .f3
1044
1045    set result
1046} [list [list 50 0] [list 52 0]]
1047test panedwindow-18.11 {MoveSash, move left} {
1048    set result {}
1049    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
1050    foreach w {.f1 .f2} c {red blue} {
1051	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew
1052    }
1053
1054    # Get the requested width of the paned window
1055    lappend result [winfo reqwidth .p]
1056
1057    .p sash place 0 10 0
1058
1059    # Get the reqwidth again, to make sure it hasn't changed
1060    lappend result [winfo reqwidth .p]
1061
1062    # Check that the sash moved
1063    lappend result [.p sash coord 0]
1064
1065    # Cleanup
1066    destroy .p .f1 .f2
1067
1068    set result
1069} [list 42 42 {10 0}]
1070test panedwindow-18.12 {MoveSash, move left, can't move outside of window} {
1071    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
1072    foreach w {.f1 .f2} c {red blue} {
1073	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew
1074    }
1075
1076    .p sash place 0 -100 0
1077
1078    # Get the new sash coord; it should be clipped by the reqwidth of
1079    # the panedwindow.
1080    set result [.p sash coord 0]
1081
1082    # Cleanup
1083    destroy .p .f1 .f2
1084
1085    set result
1086} [list 0 0]
1087test panedwindow-18.13 {MoveSash, move left respects minsize} {
1088    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
1089    foreach w {.f1 .f2} c {red blue} {
1090	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew -minsize 10
1091    }
1092
1093    .p sash place 0 0 0
1094
1095    # Get the new sash coord; it should have moved as far as possible while
1096    # respecting minsizes.
1097    set result [.p sash coord 0]
1098
1099    # Cleanup
1100    destroy .p .f1 .f2
1101
1102    set result
1103} [list 10 0]
1104test panedwindow-18.14 {MoveSash, move left respects minsize} {
1105    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
1106    foreach w {.f1 .f2 .f3} c {red blue} {
1107	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew -minsize 10
1108    }
1109
1110    .p sash place 1 0 0
1111
1112    # Get the new sash coord; it should have moved as far as possible.
1113    set result [.p sash coord 1]
1114
1115    # Cleanup
1116    destroy .p .f1 .f2 .f3
1117
1118    set result
1119} [list 22 0]
1120test panedwindow-18.15 {MoveSash, move left pushes other sashes} {
1121    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
1122    foreach w {.f1 .f2 .f3} c {red blue} {
1123	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew
1124    }
1125
1126    .p sash place 1 0 0
1127
1128    # Get the new sash coord; it should have moved as far as possible while
1129    # respecting minsizes.
1130    set result [.p sash coord 0]
1131
1132    # Cleanup
1133    destroy .p .f1 .f2 .f3
1134
1135    set result
1136} [list 0 0]
1137test panedwindow-18.16 {MoveSash, move left pushes other sashes, respects minsize} {
1138    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
1139    foreach w {.f1 .f2 .f3} c {red blue} {
1140	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew -minsize 10
1141    }
1142
1143    .p sash place 1 0 0
1144
1145    # Get the new sash coord; it should have moved as far as possible while
1146    # respecting minsizes.
1147    set result [.p sash coord 0]
1148
1149    # Cleanup
1150    destroy .p .f1 .f2 .f3
1151
1152    set result
1153} [list 10 0]
1154test panedwindow-18.17 {MoveSash, move left respects minsize, exludes pad} {
1155    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
1156    foreach w {.f1 .f2 .f3} c {red blue} {
1157	.p add [frame $w -height 20 -width 20 -bg $c] \
1158		-sticky nsew -minsize 10 -padx 5
1159    }
1160
1161    .p sash place 1 0 0
1162
1163    # Get the new sash coord; it should have moved as far as possible,
1164    # respecting minsizes.
1165    set result [.p sash coord 1]
1166
1167    # Cleanup
1168    destroy .p .f1 .f2 .f3
1169
1170    set result
1171} [list 42 0]
1172test panedwindow-18.18 {MoveSash, move left, negative minsize becomes 0} {
1173    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
1174    foreach w {.f1 .f2 .f3} c {red blue green} {
1175	.p add [frame $w -height 20 -width 20 -bg $c] \
1176		-sticky nsew -minsize -50
1177    }
1178
1179    .p sash place 1 10 0
1180
1181    # Get the new sash coord; it should have moved as far as possible,
1182    # respecting minsizes.
1183    set result [list [.p sash coord 0] [.p sash coord 1]]
1184
1185    # Cleanup
1186    destroy .p .f1 .f2 .f3
1187
1188    set result
1189} [list [list 8 0] [list 10 0]]
1190
1191test panedwindow-19.1 {MoveSash, move down} {
1192    set result {}
1193    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 \
1194            -orient vertical
1195    foreach w {.f1 .f2} c {red blue} {
1196	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew
1197    }
1198
1199    # Get the requested width of the paned window
1200    lappend result [winfo reqheight .p]
1201
1202    .p sash place 0 0 30
1203
1204    # Get the reqwidth again, to make sure it hasn't changed
1205    lappend result [winfo reqheight .p]
1206
1207    # Check that the sash moved
1208    lappend result [.p sash coord 0]
1209
1210    # Cleanup
1211    destroy .p .f1 .f2
1212
1213    set result
1214} [list 42 42 {0 30}]
1215test panedwindow-19.2 {MoveSash, move down (unmapped) clipped by reqheight} {
1216    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 \
1217            -orient vertical
1218    foreach w {.f1 .f2} c {red blue} {
1219	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew
1220    }
1221
1222    .p sash place 0 0 100
1223
1224    # Get the new sash coord; it should be clipped by the reqheight of
1225    # the panedwindow.
1226    set result [.p sash coord 0]
1227
1228    # Cleanup
1229    destroy .p .f1 .f2
1230
1231    set result
1232} [list 0 40]
1233test panedwindow-19.3 {MoveSash, move down (mapped, height < reqheight) clipped by height} {
1234    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 \
1235            -orient vertical
1236    foreach w {.f1 .f2} c {red blue} {
1237	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew
1238    }
1239
1240    # Put the panedwindow up on the display and give it a height < reqheight
1241    place .p -x 0 -y 0 -height 32
1242    update
1243
1244    .p sash place 0 0 100
1245
1246    # Get the new sash coord; it should be clipped by the visible height of
1247    # the panedwindow.
1248    set result [.p sash coord 0]
1249
1250    # Cleanup
1251    destroy .p .f1 .f2
1252
1253    set result
1254} [list 0 30]
1255test panedwindow-19.4 {MoveSash, move down (mapped, height > reqheight) clipped by height} {
1256    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 \
1257            -orient vertical
1258    foreach w {.f1 .f2} c {red blue} {
1259	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew
1260    }
1261
1262    # Put the panedwindow up on the display and give it a width > reqwidth
1263    place .p -x 0 -y 0 -height 102
1264    update
1265
1266    .p sash place 0 0 200
1267
1268    # Get the new sash coord; it should be clipped by the visible width of
1269    # the panedwindow.
1270    set result [.p sash coord 0]
1271
1272    # Cleanup
1273    destroy .p .f1 .f2
1274
1275    set result
1276} [list 0 100]
1277test panedwindow-19.5 {MoveSash, move down respects minsize} {
1278    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 \
1279            -orient vertical
1280    foreach w {.f1 .f2} c {red blue} {
1281	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew -minsize 10
1282    }
1283
1284    .p sash place 0 0 100
1285
1286    # Get the new sash coord; it should have moved as far as possible while
1287    # respecting minsizes.
1288    set result [.p sash coord 0]
1289
1290    # Cleanup
1291    destroy .p .f1 .f2
1292
1293    set result
1294} [list 0 30]
1295test panedwindow-19.6 {MoveSash, move down respects minsize} {
1296    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 \
1297            -orient vertical
1298    foreach w {.f1 .f2 .f3} c {red blue} {
1299	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew -minsize 10
1300    }
1301
1302    .p sash place 0 0 100
1303
1304    # Get the new sash coord; it should have moved as far as possible while
1305    # respecting minsizes.
1306    set result [.p sash coord 0]
1307
1308    # Cleanup
1309    destroy .p .f1 .f2 .f3
1310
1311    set result
1312} [list 0 40]
1313test panedwindow-19.7 {MoveSash, move down pushes other sashes} {
1314    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 \
1315            -orient vertical
1316    foreach w {.f1 .f2 .f3} c {red blue} {
1317	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew
1318    }
1319
1320    .p sash place 0 0 100
1321
1322    # Get the new sash coord; it should have moved as far as possible while
1323    # respecting minsizes.
1324    set result [.p sash coord 1]
1325
1326    # Cleanup
1327    destroy .p .f1 .f2 .f3
1328
1329    set result
1330} [list 0 62]
1331test panedwindow-19.8 {MoveSash, move down pushes other sashes, respects minsize} {
1332    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 \
1333            -orient vertical
1334    foreach w {.f1 .f2 .f3} c {red blue} {
1335	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew -minsize 10
1336    }
1337
1338    .p sash place 0 0 100
1339
1340    # Get the new sash coord; it should have moved as far as possible while
1341    # respecting minsizes.
1342    set result [.p sash coord 1]
1343
1344    # Cleanup
1345    destroy .p .f1 .f2 .f3
1346
1347    set result
1348} [list 0 52]
1349test panedwindow-19.9 {MoveSash, move down respects minsize, exludes pad} {
1350    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 \
1351            -orient vertical
1352    foreach w {.f1 .f2 .f3} c {red blue} {
1353	.p add [frame $w -height 20 -width 20 -bg $c] \
1354		-sticky nsew -minsize 10 -pady 5
1355    }
1356
1357    .p sash place 0 0 100
1358
1359    # Get the new sash coord; it should have moved as far as possible,
1360    # respecting minsizes.
1361    set result [.p sash coord 0]
1362
1363    # Cleanup
1364    destroy .p .f1 .f2 .f3
1365
1366    set result
1367} [list 0 50]
1368test panedwindow-19.10 {MoveSash, move right, negative minsize becomes 0} {
1369    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 \
1370            -orient vertical
1371    foreach w {.f1 .f2 .f3} c {red blue} {
1372	.p add [frame $w -height 20 -width 20 -bg $c] \
1373		-sticky nsew -minsize -50
1374    }
1375
1376    .p sash place 0 0 50
1377
1378    # Get the new sash coord; it should have moved as far as possible,
1379    # respecting minsizes.
1380    set result [list [.p sash coord 0] [.p sash coord 1]]
1381
1382    # Cleanup
1383    destroy .p .f1 .f2 .f3
1384
1385    set result
1386} [list [list 0 50] [list 0 52]]
1387test panedwindow-19.11 {MoveSash, move up} {
1388    set result {}
1389    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 \
1390            -orient vertical
1391    foreach w {.f1 .f2} c {red blue} {
1392	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew
1393    }
1394
1395    # Get the requested width of the paned window
1396    lappend result [winfo reqheight .p]
1397
1398    .p sash place 0 0 10
1399
1400    # Get the reqwidth again, to make sure it hasn't changed
1401    lappend result [winfo reqheight .p]
1402
1403    # Check that the sash moved
1404    lappend result [.p sash coord 0]
1405
1406    # Cleanup
1407    destroy .p .f1 .f2
1408
1409    set result
1410} [list 42 42 {0 10}]
1411test panedwindow-19.12 {MoveSash, move up, can't move outside of window} {
1412    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 \
1413            -orient vertical
1414    foreach w {.f1 .f2} c {red blue} {
1415	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew
1416    }
1417
1418    .p sash place 0 0 -100
1419
1420    # Get the new sash coord; it should be clipped by the reqwidth of
1421    # the panedwindow.
1422    set result [.p sash coord 0]
1423
1424    # Cleanup
1425    destroy .p .f1 .f2
1426
1427    set result
1428} [list 0 0]
1429test panedwindow-19.13 {MoveSash, move up respects minsize} {
1430    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 \
1431            -orient vertical
1432    foreach w {.f1 .f2} c {red blue} {
1433	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew -minsize 10
1434    }
1435
1436    .p sash place 0 0 0
1437
1438    # Get the new sash coord; it should have moved as far as possible while
1439    # respecting minsizes.
1440    set result [.p sash coord 0]
1441
1442    # Cleanup
1443    destroy .p .f1 .f2
1444
1445    set result
1446} [list 0 10]
1447test panedwindow-19.14 {MoveSash, move up respects minsize} {
1448    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 \
1449            -orient vertical
1450    foreach w {.f1 .f2 .f3} c {red blue} {
1451	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew -minsize 10
1452    }
1453
1454    .p sash place 1 0 0
1455
1456    # Get the new sash coord; it should have moved as far as possible.
1457    set result [.p sash coord 1]
1458
1459    # Cleanup
1460    destroy .p .f1 .f2 .f3
1461
1462    set result
1463} [list 0 22]
1464test panedwindow-19.15 {MoveSash, move up pushes other sashes} {
1465    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 \
1466            -orient vertical
1467    foreach w {.f1 .f2 .f3} c {red blue} {
1468	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew
1469    }
1470
1471    .p sash place 1 0 0
1472
1473    # Get the new sash coord; it should have moved as far as possible while
1474    # respecting minsizes.
1475    set result [.p sash coord 0]
1476
1477    # Cleanup
1478    destroy .p .f1 .f2 .f3
1479
1480    set result
1481} [list 0 0]
1482test panedwindow-19.16 {MoveSash, move up pushes other sashes, respects minsize} {
1483    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 \
1484            -orient vertical
1485    foreach w {.f1 .f2 .f3} c {red blue} {
1486	.p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew -minsize 10
1487    }
1488
1489    .p sash place 1 0 0
1490
1491    # Get the new sash coord; it should have moved as far as possible while
1492    # respecting minsizes.
1493    set result [.p sash coord 0]
1494
1495    # Cleanup
1496    destroy .p .f1 .f2 .f3
1497
1498    set result
1499} [list 0 10]
1500test panedwindow-19.17 {MoveSash, move up respects minsize, exludes pad} {
1501    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 \
1502            -orient vertical
1503    foreach w {.f1 .f2 .f3} c {red blue} {
1504	.p add [frame $w -height 20 -width 20 -bg $c] \
1505		-sticky nsew -minsize 10 -pady 5
1506    }
1507
1508    .p sash place 1 0 0
1509
1510    # Get the new sash coord; it should have moved as far as possible,
1511    # respecting minsizes.
1512    set result [.p sash coord 1]
1513
1514    # Cleanup
1515    destroy .p .f1 .f2 .f3
1516
1517    set result
1518} [list 0 42]
1519test panedwindow-19.18 {MoveSash, move up, negative minsize becomes 0} {
1520    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 \
1521            -orient vertical
1522    foreach w {.f1 .f2 .f3} c {red blue green} {
1523	.p add [frame $w -height 20 -width 20 -bg $c] \
1524		-sticky nsew -minsize -50
1525    }
1526
1527    .p sash place 1 0 10
1528
1529    # Get the new sash coord; it should have moved as far as possible,
1530    # respecting minsizes.
1531    set result [list [.p sash coord 0] [.p sash coord 1]]
1532
1533    # Cleanup
1534    destroy .p .f1 .f2 .f3
1535
1536    set result
1537} [list [list 0 8] [list 0 10]]
1538
1539# The following tests check that the panedwindow is correctly computing its
1540# geometry based on the various configuration options that can affect the
1541# geometry.
1542
1543test panedwindow-20.1 {ComputeGeometry, reqheight taken from widgets} {
1544    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 0
1545    foreach w {.f1 .f2 .f3} {
1546	.p add [frame $w -width 20 -height 20 -bg blue]
1547    }
1548    set result [list [list [winfo reqwidth .p] [winfo reqheight .p]]]
1549    .f3 configure -height 40
1550    lappend result [list [winfo reqwidth .p] [winfo reqheight .p]]
1551    destroy .p .f1 .f2 .f3
1552    set result
1553} [list [list 60 20] [list 60 40]]
1554test panedwindow-20.2 {ComputeGeometry, reqheight taken from widgets} {
1555    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 0
1556    foreach w {.f1 .f2 .f3} {
1557	.p add [frame $w -width 20 -height 20 -bg blue]
1558    }
1559    set result [list [list [winfo reqwidth .p] [winfo reqheight .p]]]
1560    .p paneconfigure .f3 -height 40
1561    lappend result [list [winfo reqwidth .p] [winfo reqheight .p]]
1562    destroy .p .f1 .f2 .f3
1563    set result
1564} [list [list 60 20] [list 60 40]]
1565test panedwindow-20.3 {ComputeGeometry, reqheight taken from widgets} {
1566    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 0
1567    foreach w {.f1 .f2 .f3} {
1568	.p add [frame $w -width 20 -height 20 -bg blue] -pady 20
1569    }
1570    set result [list [list [winfo reqwidth .p] [winfo reqheight .p]]]
1571    .p paneconfigure .f3 -height 40
1572    lappend result [list [winfo reqwidth .p] [winfo reqheight .p]]
1573    destroy .p .f1 .f2 .f3
1574    set result
1575} [list [list 60 60] [list 60 80]]
1576test panedwindow-20.4 {ComputeGeometry, reqwidth taken from widgets} {
1577    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 0 \
1578            -orient vertical
1579    foreach w {.f1 .f2 .f3} {
1580	.p add [frame $w -width 20 -height 20 -bg blue]
1581    }
1582    set result [list [list [winfo reqwidth .p] [winfo reqheight .p]]]
1583    .f3 configure -width 40
1584    lappend result [list [winfo reqwidth .p] [winfo reqheight .p]]
1585    destroy .p .f1 .f2 .f3
1586    set result
1587} [list [list 20 60] [list 40 60]]
1588test panedwindow-20.5 {ComputeGeometry, reqwidth taken from widgets} {
1589    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 0 \
1590            -orient vertical
1591    foreach w {.f1 .f2 .f3} {
1592	.p add [frame $w -width 20 -height 20 -bg blue]
1593    }
1594    set result [list [list [winfo reqwidth .p] [winfo reqheight .p]]]
1595    .p paneconfigure .f3 -width 40
1596    lappend result [list [winfo reqwidth .p] [winfo reqheight .p]]
1597    destroy .p .f1 .f2 .f3
1598    set result
1599} [list [list 20 60] [list 40 60]]
1600test panedwindow-20.6 {ComputeGeometry, reqwidth taken from widgets} {
1601    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 0 \
1602            -orient vertical
1603    foreach w {.f1 .f2 .f3} {
1604	.p add [frame $w -width 20 -height 20 -bg blue] -padx 20
1605    }
1606    set result [list [list [winfo reqwidth .p] [winfo reqheight .p]]]
1607    .p paneconfigure .f3 -width 40
1608    lappend result [list [winfo reqwidth .p] [winfo reqheight .p]]
1609    destroy .p .f1 .f2 .f3
1610    set result
1611} [list [list 60 60] [list 80 60]]
1612
1613set i 6
1614foreach bd {0 2} {
1615    foreach sp {0 5} {
1616	foreach sw {0 3} {
1617	    foreach h {0 1} {
1618		test panedwindow-20.[incr i]-$bd-$sp-$sw-$h \
1619			{ComputeGeometry, one slave, reqsize set properly} {
1620		    # With just one slave, sashpad and sashwidth should not
1621		    # affect the panedwindow's geometry, since no sash should
1622		    # ever be drawn.
1623		    panedwindow .p -borderwidth $bd -sashpad $sp \
1624			    -sashwidth $sw -handlesize 6 -showhandle $h
1625		    .p add [frame .p.f -width 20 -height 20 -bg red] -padx $h \
1626                            -sticky ""
1627		    set result [list [winfo reqwidth .p] [winfo reqheight .p]]
1628		    destroy .p .p.f
1629		    set result
1630		} [list [expr {(2 * $bd) + 20 + (2 * $h)}] \
1631			[expr {(2 * $bd) + 20}]]
1632
1633		test panedwindow-20.[incr i]-$bd-$sp-$sw-$h \
1634			{ComputeGeometry, three panes, reqsize set properly} {
1635		    panedwindow .p -borderwidth $bd -sashpad $sp \
1636			    -sashwidth $sw -handlesize 6 -showhandle $h
1637		    foreach w {.p.f1 .p.f2 .p.f3} {
1638			.p add [frame $w -width 20 -height 20 -bg blue] \
1639                                -sticky ""
1640		    }
1641		    set result [list [winfo reqwidth .p] [winfo reqheight .p]]
1642		    destroy .p .p.f1 .p.f2 .p.f3
1643		    set result
1644		} [list [expr {(2 * $bd) + ($h?12:(2*$sw)) + (4*$sp) + 60}] \
1645			[expr {(2 * $bd) + 20}]]
1646
1647		test panedwindow-20.[incr i]-$bd-$sp-$sw-$h \
1648			{ComputeGeometry, sash coords} {
1649		    panedwindow .p -borderwidth $bd -sashpad $sp \
1650			    -sashwidth $sw -handlesize 6 -showhandle $h
1651		    foreach w {.f1 .f2 .f3} {
1652			.p add [frame $w -width 20 -height 20 -bg blue] \
1653                                -sticky ""
1654		    }
1655		    set result [list [.p sash coord 0] [.p sash coord 1]]
1656		    destroy .p .f1 .f2 .f3
1657		    set result
1658		} [list [list [expr {$bd+20+($h?(6-$sw)/2:0)+$sp}] $bd] \
1659			[list [expr {$bd+40+($h?6+(6-$sw)/2:$sw)+(3*$sp)}] \
1660			    $bd]]
1661
1662		test panedwindow-20.[incr i]-$bd-$sp-$sw-$h \
1663			{ComputeGeometry/ArrangePanes, slave coords} {
1664		    panedwindow .p -borderwidth $bd -sashpad $sp \
1665			    -sashwidth $sw -handlesize 6 -showhandle $h
1666		    foreach w {.p.f1 .p.f2 .p.f3} {
1667			.p add [frame $w -width 20 -height 20 -bg blue] \
1668				-sticky nsew -pady 3 -padx 11
1669		    }
1670		    pack .p
1671		    update
1672		    set result {}
1673		    foreach w {.p.f1 .p.f2 .p.f3} {
1674			lappend result [list [winfo x $w] [winfo y $w] \
1675				[winfo width $w] [winfo height $w]]
1676		    }
1677		    destroy .p .p.f1 .p.f2 .p.f3
1678		    set result
1679		} [list [list [expr {$bd+11}] [expr {$bd+3}] 20 20] \
1680			[list [expr {$bd+53+($h?6:$sw)+(2*$sp)}] \
1681			    [expr {$bd+3}] 20 20] \
1682			[list [expr {$bd+95+($h?12:2*$sw)+(4*$sp)}] \
1683			    [expr {$bd+3}] 20 20]]
1684
1685		test panedwindow-20.[incr i]-$bd-$sp-$sw-$h \
1686			{ComputeGeometry, one slave, vertical} {
1687		    # With just one slave, sashpad and sashwidth should not
1688		    # affect the panedwindow's geometry, since no sash should
1689		    # ever be drawn.
1690		    panedwindow .p -borderwidth $bd -sashpad $sp \
1691			    -orient vertical -sashwidth $sw -handlesize 6 \
1692			    -showhandle $h
1693		    .p add [frame .f -width 20 -height 20 -bg red] -pady $h \
1694                            -sticky ""
1695		    set result [list [winfo reqwidth .p] [winfo reqheight .p]]
1696		    destroy .p .f
1697		    set result
1698		} [list [expr {(2 * $bd) + 20}] \
1699			[expr {(2 * $bd) + 20 + (2 * $h)}]]
1700
1701		test panedwindow-20.[incr i]-$bd-$sp-$sw-$h \
1702			{ComputeGeometry, three panes, vertical} {
1703		    panedwindow .p -borderwidth $bd -sashpad $sp \
1704			    -sashwidth $sw -handlesize 6 -showhandle $h \
1705			    -orient vertical
1706		    foreach w {.f1 .f2 .f3} {
1707			.p add [frame $w -width 20 -height 20 -bg blue] \
1708                                -sticky ""
1709		    }
1710		    set result [list [winfo reqwidth .p] [winfo reqheight .p]]
1711		    destroy .p .f1 .f2 .f3
1712		    set result
1713		} [list [expr {(2 * $bd) + 20}] \
1714			[expr {(2 * $bd) + ($h?12:(2*$sw)) + (4*$sp) + 60}]]
1715
1716		test panedwindow-20.[incr i]-$bd-$sp-$sw-$h \
1717			{ComputeGeometry, sash coords, vertical} {
1718		    panedwindow .p -borderwidth $bd -sashpad $sp \
1719			    -sashwidth $sw -handlesize 6 -showhandle $h \
1720			    -orient vertical
1721		    foreach w {.f1 .f2 .f3} {
1722			.p add [frame $w -width 20 -height 20 -bg blue] \
1723                                -sticky ""
1724		    }
1725		    set result [list [.p sash coord 0] [.p sash coord 1]]
1726		    destroy .p .f1 .f2 .f3
1727		    set result
1728		} [list [list $bd [expr {$bd+20+($h?(6-$sw)/2:0)+$sp}]] \
1729			[list $bd \
1730			    [expr {$bd+40+($h?6+(6-$sw)/2:$sw)+(3*$sp)}]]]
1731
1732		test panedwindow-20.[incr i]-$bd-$sp-$sw-$h \
1733			{ComputeGeometry/ArrangePanes, slave coords, vert} {
1734		    panedwindow .p -borderwidth $bd -sashpad $sp \
1735			    -sashwidth $sw -handlesize 6 -showhandle $h \
1736			    -orient vertical
1737		    foreach w {.p.f1 .p.f2 .p.f3} {
1738			.p add [frame $w -width 20 -height 20 -bg blue] \
1739				-sticky nsew -pady 11 -padx 3
1740		    }
1741		    pack .p
1742		    update
1743		    set result {}
1744		    foreach w {.p.f1 .p.f2 .p.f3} {
1745			lappend result [list [winfo x $w] [winfo y $w] \
1746				[winfo width $w] [winfo height $w]]
1747		    }
1748		    destroy .p .p.f1 .p.f2 .p.f3
1749		    set result
1750		} [list [list [expr {$bd+3}] [expr {$bd+11}] 20 20] \
1751			[list [expr {$bd+3}] \
1752			    [expr {$bd+53+($h?6:$sw)+(2*$sp)}] 20 20] \
1753			[list [expr {$bd+3}] \
1754			    [expr {$bd+95+($h?12:2*$sw)+(4*$sp)}] 20 20]]
1755	    }
1756	}
1757    }
1758}
1759
1760test panedwindow-21.1 {destroyed widgets are removed from panedwindow} {
1761    panedwindow .p
1762    .p add [frame .f -width 20 -height 20 -bg blue]
1763    destroy .f
1764    set result [.p panes]
1765    destroy .p
1766    set result
1767} {}
1768test panedwindow-21.2 {destroyed slave causes geometry recomputation} {
1769    panedwindow .p -borderwidth 0 -sashpad 0 -sashwidth 2
1770    .p add [frame .f -width 20 -height 20 -bg blue] \
1771	    [frame .f2 -width 20 -height 20 -bg red]
1772    destroy .f
1773    set result [winfo reqwidth .p]
1774    destroy .p .f2
1775    set result
1776} 20
1777
1778test panedwindow-22.1 {ArrangePanes, extra space is given to the last pane} {
1779    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
1780    .p add [frame .f1 -width 20 -height 20 -bg blue] \
1781	    [frame .f2 -width 20 -height 20 -bg red] -sticky nsew
1782    place .p -width 100 -x 0 -y 0
1783    update
1784    set result [winfo width .f2]
1785    destroy .p .f1 .f2
1786    set result
1787} 78
1788test panedwindow-22.2 {ArrangePanes, extra space is given to the last pane} {
1789    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 \
1790            -orient vertical
1791    .p add [frame .f1 -width 20 -height 20 -bg blue] \
1792	    [frame .f2 -width 20 -height 20 -bg red] -sticky nsew
1793    place .p -height 100 -x 0 -y 0
1794    update
1795    set result [winfo height .f2]
1796    destroy .p .f1 .f2
1797    set result
1798} 78
1799test panedwindow-22.3 {ArrangePanes, explicit height/width are preferred} {
1800    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
1801    .p add [frame .f1 -width 20 -height 20 -bg blue] \
1802	    [frame .f2 -width 20 -height 20 -bg red] -sticky ""
1803    .p paneconfigure .f1 -width 10 -height 15
1804    pack .p
1805    update
1806    set result [list [winfo width .f1] [winfo height .f1]]
1807    destroy .p .f1 .f2
1808    set result
1809} {10 15}
1810test panedwindow-22.4 {ArrangePanes, panes clipped by size of pane} {
1811    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
1812    .p add [frame .f1 -width 20 -height 20 -bg blue] \
1813	    [frame .f2 -width 20 -height 20 -bg red]
1814    .p sash place 0 10 0
1815    pack .p
1816    update
1817    set result [list [winfo width .f1] [winfo height .f1]]
1818    destroy .p .f1 .f2
1819    set result
1820} {10 20}
1821test panedwindow-22.5 {ArrangePanes, panes clipped by size of pane} {
1822    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 \
1823            -orient vertical
1824    .p add [frame .f1 -width 20 -height 20 -bg blue] \
1825	    [frame .f2 -width 20 -height 20 -bg red]
1826    .p sash place 0 0 10
1827    pack .p
1828    update
1829    set result [list [winfo width .f1] [winfo height .f1]]
1830    destroy .p .f1 .f2
1831    set result
1832} {20 10}
1833test panedwindow-22.6 {ArrangePanes, height of pane taken from total height} {
1834    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
1835    .p add [frame .p.f1 -width 20 -height 20 -bg blue] \
1836	    [frame .p.f2 -width 20 -height 40 -bg red] -sticky ""
1837    pack .p
1838    update
1839    set result [list [winfo y .p.f1]]
1840    destroy .p .p.f1 .p.f2
1841    set result
1842} 10
1843test panedwindow-22.8 {ArrangePanes, width of pane taken from total width} {
1844    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 \
1845            -orient vertical
1846    .p add [frame .p.f1 -width 20 -height 20 -bg blue] \
1847	    [frame .p.f2 -width 40 -height 40 -bg red] -sticky ""
1848    pack .p
1849    update
1850    set result [list [winfo x .p.f1]]
1851    destroy .p .p.f1 .p.f2
1852    set result
1853} 10
1854test panedwindow-22.9 {ArrangePanes, panes with width <= 0 are unmapped} {
1855    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
1856    .p add [frame .f1 -width 20 -height 20 -bg blue] \
1857	    [frame .f2 -width 20 -height 40 -bg red]
1858    pack .p
1859    update
1860    set result [winfo ismapped .f1]
1861    .p sash place 0 0 0
1862    update
1863    lappend result [winfo ismapped .f1]
1864    destroy .p .f1 .f2
1865    set result
1866} {1 0}
1867test panedwindow-22.10 {ArrangePanes, panes with width <= 0 are unmapped} {
1868    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
1869    .p add [frame .p.f1 -width 20 -height 20 -bg blue] \
1870	    [frame .p.f2 -width 20 -height 40 -bg red]
1871    pack .p
1872    update
1873    set result [winfo ismapped .p.f1]
1874    .p sash place 0 0 0
1875    update
1876    lappend result [winfo ismapped .p.f1]
1877    destroy .p .p.f1 .p.f2
1878    set result
1879} {1 0}
1880test panedwindow-22.11 {ArrangePanes, panes with width <= 0 are unmapped} {
1881    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 -orient vertical
1882    .p add [frame .p.f1 -width 20 -height 20 -bg blue] \
1883	    [frame .p.f2 -width 20 -height 40 -bg red]
1884    pack .p
1885    update
1886    set result [winfo ismapped .p.f1]
1887    .p sash place 0 0 0
1888    update
1889    lappend result [winfo ismapped .p.f1]
1890    destroy .p .p.f1 .p.f2
1891    set result
1892} {1 0}
1893test panedwindow-22.12 {ArrangePanes, last pane shrinks} {
1894    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2
1895    .p add [frame .f1 -width 20 -height 20 -bg blue] \
1896	    [frame .f2 -width 20 -height 20 -bg red] -sticky nsew
1897    place .p -width 40 -x 0 -y 0
1898    update
1899    set result [winfo width .f2]
1900    destroy .p .f1 .f2
1901    set result
1902} 18
1903test panedwindow-22.13 {ArrangePanes, last pane shrinks} {
1904    panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 \
1905            -orient vertical
1906    .p add [frame .f1 -width 20 -height 20 -bg blue] \
1907	    [frame .f2 -width 20 -height 20 -bg red] -sticky nsew
1908    place .p -height 40 -x 0 -y 0
1909    update
1910    set result [winfo height .f2]
1911    destroy .p .f1 .f2
1912    set result
1913} 18
1914test panedwindow-22.14 {ArrangePanes, panedwindow resizes} {
1915    -body {
1916	panedwindow .p -width 200 -borderwidth 0
1917	frame .f1 -height 50 -bg blue
1918	set result [list]
1919	lappend result [winfo reqwidth .p] [winfo reqheight .p]
1920	.p add .f1
1921	pack .p
1922	lappend result [winfo reqwidth .p] [winfo reqheight .p]
1923    }
1924    -cleanup {destroy .p .f1}
1925    -result {200 1 200 50}
1926}
1927test panedwindow-22.15 {ArrangePanes, panedwindow resizes} {
1928    -body {
1929	panedwindow .p -height 200 -borderwidth 0 -orient vertical
1930	frame .f1 -width 50 -bg blue
1931	set result [list]
1932	lappend result [winfo reqwidth .p] [winfo reqheight .p]
1933	.p add .f1
1934	pack .p
1935	lappend result [winfo reqwidth .p] [winfo reqheight .p]
1936    }
1937    -cleanup {destroy .p .f1}
1938    -result {1 200 50 200}
1939}
1940test panedwindow-22.16 {ArrangePanes, last pane grows} {
1941    -body {
1942	panedwindow .p -showhandle false -height 50
1943	.p add [frame .f1 -width 50 -bg red] [frame .f2 -width 50 -bg white] \
1944		[frame .f3 -width 50 -bg blue] [frame .f4 -width 50 -bg green]
1945	.p sash place 1 250 0
1946	pack .p
1947	update
1948	set result [list]
1949	lappend result [winfo width .f1] [winfo width .f2] [winfo width .f3] \
1950		[winfo width .f4] [winfo width .p]
1951	.p configure -width 300
1952	update
1953	lappend result [winfo width .f1] [winfo width .f2] [winfo width .f3] \
1954		[winfo width .f4] [winfo width .p]
1955    }
1956    -cleanup {destroy .p .f1 .f2 .f3 .f4}
1957    -result {50 150 1 1 211 50 150 1 89 300}
1958}
1959
1960
1961test panedwindow-23.1 {PanedWindowReqProc, react to slave geometry changes} {
1962    # Basically just want to make sure that the PanedWindowReqProc is called
1963    panedwindow .p -borderwidth 0 -sashpad 0 -sashwidth 2
1964    .p add [frame .f1 -width 20 -height 20 -bg blue] \
1965	    [frame .f2 -width 20 -height 40 -bg red]
1966    set result [winfo reqheight .p]
1967    .f1 configure -height 80
1968    lappend result [winfo reqheight .p]
1969    destroy .p .f1 .f2
1970    set result
1971} {40 80}
1972test panedwindow-23.2 {PanedWindowReqProc, react to slave geometry changes} {
1973    panedwindow .p -orient horizontal -sashpad 0 -sashwidth 2
1974    .p add [frame .f1 -width 10] [frame .f2 -width 10]
1975    set result [winfo reqwidth .p]
1976    .f1 configure -width 20
1977    lappend result [winfo reqwidth .p]
1978    destroy .p .f1 .f2
1979    expr {[lindex $result 1] - [lindex $result 0]}
1980} {10}
1981
1982
1983test panedwindow-24.1 {ConfigurePanes, can't add panedwindow to itself} {
1984    panedwindow .p
1985    set result [list [catch {.p add .p} msg] $msg]
1986    destroy .p
1987    set result
1988} [list 1 "can't add .p to itself"]
1989test panedwindow-24.2 {ConfigurePanes, bad window throws error} {
1990    panedwindow .p
1991    set result [list [catch {.p add .b} msg] $msg]
1992    destroy .p
1993    set result
1994} [list 1 "bad window path name \".b\""]
1995test panedwindow-24.3 {ConfigurePanes, bad window aborts processing} {
1996    panedwindow .p
1997    button .b
1998    catch {.p add .b .a}
1999    set result [.p panes]
2000    destroy .p .b
2001    set result
2002} {}
2003test panedwindow-24.4 {ConfigurePanes, bad option aborts processing} {
2004    panedwindow .p
2005    button .b
2006    catch {.p add .b -sticky foobar}
2007    set result [.p panes]
2008    destroy .p .b
2009    set result
2010} {}
2011test panedwindow-24.5 {ConfigurePanes, after win isn't managed by panedwin} {
2012    panedwindow .p
2013    button .b
2014    button .c
2015    set result [list [catch {.p add .b -after .c} msg] $msg]
2016    destroy .p .b .c
2017    set result
2018} [list 1 "window \".c\" is not managed by .p"]
2019test panedwindow-24.6 {ConfigurePanes, before win isn't managed by panedwin} {
2020    panedwindow .p
2021    button .b
2022    button .c
2023    set result [list [catch {.p add .b -before .c} msg] $msg]
2024    destroy .p .b .c
2025    set result
2026} [list 1 "window \".c\" is not managed by .p"]
2027test panedwindow-24.7 {ConfigurePanes, -after {} is a no-op} {
2028    panedwindow .p
2029    .p add [button .b] [button .c]
2030    .p paneconfigure .b -after {}
2031    set result [.p panes]
2032    destroy .p .b .c
2033    set result
2034} {.b .c}
2035test panedwindow-24.8 {ConfigurePanes, -before {} is a no-op} {
2036    panedwindow .p
2037    .p add [button .b] [button .c]
2038    .p paneconfigure .b -before {}
2039    set result [.p panes]
2040    destroy .p .b .c
2041    set result
2042} {.b .c}
2043test panedwindow-24.9 {ConfigurePanes, new panes are added} {
2044    panedwindow .p
2045    .p add [button .b] [button .c]
2046    set result [.p panes]
2047    destroy .p .b .c
2048    set result
2049} {.b .c}
2050test panedwindow-24.10 {ConfigurePanes, options applied to all panes} {
2051    panedwindow .p
2052    .p add [button .b] [button .c] -sticky ne -height 5 -width 5 -minsize 10
2053    set result {}
2054    foreach w {.b .c} {
2055	set val {}
2056	foreach option {-sticky -height -width -minsize} {
2057	    lappend val $option [.p panecget $w $option]
2058	}
2059	lappend result $w $val
2060    }
2061    destroy .p .b .c
2062    set result
2063} [list .b {-sticky ne -height 5 -width 5 -minsize 10} \
2064	.c {-sticky ne -height 5 -width 5 -minsize 10}]
2065test panedwindow-24.11 {ConfigurePanes, existing panes are reconfigured} {
2066    panedwindow .p
2067    .p add [button .b] -sticky nw -height 10
2068    .p add .b [button .c] -sticky se -height 2
2069    set result [list [.p panes] \
2070	    [.p panecget .b -sticky] [.p panecget .b -height] \
2071	    [.p panecget .c -sticky] [.p panecget .c -height]]
2072    destroy .p .b .c
2073    set result
2074} [list {.b .c} es 2 es 2]
2075test panedwindow-24.12 {ConfigurePanes, widgets added to end by default} {
2076    panedwindow .p
2077    .p add [button .b]
2078    .p add [button .c]
2079    .p add [button .d]
2080    set result [.p panes]
2081    destroy .p .b .c .d
2082    set result
2083} {.b .c .d}
2084test panedwindow-24.13 {ConfigurePanes, -after, single addition} {
2085    panedwindow .p
2086    button .a
2087    button .b
2088    button .c
2089
2090    .p add .a .b
2091    .p add .c -after .a
2092    set result [.p panes]
2093    destroy .p .a .b .c
2094    set result
2095} {.a .c .b}
2096test panedwindow-24.14 {ConfigurePanes, -after, multiple additions} {
2097    panedwindow .p
2098    button .a
2099    button .b
2100    button .c
2101    button .d
2102
2103    .p add .a .b
2104    .p add .c .d -after .a
2105    set result [.p panes]
2106    destroy .p .a .b .c .d
2107    set result
2108} {.a .c .d .b}
2109test panedwindow-24.15 {ConfigurePanes, -after, relocates existing widget} {
2110    panedwindow .p
2111    button .a
2112    button .b
2113    button .c
2114    button .d
2115
2116    .p add .a .b .c .d
2117    .p add .d -after .a
2118    set result [.p panes]
2119    destroy .p .a .b .c .d
2120    set result
2121} {.a .d .b .c}
2122test panedwindow-24.16 {ConfigurePanes, -after, relocates existing widgets} {
2123    panedwindow .p
2124    button .a
2125    button .b
2126    button .c
2127    button .d
2128
2129    .p add .a .b .c .d
2130    .p add .b .d -after .a
2131    set result [.p panes]
2132    destroy .p .a .b .c .d
2133    set result
2134} {.a .b .d .c}
2135test panedwindow-24.17 {ConfigurePanes, -after, relocates existing widgets} {
2136    panedwindow .p
2137    button .a
2138    button .b
2139    button .c
2140    button .d
2141
2142    .p add .a .b .c .d
2143    .p add .d .a -after .b
2144    set result [.p panes]
2145    destroy .p .a .b .c .d
2146    set result
2147} {.b .d .a .c}
2148test panedwindow-24.18 {ConfigurePanes, -after, relocates existing widgets} {
2149    panedwindow .p
2150    button .a
2151    button .b
2152    button .c
2153    button .d
2154
2155    .p add .a .b .c .d
2156    .p add .d .a -after .a
2157    set result [.p panes]
2158    destroy .p .a .b .c .d
2159    set result
2160} {.d .a .b .c}
2161test panedwindow-24.19 {ConfigurePanes, -after, after last window} {
2162    panedwindow .p
2163    button .a
2164    button .b
2165    button .c
2166    button .d
2167
2168    .p add .a .b .c
2169    .p add .d -after .c
2170    set result [.p panes]
2171    destroy .p .a .b .c .d
2172    set result
2173} {.a .b .c .d}
2174test panedwindow-24.20 {ConfigurePanes, -before, before first window} {
2175    panedwindow .p
2176    button .a
2177    button .b
2178    button .c
2179    button .d
2180
2181    .p add .a .b .c
2182    .p add .d -before .a
2183    set result [.p panes]
2184    destroy .p .a .b .c .d
2185    set result
2186} {.d .a .b .c}
2187test panedwindow-24.21 {ConfigurePanes, -before, relocate existing windows} {
2188    panedwindow .p
2189    button .a
2190    button .b
2191    button .c
2192    button .d
2193
2194    .p add .a .b .c
2195    .p add .d .b -before .a
2196    set result [.p panes]
2197    destroy .p .a .b .c .d
2198    set result
2199} {.d .b .a .c}
2200test panedwindow-24.22 {ConfigurePanes, slave specified multiple times} {
2201    # This test should not cause a core dump
2202
2203    panedwindow .p
2204    button .a
2205    button .b
2206    button .c
2207
2208    .p add .a .a .b .c
2209    set result [.p panes]
2210    destroy .p .a .b .c
2211    set result
2212} {.a .b .c}
2213test panedwindow-24.23 {ConfigurePanes, slave specified multiple times} {
2214    # This test should not cause a core dump
2215
2216    panedwindow .p
2217    button .a
2218    button .b
2219    button .c
2220
2221    .p add .a .a .b .c
2222    .p add .a .b .a -after .c
2223    set result [.p panes]
2224    destroy .p .a .b .c
2225    set result
2226} {.c .a .b}
2227test panedwindow-24.24 {ConfigurePanes, panedwindow cannot manage toplevels} {
2228    panedwindow .p
2229    toplevel .t
2230    set result [list [catch {.p add .t} msg] $msg]
2231    destroy .p .t
2232    set result
2233} [list 1 "can't add toplevel .t to .p"]
2234test panedwindow-24.25 {ConfigurePanes, restrict possible panes} {
2235    panedwindow .p
2236    frame .f
2237    button .f.b
2238    set result [list [catch {.p add .f.b} msg] $msg]
2239    destroy .p .f .f.b
2240    set result
2241} [list 1 "can't add .f.b to .p"]
2242test panedwindow-24.26 {ConfigurePanes, restrict possible panes} {
2243    frame .f
2244    panedwindow .f.p
2245    button .b
2246    set result [list [catch {.f.p add .b} msg] $msg]
2247    destroy .f.p .f .b
2248    set result
2249} [list 0 ""]
2250test panedwindow-24.27 {ConfigurePanes, restrict possible panes} {
2251    panedwindow .p
2252    button .p.b
2253    set result [list [catch {.p add .p.b} msg] $msg]
2254    destroy .p .p.b
2255    set result
2256} [list 0 ""]
2257test panedwindow-24.28 {ConfigurePanes, restrict possible panes} {
2258    frame .f
2259    frame .f.f
2260    frame .f.f.f
2261    panedwindow .f.f.f.p
2262    button .b
2263    set result [list [catch {.f.f.f.p add .b} msg] $msg]
2264    destroy .f .f.f .f.f.f .f.f.f.p .b
2265    set result
2266} [list 0 ""]
2267test panedwindow-24.29.1 {ConfigurePanes, -hide works} {
2268    -body {
2269	panedwindow .p -showhandle false
2270	frame .f1 -width 40 -height 100 -bg red
2271	frame .f2 -width 40 -height 100 -bg white
2272	frame .f3 -width 40 -height 100 -bg blue
2273	frame .f4 -width 40 -height 100 -bg green
2274	.p add .f1 .f2 .f3 .f4
2275	pack .p
2276	update
2277	set result [list]
2278	lappend result [winfo ismapped .f1] [winfo ismapped .f2] \
2279		[winfo ismapped .f3] [winfo ismapped .f4]
2280	lappend result [winfo width .f1] [winfo width .f2] [winfo width .f3] \
2281		[winfo width .f4] [winfo width .p]
2282	.p paneconfigure .f2 -hide 1
2283	update
2284	lappend result [winfo ismapped .f1] [winfo ismapped .f2] \
2285		[winfo ismapped .f3] [winfo ismapped .f4]
2286	lappend result [winfo width .f1] [winfo width .f2] [winfo width .f3] \
2287		[winfo width .f4] [winfo width .p]
2288    }
2289    -cleanup {destroy .p .f1 .f2 .f3 .f4}
2290    -result {1 1 1 1 40 40 40 40 171 1 0 1 1 40 40 40 40 128}
2291}
2292test panedwindow-24.29.2 {ConfigurePanes, -hide works} {
2293    -body {
2294	panedwindow .p -showhandle false -width 130 -height 100
2295	frame .f1 -width 40 -bg red
2296	frame .f2 -width 40 -bg white
2297	frame .f3 -width 40 -bg blue
2298	frame .f4 -width 40 -bg green
2299	.p add .f1 .f2 .f3 .f4
2300	pack .p
2301	update
2302	set result [list]
2303	lappend result [winfo ismapped .f1] [winfo ismapped .f2] \
2304		[winfo ismapped .f3] [winfo ismapped .f4]
2305	lappend result [winfo width .f1] [winfo width .f2] [winfo width .f3] \
2306		[winfo width .f4] [winfo width .p]
2307	.p paneconfigure .f2 -hide 1
2308	update
2309	lappend result [winfo ismapped .f1] [winfo ismapped .f2] \
2310		[winfo ismapped .f3] [winfo ismapped .f4]
2311	lappend result [winfo width .f1] [winfo width .f2] [winfo width .f3] \
2312		[winfo width .f4] [winfo width .p]
2313    }
2314    -cleanup {destroy .p .f1 .f2 .f3 .f4}
2315    -result {1 1 1 0 39 40 40 1 130 1 0 1 1 40 40 40 42 130}
2316}
2317test panedwindow-24.29.3 {ConfigurePanes, -hide works, last pane stretches} {
2318    -body {
2319	panedwindow .p -showhandle false -width 200 -height 200 -borderwidth 0
2320	frame .f1 -width 50 -bg red
2321	frame .f2 -width 50 -bg green
2322	frame .f3 -width 50 -bg blue
2323	.p add .f1 .f2 .f3
2324	pack .p
2325	update
2326	set result [list]
2327	lappend result [winfo width .f1] [winfo width .f2] [winfo width .f3]
2328	.p paneconfigure .f2 -hide 1
2329	update
2330	lappend result [winfo width .f1] [winfo width .f2] [winfo width .f3]
2331    }
2332    -cleanup {destroy .p .f1 .f2 .f3}
2333    -result {50 50 94 50 50 147}
2334}
2335test panedwindow-24.29.4 {ConfigurePanes, -hide works, last pane stretches} {
2336    -body {
2337	panedwindow .p -showhandle false -width 200 -height 200 \
2338		-borderwidth 0 -orient vertical
2339	frame .f1 -height 50 -bg red
2340	frame .f2 -height 50 -bg green
2341	frame .f3 -height 50 -bg blue
2342	.p add .f1 .f2 .f3
2343	pack .p
2344	update
2345	set result [list]
2346	lappend result [winfo height .f1] [winfo height .f2] [winfo height .f3]
2347	.p paneconfigure .f2 -hide 1
2348	update
2349	lappend result [winfo height .f1] [winfo height .f2] [winfo height .f3]
2350    }
2351    -cleanup {destroy .p .f1 .f2 .f3}
2352    -result {50 50 94 50 50 147}
2353}
2354
2355test panedwindow-24.30 {ConfigurePanes, -stretch first} {
2356    -body {
2357	panedwindow .p -showhandle false -height 100 -width 182
2358	frame .f1 -width 40 -bg red
2359	frame .f2 -width 40 -bg white
2360	frame .f3 -width 40 -bg blue
2361	frame .f4 -width 40 -bg green
2362	.p add .f1 .f2 .f3 .f4 -stretch first
2363	pack .p
2364	update
2365	set result [list]
2366	lappend result [winfo width .f1] [winfo width .f2] [winfo width .f3] \
2367		[winfo width .f4]
2368	.p paneconfigure .f2 -hide 1
2369	update
2370	lappend result [winfo width .f1] [winfo width .f2] [winfo width .f3] \
2371		[winfo width .f4]
2372    }
2373    -cleanup {destroy .p .f1 .f2 .f3 .f4}
2374    -result {51 40 40 40 94 40 40 40}
2375}
2376test panedwindow-24.31 {ConfigurePanes, -stretch middle} {
2377    -body {
2378	panedwindow .p -showhandle false -height 100 -width 182
2379	frame .f1 -width 40 -bg red
2380	frame .f2 -width 40 -bg white
2381	frame .f3 -width 40 -bg blue
2382	frame .f4 -width 40 -bg green
2383	.p add .f1 .f2 .f3 .f4 -stretch middle
2384	pack .p
2385	update
2386	set result [list]
2387	lappend result [winfo width .f1] [winfo width .f2] [winfo width .f3] \
2388		[winfo width .f4]
2389	.p paneconfigure .f2 -hide 1
2390	update
2391	lappend result [winfo width .f1] [winfo width .f2] [winfo width .f3] \
2392		[winfo width .f4]
2393    }
2394    -cleanup {destroy .p .f1 .f2 .f3 .f4}
2395    -result {40 45 46 40 40 45 94 40}
2396}
2397test panedwindow-24.32 {ConfigurePanes, -stretch always} {
2398    -body {
2399	panedwindow .p -showhandle false -height 100 -width 182
2400	frame .f1 -width 40 -bg red
2401	frame .f2 -width 40 -bg white
2402	frame .f3 -width 40 -bg blue
2403	frame .f4 -width 40 -bg green
2404	.p add .f1 .f2 .f3 .f4 -stretch always
2405	pack .p
2406	update
2407	set result [list]
2408	lappend result [winfo width .f1] [winfo width .f2] [winfo width .f3] \
2409		[winfo width .f4]
2410	.p paneconfigure .f2 -hide 1
2411	update
2412	lappend result [winfo width .f1] [winfo width .f2] [winfo width .f3] \
2413		[winfo width .f4]
2414    }
2415    -cleanup {destroy .p .f1 .f2 .f3 .f4}
2416    -result {42 43 43 43 58 43 58 58}
2417}
2418test panedwindow-24.33 {ConfigurePanes, -stretch never} {
2419    -body {
2420	panedwindow .p -showhandle false -height 100 -width 182
2421	frame .f1 -width 40 -bg red
2422	frame .f2 -width 40 -bg white
2423	frame .f3 -width 40 -bg blue
2424	frame .f4 -width 40 -bg green
2425	.p add .f1 .f2 .f3 .f4 -stretch never
2426	pack .p
2427	update
2428	set result [list]
2429	lappend result [winfo width .f1] [winfo width .f2] [winfo width .f3] \
2430		[winfo width .f4]
2431	.p paneconfigure .f2 -hide 1
2432	update
2433	lappend result [winfo width .f1] [winfo width .f2] [winfo width .f3] \
2434		[winfo width .f4]
2435    }
2436    -cleanup {destroy .p .f1 .f2 .f3 .f4}
2437    -result {40 40 40 40 40 40 40 40}
2438}
2439
2440test panedwindow-25.1 {Unlink, remove a paned with -before/-after refs} {
2441    # Bug 928413
2442    set result {}
2443    panedwindow .pw
2444    label .pw.l1 -text Label1
2445    label .pw.l2 -text Label2
2446    label .pw.l3 -text Label3
2447    .pw add .pw.l1
2448    .pw add .pw.l3
2449    .pw add .pw.l2 -before .pw.l3
2450    lappend result [.pw panecget .pw.l2 -before]
2451    destroy .pw.l3
2452    lappend result [.pw panecget .pw.l2 -before]
2453    .pw paneconfigure .pw.l2 -before .pw.l1
2454    lappend result [.pw panecget .pw.l2 -before]
2455    destroy .pw
2456    set result
2457} {.pw.l3 {} .pw.l1}
2458
2459test panedwindow-26.1 {DestroyPanedWindow} {
2460    # This test should not result in any memory leaks.
2461    panedwindow .p
2462    foreach w {.a .b .c .d .e .f .g .h .i .j .k .l .m .n .o .q .r .s .t} {
2463	.p add [button $w]
2464    }
2465    foreach w {.a .b .c .d .e .f .g .h .i .j .k .l .m .n .o .p .q .r .s .t} {
2466	destroy $w
2467    }
2468    set result {}
2469} {}
2470test panedwindow-26.2 {UnmapNotify and MapNotify events are propagated to slaves} {
2471    panedwindow .pw
2472    .pw add [button .pw.b]
2473    pack .pw
2474    update
2475    set result [winfo ismapped .pw.b]
2476    pack forget .pw
2477    update
2478    lappend result [winfo ismapped .pw.b]
2479    lappend result [winfo ismapped .pw]
2480    pack .pw
2481    update
2482    lappend result [winfo ismapped .pw]
2483    lappend result [winfo ismapped .pw.b]
2484    destroy .pw .pw.b
2485    set result
2486} {1 0 0 1 1}
2487
2488test panedwindow-27.1 {PanedWindowIdentifyCoords} {
2489    panedwindow .p -bd 0 -sashwidth 2 -sashpad 2
2490    .p add [frame .f -bg red -width 20 -height 20] \
2491	    [frame .f2 -bg blue -width 20 -height 20]
2492    set result [.p identify 0 0]
2493    destroy .p .f .f2
2494    set result
2495} {}
2496test panedwindow-27.2 {PanedWindowIdentifyCoords, padding is included} {
2497    panedwindow .p -bd 0 -sashwidth 2 -sashpad 2
2498    .p add [frame .f -bg red -width 20 -height 20] \
2499	    [frame .f2 -bg blue -width 20 -height 20]
2500    set result [.p identify 20 0]
2501    destroy .p .f .f2
2502    set result
2503} {0 sash}
2504test panedwindow-27.3 {PanedWindowIdentifyCoords} {
2505    panedwindow .p -bd 0 -sashwidth 2 -sashpad 2
2506    .p add [frame .f -bg red -width 20 -height 20] \
2507	    [frame .f2 -bg blue -width 20 -height 20]
2508    set result [.p identify 22 0]
2509    destroy .p .f .f2
2510    set result
2511} {0 sash}
2512test panedwindow-27.4 {PanedWindowIdentifyCoords} {
2513    panedwindow .p -bd 0 -sashwidth 2 -sashpad 2
2514    .p add [frame .f -bg red -width 20 -height 20] \
2515	    [frame .f2 -bg blue -width 20 -height 20]
2516    set result [.p identify 24 0]
2517    destroy .p .f .f2
2518    set result
2519} {0 sash}
2520test panedwindow-27.5 {PanedWindowIdentifyCoords} {
2521    panedwindow .p -bd 0 -sashwidth 2 -sashpad 2
2522    .p add [frame .f -bg red -width 20 -height 20] \
2523	    [frame .f2 -bg blue -width 20 -height 20]
2524    set result [.p identify 26 0]
2525    destroy .p .f .f2
2526    set result
2527} {0 sash}
2528test panedwindow-27.6 {PanedWindowIdentifyCoords} {
2529    panedwindow .p -bd 0 -sashwidth 2 -sashpad 2
2530    .p add [frame .f -bg red -width 20 -height 20] \
2531	    [frame .f2 -bg blue -width 20 -height 20]
2532    set result [.p identify 26 -1]
2533    destroy .p .f .f2
2534    set result
2535} {}
2536test panedwindow-27.7 {PanedWindowIdentifyCoords} {
2537    panedwindow .p -bd 0 -sashwidth 2 -sashpad 2
2538    .p add [frame .f -bg red -width 20 -height 20] \
2539	    [frame .f2 -bg blue -width 20 -height 20]
2540    set result [.p identify 26 100]
2541    destroy .p .f .f2
2542    set result
2543} {}
2544test panedwindow-27.8 {PanedWindowIdentifyCoords} {
2545    panedwindow .p -bd 0 -sashwidth 2 -sashpad 2 -showhandle 1 -handlepad 5 \
2546	    -handlesize 6
2547    .p add [frame .f -bg red -width 20 -height 20] \
2548	    [frame .f2 -bg blue -width 20 -height 20]
2549    set result [.p identify 22 4]
2550    destroy .p .f .f2
2551    set result
2552} {0 sash}
2553test panedwindow-27.9 {PanedWindowIdentifyCoords} {
2554    panedwindow .p -bd 0 -sashwidth 2 -sashpad 2 -showhandle 1 -handlepad 5 \
2555	    -handlesize 6
2556    .p add [frame .f -bg red -width 20 -height 20] \
2557	    [frame .f2 -bg blue -width 20 -height 20]
2558    set result [.p identify 22 5]
2559    destroy .p .f .f2
2560    set result
2561} {0 handle}
2562test panedwindow-27.10 {PanedWindowIdentifyCoords} {
2563    panedwindow .p -bd 0 -sashwidth 2 -sashpad 2 -showhandle 1 -handlepad 5 \
2564	    -handlesize 8
2565    .p add [frame .f -bg red -width 20 -height 20] \
2566	    [frame .f2 -bg blue -width 20 -height 20]
2567    set result [.p identify 20 5]
2568    destroy .p .f .f2
2569    set result
2570} {0 handle}
2571test panedwindow-27.11 {PanedWindowIdentifyCoords} {
2572    panedwindow .p -bd 0 -sashwidth 2 -sashpad 2 -showhandle 1 -handlepad 5 \
2573	    -handlesize 8
2574    .p add [frame .f -bg red -width 20 -height 20] \
2575	    [frame .f2 -bg blue -width 20 -height 20]
2576    set result [.p identify 20 0]
2577    destroy .p .f .f2
2578    set result
2579} {0 sash}
2580test panedwindow-27.12 {PanedWindowIdentifyCoords} {
2581    panedwindow .p -showhandle false -bd 0 -sashwidth 2 -sashpad 2
2582    .p add [frame .f -bg red -width 20 -height 20] \
2583	    [frame .f2 -bg blue -width 20 -height 20] \
2584	    [frame .f3 -bg green -width 20 -height 20]
2585    set result [.p identify 48 0]
2586    destroy .p .f .f2 .f3
2587    set result
2588} {1 sash}
2589test panedwindow-27.13 {identify subcommand errors} {
2590    panedwindow .p -borderwidth 0 -sashpad 2 -sashwidth 4
2591    set result [list [catch {.p identify} msg] $msg]
2592    destroy .p
2593    set result
2594} [list 1 "wrong # args: should be \".p identify x y\""]
2595test panedwindow-27.14 {identify subcommand errors} {
2596    panedwindow .p
2597    set result [list [catch {.p identify foo bar} msg] $msg]
2598    destroy .p
2599    set result
2600} [list 1 "expected integer but got \"foo\""]
2601test panedwindow-27.14a {identify subcommand errors} {
2602    panedwindow .p
2603    set result [list [catch {.p identify 0 bar} msg] $msg]
2604    destroy .p
2605    set result
2606} [list 1 "expected integer but got \"bar\""]
2607test panedwindow-27.15 {PanedWindowIdentifyCoords} {
2608    panedwindow .p -bd 0 -sashwidth 2 -sashpad 2 -orient vertical
2609    .p add [frame .f -bg red -width 20 -height 20] \
2610	    [frame .f2 -bg blue -width 20 -height 20]
2611    set result [.p identify 0 0]
2612    destroy .p .f .f2
2613    set result
2614} {}
2615test panedwindow-27.16 {PanedWindowIdentifyCoords, padding is included} {
2616    panedwindow .p -bd 0 -sashwidth 2 -sashpad 2 -orient vertical
2617    .p add [frame .f -bg red -width 20 -height 20] \
2618	    [frame .f2 -bg blue -width 20 -height 20]
2619    set result [.p identify 0 20]
2620    destroy .p .f .f2
2621    set result
2622} {0 sash}
2623test panedwindow-27.17 {PanedWindowIdentifyCoords} {
2624    panedwindow .p -bd 0 -sashwidth 2 -sashpad 2 -orient vertical
2625    .p add [frame .f -bg red -width 20 -height 20] \
2626	    [frame .f2 -bg blue -width 20 -height 20]
2627    set result [.p identify 0 22]
2628    destroy .p .f .f2
2629    set result
2630} {0 sash}
2631test panedwindow-27.18 {PanedWindowIdentifyCoords} {
2632    panedwindow .p -bd 0 -sashwidth 2 -sashpad 2 -orient vertical
2633    .p add [frame .f -bg red -width 20 -height 20] \
2634	    [frame .f2 -bg blue -width 20 -height 20]
2635    set result [.p identify 0 24]
2636    destroy .p .f .f2
2637    set result
2638} {0 sash}
2639test panedwindow-27.19 {PanedWindowIdentifyCoords} {
2640    panedwindow .p -bd 0 -sashwidth 2 -sashpad 2 -orient vertical
2641    .p add [frame .f -bg red -width 20 -height 20] \
2642	    [frame .f2 -bg blue -width 20 -height 20]
2643    set result [.p identify 0 26]
2644    destroy .p .f .f2
2645    set result
2646} {0 sash}
2647test panedwindow-27.20 {PanedWindowIdentifyCoords} {
2648    panedwindow .p -bd 0 -sashwidth 2 -sashpad 2 -orient vertical
2649    .p add [frame .f -bg red -width 20 -height 20] \
2650	    [frame .f2 -bg blue -width 20 -height 20]
2651    set result [.p identify -1 26]
2652    destroy .p .f .f2
2653    set result
2654} {}
2655test panedwindow-27.21 {PanedWindowIdentifyCoords} {
2656    panedwindow .p -bd 0 -sashwidth 2 -sashpad 2 -orient vertical
2657    .p add [frame .f -bg red -width 20 -height 20] \
2658	    [frame .f2 -bg blue -width 20 -height 20]
2659    set result [.p identify 100 26]
2660    destroy .p .f .f2
2661    set result
2662} {}
2663test panedwindow-27.22 {PanedWindowIdentifyCoords} {
2664    panedwindow .p -bd 0 -sashwidth 2 -sashpad 2 -showhandle 1 -handlepad 5 \
2665	    -handlesize 6 -orient vertical
2666    .p add [frame .f -bg red -width 20 -height 20] \
2667	    [frame .f2 -bg blue -width 20 -height 20]
2668    set result [.p identify 4 22]
2669    destroy .p .f .f2
2670    set result
2671} {0 sash}
2672test panedwindow-27.23 {PanedWindowIdentifyCoords} {
2673    panedwindow .p -bd 0 -sashwidth 2 -sashpad 2 -showhandle 1 -handlepad 5 \
2674	    -handlesize 6 -orient vertical
2675    .p add [frame .f -bg red -width 20 -height 20] \
2676	    [frame .f2 -bg blue -width 20 -height 20]
2677    set result [.p identify 5 22]
2678    destroy .p .f .f2
2679    set result
2680} {0 handle}
2681test panedwindow-27.24 {PanedWindowIdentifyCoords} {
2682    panedwindow .p -bd 0 -sashwidth 2 -sashpad 2 -showhandle 1 -handlepad 5 \
2683	    -handlesize 8 -orient vertical
2684    .p add [frame .f -bg red -width 20 -height 20] \
2685	    [frame .f2 -bg blue -width 20 -height 20]
2686    set result [.p identify 5 20]
2687    destroy .p .f .f2
2688    set result
2689} {0 handle}
2690test panedwindow-27.25 {PanedWindowIdentifyCoords} {
2691    panedwindow .p -bd 0 -sashwidth 2 -sashpad 2 -showhandle 1 -handlepad 5 \
2692	    -handlesize 8 -orient vertical
2693    .p add [frame .f -bg red -width 20 -height 20] \
2694	    [frame .f2 -bg blue -width 20 -height 20]
2695    set result [.p identify 0 20]
2696    destroy .p .f .f2
2697    set result
2698} {0 sash}
2699test panedwindow-27.26 {PanedWindowIdentifyCoords} {
2700    panedwindow .p -showhandle false -bd 0 -sashwidth 2 -sashpad 2 -orient vertical
2701    .p add [frame .f -bg red -width 20 -height 20] \
2702	    [frame .f2 -bg blue -width 20 -height 20] \
2703	    [frame .f3 -bg green -width 20 -height 20]
2704    set result [.p identify 0 48]
2705    destroy .p .f .f2 .f3
2706    set result
2707} {1 sash}
2708
2709test panedwindow-28.1 {destroy the window cleanly on error [Bug #616589]} {
2710    list [catch {panedwindow .p -bogusopt bogus} msg] $msg
2711} {1 {unknown option "-bogusopt"}}
2712test panedwindow-28.2 {destroy the window cleanly on rename [Bug #616589]} {
2713    destroy .p
2714    panedwindow .p
2715    rename .p {}
2716    winfo exists .p
2717} {0}
2718
2719
2720test panedwindow-29.1 {resizing width} {
2721    -body {
2722        panedwindow .p -bd 5
2723        frame .f1 -width 100 -height 50 -bg blue
2724        frame .f2 -width 100 -height 50 -bg red
2725
2726        .p add .f1 -sticky news
2727        .p add .f2 -sticky news
2728        pack .p -side top -fill both -expand 1
2729        wm geometry . ""
2730        update
2731        # Note the width
2732        set a [winfo width .f2]
2733        # Increase the size by 10
2734        regexp {^(\d+)x(\d+)} [wm geometry .] -> w h
2735        wm geometry . [expr {$w + 10}]x$h
2736        update
2737        set b "$a [winfo width .f2]"
2738    }
2739    -cleanup {destroy .p .f1 .f2}
2740    -result {100 110}
2741}
2742
2743test panedwindow-29.2 {resizing height} {
2744    -body {
2745        panedwindow .p -orient vertical -bd 5
2746        frame .f1 -width 50 -height 100 -bg blue
2747        frame .f2 -width 50 -height 100 -bg red
2748
2749        .p add .f1 -sticky news
2750        .p add .f2 -sticky news
2751        pack .p -side top -fill both -expand 1
2752        wm geometry . ""
2753        update
2754        # Note the height
2755        set a [winfo height .f2]
2756        # Increase the size by 10
2757        regexp {^(\d+)x(\d+)} [wm geometry .] -> w h
2758        wm geometry . ${w}x[expr {$h + 10}]
2759        update
2760        set b "$a [winfo height .f2]"
2761    }
2762    -cleanup {destroy .p .f1 .f2}
2763    -result {100 110}
2764}
2765
2766test panedwindow-30.1 {display on depths other than the default one} {
2767    -constraints {pseudocolor8 haveTruecolor24}
2768    -body {
2769	toplevel .t -visual {truecolor 24}
2770	pack [panedwindow .t.p]
2771	.t.p add [frame .t.p.f1] [frame .t.p.f2]
2772	update
2773	# If we got here, we didn't crash and that's good
2774    }
2775    -cleanup {destroy .t}
2776    -result {}
2777}
2778test panedwindow-30.2 {display on depths other than the default one} {
2779    -constraints {pseudocolor8 haveTruecolor24}
2780    -body {
2781	toplevel .t -visual {pseudocolor 8}
2782	pack [frame .t.f -visual {truecolor 24}]
2783	pack [panedwindow .t.f.p]
2784	.t.f.p add [frame .t.f.p.f1 -width 5] [frame .t.f.p.f2 -width 5]
2785	update
2786	.t.f.p proxy place 1 1
2787	update
2788	.t.f.p proxy forget
2789	update
2790	# If we got here, we didn't crash and that's good
2791    }
2792    -cleanup {destroy .t}
2793    -result {}
2794}
2795
2796# cleanup
2797cleanupTests
2798return
2799