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