OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tk/] [tests/] [grid.test] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# This file is a Tcl script to test out the *NEW* "grid" command
2
# of Tk.  It is (almost) organized in the standard fashion for Tcl tests.
3
#
4
# Copyright (c) 1996 Sun Microsystems, Inc.
5
#
6
# See the file "license.terms" for information on usage and redistribution
7
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
8
#
9
# RCS: @(#) $Id: grid.test,v 1.1.1.1 2002-01-16 10:25:58 markom Exp $
10
 
11
if {[string compare test [info procs test]] == 1} then \
12
  {source ../tests/defs}
13
 
14
# Test Arguments:
15
# name -                Name of test, in the form foo-1.2.
16
# description -         Short textual description of the test, to
17
#                       help humans understand what it does.
18
# constraints -         A list of one or more keywords, each of
19
#                       which must be the name of an element in
20
#                       the array "testConfig".  If any of these
21
#                       elements is zero, the test is skipped.
22
#                       This argument may be omitted.
23
# script -              Script to run to carry out the test.  It must
24
#                       return a result that can be checked for
25
#                       correctness.
26
# answer -              Expected result from script.
27
 
28
# helper routine to return "." to a sane state after a test
29
# The variable GRID_VERBOSE can be used to "look" at the result
30
# of one or all of the tests
31
 
32
proc grid_reset {{test ?} {top .}} {
33
    global GRID_VERBOSE
34
    if {[info exists GRID_VERBOSE]} {
35
        if {$GRID_VERBOSE=="" || $GRID_VERBOSE==$test} {
36
            puts -nonewline "grid test $test: "
37
            flush stdout
38
            gets stdin
39
        }
40
    }
41
    eval destroy [winfo children $top]
42
    update
43
    foreach {cols rows} [grid size .] {}
44
    for {set i 0} {$i <= $cols} {incr i} {
45
        grid columnconfigure . $i -weight 0 -minsize 0 -pad 0
46
    }
47
    for {set i 0} {$i <= $rows} {incr i} {
48
        grid rowconfigure . $i -weight 0 -minsize 0 -pad 0
49
    }
50
    grid propagate . 1
51
    update
52
}
53
 
54
grid_reset 0.0
55
wm geometry . {}
56
 
57
test grid-1.1 {basic argument checking} {
58
        list [catch grid msg] $msg
59
} {1 {wrong # args: should be "grid option arg ?arg ...?"}}
60
 
61
test grid-1.2 {basic argument checking} {
62
        list [catch {grid foo bar} msg] $msg
63
} {1 {bad option "foo":  must be bbox, columnconfigure, configure, forget, info, location, propagate, remove, rowconfigure, size, or slaves.}}
64
 
65
test grid-1.3 {basic argument checking} {
66
        button .b
67
        list [catch {grid .b -row 0 -column} msg] $msg
68
} {1 {extra option or option with no value}}
69
grid_reset 1.3
70
 
71
test grid-1.4 {basic argument checking} {
72
        button .b
73
        list [catch {grid configure .b - foo} msg] $msg
74
} {1 {unexpected parameter, "foo", in configure list. Should be window name or option}}
75
grid_reset 1.4
76
 
77
test grid-1.5 {basic argument checking} {
78
        list [catch {grid .} msg] $msg
79
} {1 {can't manage ".": it's a top-level window}}
80
 
81
test grid-1.6 {basic argument checking} {
82
        list [catch {grid x} msg] $msg
83
} {1 {can't determine master window}}
84
 
85
test grid-2.1 {bbox} {
86
        list [catch {grid bbox .} msg] $msg
87
} {0 {0 0 0 0}}
88
 
89
test grid-2.2 {bbox} {
90
        button .b
91
        grid .b
92
        destroy .b
93
        update
94
        list [catch {grid bbox .} msg] $msg
95
} {0 {0 0 0 0}}
96
 
97
test grid-2.3 {bbox: argument checking} {
98
        list [catch {grid bbox . 0 0 5} msg] $msg
99
} {1 {wrong number of arguments: must be "grid bbox master ?column row ?column row??"}}
100
 
101
test grid-2.4 {bbox} {
102
        list [catch {grid bbox .bad 0 0} msg] $msg
103
} {1 {bad window path name ".bad"}}
104
 
105
test grid-2.5 {bbox} {
106
        list [catch {grid bbox . x 0} msg] $msg
107
} {1 {expected integer but got "x"}}
108
 
109
test grid-2.6 {bbox} {
110
        list [catch {grid bbox . 0 x} msg] $msg
111
} {1 {expected integer but got "x"}}
112
 
113
test grid-2.7 {bbox} {
114
        list [catch {grid bbox . 0 0 x 0} msg] $msg
115
} {1 {expected integer but got "x"}}
116
 
117
test grid-2.8 {bbox} {
118
        list [catch {grid bbox . 0 0 0 x} msg] $msg
119
} {1 {expected integer but got "x"}}
120
 
121
test grid-2.9 {bbox} {
122
    frame .1 -width 75 -height 75 -bg red
123
    frame .2 -width 90 -height 90 -bg red
124
    grid .1 -row 0 -column 0
125
    grid .2 -row 1 -column 1
126
    update
127
    set a ""
128
    lappend a [grid bbox .]
129
    lappend a [grid bbox . 0 0]
130
    lappend a [grid bbox . 0 0 1 1]
131
    lappend a [grid bbox . 1 1]
132
    set a
133
} {{0 0 165 165} {0 0 75 75} {0 0 165 165} {75 75 90 90}}
134
grid_reset 2.9
135
 
136
test grid-2.10 {bbox} {
137
    frame .1 -width 75 -height 75 -bg red
138
    frame .2 -width 90 -height 90 -bg red
139
    grid .1 -row 0 -column 0
140
    grid .2 -row 1 -column 1
141
    update
142
    set a ""
143
    lappend a [grid bbox . 10 10 0 0]
144
    lappend a [grid bbox . -2 -2 -1 -1]
145
    lappend a [grid bbox . 10 10 12 12]
146
    set a
147
} {{0 0 165 165} {0 0 0 0} {165 165 0 0}}
148
grid_reset 2.10
149
 
150
test grid-3.1 {configure: basic argument checking} {
151
    list [catch {grid configure foo} msg] $msg
152
} {1 {bad argument "foo": must be name of window}}
153
 
154
test grid-3.2 {configure: basic argument checking} {
155
    button .b
156
    grid configure .b
157
    grid slaves .
158
} {.b}
159
grid_reset 3.2
160
 
161
test grid-3.3 {configure: basic argument checking} {
162
    button .b
163
    list [catch {grid .b -row -1} msg] $msg
164
} {1 {bad grid value "-1": must be a non-negative integer}}
165
grid_reset 3.3
166
 
167
test grid-3.4 {configure: basic argument checking} {
168
    button .b
169
    list [catch {grid .b -column -1} msg] $msg
170
} {1 {bad column value "-1": must be a non-negative integer}}
171
grid_reset 3.4
172
 
173
test grid-3.5 {configure: basic argument checking} {
174
    button .b
175
    list [catch {grid .b -rowspan 0} msg] $msg
176
} {1 {bad rowspan value "0": must be a positive integer}}
177
grid_reset 3.5
178
 
179
test grid-3.6 {configure: basic argument checking} {
180
    button .b
181
    list [catch {grid .b -columnspan 0} msg] $msg
182
} {1 {bad columnspan value "0": must be a positive integer}}
183
grid_reset 3.6
184
 
185
test grid-3.7 {configure: basic argument checking} {
186
    frame .f
187
    button .f.b
188
    list [catch {grid .f .f.b} msg] $msg
189
} {1 {can't put .f.b inside .}}
190
grid_reset 3.7
191
 
192
test grid-4.1 {forget: basic argument checking} {
193
    list [catch {grid forget foo} msg] $msg
194
} {1 {bad window path name "foo"}}
195
 
196
test grid-4.2 {forget} {
197
    button .c
198
    grid [button .b]
199
    set a [grid slaves .]
200
    grid forget .b .c
201
    lappend a [grid slaves .]
202
    set a
203
} {.b {}}
204
grid_reset 4.2
205
 
206
test grid-4.3 {forget} {
207
    button .c
208
    grid .c -row 2 -column 2 -rowspan 2 -columnspan 2 -padx 3 -pady 4 -sticky ns
209
    grid forget .c
210
    grid .c -row 0 -column 0
211
    grid info .c
212
} {-in . -column 0 -row 0 -columnspan 1 -rowspan 1 -ipadx 0 -ipady 0 -padx 0 -pady 0 -sticky {}}
213
grid_reset 4.3
214
 
215
test grid-4.4 {forget, calling Tk_UnmaintainGeometry} {
216
    frame .f -bd 2 -relief raised
217
    place .f -x 10 -y 20 -width 200 -height 100
218
    frame .f2 -width 50 -height 30 -bg red
219
    grid .f2 -in .f
220
    update
221
    set x [winfo ismapped .f2]
222
    grid forget .f2
223
    place .f -x 30
224
    update
225
    lappend x [winfo ismapped .f2]
226
} {1 0}
227
grid_reset 4.4
228
 
229
test grid-5.1 {info: basic argument checking} {
230
        list [catch {grid info a b} msg] $msg
231
} {1 {wrong # args: should be "grid info window"}}
232
 
233
test grid-5.2 {info} {
234
    frame .1 -width 75 -height 75 -bg red
235
    grid .1 -row 0 -column 0
236
    update
237
    list [catch {grid info .x} msg] $msg
238
} {1 {bad window path name ".x"}}
239
grid_reset 5.2
240
 
241
test grid-5.3 {info} {
242
    frame .1 -width 75 -height 75 -bg red
243
    grid .1 -row 0 -column 0
244
    update
245
    list [catch {grid info .1} msg] $msg
246
} {0 {-in . -column 0 -row 0 -columnspan 1 -rowspan 1 -ipadx 0 -ipady 0 -padx 0 -pady 0 -sticky {}}}
247
grid_reset 5.3
248
 
249
test grid-5.4 {info} {
250
    frame .1 -width 75 -height 75 -bg red
251
    update
252
    list [catch {grid info .1} msg] $msg
253
} {0 {}}
254
grid_reset 5.4
255
 
256
test grid-6.1 {location: basic argument checking} {
257
        list [catch "grid location ." msg] $msg
258
} {1 {wrong # args: should be "grid location master x y"}}
259
 
260
test grid-6.2 {location: basic argument checking} {
261
        list [catch "grid location .bad 0 0" msg] $msg
262
} {1 {bad window path name ".bad"}}
263
 
264
test grid-6.3 {location: basic argument checking} {
265
        list [catch "grid location . x y" msg] $msg
266
} {1 {bad screen distance "x"}}
267
 
268
test grid-6.4 {location: basic argument checking} {
269
        list [catch "grid location . 1c y" msg] $msg
270
} {1 {bad screen distance "y"}}
271
 
272
test grid-6.5 {location: basic argument checking} {
273
        frame .f
274
        grid location .f 10 10
275
} {-1 -1}
276
grid_reset 6.5
277
 
278
test grid-6.6 {location (x)} {
279
    frame .f -width 200 -height 100 -highlightthickness 0 -bg red
280
    grid .f
281
    update
282
    set got ""
283
    set result ""
284
    for {set x -10} { $x < 220} { incr x} {
285
        set a [grid location . $x 0]
286
        if {$a != $got} {
287
            lappend result $x->$a
288
            set got $a
289
        }
290
    }
291
    set result
292
} {{-10->-1 0} {0->0 0} {201->1 0}}
293
grid_reset 6.6
294
 
295
test grid-6.7 {location (y)} {
296
    frame .f -width 200 -height 100 -highlightthickness 0 -bg red
297
    grid .f
298
    update
299
    set got ""
300
    set result ""
301
    for {set y -10} { $y < 110} { incr y} {
302
        set a [grid location . 0 $y]
303
        if {$a != $got} {
304
            lappend result $y->$a
305
            set got $a
306
        }
307
    }
308
    set result
309
} {{-10->0 -1} {0->0 0} {101->0 1}}
310
grid_reset 6.7
311
 
312
test grid-6.8 {location (weights)} {
313
    frame .f -width 200 -height 100 -highlightthickness 0 -bg red
314
    frame .a
315
    grid .a
316
    grid .f -in .a
317
    grid rowconfigure .f 0 -weight 1
318
    grid columnconfigure .f 0 -weight 1
319
    grid propagate .a 0
320
    .a configure -width 110 -height 15
321
    update
322
    set got ""
323
    set result ""
324
    for {set y -10} { $y < 120} { incr y} {
325
        set a [grid location . $y $y]
326
        if {$a != $got} {
327
            lappend result $y->$a
328
            set got $a
329
        }
330
    }
331
    set result
332
} {{-10->-1 -1} {0->0 0} {16->0 1} {111->1 1}}
333
grid_reset 6.8
334
 
335
test grid-6.9 {location: check updates pending} {
336
        set a ""
337
        foreach i {0 1 2} {
338
            frame .$i -width 120 -height 75 -bg red
339
            lappend a [grid location . 150 90]
340
            grid .$i -row $i -column $i
341
        }
342
        set a
343
} {{0 0} {1 1} {1 1}}
344
grid_reset 6.9
345
 
346
test grid-7.1 {propagate} {
347
    list [catch {grid propagate . 1 xxx} msg] $msg
348
} {1 {wrong # args: should be "grid propagate window ?boolean?"}}
349
grid_reset 7.1
350
 
351
test grid-7.2 {propagate} {
352
    list [catch {grid propagate .} msg] $msg
353
} {0 1}
354
grid_reset 7.2
355
 
356
test grid-7.3 {propagate} {
357
    list [catch {grid propagate . 0;grid propagate .} msg] $msg
358
} {0 0}
359
grid_reset 7.3
360
 
361
test grid-7.4 {propagate} {
362
    list [catch {grid propagate .x} msg] $msg
363
} {1 {bad window path name ".x"}}
364
grid_reset 7.4
365
 
366
test grid-7.5 {propagate} {
367
    list [catch {grid propagate . x} msg] $msg
368
} {1 {expected boolean value but got "x"}}
369
grid_reset 7.5
370
 
371
test grid-7.6 {propagate} {
372
    frame .f -width 100 -height 100 -bg red
373
    grid .f -row 0 -column 0
374
    update
375
    set a [winfo width .f]x[winfo height .f]
376
    grid propagate .f 0
377
    frame .g -width 75 -height 85 -bg green
378
    grid .g -in .f -row 0 -column 0
379
    update
380
    lappend a [winfo width .f]x[winfo height .f]
381
    grid propagate .f 1
382
    update
383
    lappend a [winfo width .f]x[winfo height .f]
384
    set a
385
} {100x100 100x100 75x85}
386
grid_reset 7.6
387
 
388
 
389
test grid-8.1 {size} {
390
    list [catch {grid size . foo} msg] $msg
391
} {1 {wrong # args: should be "grid size window"}}
392
grid_reset 8.1
393
 
394
test grid-8.2 {size} {
395
    list [catch {grid size .x} msg] $msg
396
} {1 {bad window path name ".x"}}
397
grid_reset 8.2
398
 
399
test grid-8.3 {size} {
400
    frame .f
401
    list [catch {grid size .f} msg] $msg
402
} {0 {0 0}}
403
grid_reset 8.3
404
 
405
test grid-8.4 {size} {
406
    catch {unset a}
407
    scale .f
408
    grid .f -row 0 -column 0
409
    update
410
    lappend a [grid size .]
411
    grid .f -row 4 -column 5
412
    update
413
    lappend a [grid size .]
414
    grid .f -row 947 -column 663
415
    update
416
    lappend a [grid size .]
417
    grid .f -row 0 -column 0
418
    update
419
    lappend a [grid size .]
420
    set a
421
} {{1 1} {6 5} {664 948} {1 1}}
422
grid_reset 8.4
423
 
424
test grid-8.5 {size} {
425
    catch {unset a}
426
    scale .f
427
    grid .f -row 0 -column 0
428
    update
429
    lappend a [grid size .]
430
    grid rowconfigure . 17 -weight 1
431
    update
432
    lappend a [grid size .]
433
    grid columnconfigure . 63 -weight 1
434
    update
435
    lappend a [grid size .]
436
    grid columnconfigure . 63 -weight 0
437
    grid rowconfigure . 17 -weight 0
438
    update
439
    lappend a [grid size .]
440
    set a
441
} {{1 1} {1 18} {64 18} {1 1}}
442
grid_reset 8.5
443
 
444
test grid-8.6 {size} {
445
    catch {unset a}
446
    scale .f
447
    grid .f -row 10 -column 50
448
    update
449
    lappend a [grid size .]
450
    grid columnconfigure . 15 -weight 1
451
    grid columnconfigure . 30 -weight 1
452
    update
453
    lappend a [grid size .]
454
    grid .f -row 10 -column 20
455
    update
456
    lappend a [grid size .]
457
    grid columnconfigure . 30 -weight 0
458
    update
459
    lappend a [grid size .]
460
    grid .f -row 0 -column 0
461
    update
462
    lappend a [grid size .]
463
    grid columnconfigure . 15 -weight 0
464
    update
465
    lappend a [grid size .]
466
    set a
467
} {{51 11} {51 11} {31 11} {21 11} {16 1} {1 1}}
468
grid_reset 8.6
469
 
470
test grid-9.1 {slaves} {
471
        list [catch {grid slaves .} msg] $msg
472
} {0 {}}
473
 
474
test grid-9.2 {slaves} {
475
        list [catch {grid slaves .foo} msg] $msg
476
} {1 {bad window path name ".foo"}}
477
 
478
test grid-9.3 {slaves} {
479
        list [catch {grid slaves a b} msg] $msg
480
} {1 {wrong # args: should be "grid slaves window ?-option value...?"}}
481
 
482
test grid-9.4 {slaves} {
483
        list [catch {grid slaves . a b} msg] $msg
484
} {1 {invalid args: should be "grid slaves window ?-option value...?"}}
485
 
486
test grid-9.5 {slaves} {
487
        list [catch {grid slaves . -foo x} msg] $msg
488
} {1 {expected integer but got "x"}}
489
 
490
test grid-9.6 {slaves} {
491
        list [catch {grid slaves . -foo -3} msg] $msg
492
} {1 {-foo is an invalid value: should NOT be < 0}}
493
 
494
test grid-9.7 {slaves} {
495
        list [catch {grid slaves . -foo 3} msg] $msg
496
} {1 {-foo is an invalid option: should be "-row, -column"}}
497
 
498
test grid-9.8 {slaves} {
499
        list [catch {grid slaves .x -row 3} msg] $msg
500
} {1 {bad window path name ".x"}}
501
 
502
test grid-9.9 {slaves} {
503
        list [catch {grid slaves . -row 3} msg] $msg
504
} {0 {}}
505
 
506
test grid-9.10 {slaves} {
507
        foreach i {0 1 2} {
508
            label .$i -text $i
509
            grid .$i -row $i -column $i
510
        }
511
        list [catch {grid slaves .} msg] $msg
512
} {0 {.2 .1 .0}}
513
grid_reset 9.10
514
 
515
test grid-9.11 {slaves} {
516
    catch {unset a}
517
    foreach i {0 1 2} {
518
        label .$i -text $i
519
        label .$i-x -text $i-x
520
        grid .$i -row $i -column $i
521
        grid .$i-x -row $i -column [incr i]
522
    }
523
    foreach row {0 1 2 3} {
524
        lappend a $row{[grid slaves . -row $row]}
525
    }
526
    foreach col {0 1 2 3} {
527
        lappend a $col{[grid slaves . -column $col]}
528
    }
529
    set a
530
} {{0{.0-x .0}} {1{.1-x .1}} {2{.2-x .2}} 3{} 0{.0} {1{.1 .0-x}} {2{.2 .1-x}} 3{.2-x}}
531
grid_reset 9.11
532
 
533
# column/row configure
534
 
535
test grid-10.1 {column/row configure} {
536
        list [catch {grid columnconfigure .} msg] $msg
537
} {1 {wrong # args: should be "grid columnconfigure master index ?-option value...?"}}
538
grid_reset 10.1
539
 
540
test grid-10.2 {column/row configure} {
541
        list [catch {grid columnconfigure . 0 -weight 0 -pad} msg] $msg
542
} {1 {wrong # args: should be "grid columnconfigure master index ?-option value...?"}}
543
grid_reset 10.2
544
 
545
test grid-10.3 {column/row configure} {
546
        list [catch {grid columnconfigure .f 0 -weight} msg] $msg
547
} {1 {bad window path name ".f"}}
548
grid_reset 10.3
549
 
550
test grid-10.4 {column/row configure} {
551
        list [catch {grid columnconfigure . nine -weight} msg] $msg
552
} {1 {expected integer but got "nine"}}
553
grid_reset 10.4
554
 
555
test grid-10.5 {column/row configure} {
556
        list [catch {grid columnconfigure . 265 -weight} msg] $msg
557
} {0 0}
558
grid_reset 10.5
559
 
560
test grid-10.6 {column/row configure} {
561
        list [catch {grid columnconfigure . 0} msg] $msg
562
} {0 {-minsize 0 -pad 0 -weight 0}}
563
grid_reset 10.6
564
 
565
test grid-10.7 {column/row configure} {
566
        list [catch {grid columnconfigure . 0 -foo} msg] $msg
567
} {1 {invalid arg "-foo": expecting -minsize, -pad, or -weight.}}
568
grid_reset 10.7
569
 
570
test grid-10.8 {column/row configure} {
571
        list [catch {grid columnconfigure . 0 -minsize foo} msg] $msg
572
} {1 {bad screen distance "foo"}}
573
grid_reset 10.8
574
 
575
test grid-10.9 {column/row configure} {
576
        list [catch {grid columnconfigure . 0 -minsize foo} msg] $msg
577
} {1 {bad screen distance "foo"}}
578
grid_reset 10.9
579
 
580
test grid-10.10 {column/row configure} {
581
        grid columnconfigure . 0 -minsize 10
582
        grid columnconfigure . 0 -minsize
583
} {10}
584
grid_reset 10.10
585
 
586
test grid-10.11 {column/row configure} {
587
        list [catch {grid columnconfigure . 0 -weight bad} msg] $msg
588
} {1 {expected integer but got "bad"}}
589
grid_reset 10.10a
590
 
591
test grid-10.12 {column/row configure} {
592
        list [catch {grid columnconfigure . 0 -weight -3} msg] $msg
593
} {1 {invalid arg "-weight": should be non-negative}}
594
grid_reset 10.11
595
 
596
test grid-10.13 {column/row configure} {
597
        grid columnconfigure . 0 -weight 3
598
        grid columnconfigure . 0 -weight
599
} {3}
600
grid_reset 10.12
601
 
602
test grid-10.14 {column/row configure} {
603
        list [catch {grid columnconfigure . 0 -pad foo} msg] $msg
604
} {1 {bad screen distance "foo"}}
605
grid_reset 10.13
606
 
607
test grid-10.15 {column/row configure} {
608
        list [catch {grid columnconfigure . 0 -pad -3} msg] $msg
609
} {1 {invalid arg "-pad": should be non-negative}}
610
grid_reset 10.14
611
 
612
test grid-10.16 {column/row configure} {
613
        grid columnconfigure . 0 -pad 3
614
        grid columnconfigure . 0 -pad
615
} {3}
616
grid_reset 10.15
617
 
618
test grid-10.17 {column/row configure} {
619
        frame .f
620
        set a ""
621
        grid columnconfigure .f 0 -weight 0
622
        lappend a [grid columnconfigure .f 0 -weight]
623
        grid columnconfigure .f 0 -weight 1
624
        lappend a [grid columnconfigure .f 0 -weight]
625
        grid rowconfigure .f 0 -weight 0
626
        lappend a [grid rowconfigure .f 0 -weight]
627
        grid rowconfigure .f 0 -weight 1
628
        lappend a [grid columnconfigure .f 0 -weight]
629
        grid columnconfigure .f 0 -weight 0
630
        set a
631
} {0 1 0 1}
632
grid_reset 10.16
633
 
634
test grid-10.18 {column/row configure} {
635
        frame .f
636
        grid columnconfigure .f 0 -minsize 10 -weight 1
637
        list [grid columnconfigure .f 0 -minsize] \
638
                [grid columnconfigure .f 1 -minsize] \
639
                [grid columnconfigure .f 0 -weight] \
640
                [grid columnconfigure .f 1 -weight]
641
}  {10 0 1 0}
642
grid_reset 10.17
643
 
644
# auto-placement tests
645
 
646
test grid-11.1 {default widget placement} {
647
        list [catch {grid ^} msg] $msg
648
} {1 {can't use '^', cant find master}}
649
grid_reset 11.1
650
 
651
test grid-11.2 {default widget placement} {
652
        button .b
653
        list [catch {grid .b ^} msg] $msg
654
} {1 {can't find slave to extend with "^".}}
655
grid_reset 11.2
656
 
657
test grid-11.3 {default widget placement} {
658
        button .b
659
        list [catch {grid .b - - .c} msg] $msg
660
} {1 {bad window path name ".c"}}
661
grid_reset 11.3
662
 
663
test grid-11.4 {default widget placement} {
664
        button .b
665
        list [catch {grid .b - - = -} msg] $msg
666
} {1 {invalid window shortcut, "=" should be '-', 'x', or '^'}}
667
grid_reset 11.4
668
 
669
test grid-11.5 {default widget placement} {
670
        button .b
671
        list [catch {grid .b - x -} msg] $msg
672
} {1 {Must specify window before shortcut '-'.}}
673
grid_reset 11.5
674
 
675
test grid-11.6 {default widget placement} {
676
    foreach i {1 2 3 4 5 6} {
677
        frame .f$i -width 50 -height 50 -highlightthickness 0 -bg red
678
    }
679
    grid .f1 .f2 .f3 .f4
680
    grid .f5   -  x  .f6 -sticky nsew
681
    update
682
    set a ""
683
    foreach i {5 6} {
684
        lappend a "[winfo x .f$i],[winfo y .f$i] \
685
                [winfo width .f$i],[winfo height .f$i]"
686
    }
687
    set a
688
} {{0,50  100,50} {150,50  50,50}}
689
grid_reset 11.6
690
 
691
test grid-11.7 {default widget placement} {
692
    frame .f -width 20 -height 20 -highlightthickness 0 -bg red
693
    grid .f -row 5 -column 5
694
    list [catch "grid .f x -" msg] $msg
695
} {1 {Must specify window before shortcut '-'.}}
696
grid_reset 11.7
697
 
698
test grid-11.8 {default widget placement} {
699
    frame .f -width 20 -height 20 -highlightthickness 0 -bg red
700
    grid .f -row 5 -column 5
701
    list [catch "grid .f ^ -" msg] $msg
702
} {1 {Must specify window before shortcut '-'.}}
703
grid_reset 11.8
704
 
705
test grid-11.9 {default widget placement} {
706
    frame .f -width 20 -height 20 -highlightthickness 0 -bg red
707
    grid .f -row 5 -column 5
708
    list [catch "grid .f x ^" msg] $msg
709
} {1 {can't find slave to extend with "^".}}
710
grid_reset 11.9
711
 
712
test grid-11.10 {default widget placement} {
713
    foreach i {1 2 3} {
714
                frame .f$i -width 100 -height 50 -highlightthickness 0 -bg red
715
    }
716
    grid .f1 .f2  -sticky nsew
717
    grid .f3   ^  -sticky nsew
718
    update
719
    set a ""
720
    foreach i {1 2 3} {
721
        lappend a "[winfo x .f$i],[winfo y .f$i] \
722
                [winfo width .f$i],[winfo height .f$i]"
723
    }
724
    set a
725
} {{0,0  100,50} {100,0  100,100} {0,50  100,50}}
726
grid_reset 11.10
727
 
728
test grid-11.11 {default widget placement} {
729
    foreach i {1 2 3 4 5 6 7 8 9 10 11 12} {
730
                frame .f$i -width 50 -height 50 -highlightthickness 1 -highlightbackground black
731
    }
732
    grid .f1  .f2  .f3 .f4 -sticky nsew
733
    grid .f5  .f6   -  .f7  -sticky nsew
734
    grid .f8    ^   ^  .f9  -sticky nsew
735
    grid .f10   ^   ^  .f11  -sticky nsew
736
        grid .f12   -   -   - -sticky nsew
737
    update
738
    set a ""
739
    foreach i {5 6 7 8 9 10 11 12 } {
740
        lappend a "[winfo x .f$i],[winfo y .f$i] \
741
                [winfo width .f$i],[winfo height .f$i]"
742
    }
743
    set a
744
} {{0,50  50,50} {50,50  100,150} {150,50  50,50} {0,100  50,50} {150,100  50,50} {0,150  50,50} {150,150  50,50} {0,200  200,50}}
745
grid_reset 11.11
746
 
747
test grid-11.12 {default widget placement} {
748
    foreach i {1 2 3 4} {
749
                frame .f$i -width 75 -height 50 -highlightthickness 1 -highlightbackground black
750
    }
751
    grid .f1  .f2   .f3     -sticky nsew
752
    grid .f4    ^           -sticky nsew
753
    update
754
    set a ""
755
    foreach i {1 2 3 4} {
756
                lappend a "[winfo x .f$i],[winfo y .f$i] \
757
                        [winfo width .f$i],[winfo height .f$i]"
758
    }
759
    grid .f4    ^   -column 1
760
    update
761
    foreach i {1 2 3 4} {
762
                lappend a "[winfo x .f$i],[winfo y .f$i] \
763
                        [winfo width .f$i],[winfo height .f$i]"
764
        }
765
        set a
766
} {{0,0  75,50} {75,0  75,100} {150,0  75,50} {0,50  75,50} {0,0  75,50} {75,0  75,100} {150,0  75,100} {75,50  75,50}}
767
grid_reset 11.12
768
 
769
test grid-11.13 {default widget placement} {
770
    foreach i {1 2 3 4 5 6 7} {
771
                frame .f$i -width 40 -height 50 -highlightthickness 1 -highlightbackground black
772
    }
773
    grid .f1  .f2  .f3 .f4 .f5 -sticky nsew
774
    grid .f6    -  .f7         -sticky nsew -columnspan 2
775
    update
776
    set a ""
777
    foreach i {6 7} {
778
        lappend a "[winfo x .f$i],[winfo y .f$i] \
779
                [winfo width .f$i],[winfo height .f$i]"
780
    }
781
    set a
782
} {{0,50  120,50} {120,50  80,50}}
783
grid_reset 11.13
784
 
785
test grid-11.14 {default widget placement} {
786
    foreach i {1 2 3} {
787
        frame .f$i -width 50 -height 50 -highlightthickness 0 -bg red
788
    }
789
    grid .f1 .f2
790
    grid  ^  .f3
791
    update
792
    set a ""
793
    foreach i {1 2 3} {
794
        lappend a "[winfo x .f$i],[winfo y .f$i] \
795
                [winfo width .f$i],[winfo height .f$i]"
796
    }
797
    set a
798
} {{0,25  50,50} {50,0  50,50} {50,50  50,50}}
799
grid_reset 11.14
800
 
801
test grid-12.1 {-sticky} {
802
    catch {unset data}
803
    frame .f -width 200 -height 100 -highlightthickness 0 -bg red
804
    set a ""
805
    grid .f
806
    grid rowconfigure . 0 -weight 1
807
    grid columnconfigure . 0 -weight 1
808
    grid propagate . 0
809
    . configure -width 250 -height 150
810
    foreach i { {} n s e w ns ew nw ne se sw nse nsw sew new nsew} {
811
        grid .f -sticky $i
812
        update
813
        array set data [grid info .f]
814
        append a "($data(-sticky)) [winfo x .f] [winfo y .f] [winfo width .f] [winfo height .f]\n"
815
    }
816
    set a
817
} {() 25 25 200 100
818
(n) 25 0 200 100
819
(s) 25 50 200 100
820
(e) 50 25 200 100
821
(w) 0 25 200 100
822
(ns) 25 0 200 150
823
(ew) 0 25 250 100
824
(nw) 0 0 200 100
825
(ne) 50 0 200 100
826
(es) 50 50 200 100
827
(sw) 0 50 200 100
828
(nes) 50 0 200 150
829
(nsw) 0 0 200 150
830
(esw) 0 50 250 100
831
(new) 0 0 250 100
832
(nesw) 0 0 250 150
833
}
834
grid_reset 12.1
835
 
836
test grid-12.2 {-sticky} {
837
    frame .f -bg red
838
    list [catch "grid .f -sticky glue" msg] $msg
839
} {1 {bad stickyness value "glue": must be a string containing n, e, s, and/or w}}
840
grid_reset 12.2
841
 
842
test grid-12.3 {-sticky} {
843
    frame .f -bg red
844
    grid .f -sticky {n,s,e,w}
845
    array set A [grid info .f]
846
    set A(-sticky)
847
} {nesw}
848
grid_reset 12.3
849
 
850
test grid-13.1 {-in} {
851
    frame .f -bg red
852
    list [catch "grid .f -in .f" msg] $msg
853
} {1 {Window can't be managed in itself}}
854
grid_reset 13.1
855
 
856
test grid-13.2 {-in} {
857
    frame .f -bg red
858
    list [catch "grid .f -in .bad" msg] $msg
859
} {1 {bad window path name ".bad"}}
860
grid_reset 13.2
861
 
862
test grid-13.3 {-in} {
863
    frame .f -bg red
864
    toplevel .top
865
    list [catch "grid .f -in .top" msg] $msg
866
} {1 {can't put .f inside .top}}
867
destroy .top
868
grid_reset 13.3
869
 
870
test grid-13.4 {-ipadx} {
871
    frame .f -width 20 -height 20 -highlightthickness 0 -bg red
872
    list [catch "grid .f -ipadx x" msg] $msg
873
} {1 {bad ipadx value "x": must be positive screen distance}}
874
grid_reset 13.4
875
 
876
test grid-13.5 {-ipadx} {
877
    frame .f -width 200 -height 100 -highlightthickness 0 -bg red
878
    grid .f
879
    update
880
    set a [winfo width .f]
881
    grid .f -ipadx 1
882
    update
883
    list $a [winfo width .f]
884
} {200 202}
885
grid_reset 13.5
886
 
887
test grid-13.6 {-ipady} {
888
    frame .f -width 20 -height 20 -highlightthickness 0 -bg red
889
    list [catch "grid .f -ipady x" msg] $msg
890
} {1 {bad ipady value "x": must be positive screen distance}}
891
grid_reset 13.6
892
 
893
test grid-13.7 {-ipady} {
894
    frame .f -width 200 -height 100 -highlightthickness 0 -bg red
895
    grid .f
896
    update
897
    set a [winfo height .f]
898
    grid .f -ipady 1
899
    update
900
    list $a [winfo height .f]
901
} {100 102}
902
grid_reset 13.7
903
 
904
test grid-13.8 {-padx} {
905
    frame .f -width 20 -height 20 -highlightthickness 0 -bg red
906
    list [catch "grid .f -padx x" msg] $msg
907
} {1 {bad padx value "x": must be positive screen distance}}
908
grid_reset 13.8
909
 
910
test grid-13.9 {-padx} {
911
    frame .f -width 200 -height 100 -highlightthickness 0 -bg red
912
    grid .f
913
    update
914
    set a "[winfo width .f] [winfo width .]"
915
    grid .f -padx 1
916
    update
917
    list $a "[winfo width .f] [winfo width .]"
918
} {{200 200} {200 202}}
919
grid_reset 13.9
920
 
921
test grid-13.10 {-pady} {
922
    frame .f -width 20 -height 20 -highlightthickness 0 -bg red
923
    list [catch "grid .f -pady x" msg] $msg
924
} {1 {bad pady value "x": must be positive screen distance}}
925
grid_reset 13.10
926
 
927
test grid-13.11 {-pady} {
928
    frame .f -width 200 -height 100 -highlightthickness 0 -bg red
929
    grid .f
930
    update
931
    set a "[winfo height .f] [winfo height .]"
932
    grid .f -pady 1
933
    update
934
    list $a "[winfo height .f] [winfo height .]"
935
} {{100 100} {100 102}}
936
grid_reset 13.11
937
 
938
test grid-13.12 {-ipad x and y} {
939
    frame .f -width 20 -height 20 -highlightthickness 0 -bg red
940
    grid columnconfigure . 0 -minsize 150
941
    grid rowconfigure . 0 -minsize 100
942
    set a ""
943
    foreach x {0 5} {
944
        foreach y {0 5} {
945
            grid .f -ipadx $x -ipady $y
946
            update
947
            append a " $x,$y:"
948
            foreach prop {x y width height} {
949
                append a ,[winfo $prop .f]
950
            }
951
        }
952
    }
953
    set a
954
} { 0,0:,65,40,20,20 0,5:,65,35,20,30 5,0:,60,40,30,20 5,5:,60,35,30,30}
955
grid_reset 13.12
956
 
957
test grid-13.13 {reparenting} {
958
    frame .1
959
    frame .2
960
    button .b
961
    grid .1 .2
962
    grid .b -in .1
963
    set a ""
964
    catch {unset info}; array set info [grid info .b]
965
    lappend a [grid slaves .1],[grid slaves .2],$info(-in)
966
    grid .b -in .2
967
    catch {unset info}; array set info [grid info .b]
968
    lappend a [grid slaves .1],[grid slaves .2],$info(-in)
969
    unset info
970
    set a
971
} {.b,,.1 ,.b,.2}
972
grid_reset 13.13
973
 
974
test grid-14.1 {structure notify} {
975
    frame .f -width 200 -height 100 -highlightthickness 0 -bg red
976
    frame .g -width 200 -height 100 -highlightthickness 0 -bg red
977
    grid .f
978
    grid .g -in .f
979
    update
980
    set a ""
981
    lappend a "[winfo x .g],[winfo y .g] \
982
        [winfo width .g],[winfo height .g]"
983
    .f configure -bd 5 -relief raised
984
    update
985
    lappend a "[winfo x .g],[winfo y .g] \
986
        [winfo width .g],[winfo height .g]"
987
    set a
988
} {{0,0  200,100} {5,5  200,100}}
989
grid_reset 14.1
990
 
991
test grid-14.2 {structure notify} {
992
    frame .f -width 200 -height 100
993
    frame .f.g -width 200 -height 100
994
    grid .f
995
    grid .f.g
996
    update
997
    set a ""
998
    lappend a [grid bbox .],[grid bbox .f]
999
    .f config -bd 20
1000
    update
1001
    lappend a [grid bbox .],[grid bbox .f]
1002
} {{0 0 200 100,0 0 200 100} {0 0 240 140,20 20 200 100}}
1003
grid_reset 14.2
1004
 
1005
test grid-14.3 {map notify} {
1006
        global A
1007
        catch {unset A}
1008
        bind .  {incr A(%W)}
1009
        set A(.) 0
1010
        foreach i {0 1 2} {
1011
                frame .$i -width 100 -height 75
1012
                set A(.$i) 0
1013
        }
1014
        grid .0 .1 .2
1015
        update
1016
        bind  .1 {destroy .0}
1017
        .2 configure -bd 10
1018
        update
1019
        bind .  {}
1020
        array get A
1021
} {.2 2 .0 1 . 1 .1 1}
1022
grid_reset 14.3
1023
 
1024
test grid-15.1 {lost slave} {
1025
    button .b
1026
    grid .b
1027
    set a [grid slaves .]
1028
    pack .b
1029
    lappend a [grid slaves .]
1030
    grid .b
1031
    lappend a [grid slaves .]
1032
} {.b {} .b}
1033
grid_reset 15.1
1034
 
1035
test grid-15.2 {lost slave} {
1036
    frame .f
1037
    grid .f
1038
    button .b
1039
    grid .b -in .f
1040
    set a [grid slaves .f]
1041
    pack .b
1042
    lappend a [grid slaves .f]
1043
    grid .b -in .f
1044
    lappend a [grid slaves .f]
1045
} {.b {} .b}
1046
grid_reset 15.2
1047
 
1048
test grid-16.1 {layout centering} {
1049
    foreach i {0 1 2} {
1050
        frame .$i -bg gray  -width 75 -height 50 -bd 2 -relief ridge
1051
        grid .$i -row $i -column $i -sticky nswe
1052
    }
1053
    grid propagate . 0
1054
    . configure -width 300 -height 250
1055
    update
1056
    grid bbox .
1057
} {37 50 225 150}
1058
grid_reset 16.1
1059
 
1060
test grid-16.2 {layout weights (expanding)} {
1061
    foreach i {0 1 2} {
1062
        frame .$i -bg gray  -width 75 -height 50 -bd 2 -relief ridge
1063
        grid .$i -row $i -column $i -sticky nswe
1064
        grid rowconfigure . $i -weight [expr $i + 1]
1065
        grid columnconfigure . $i -weight [expr $i + 1]
1066
    }
1067
    grid propagate . 0
1068
    . configure -width 500 -height 300
1069
    set a ""
1070
    update
1071
    foreach i {0 1 2} {
1072
        lappend a [winfo width .$i]-[winfo height .$i]
1073
    }
1074
    set a
1075
} {120-75 167-100 213-125}
1076
grid_reset 16.2
1077
 
1078
test grid-16.3 {layout weights (shrinking)} {
1079
    foreach i {0 1 2} {
1080
        frame .$i -bg gray  -width 100 -height 75 -bd 2 -relief ridge
1081
        grid .$i -row $i -column $i -sticky nswe
1082
        grid rowconfigure . $i -weight [expr $i + 1]
1083
        grid columnconfigure . $i -weight [expr $i + 1]
1084
    }
1085
    grid propagate . 0
1086
    . configure -width 200 -height 150
1087
    set a ""
1088
    update
1089
    foreach i {0 1 2} {
1090
        lappend a [winfo width .$i]-[winfo height .$i]
1091
    }
1092
    set a
1093
} {84-63 66-50 50-37}
1094
grid_reset 16.3
1095
 
1096
test grid-16.4 {layout weights (shrinking with minsize)} {
1097
    foreach i {0 1 2} {
1098
        frame .$i -bg gray  -width 100 -height 75 -bd 2 -relief ridge
1099
        grid .$i -row $i -column $i -sticky nswe
1100
        grid rowconfigure . $i -weight [expr $i + 1] -minsize 45
1101
        grid columnconfigure . $i -weight [expr $i + 1] -minsize 65
1102
    }
1103
    grid propagate . 0
1104
    . configure -width 200 -height 150
1105
    set a ""
1106
    update
1107
    foreach i {0 1 2} {
1108
        lappend a [winfo width .$i]-[winfo height .$i]
1109
    }
1110
    set a
1111
} {70-60 65-45 65-45}
1112
grid_reset 16.4
1113
 
1114
test grid-16.5 {layout weights (shrinking at minsize)} {
1115
    foreach i {0 1 2} {
1116
        frame .$i -bg gray  -width 100 -height 75 -bd 2 -relief ridge
1117
        grid .$i -row $i -column $i -sticky nswe
1118
        grid rowconfigure . $i -weight 0 -minsize 70
1119
        grid columnconfigure . $i -weight 0 -minsize 90
1120
    }
1121
    grid propagate . 0
1122
    . configure -width 100 -height 75
1123
    set a ""
1124
    update
1125
    foreach i {0 1 2} {
1126
        lappend a [winfo width .$i]-[winfo height .$i]
1127
    }
1128
    set a
1129
} {100-75 100-75 100-75}
1130
grid_reset 16.5
1131
 
1132
 
1133
test grid-16.6 {layout weights (shrinking at minsize)} {
1134
    foreach i {0 1 2} {
1135
        frame .$i -bg gray  -width 100 -height 75 -bd 2 -relief ridge
1136
        grid .$i -row $i -column $i -sticky nswe
1137
        grid rowconfigure . $i -weight [expr $i + 1] -minsize 52
1138
        grid columnconfigure . $i -weight [expr $i + 1] -minsize 69
1139
    }
1140
    grid propagate . 0
1141
    . configure -width 200 -height 150
1142
    set a ""
1143
    update
1144
    foreach i {0 1 2} {
1145
        lappend a [winfo width .$i]-[winfo height .$i]
1146
    }
1147
    set a
1148
} {69-52 69-52 69-52}
1149
grid_reset 16.6
1150
 
1151
test grid-16.7 {layout weights (shrinking at minsize)} {
1152
    foreach i {0 1 2} {
1153
        frame .$i -bg gray  -width 100 -height 75 -bd 2 -relief ridge
1154
        grid .$i -row $i -column $i -sticky nswe
1155
    }
1156
    grid propagate . 0
1157
    grid columnconfigure . 1 -weight 1 -minsize 0
1158
    grid rowconfigure . 1 -weight 1 -minsize 0
1159
    . configure -width 100 -height 75
1160
    set a ""
1161
    update
1162
    foreach i {0 1 2} {
1163
        lappend a [winfo width .$i]-[winfo height .$i]-[winfo ismapped .$i]
1164
    }
1165
    set a
1166
} {100-75-1 1-1-0 200-150-1}
1167
grid_reset 16.7
1168
 
1169
test grid-16.8 {layout internal constraints} {
1170
    foreach i {0 1 2 3 4} {
1171
        frame .$i -bg gray  -width 30 -height 25 -bd 2 -relief ridge
1172
        grid .$i -row $i -column $i -sticky nswe
1173
    }
1174
    frame .f -bg red -width 250 -height 200
1175
    frame .g -bg green -width 200 -height 180
1176
    lower .f
1177
    raise .g .f
1178
    grid .f -row 1 -column 1 -rowspan 3 -columnspan 3 -sticky nswe
1179
    grid .g -row 1 -column 1 -rowspan 2 -columnspan 2 -sticky nswe
1180
    update
1181
    set a ""
1182
    foreach i {0 1 2 3 4} {
1183
        append a "[winfo x .$i] "
1184
    }
1185
    append a ", "
1186
    grid remove .f
1187
    update
1188
    foreach i {0 1 2 3 4} {
1189
        append a "[winfo x .$i] "
1190
    }
1191
    append a ", "
1192
    grid remove .g
1193
    grid .f
1194
    update
1195
    foreach i {0 1 2 3 4} {
1196
        append a "[winfo x .$i] "
1197
    }
1198
    append a ", "
1199
    grid remove .f
1200
    update
1201
    foreach i {0 1 2 3 4} {
1202
        append a "[winfo x .$i] "
1203
    }
1204
    set a
1205
} {0 30 70 250 280 , 0 30 130 230 260 , 0 30 113 197 280 , 0 30 60 90 120 }

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.