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