1 # This file is a Tcl script to test out the "listbox" command
2 # of Tk. It is organized in the standard fashion for Tcl tests.
4 # Copyright (c) 1993-1994 The Regents of the University of California.
5 # Copyright (c) 1994-1997 Sun Microsystems, Inc.
6 # Copyright (c) 1998-1999 by Scriptics Corporation.
11 if {[lsearch [namespace children] ::tcltest] == -1} {
12 source [file join [pwd] [file dirname [info script]] defs.tcl]
15 foreach i [winfo children .] {
20 set fixed {Courier -12}
28 regexp {(^[^+-]*)} [wm geometry $w] foo x
32 proc resetGridInfo {} {
33 # Some window managers, such as mwm, don't reset gridding information
34 # unless the window is withdrawn and re-mapped. If this procedure
35 # isn't invoked, the window manager will stay in gridded mode, which
36 # can cause all sorts of problems. The "wm positionfrom" command is
37 # needed so that the window manager doesn't ask the user to
38 # manually position the window when it is re-mapped.
41 wm positionfrom . user
45 # Procedure that creates a second listbox for checking things related
46 # to partially visible lines.
48 proc mkPartial {{w .partial}} {
52 listbox $w.l -width 30 -height 5
53 pack $w.l -expand 1 -fill both
54 $w.l insert end one two three four five six seven eight nine ten \
55 eleven twelve thirteen fourteen fifteen
57 scan [wm geometry $w] "%dx%d" width height
58 wm geometry $w ${width}x[expr $height-3]
62 # Create entries in the option database to be sure that geometry options
63 # like border width have predictable values.
65 option add *Listbox.borderWidth 2
66 option add *Listbox.highlightThickness 2
67 option add *Listbox.font {Helvetica -12 bold}
76 {-background #ff0000 #ff0000 non-existent
77 {unknown color name "non-existent"}}
78 {-bd 4 4 badValue {bad screen distance "badValue"}}
79 {-bg #ff0000 #ff0000 non-existent {unknown color name "non-existent"}}
80 {-borderwidth 1.3 1 badValue {bad screen distance "badValue"}}
81 {-cursor arrow arrow badValue {bad cursor spec "badValue"}}
82 {-exportselection yes 1 xyzzy {expected boolean value but got "xyzzy"}}
83 {-fg #110022 #110022 bogus {unknown color name "bogus"}}
84 {-font {Helvetica 12} {Helvetica 12} {} {font "" doesn't exist}}
85 {-foreground #110022 #110022 bogus {unknown color name "bogus"}}
86 {-height 30 30 20p {expected integer but got "20p"}}
87 {-highlightbackground #112233 #112233 ugly {unknown color name "ugly"}}
88 {-highlightcolor #123456 #123456 bogus {unknown color name "bogus"}}
89 {-highlightthickness 6 6 bogus {bad screen distance "bogus"}}
90 {-highlightthickness -2 0 {} {}}
91 {-relief groove groove 1.5 {bad relief "1.5": must be flat, groove, raised, ridge, solid, or sunken}}
92 {-selectbackground #110022 #110022 bogus {unknown color name "bogus"}}
93 {-selectborderwidth 1.3 1 badValue {bad screen distance "badValue"}}
94 {-selectforeground #654321 #654321 bogus {unknown color name "bogus"}}
95 {-selectmode string string {} {}}
96 {-setgrid false 0 lousy {expected boolean value but got "lousy"}}
97 {-takefocus "any string" "any string" {} {}}
98 {-width 45 45 3p {expected integer but got "3p"}}
99 {-xscrollcommand {Some command} {Some command} {} {}}
100 {-yscrollcommand {Another command} {Another command} {} {}}
101 {-listvar testVariable testVariable {} {}}
103 set name [lindex $test 0]
104 test listbox-1.$i {configuration options} {
105 .l configure $name [lindex $test 1]
106 list [lindex [.l configure $name] 4] [.l cget $name]
107 } [list [lindex $test 2] [lindex $test 2]]
109 if {[lindex $test 3] != ""} {
110 test listbox-1.$i {configuration options} {
111 list [catch {.l configure $name [lindex $test 3]} msg] $msg
112 } [list 1 [lindex $test 4]]
114 .l configure $name [lindex [.l configure $name] 3]
118 test listbox-2.1 {Tk_ListboxCmd procedure} {
119 list [catch {listbox} msg] $msg
120 } {1 {wrong # args: should be "listbox pathName ?options?"}}
121 test listbox-2.2 {Tk_ListboxCmd procedure} {
122 list [catch {listbox gorp} msg] $msg
123 } {1 {bad window path name "gorp"}}
124 test listbox-2.3 {Tk_ListboxCmd procedure} {
127 list [winfo exists .l] [winfo class .l] [info commands .l]
129 test listbox-2.4 {Tk_ListboxCmd procedure} {
131 list [catch {listbox .l -gorp foo} msg] $msg [winfo exists .l] \
133 } {1 {unknown option "-gorp"} 0 {}}
134 test listbox-2.5 {Tk_ListboxCmd procedure} {
140 listbox .l -width 20 -height 5 -bd 4 -highlightthickness 1 -selectborderwidth 2
142 .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11 el12 el13 el14 \
145 test listbox-3.1 {ListboxWidgetCmd procedure} {
146 list [catch .l msg] $msg
147 } {1 {wrong # args: should be ".l option ?arg arg ...?"}}
148 test listbox-3.2 {ListboxWidgetCmd procedure, "activate" option} {
149 list [catch {.l activate} msg] $msg
150 } {1 {wrong # args: should be ".l activate index"}}
151 test listbox-3.3 {ListboxWidgetCmd procedure, "activate" option} {
152 list [catch {.l activate a b} msg] $msg
153 } {1 {wrong # args: should be ".l activate index"}}
154 test listbox-3.4 {ListboxWidgetCmd procedure, "activate" option} {
155 list [catch {.l activate fooey} msg] $msg
156 } {1 {bad listbox index "fooey": must be active, anchor, end, @x,y, or a number}}
157 test listbox-3.5 {ListboxWidgetCmd procedure, "activate" option} {
161 test listbox-3.6 {ListboxWidgetCmd procedure, "activate" option} {
165 test listbox-3.7 {ListboxWidgetCmd procedure, "activate" option} {
169 test listbox-3.8 {ListboxWidgetCmd procedure, "activate" option} {
173 test listbox-3.9 {ListboxWidgetCmd procedure, "bbox" option} {
174 list [catch {.l bbox} msg] $msg
175 } {1 {wrong # args: should be ".l bbox index"}}
176 test listbox-3.10 {ListboxWidgetCmd procedure, "bbox" option} {
177 list [catch {.l bbox a b} msg] $msg
178 } {1 {wrong # args: should be ".l bbox index"}}
179 test listbox-3.11 {ListboxWidgetCmd procedure, "bbox" option} {
180 list [catch {.l bbox fooey} msg] $msg
181 } {1 {bad listbox index "fooey": must be active, anchor, end, @x,y, or a number}}
182 test listbox-3.12 {ListboxWidgetCmd procedure, "bbox" option} {
185 list [.l bbox 2] [.l bbox 8]
187 test listbox-3.13 {ListboxWidgetCmd procedure, "bbox" option} {
188 # Used to generate a core dump before a bug was fixed (the last
189 # element would be on-screen if it existed, but it doesn't exist).
193 tkwait visibility .l2
198 test listbox-3.14 {ListboxWidgetCmd procedure, "bbox" option} {fonts} {
201 list [.l bbox 3] [.l bbox 4]
202 } {{7 7 17 14} {7 26 17 14}}
203 test listbox-3.15 {ListboxWidgetCmd procedure, "bbox" option} {fonts} {
206 list [.l bbox -1] [.l bbox 0]
208 test listbox-3.16 {ListboxWidgetCmd procedure, "bbox" option} {fonts} {
211 list [.l bbox 17] [.l bbox end] [.l bbox 18]
212 } {{7 83 24 14} {7 83 24 14} {}}
213 test listbox-3.17 {ListboxWidgetCmd procedure, "bbox" option} {fonts} {
217 listbox .t.l -width 10 -height 5
218 .t.l insert 0 "Short" "Somewhat longer" "Really, quite a whole lot longer than can possibly fit on the screen" "Short"
224 test listbox-3.18 {ListboxWidgetCmd procedure, "bbox" option, partial last line} {fonts} {
226 list [.partial.l bbox 3] [.partial.l bbox 4]
227 } {{5 56 24 14} {5 73 23 14}}
228 test listbox-3.19 {ListboxWidgetCmd procedure, "cget" option} {
229 list [catch {.l cget} msg] $msg
230 } {1 {wrong # args: should be ".l cget option"}}
231 test listbox-3.20 {ListboxWidgetCmd procedure, "cget" option} {
232 list [catch {.l cget a b} msg] $msg
233 } {1 {wrong # args: should be ".l cget option"}}
234 test listbox-3.21 {ListboxWidgetCmd procedure, "cget" option} {
235 list [catch {.l cget -gorp} msg] $msg
236 } {1 {unknown option "-gorp"}}
237 test listbox-3.22 {ListboxWidgetCmd procedure, "cget" option} {
240 test listbox-3.23 {ListboxWidgetCmd procedure, "configure" option} {
241 llength [.l configure]
243 test listbox-3.24 {ListboxWidgetCmd procedure, "configure" option} {
244 list [catch {.l configure -gorp} msg] $msg
245 } {1 {unknown option "-gorp"}}
246 test listbox-3.25 {ListboxWidgetCmd procedure, "configure" option} {
247 .l configure -setgrid
248 } {-setgrid setGrid SetGrid 0 0}
249 test listbox-3.26 {ListboxWidgetCmd procedure, "configure" option} {
250 list [catch {.l configure -gorp is_messy} msg] $msg
251 } {1 {unknown option "-gorp"}}
252 test listbox-3.27 {ListboxWidgetCmd procedure, "configure" option} {
253 set oldbd [.l cget -bd]
254 set oldht [.l cget -highlightthickness]
255 .l configure -bd 3 -highlightthickness 0
256 set x "[.l cget -bd] [.l cget -highlightthickness]"
257 .l configure -bd $oldbd -highlightthickness $oldht
260 test listbox-3.28 {ListboxWidgetCmd procedure, "curselection" option} {
261 list [catch {.l curselection a} msg] $msg
262 } {1 {wrong # args: should be ".l curselection"}}
263 test listbox-3.29 {ListboxWidgetCmd procedure, "curselection" option} {
264 .l selection clear 0 end
269 test listbox-3.30 {ListboxWidgetCmd procedure, "delete" option} {
270 list [catch {.l delete} msg] $msg
271 } {1 {wrong # args: should be ".l delete firstIndex ?lastIndex?"}}
272 test listbox-3.31 {ListboxWidgetCmd procedure, "delete" option} {
273 list [catch {.l delete a b c} msg] $msg
274 } {1 {wrong # args: should be ".l delete firstIndex ?lastIndex?"}}
275 test listbox-3.32 {ListboxWidgetCmd procedure, "delete" option} {
276 list [catch {.l delete badIndex} msg] $msg
277 } {1 {bad listbox index "badIndex": must be active, anchor, end, @x,y, or a number}}
278 test listbox-3.33 {ListboxWidgetCmd procedure, "delete" option} {
279 list [catch {.l delete 2 123ab} msg] $msg
280 } {1 {bad listbox index "123ab": must be active, anchor, end, @x,y, or a number}}
281 test listbox-3.34 {ListboxWidgetCmd procedure, "delete" option} {
284 .l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
286 list [.l2 get 2] [.l2 get 3] [.l2 index end]
288 test listbox-3.35 {ListboxWidgetCmd procedure, "delete" option} {
291 .l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
293 list [.l2 get 1] [.l2 get 2] [.l2 index end]
295 test listbox-3.36 {ListboxWidgetCmd procedure, "delete" option} {
298 .l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
301 } {el3 el4 el5 el6 el7}
302 test listbox-3.37 {ListboxWidgetCmd procedure, "delete" option} {
305 .l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
308 } {el0 el1 el2 el3 el4 el5 el6 el7}
309 test listbox-3.38 {ListboxWidgetCmd procedure, "delete" option} {
312 .l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
316 test listbox-3.39 {ListboxWidgetCmd procedure, "delete" option} {
319 .l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
322 } {el0 el1 el2 el3 el4}
323 test listbox-3.40 {ListboxWidgetCmd procedure, "delete" option} {
326 .l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
329 } {el0 el1 el2 el3 el4 el5 el6}
330 test listbox-3.41 {ListboxWidgetCmd procedure, "delete" option} {
333 .l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
336 } {el0 el1 el2 el3 el4 el5 el6 el7}
337 test listbox-3.42 {ListboxWidgetCmd procedure, "get" option} {
338 list [catch {.l get} msg] $msg
339 } {1 {wrong # args: should be ".l get firstIndex ?lastIndex?"}}
340 test listbox-3.43 {ListboxWidgetCmd procedure, "get" option} {
341 list [catch {.l get a b c} msg] $msg
342 } {1 {wrong # args: should be ".l get firstIndex ?lastIndex?"}}
343 test listbox-3.44 {ListboxWidgetCmd procedure, "get" option} {
344 list [catch {.l get 2.4} msg] $msg
345 } {1 {bad listbox index "2.4": must be active, anchor, end, @x,y, or a number}}
346 test listbox-3.45 {ListboxWidgetCmd procedure, "get" option} {
347 list [catch {.l get end bogus} msg] $msg
348 } {1 {bad listbox index "bogus": must be active, anchor, end, @x,y, or a number}}
349 test listbox-3.46 {ListboxWidgetCmd procedure, "get" option} {
352 .l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
353 list [.l2 get 0] [.l2 get 3] [.l2 get end]
355 test listbox-3.47 {ListboxWidgetCmd procedure, "get" option} {
358 list [.l2 get 0] [.l2 get end]
360 test listbox-3.48 {ListboxWidgetCmd procedure, "get" option} {
363 .l2 insert 0 el0 el1 el2 "two words" el4 el5 el6 el7
365 } {{two words} el4 el5 el6 el7}
366 test listbox-3.49 {ListboxWidgetCmd procedure, "get" option} {
369 test listbox-3.50 {ListboxWidgetCmd procedure, "get" option} {
372 test listbox-3.51 {ListboxWidgetCmd procedure, "get" option} {
375 test listbox-3.52 {ListboxWidgetCmd procedure, "get" option} {
377 } {el12 el13 el14 el15 el16 el17}
378 test listbox-3.53 {ListboxWidgetCmd procedure, "get" option} {
380 } {el12 el13 el14 el15 el16 el17}
381 test listbox-3.54 {ListboxWidgetCmd procedure, "get" option} {
384 test listbox-3.55 {ListboxWidgetCmd procedure, "get" option} {
387 test listbox-3.56 {ListboxWidgetCmd procedure, "get" option} {
390 test listbox-3.57 {ListboxWidgetCmd procedure, "index" option} {
391 list [catch {.l index} msg] $msg
392 } {1 {wrong # args: should be ".l index index"}}
393 test listbox-3.58 {ListboxWidgetCmd procedure, "index" option} {
394 list [catch {.l index a b} msg] $msg
395 } {1 {wrong # args: should be ".l index index"}}
396 test listbox-3.59 {ListboxWidgetCmd procedure, "index" option} {
397 list [catch {.l index @} msg] $msg
398 } {1 {bad listbox index "@": must be active, anchor, end, @x,y, or a number}}
399 test listbox-3.60 {ListboxWidgetCmd procedure, "index" option} {
402 test listbox-3.61 {ListboxWidgetCmd procedure, "index" option} {
405 test listbox-3.62 {ListboxWidgetCmd procedure, "index" option} {
408 test listbox-3.63 {ListboxWidgetCmd procedure, "index" option} {
411 test listbox-3.64 {ListboxWidgetCmd procedure, "insert" option} {
412 list [catch {.l insert} msg] $msg
413 } {1 {wrong # args: should be ".l insert index ?element element ...?"}}
414 test listbox-3.65 {ListboxWidgetCmd procedure, "insert" option} {
415 list [catch {.l insert badIndex} msg] $msg
416 } {1 {bad listbox index "badIndex": must be active, anchor, end, @x,y, or a number}}
417 test listbox-3.66 {ListboxWidgetCmd procedure, "insert" option} {
420 .l2 insert end a b c d e
424 test listbox-3.67 {ListboxWidgetCmd procedure, "insert" option} {
431 test listbox-3.68 {ListboxWidgetCmd procedure, "insert" option} {
438 test listbox-3.69 {ListboxWidgetCmd procedure, "insert" option} {
445 test listbox-3.70 {ListboxWidgetCmd procedure, "nearest" option} {
446 list [catch {.l nearest} msg] $msg
447 } {1 {wrong # args: should be ".l nearest y"}}
448 test listbox-3.71 {ListboxWidgetCmd procedure, "nearest" option} {
449 list [catch {.l nearest a b} msg] $msg
450 } {1 {wrong # args: should be ".l nearest y"}}
451 test listbox-3.72 {ListboxWidgetCmd procedure, "nearest" option} {
452 list [catch {.l nearest 20p} msg] $msg
453 } {1 {expected integer but got "20p"}}
454 test listbox-3.73 {ListboxWidgetCmd procedure, "nearest" option} {
458 test listbox-3.74 {ListboxWidgetCmd procedure, "scan" option} {
459 list [catch {.l scan a b} msg] $msg
460 } {1 {wrong # args: should be ".l scan mark|dragto x y"}}
461 test listbox-3.75 {ListboxWidgetCmd procedure, "scan" option} {
462 list [catch {.l scan a b c d} msg] $msg
463 } {1 {wrong # args: should be ".l scan mark|dragto x y"}}
464 test listbox-3.76 {ListboxWidgetCmd procedure, "scan" option} {
465 list [catch {.l scan foo bogus 2} msg] $msg
466 } {1 {expected integer but got "bogus"}}
467 test listbox-3.77 {ListboxWidgetCmd procedure, "scan" option} {
468 list [catch {.l scan foo 2 2.3} msg] $msg
469 } {1 {expected integer but got "2.3"}}
470 test listbox-3.78 {ListboxWidgetCmd procedure, "scan" option} {fonts} {
474 listbox .t.l -width 10 -height 5
475 .t.l insert 0 "Short" "Somewhat longer" "Really, quite a whole lot longer than can possibly fit on the screen" "Short" a b c d e f g h i j
478 .t.l scan mark 100 140
479 .t.l scan dragto 90 137
481 list [.t.l xview] [.t.l yview]
482 } {{0.249364 0.427481} {0.0714286 0.428571}}
483 test listbox-3.79 {ListboxWidgetCmd procedure, "scan" option} {
484 list [catch {.l scan foo 2 4} msg] $msg
485 } {1 {bad option "foo": must be mark or dragto}}
486 test listbox-3.80 {ListboxWidgetCmd procedure, "see" option} {
487 list [catch {.l see} msg] $msg
488 } {1 {wrong # args: should be ".l see index"}}
489 test listbox-3.81 {ListboxWidgetCmd procedure, "see" option} {
490 list [catch {.l see a b} msg] $msg
491 } {1 {wrong # args: should be ".l see index"}}
492 test listbox-3.82 {ListboxWidgetCmd procedure, "see" option} {
493 list [catch {.l see gorp} msg] $msg
494 } {1 {bad listbox index "gorp": must be active, anchor, end, @x,y, or a number}}
495 test listbox-3.83 {ListboxWidgetCmd procedure, "see" option} {
500 test listbox-3.84 {ListboxWidgetCmd procedure, "see" option} {
505 test listbox-3.85 {ListboxWidgetCmd procedure, "see" option} {
510 test listbox-3.86 {ListboxWidgetCmd procedure, "see" option} {
515 test listbox-3.87 {ListboxWidgetCmd procedure, "see" option} {
520 test listbox-3.88 {ListboxWidgetCmd procedure, "see" option} {
525 test listbox-3.89 {ListboxWidgetCmd procedure, "see" option} {
530 test listbox-3.90 {ListboxWidgetCmd procedure, "see" option} {
535 test listbox-3.91 {ListboxWidgetCmd procedure, "see" option} {
540 test listbox-3.92 {ListboxWidgetCmd procedure, "see" option, partial last line} {
543 .partial.l index @0,0
545 test listbox-3.93 {ListboxWidgetCmd procedure, "selection" option} {
546 list [catch {.l select a} msg] $msg
547 } {1 {wrong # args: should be ".l selection option index ?index?"}}
548 test listbox-3.94 {ListboxWidgetCmd procedure, "selection" option} {
549 list [catch {.l select a b c d} msg] $msg
550 } {1 {wrong # args: should be ".l selection option index ?index?"}}
551 test listbox-3.95 {ListboxWidgetCmd procedure, "selection" option} {
552 list [catch {.l selection a bogus} msg] $msg
553 } {1 {bad listbox index "bogus": must be active, anchor, end, @x,y, or a number}}
554 test listbox-3.96 {ListboxWidgetCmd procedure, "selection" option} {
555 list [catch {.l selection a 0 lousy} msg] $msg
556 } {1 {bad listbox index "lousy": must be active, anchor, end, @x,y, or a number}}
557 test listbox-3.97 {ListboxWidgetCmd procedure, "selection" option} {
558 list [catch {.l selection anchor 0 0} msg] $msg
559 } {1 {wrong # args: should be ".l selection anchor index"}}
560 test listbox-3.98 {ListboxWidgetCmd procedure, "selection" option} {
561 list [.l selection anchor 5; .l index anchor] \
562 [.l selection anchor 0; .l index anchor]
564 test listbox-3.99 {ListboxWidgetCmd procedure, "selection" option} {
565 .l selection anchor -1
568 test listbox-3.100 {ListboxWidgetCmd procedure, "selection" option} {
569 .l selection anchor end
572 test listbox-3.101 {ListboxWidgetCmd procedure, "selection" option} {
573 .l selection anchor 44
576 test listbox-3.102 {ListboxWidgetCmd procedure, "selection" option} {
577 .l selection clear 0 end
579 .l selection clear 3 4
582 test listbox-3.103 {ListboxWidgetCmd procedure, "selection" option} {
583 list [catch {.l selection includes 0 0} msg] $msg
584 } {1 {wrong # args: should be ".l selection includes index"}}
585 test listbox-3.104 {ListboxWidgetCmd procedure, "selection" option} {
586 .l selection clear 0 end
589 list [.l selection includes 3] [.l selection includes 4] \
590 [.l selection includes 5]
592 test listbox-3.105 {ListboxWidgetCmd procedure, "selection" option} {
593 .l selection set 0 end
594 .l selection includes -1
596 test listbox-3.106 {ListboxWidgetCmd procedure, "selection" option} {
597 .l selection clear 0 end
599 .l selection includes end
601 test listbox-3.107 {ListboxWidgetCmd procedure, "selection" option} {
602 .l selection set 0 end
603 .l selection includes 44
605 test listbox-3.108 {ListboxWidgetCmd procedure, "selection" option} {
608 .l2 selection includes 0
610 test listbox-3.109 {ListboxWidgetCmd procedure, "selection" option} {
611 .l selection clear 0 end
616 test listbox-3.110 {ListboxWidgetCmd procedure, "selection" option} {
620 test listbox-3.111 {ListboxWidgetCmd procedure, "selection" option} {
621 list [catch {.l selection badOption 0 0} msg] $msg
622 } {1 {bad option "badOption": must be anchor, clear, includes, or set}}
623 test listbox-3.112 {ListboxWidgetCmd procedure, "size" option} {
624 list [catch {.l size a} msg] $msg
625 } {1 {wrong # args: should be ".l size"}}
626 test listbox-3.113 {ListboxWidgetCmd procedure, "size" option} {
629 test listbox-3.114 {ListboxWidgetCmd procedure, "xview" option} {
635 test listbox-3.115 {ListboxWidgetCmd procedure, "xview" option} {
637 listbox .l -width 10 -height 5 -font $fixed
638 .l insert 0 a b c d e f g h i j k l m n o p q r s t
644 listbox .l -width 10 -height 5 -font $fixed
645 .l insert 0 a b c d e f g h i j k l m n o p q r s t
646 .l insert 1 "0123456789a123456789b123456789c123456789d123456789"
649 test listbox-3.116 {ListboxWidgetCmd procedure, "xview" option} {fonts} {
653 test listbox-3.117 {ListboxWidgetCmd procedure, "xview" option} {
654 list [catch {.l xview foo} msg] $msg
655 } {1 {expected integer but got "foo"}}
656 test listbox-3.118 {ListboxWidgetCmd procedure, "xview" option} {
657 list [catch {.l xview zoom a b} msg] $msg
658 } {1 {unknown option "zoom": must be moveto or scroll}}
659 test listbox-3.119 {ListboxWidgetCmd procedure, "xview" option} {fonts} {
665 test listbox-3.120 {ListboxWidgetCmd procedure, "xview" option} {fonts} {
667 .l xview scroll 2 units
671 test listbox-3.121 {ListboxWidgetCmd procedure, "xview" option} {fonts} {
673 .l xview scroll -1 pages
677 test listbox-3.122 {ListboxWidgetCmd procedure, "xview" option} {fonts} {
678 .l configure -width 1
681 .l xview scroll -4 pages
685 test listbox-3.123 {ListboxWidgetCmd procedure, "yview" option} {
692 test listbox-3.124 {ListboxWidgetCmd procedure, "yview" option} {
701 listbox .l -width 10 -height 5 -font $fixed
702 .l insert 0 a b c d e f g h i j k l m n o p q r s t
705 test listbox-3.125 {ListboxWidgetCmd procedure, "yview" option} {
710 test listbox-3.126 {ListboxWidgetCmd procedure, "yview" option, partial last line} {
714 test listbox-3.127 {ListboxWidgetCmd procedure, "xview" option} {
715 list [catch {.l yview foo} msg] $msg
716 } {1 {bad listbox index "foo": must be active, anchor, end, @x,y, or a number}}
717 test listbox-3.128 {ListboxWidgetCmd procedure, "xview" option} {
718 list [catch {.l yview foo a b} msg] $msg
719 } {1 {unknown option "foo": must be moveto or scroll}}
720 test listbox-3.129 {ListboxWidgetCmd procedure, "xview" option} {
725 test listbox-3.130 {ListboxWidgetCmd procedure, "xview" option} {
727 .l yview scroll 2 pages
730 test listbox-3.131 {ListboxWidgetCmd procedure, "xview" option} {
732 .l yview scroll -3 units
735 test listbox-3.132 {ListboxWidgetCmd procedure, "xview" option} {
736 .l configure -height 2
739 .l yview scroll -4 pages
742 test listbox-3.133 {ListboxWidgetCmd procedure, "xview" option} {
743 list [catch {.l whoknows} msg] $msg
744 } {1 {bad option "whoknows": must be activate, bbox, cget, configure, curselection, delete, get, index, insert, itemcget, itemconfigure, nearest, scan, see, selection, size, xview, or yview}}
745 test listbox-3.134 {ListboxWidgetCmd procedure, "xview" option} {
746 list [catch {.l c} msg] $msg
747 } {1 {ambiguous option "c": must be activate, bbox, cget, configure, curselection, delete, get, index, insert, itemcget, itemconfigure, nearest, scan, see, selection, size, xview, or yview}}
748 test listbox-3.135 {ListboxWidgetCmd procedure, "xview" option} {
749 list [catch {.l in} msg] $msg
750 } {1 {ambiguous option "in": must be activate, bbox, cget, configure, curselection, delete, get, index, insert, itemcget, itemconfigure, nearest, scan, see, selection, size, xview, or yview}}
751 test listbox-3.136 {ListboxWidgetCmd procedure, "xview" option} {
752 list [catch {.l s} msg] $msg
753 } {1 {ambiguous option "s": must be activate, bbox, cget, configure, curselection, delete, get, index, insert, itemcget, itemconfigure, nearest, scan, see, selection, size, xview, or yview}}
754 test listbox-3.137 {ListboxWidgetCmd procedure, "xview" option} {
755 list [catch {.l se} msg] $msg
756 } {1 {ambiguous option "se": must be activate, bbox, cget, configure, curselection, delete, get, index, insert, itemcget, itemconfigure, nearest, scan, see, selection, size, xview, or yview}}
758 # No tests for DestroyListbox: I can't come up with anything to test
761 test listbox-4.1 {ConfigureListbox procedure} {fonts} {
763 listbox .l -setgrid 1 -width 25 -height 15
767 .l configure -setgrid 0
772 test listbox-4.2 {ConfigureListbox procedure} {
773 .l configure -highlightthickness -3
774 .l cget -highlightthickness
776 test listbox-4.3 {ConfigureListbox procedure} {
777 .l configure -exportselection 0
779 .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8
781 .l configure -exportselection 1
786 test listbox-4.4 {ConfigureListbox procedure} {
792 .l configure -exportselection 0
794 .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8
796 .l selection clear 3 5
797 .l configure -exportselection 1
798 list [selection own] [selection get]
800 test listbox-4.5 {-exportselection option} {
802 .l configure -exportselection 1
804 .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8
807 lappend x [catch {selection get} msg] $msg [.l curselection]
808 .l config -exportselection 0
809 lappend x [catch {selection get} msg] $msg [.l curselection]
810 .l selection clear 0 end
811 lappend x [catch {selection get} msg] $msg [.l curselection]
813 lappend x [catch {selection get} msg] $msg [.l curselection]
814 .l config -exportselection 1
815 lappend x [catch {selection get} msg] $msg [.l curselection]
816 } {0 el1 1 1 {PRIMARY selection doesn't exist or form "STRING" not defined} 1 1 {PRIMARY selection doesn't exist or form "STRING" not defined} {} 1 {PRIMARY selection doesn't exist or form "STRING" not defined} {1 2 3} 0 {el1
819 test listbox-4.6 {ConfigureListbox procedure} {fonts} {
822 # The following code (reset geometry, withdraw, etc.) is necessary
823 # to reset the state of some window managers like olvwm under
830 listbox .l -font $fixed -width 15 -height 20
835 .l configure -setgrid 1
839 test listbox-4.7 {ConfigureListbox procedure} {
842 listbox .l -font $fixed -width 30 -height 20 -setgrid 1
847 set result [getsize .]
850 lappend result [getsize .]
851 .l configure -setgrid 1
853 lappend result [getsize .]
854 } {30x20 26x15 26x15}
858 test listbox-4.8 {ConfigureListbox procedure} {
860 listbox .l -width 15 -height 20 -xscrollcommand "record x" \
861 -yscrollcommand "record y"
864 .l configure -fg black
869 test listbox-4.9 {ConfigureListbox procedure, -listvar} {
872 listbox .l -listvar x
875 test listbox-4.10 {ConfigureListbox, no listvar -> existing listvar} {
879 .l insert end 1 2 3 4
880 .l configure -listvar x
883 test listbox-4.11 {ConfigureListbox procedure, listvar -> no listvar} {
886 listbox .l -listvar x
887 .l configure -listvar {}
888 .l insert end 1 2 3 4
889 list $x [.l get 0 end]
890 } [list [list a b c d] [list a b c d 1 2 3 4]]
891 test listbox-4.12 {ConfigureListbox procedure, listvar -> different listvar} {
896 .l configure -listvar x
897 .l configure -listvar y
898 .l insert end 5 6 7 8
900 } [list [list a b c d] [list 1 2 3 4 5 6 7 8]]
901 test listbox-4.13 {ConfigureListbox, no listvar -> non-existant listvar} {
905 .l insert end a b c d
906 .l configure -listvar x
909 test listbox-4.14 {ConfigureListbox, non-existant listvar} {
912 listbox .l -listvar x
913 list [info exists x] $x
915 test listbox-4.15 {ConfigureListbox, listvar -> non-existant listvar} {
919 listbox .l -listvar x
920 .l configure -listvar y
921 list [info exists y] $y
922 } [list 1 [list a b c d]]
923 test listbox-4.16 {ConfigureListbox, listvar -> same listvar} {
926 listbox .l -listvar x
927 .l configure -listvar x
930 test listbox-4.17 {ConfigureListbox, no listvar -> no listvar} {
933 .l insert end a b c d
934 .l configure -listvar {}
937 test listbox-4.18 {ConfigureListbox, no listvar -> bad listvar} {
940 .l insert end a b c d
941 set x {this is a " bad list}
942 catch {.l configure -listvar x} result
943 list [.l get 0 end] [.l cget -listvar] $result
944 } [list [list a b c d] {} \
945 "unmatched open quote in list: invalid listvar value"]
947 # No tests for DisplayListbox: I don't know how to test this procedure.
949 test listbox-5.1 {ListboxComputeGeometry procedure} {fonts} {
951 listbox .l -font $fixed -width 15 -height 20
953 list [winfo reqwidth .l] [winfo reqheight .l]
955 test listbox-5.2 {ListboxComputeGeometry procedure} {fonts} {
957 listbox .l -font $fixed -width 0 -height 10
960 list [winfo reqwidth .l] [winfo reqheight .l]
962 test listbox-5.3 {ListboxComputeGeometry procedure} {fonts} {
964 listbox .l -font $fixed -width 0 -height 10 -bd 3
965 .l insert 0 Short "Really much longer" Longer
968 list [winfo reqwidth .l] [winfo reqheight .l]
970 test listbox-5.4 {ListboxComputeGeometry procedure} {fonts} {
972 listbox .l -font $fixed -width 10 -height 0
975 list [winfo reqwidth .l] [winfo reqheight .l]
977 test listbox-5.5 {ListboxComputeGeometry procedure} {fonts} {
979 listbox .l -font $fixed -width 10 -height 0 -highlightthickness 0
980 .l insert 0 Short "Really much longer" Longer
983 list [winfo reqwidth .l] [winfo reqheight .l]
985 test listbox-5.6 {ListboxComputeGeometry procedure} {
986 # If "0" in selected font had 0 width, caused divide-by-zero error.
989 pack [listbox .l -font {{open look glyph}}]
995 listbox .l -height 2 -xscrollcommand "record x" -yscrollcommand "record y"
998 test listbox-6.1 {InsertEls procedure} {
1000 .l insert end a b c d
1005 } {q r s a b A c d x y z}
1006 test listbox-6.2 {InsertEls procedure} {
1008 .l insert 0 a b c d e f g h i j
1009 .l selection anchor 2
1013 test listbox-6.3 {InsertEls procedure} {
1015 .l insert 0 a b c d e f g h i j
1016 .l selection anchor 2
1020 test listbox-6.4 {InsertEls procedure} {
1022 .l insert 0 a b c d e f g h i j
1028 test listbox-6.5 {InsertEls procedure} {
1030 .l insert 0 a b c d e f g h i j
1036 test listbox-6.6 {InsertEls procedure} {
1038 .l insert 0 a b c d e f g h i j
1043 test listbox-6.7 {InsertEls procedure} {
1045 .l insert 0 a b c d e f g h i j
1050 test listbox-6.8 {InsertEls procedure} {
1055 test listbox-6.9 {InsertEls procedure} {
1060 test listbox-6.10 {InsertEls procedure} {
1062 .l insert 0 a b "two words" c d e f g h i j
1069 test listbox-6.11 {InsertEls procedure} {
1071 .l insert 0 a b "two words" c d e f g h i j
1074 .l insert 0 "much longer entry"
1077 } {{y 0 0.166667} {x 0 1}}
1078 test listbox-6.12 {InsertEls procedure} {fonts} {
1080 listbox .l2 -width 0 -height 0
1082 .l2 insert 0 a b "two words" c d
1084 lappend x [winfo reqwidth .l2] [winfo reqheight .l2]
1085 .l2 insert 0 "much longer entry"
1086 lappend x [winfo reqwidth .l2] [winfo reqheight .l2]
1088 test listbox-6.13 {InsertEls procedure, check -listvar update} {
1090 set x [list a b c d]
1091 listbox .l2 -listvar x
1092 .l2 insert 0 1 2 3 4
1094 } [list 1 2 3 4 a b c d]
1095 test listbox-6.14 {InsertEls procedure, check selection update} {
1098 .l2 insert 0 0 1 2 3 4
1099 .l2 selection set 2 4
1105 test listbox-7.1 {DeleteEls procedure} {
1107 .l insert 0 a b c d e f g h i j
1108 .l selection set 1 6
1110 list [.l size] [selection get]
1117 test listbox-7.2 {DeleteEls procedure} {
1119 .l insert 0 a b c d e f g h i j
1120 .l selection set 3 6
1122 list [.l size] [.l get 4] [.l curselection]
1124 test listbox-7.3 {DeleteEls procedure} {
1126 .l insert 0 a b c d e f g h i j
1128 list [.l size] [.l get 0] [.l get 1]
1130 test listbox-7.4 {DeleteEls procedure} {
1132 .l insert 0 a b c d e f g h i j
1134 list [.l size] [.l get 7]
1136 test listbox-7.5 {DeleteEls procedure} {
1138 .l insert 0 a b c d e f g h i j
1139 .l selection anchor 2
1143 test listbox-7.6 {DeleteEls procedure} {
1145 .l insert 0 a b c d e f g h i j
1146 .l selection anchor 2
1150 test listbox-7.7 {DeleteEls procedure} {
1152 .l insert 0 a b c d e f g h i j
1153 .l selection anchor 4
1157 test listbox-7.8 {DeleteEls procedure} {
1159 .l insert 0 a b c d e f g h i j
1160 .l selection anchor 3
1164 test listbox-7.9 {DeleteEls procedure} {
1166 .l insert 0 a b c d e f g h i j
1172 test listbox-7.10 {DeleteEls procedure} {
1174 .l insert 0 a b c d e f g h i j
1180 test listbox-7.11 {DeleteEls procedure} {
1182 .l insert 0 a b c d e f g h i j
1188 test listbox-7.12 {DeleteEls procedure} {
1190 .l insert 0 a b c d e f g h i j
1196 test listbox-7.13 {DeleteEls procedure, updating view with partial last line} {
1200 .partial.l delete 10 13
1201 .partial.l index @0,0
1203 test listbox-7.14 {DeleteEls procedure} {
1205 .l insert 0 a b c d e f g h i j
1210 test listbox-7.15 {DeleteEls procedure} {
1212 .l insert 0 a b c d e f g h i j
1217 test listbox-7.16 {DeleteEls procedure} {
1219 .l insert 0 a b c d e f g h i j
1224 test listbox-7.17 {DeleteEls procedure} {
1226 .l insert 0 a b c d e f g h i j
1231 test listbox-7.18 {DeleteEls procedure} {
1233 .l insert 0 a b c "two words" d e f g h i j
1240 test listbox-7.19 {DeleteEls procedure} {
1242 .l insert 0 a b c "two words" d e f g h i j
1248 } {{y 0 0.2} {x 0 1}}
1249 test listbox-7.20 {DeleteEls procedure} {fonts} {
1251 listbox .l2 -width 0 -height 0
1253 .l2 insert 0 a b "two words" c d e f g
1255 lappend x [winfo reqwidth .l2] [winfo reqheight .l2]
1257 lappend x [winfo reqwidth .l2] [winfo reqheight .l2]
1260 test listbox-7.21 {DeleteEls procedure, check -listvar update} {
1262 set x [list a b c d]
1263 listbox .l2 -listvar x
1268 test listbox-8.1 {ListboxEventProc procedure} {fonts} {
1270 listbox .l -setgrid 1
1275 list $x [getsize .] [winfo exists .l] [info command .l]
1276 } {20x10 150x178 0 {}}
1278 test listbox-8.2 {ListboxEventProc procedure} {fonts} {
1280 listbox .l -height 5 -width 10
1281 .l insert 0 a b c "A string that is very very long" d e f g h i j k
1284 place .l -width 50 -height 80
1286 list [.l xview] [.l yview]
1287 } {{0 0.222222} {0 0.333333}}
1288 test listbox-8.3 {ListboxEventProc procedure} {
1289 eval destroy [winfo children .]
1290 listbox .l1 -bg #543210
1293 lappend x [winfo children .]
1294 lappend x [.l2 cget -bg]
1296 lappend x [info command .l*] [winfo children .]
1297 } {.l1 #543210 {} {}}
1299 test listbox-9.1 {ListboxCmdDeletedProc procedure} {
1300 eval destroy [winfo children .]
1303 list [info command .l*] [winfo children .]
1305 test listbox-9.2 {ListboxCmdDeletedProc procedure, disabling -setgrid} fonts {
1306 catch {destroy .top}
1309 listbox .top.l -setgrid 1 -width 20 -height 10
1312 set x [wm geometry .top]
1315 lappend x [wm geometry .top]
1318 } {20x10+0+0 150x178+0+0}
1324 .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
1325 test listbox-10.1 {GetListboxIndex procedure} {
1327 list [.l activate 3; .l index active] [.l activate 6; .l index active]
1329 test listbox-10.2 {GetListboxIndex procedure} {
1330 .l selection anchor 2
1333 test listbox-10.3 {GetListboxIndex procedure} {
1334 .l insert end A B C D E
1335 .l selection anchor end
1337 list [.l index anchor] [.l index end]
1339 test listbox-10.4 {GetListboxIndex procedure} {
1340 list [catch {.l index a} msg] $msg
1341 } {1 {bad listbox index "a": must be active, anchor, end, @x,y, or a number}}
1342 test listbox-10.5 {GetListboxIndex procedure} {
1345 test listbox-10.6 {GetListboxIndex procedure} {
1348 test listbox-10.7 {GetListboxIndex procedure} {
1353 .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
1355 test listbox-10.8 {GetListboxIndex procedure} {
1356 list [catch {.l index @} msg] $msg
1357 } {1 {bad listbox index "@": must be active, anchor, end, @x,y, or a number}}
1358 test listbox-10.9 {GetListboxIndex procedure} {
1359 list [catch {.l index @foo} msg] $msg
1360 } {1 {bad listbox index "@foo": must be active, anchor, end, @x,y, or a number}}
1361 test listbox-10.10 {GetListboxIndex procedure} {
1362 list [catch {.l index @1x3} msg] $msg
1363 } {1 {bad listbox index "@1x3": must be active, anchor, end, @x,y, or a number}}
1364 test listbox-10.11 {GetListboxIndex procedure} {
1365 list [catch {.l index @1,} msg] $msg
1366 } {1 {bad listbox index "@1,": must be active, anchor, end, @x,y, or a number}}
1367 test listbox-10.12 {GetListboxIndex procedure} {
1368 list [catch {.l index @1,foo} msg] $msg
1369 } {1 {bad listbox index "@1,foo": must be active, anchor, end, @x,y, or a number}}
1370 test listbox-10.13 {GetListboxIndex procedure} {
1371 list [catch {.l index @1,2x} msg] $msg
1372 } {1 {bad listbox index "@1,2x": must be active, anchor, end, @x,y, or a number}}
1373 test listbox-10.14 {GetListboxIndex procedure} {fonts} {
1374 list [.l index @5,57] [.l index @5,58]
1376 test listbox-10.15 {GetListboxIndex procedure} {
1377 list [catch {.l index 1xy} msg] $msg
1378 } {1 {bad listbox index "1xy": must be active, anchor, end, @x,y, or a number}}
1379 test listbox-10.16 {GetListboxIndex procedure} {
1382 test listbox-10.17 {GetListboxIndex procedure} {
1385 test listbox-10.18 {GetListboxIndex procedure} {
1388 test listbox-10.19 {GetListboxIndex procedure} {
1391 test listbox-10.20 {GetListboxIndex procedure} {
1396 test listbox-11.1 {ChangeListboxView procedure, boundary conditions for index} {
1398 listbox .l -height 5
1400 .l insert 0 a b c d e f g h i j
1403 set x [.l index @0,0]
1406 lappend x [.l index @0,0]
1408 test listbox-11.2 {ChangeListboxView procedure, boundary conditions for index} {
1410 listbox .l -height 5
1412 .l insert 0 a b c d e f g h i j
1415 set x [.l index @0,0]
1418 lappend x [.l index @0,0]
1420 test listbox-11.3 {ChangeListboxView procedure} {
1422 listbox .l -height 5 -yscrollcommand "record y"
1424 .l insert 0 a b c d e f g h i j
1429 list [.l yview] $log
1430 } {{0.2 0.7} {{y 0.2 0.7}}}
1431 test listbox-11.4 {ChangeListboxView procedure} {
1433 listbox .l -height 5 -yscrollcommand "record y"
1435 .l insert 0 a b c d e f g h i j
1440 list [.l yview] $log
1441 } {{0.5 1} {{y 0.5 1}}}
1442 test listbox-11.5 {ChangeListboxView procedure} {
1444 listbox .l -height 5 -yscrollcommand "record y"
1446 .l insert 0 a b c d e f g h i j
1452 list [.l yview] $log
1454 test listbox-11.6 {ChangeListboxView procedure, partial last line} {
1457 .partial.l index @0,0
1461 listbox .l -font $fixed -xscrollcommand "record x" -width 10
1462 .l insert 0 0123456789a123456789b123456789c123456789d123456789e123456789f123456789g123456789h123456789i123456789
1465 test listbox-12.1 {ChangeListboxOffset procedure} {fonts} {
1469 list [.l xview] $log
1470 } {{0.9 1} {{x 0.9 1}}}
1471 test listbox-12.2 {ChangeListboxOffset procedure} {fonts} {
1473 .l xview moveto -.25
1475 list [.l xview] $log
1476 } {{0 0.1} {{x 0 0.1}}}
1477 test listbox-12.3 {ChangeListboxOffset procedure} {fonts} {
1483 list [.l xview] $log
1487 listbox .l -font $fixed -width 10 -height 5
1489 .l insert 0 a bb c d e f g h i j k l m n o p q r s
1490 .l insert 0 0123456789a123456789b123456789c123456789d123456789
1492 set width [expr [lindex [.l bbox 2] 2] - [lindex [.l bbox 1] 2]]
1493 set height [expr [lindex [.l bbox 2] 1] - [lindex [.l bbox 1] 1]]
1494 test listbox-13.1 {ListboxScanTo procedure} {fonts} {
1498 .l scan dragto [expr 10-$width] [expr 20-$height]
1500 list [.l xview] [.l yview]
1501 } {{0.2 0.4} {0.5 0.75}}
1502 test listbox-13.2 {ListboxScanTo procedure} {fonts} {
1506 .l scan dragto 20 40
1508 set x [list [.l xview] [.l yview]]
1509 .l scan dragto [expr 20-$width] [expr 40-$height]
1511 lappend x [.l xview] [.l yview]
1512 } {{0 0.2} {0 0.25} {0.2 0.4} {0.5 0.75}}
1513 test listbox-13.3 {ListboxScanTo procedure} {fonts} {
1519 set x [list [.l xview] [.l yview]]
1520 .l scan dragto [expr 5+$width] [expr 10+$height]
1522 lappend x [.l xview] [.l yview]
1523 } {{0.8 1} {0.75 1} {0.62 0.82} {0.25 0.5}}
1525 test listbox-14.1 {NearestListboxElement procedure, partial last line} {
1527 .partial.l nearest [winfo height .partial.l]
1530 listbox .l -font $fixed -width 20 -height 10
1531 .l insert 0 a b c d e f g h i j k l m n o p q r s t
1535 test listbox-14.2 {NearestListboxElement procedure} {fonts} {
1538 test listbox-14.3 {NearestListboxElement procedure} {fonts} {
1539 list [.l index @50,35] [.l index @50,36]
1541 test listbox-14.4 {NearestListboxElement procedure} {fonts} {
1545 test listbox-15.1 {ListboxSelect procedure} {
1547 .l insert 0 a b c d e f g h i j k l m n o p
1552 } {2 3 8 9 10 11 12}
1553 test listbox-15.2 {ListboxSelect procedure} {
1555 .l insert 0 a b c d e f g h i j k l m n o p
1558 .e insert 0 "This is some text"
1561 .l selection clear 2 4
1562 set x [selection own]
1564 list $x [selection own] [selection get]
1566 test listbox-15.3 {ListboxSelect procedure} {
1568 .l selection clear 0 end
1572 test listbox-15.4 {ListboxSelect procedure, boundary conditions for indices} {
1574 .l insert 0 a b c d e f
1575 .l select clear 0 end
1579 test listbox-15.5 {ListboxSelect procedure, boundary conditions for indices} {
1581 .l insert 0 a b c d e f
1582 .l select clear 0 end
1586 test listbox-15.6 {ListboxSelect procedure, boundary conditions for indices} {
1588 .l insert 0 a b c d e f
1589 .l select clear 0 end
1593 test listbox-15.7 {ListboxSelect procedure, boundary conditions for indices} {
1595 .l insert 0 a b c d e f
1596 .l select clear 0 end
1600 test listbox-15.8 {ListboxSelect procedure, boundary conditions for indices} {
1602 .l insert 0 a b c d e f
1603 .l select clear 0 end
1607 test listbox-15.9 {ListboxSelect procedure, boundary conditions for indices} {
1609 .l insert 0 a b c d e f
1610 .l select clear 0 end
1611 .l select set end 30
1614 test listbox-15.10 {ListboxSelect procedure, boundary conditions for indices} {
1616 .l insert 0 a b c d e f
1617 .l select clear 0 end
1622 test listbox-16.1 {ListboxFetchSelection procedure} {
1624 .l insert 0 a b c "two words" e f g h i \\ k l m n o p
1625 .l selection set 2 4
1627 .l selection set 11 12
1629 } "c\ntwo words\ne\n\\\nl\nm"
1630 test listbox-16.2 {ListboxFetchSelection procedure} {
1632 .l insert 0 a b c "two words" e f g h i \\ k l m n o p
1636 test listbox-16.3 {ListboxFetchSelection procedure, retrieve in several parts} {
1637 set long "This is quite a long string\n"
1638 append long $long $long $long $long
1639 append long $long $long $long $long
1640 append long $long $long
1642 .l insert 0 1$long 2$long 3$long 4$long 5$long
1643 .l selection set 0 end
1644 set sel [selection get]
1645 string compare 1$long\n2$long\n3$long\n4$long\n5$long $sel
1647 catch {unset long sel}
1649 test listbox-17.1 {ListboxLostSelection procedure} {
1651 .l insert 0 a b c d e
1655 .e insert 0 "This is some text"
1660 test listbox-17.2 {ListboxLostSelection procedure} {
1662 .l insert 0 a b c d e
1664 .l configure -exportselection 0
1667 .e insert 0 "This is some text"
1674 listbox .l -font $fixed -width 10 -height 5
1677 test listbox-18.1 {ListboxUpdateVScrollbar procedure} {
1678 .l configure -yscrollcommand "record y"
1682 .l insert end d e f g h
1687 } {{y 0 1} {y 0 0.625} {y 0 1}}
1688 test listbox-18.2 {ListboxUpdateVScrollbar procedure, partial last line} {
1690 .partial.l configure -yscrollcommand "record y"
1695 } {{y 0.2 0.466667}}
1696 test listbox-18.3 {ListboxUpdateVScrollbar procedure} {
1699 set x [list $args $errorInfo]
1701 .l configure -yscrollcommand gorp
1705 } {{{invalid command name "gorp"}} {invalid command name "gorp"
1708 (vertical scrolling command executed by listbox)}}
1709 if {[info exists bgerror]} {
1714 listbox .l -font $fixed -width 10 -height 5
1717 test listbox-19.1 {ListboxUpdateVScrollbar procedure} {fonts} {
1718 .l configure -xscrollcommand "record x"
1722 .l insert 0 "This is a much longer string..."
1727 } {{x 0 1} {x 0 0.322581} {x 0 1}}
1728 test listbox-19.2 {ListboxUpdateVScrollbar procedure} {
1731 set x [list $args $errorInfo]
1733 .l configure -xscrollcommand bogus
1737 } {{{invalid command name "bogus"}} {invalid command name "bogus"
1740 (horizontal scrolling command executed by listbox)}}
1742 set l [interp hidden]
1743 eval destroy [winfo children .]
1745 test listbox-20.1 {listbox vs hidden commands} {
1750 list [winfo children .] [interp hidden]
1753 # tests for ListboxListVarProc
1754 test listbox-21.1 {ListboxListVarProc} {
1757 listbox .l -listvar x
1758 set x [list a b c d]
1761 test listbox-21.2 {ListboxListVarProc} {
1763 set x [list a b c d]
1764 listbox .l -listvar x
1768 test listbox-21.3 {ListboxListVarProc} {
1770 set x [list a b c d]
1771 listbox .l -listvar x
1772 .l configure -listvar {}
1776 test listbox-21.4 {ListboxListVarProc} {
1778 set x [list a b c d]
1779 listbox .l -listvar x
1783 test listbox-21.5 {ListboxListVarProc, test selection after listvar mod} {
1785 set x [list a b c d e f g]
1786 listbox .l -listvar x
1787 .l selection set end
1788 set x [list a b c d]
1789 set x [list 0 1 2 3 4 5 6]
1792 test listbox-21.6 {ListboxListVarProc, test selection after listvar mod} {
1794 set x [list a b c d]
1795 listbox .l -listvar x
1800 test listbox-21.7 {ListboxListVarProc, test selection after listvar mod} {
1802 set x [list a b c d]
1803 listbox .l -listvar x
1805 set x [linsert $x 0 1 2 3 4]
1808 test listbox-21.8 {ListboxListVarProc, test selection after listvar mod} {
1810 set x [list a b c d]
1811 listbox .l -listvar x
1816 test listbox-21.9 {ListboxListVarProc, test hscrollbar after listvar mod} {
1820 listbox .l -font $fixed -width 10 -xscrollcommand "record x" -listvar x
1823 lappend x "0000000000"
1825 lappend x "00000000000000000000"
1828 } [list {x 0 1} {x 0 1} {x 0 0.5}]
1829 test listbox-21.10 {ListboxListVarProc, test hscrollbar after listvar mod} {
1833 listbox .l -font $fixed -width 10 -xscrollcommand "record x" -listvar x
1836 lappend x "0000000000"
1838 lappend x "00000000000000000000"
1840 set x [list "0000000000"]
1843 } [list {x 0 1} {x 0 1} {x 0 0.5} {x 0 1}]
1844 test listbox-21.11 {ListboxListVarProc, bad list} {
1847 listbox .l -listvar x
1848 set x [list a b c d]
1849 catch {set x {this is a " bad list}} result
1851 } {can't set "x": invalid listvar value}
1852 test listbox-21.12 {ListboxListVarProc, cleanup item attributes} {
1854 set x [list a b c d e f g]
1855 listbox .l -listvar x
1856 .l itemconfigure end -fg red
1857 set x [list a b c d]
1858 set x [list 0 1 2 3 4 5 6]
1861 test listbox-21.12 {ListboxListVarProc, cleanup item attributes} {
1863 set x [list a b c d e f g]
1864 listbox .l -listvar x
1865 .l itemconfigure end -fg red
1866 set x [list a b c d]
1867 set x [list 0 1 2 3 4 5 6]
1870 test listbox-21.13 {listbox item configurations and listvar based deletions} {
1873 listbox .l -listvar x
1875 .l itemconfigure 1 -fg red
1879 test listbox-21.14 {listbox item configurations and listvar based inserts} {
1882 listbox .l -listvar x
1884 .l itemconfigure 0 -fg red
1885 set x [list 1 2 3 4 a b c]
1888 test listbox-21.15 {ListboxListVarProc, update vertical scrollbar} {
1892 listbox .l -listvar x -yscrollcommand "record y" -font fixed -height 3
1895 lappend x a b c d e f
1898 } [list {y 0 1} {y 0 0.5}]
1899 test listbox-21.16 {ListboxListVarProc, update vertical scrollbar} {
1902 listbox .l -listvar x -height 3
1905 set x [list 0 1 2 3 4 5]
1906 .l yview scroll 3 units
1909 lappend result [.l yview]
1910 set x [lreplace $x 3 3]
1911 set x [lreplace $x 3 3]
1912 set x [lreplace $x 3 3]
1914 lappend result [.l yview]
1916 } [list {0.5 1} {0 1}]
1919 test listbox-22.1 {UpdateHScrollbar} {
1922 listbox .l -font $fixed -width 10 -xscrollcommand "record x"
1925 .l insert end "0000000000"
1927 .l insert end "00000000000000000000"
1930 } [list {x 0 1} {x 0 1} {x 0 0.5}]
1932 # ConfigureListboxItem
1933 test listbox-23.1 {ConfigureListboxItem} {
1936 catch {.l itemconfigure 0} result
1938 } {item number "0" out of range}
1939 test listbox-23.2 {ConfigureListboxItem} {
1942 .l insert end a b c d
1944 } [list {-background background Background {} {}} \
1947 {-foreground foreground Foreground {} {}} \
1948 {-selectbackground selectBackground Foreground {} {}} \
1949 {-selectforeground selectForeground Background {} {}}]
1950 test listbox-23.3 {ConfigureListboxItem, itemco shortcut} {
1953 .l insert end a b c d
1954 .l itemco 0 -background
1955 } {-background background Background {} {}}
1956 test listbox-23.4 {ConfigureListboxItem, wrong num args} {
1960 catch {.l itemco} result
1962 } {wrong # args: should be ".l itemconfigure index ?option? ?value? ?option value ...?"}
1963 test listbox-23.5 {ConfigureListboxItem, multiple calls} {
1967 foreach color {red orange yellow green blue darkblue violet} {
1968 .l insert end $color
1969 .l itemconfigure $i -bg $color
1974 list [.l itemcget 0 -bg] [.l itemcget 1 -bg] [.l itemcget 2 -bg] \
1975 [.l itemcget 3 -bg] [.l itemcget 4 -bg] [.l itemcget 5 -bg] \
1977 } {red orange yellow green blue darkblue violet}
1980 .l insert end a b c d
1983 {-background #ff0000 #ff0000 non-existent
1984 {unknown color name "non-existent"}}
1985 {-bg #ff0000 #ff0000 non-existent {unknown color name "non-existent"}}
1986 {-fg #110022 #110022 bogus {unknown color name "bogus"}}
1987 {-foreground #110022 #110022 bogus {unknown color name "bogus"}}
1988 {-selectbackground #110022 #110022 bogus {unknown color name "bogus"}}
1989 {-selectforeground #654321 #654321 bogus {unknown color name "bogus"}}
1991 set name [lindex $test 0]
1992 test listbox-23.$i {configuration options} {
1993 .l itemconfigure 0 $name [lindex $test 1]
1994 list [lindex [.l itemconfigure 0 $name] 4] [.l itemcget 0 $name]
1995 } [list [lindex $test 2] [lindex $test 2]]
1997 if {[lindex $test 3] != ""} {
1998 test listbox-1.$i {configuration options} {
1999 list [catch {.l configure $name [lindex $test 3]} msg] $msg
2000 } [list 1 [lindex $test 4]]
2002 .l configure $name [lindex [.l configure $name] 3]
2006 # ListboxWidgetObjCmd, itemcget
2007 test listbox-24.1 {itemcget} {
2010 .l insert end a b c d
2013 test listbox-24.2 {itemcget} {
2016 .l insert end a b c d
2017 .l itemconfigure 0 -fg red
2020 test listbox-24.3 {itemcget} {
2023 .l insert end a b c d
2024 catch {.l itemcget 0} result
2026 } {wrong # args: should be ".l itemcget index option"}
2027 test listbox-24.3 {itemcget, itemcg shortcut} {
2030 .l insert end a b c d
2031 catch {.l itemcg 0} result
2033 } {wrong # args: should be ".l itemcget index option"}
2035 # General item configuration issues
2036 test listbox-25.1 {listbox item configurations and widget based deletions} {
2040 .l itemconfigure 0 -fg red
2045 test listbox-25.2 {listbox item configurations and widget based inserts} {
2049 .l itemconfigure 0 -fg red
2051 list [.l itemcget 0 -fg] [.l itemcget 4 -fg]
2060 catch {destroy .partial}
2064 ::tcltest::cleanupTests