1# This file is a Tcl script to test the code in the file tkTextWind.c. 2# This file is organized in the standard fashion for Tcl tests. 3# 4# Copyright (c) 1994 The Regents of the University of California. 5# Copyright (c) 1994-1995 Sun Microsystems, Inc. 6# Copyright (c) 1998-1999 by Scriptics Corporation. 7# All rights reserved. 8# 9# RCS: @(#) $Id: textWind.test,v 1.5.2.1 2005/11/30 23:42:49 hobbs Exp $ 10 11package require tcltest 2.1 12namespace import -force tcltest::configure 13namespace import -force tcltest::testsDirectory 14configure -testdir [file join [pwd] [file dirname [info script]]] 15configure -loadfile [file join [testsDirectory] constraints.tcl] 16tcltest::loadTestedCommands 17 18# Create entries in the option database to be sure that geometry options 19# like border width have predictable values. 20 21option add *Text.borderWidth 2 22option add *Text.highlightThickness 2 23option add *Text.font {Courier -12} 24 25text .t -width 30 -height 6 -bd 2 -highlightthickness 2 26pack append . .t {top expand fill} 27update 28.t debug on 29wm geometry . {} 30if {[winfo depth .t] > 1} { 31 set color green 32} else { 33 set color black 34} 35 36# The statements below reset the main window; it's needed if the window 37# manager is mwm to make mwm forget about a previous minimum size setting. 38 39wm withdraw . 40wm minsize . 1 1 41wm positionfrom . user 42wm deiconify . 43 44test textWind-1.1 {basic tests of options} {fonts} { 45 .t delete 1.0 end 46 .t insert end "This is the first line" 47 .t insert end "\nAnd this is a second line, which wraps around" 48 frame .f -width 3 -height 3 -bg $color 49 .t window create 2.2 -window .f 50 update 51 list [winfo ismapped .f] [winfo geom .f] [.t bbox .f] \ 52 [.t window configure .f -window] 53} {1 3x3+19+23 {19 23 3 3} {-window {} {} {} .f}} 54test textWind-1.2 {basic tests of options} {fonts} { 55 .t delete 1.0 end 56 .t insert end "This is the first line" 57 .t insert end "\nAnd this is a second line, which wraps around" 58 frame .f -width 3 -height 3 -bg $color 59 .t window create 2.2 -window .f -align top 60 update 61 list [winfo ismapped .f] [winfo geom .f] [.t bbox .f] \ 62 [.t window configure .f -align] 63} {1 3x3+19+18 {19 18 3 3} {-align {} {} center top}} 64test textWind-1.3 {basic tests of options} { 65 .t delete 1.0 end 66 .t insert end "This is the first line" 67 .t insert end "\nAnd this is a second line, which wraps around" 68 .t window create 2.2 -create "Test script" 69 .t window configure 2.2 -create 70} {-create {} {} {} {Test script}} 71test textWind-1.4 {basic tests of options} {fonts} { 72 .t delete 1.0 end 73 .t insert end "This is the first line" 74 .t insert end "\nAnd this is a second line, which wraps around" 75 frame .f -width 10 -height 20 -bg $color 76 .t window create 2.2 -window .f -padx 5 77 update 78 list [winfo geom .f] [.t window configure .f -padx] [.t bbox 2.3] 79} {10x20+24+18 {-padx {} {} 0 5} {39 21 7 13}} 80test textWind-1.5 {basic tests of options} {fonts} { 81 .t delete 1.0 end 82 .t insert end "This is the first line" 83 .t insert end "\nAnd this is a second line, which wraps around" 84 frame .f -width 10 -height 20 -bg $color 85 .t window create 2.2 -window .f -pady 4 86 update 87 list [winfo geom .f] [.t window configure .f -pady] [.t bbox 2.31] 88} {10x20+19+22 {-pady {} {} 0 4} {19 46 7 13}} 89test textWind-1.6 {basic tests of options} {fonts} { 90 .t delete 1.0 end 91 .t insert end "This is the first line" 92 .t insert end "\nAnd this is a second line, which wraps around" 93 frame .f -width 5 -height 5 -bg $color 94 .t window create 2.2 -window .f -stretch 1 95 update 96 list [winfo geom .f] [.t window configure .f -stretch] 97} {5x13+19+18 {-stretch {} {} 0 1}} 98 99.t delete 1.0 end 100.t insert end "This is the first line" 101frame .f -width 10 -height 6 -bg $color 102.t window create 1.3 -window .f -padx 1 -pady 2 103test textWind-2.1 {TkTextWindowCmd procedure} { 104 list [catch {.t window} msg] $msg 105} {1 {wrong # args: should be ".t window option ?arg arg ...?"}} 106test textWind-2.2 {TkTextWindowCmd procedure, "cget" option} { 107 list [catch {.t window cget} msg] $msg 108} {1 {wrong # args: should be ".t window cget index option"}} 109test textWind-2.3 {TkTextWindowCmd procedure, "cget" option} { 110 list [catch {.t window cget a b c} msg] $msg 111} {1 {wrong # args: should be ".t window cget index option"}} 112test textWind-2.4 {TkTextWindowCmd procedure, "cget" option} { 113 list [catch {.t window cget gorp -padx} msg] $msg 114} {1 {bad text index "gorp"}} 115test textWind-2.5 {TkTextWindowCmd procedure, "cget" option} { 116 list [catch {.t window cget 1.2 -padx} msg] $msg 117} {1 {no embedded window at index "1.2"}} 118test textWind-2.6 {TkTextWindowCmd procedure, "cget" option} { 119 list [catch {.t window cget .f -bogus} msg] $msg 120} {1 {unknown option "-bogus"}} 121test textWind-2.7 {TkTextWindowCmd procedure, "cget" option} { 122 list [catch {.t window cget .f -pady} msg] $msg 123} {0 2} 124test textWind-2.8 {TkTextWindowCmd procedure} { 125 list [catch {.t window co} msg] $msg 126} {1 {wrong # args: should be ".t window configure index ?option value ...?"}} 127test textWind-2.9 {TkTextWindowCmd procedure} { 128 list [catch {.t window configure gorp} msg] $msg 129} {1 {bad text index "gorp"}} 130test textWind-2.10 {TkTextWindowCmd procedure} { 131 .t delete 1.0 end 132 list [catch {.t window configure 1.0} msg] $msg 133} {1 {no embedded window at index "1.0"}} 134test textWind-2.11 {TkTextWindowCmd procedure} { 135 .t delete 1.0 end 136 .t insert end "This is the first line" 137 .t insert end "\nAnd this is a second line, which wraps around" 138 frame .f -width 10 -height 6 -bg $color 139 .t window create 2.2 -window .f -align baseline -padx 1 -pady 2 -create foo 140 update 141 list [catch {.t window configure .f} msg] $msg 142} {0 {{-align {} {} center baseline} {-create {} {} {} foo} {-padx {} {} 0 1} {-pady {} {} 0 2} {-stretch {} {} 0 0} {-window {} {} {} .f}}} 143test textWind-2.12 {TkTextWindowCmd procedure} { 144 .t delete 1.0 end 145 .t insert end "This is the first line" 146 .t insert end "\nAnd this is a second line, which wraps around" 147 frame .f -width 10 -height 6 -bg $color 148 .t window create 2.2 -window .f -align baseline -padx 1 -pady 2 -create foo 149 update 150 list [.t window configure .f -padx 33] [.t window configure .f -padx] 151} {{} {-padx {} {} 0 33}} 152test textWind-2.13 {TkTextWindowCmd procedure} { 153 .t delete 1.0 end 154 .t insert end "This is the first line" 155 .t insert end "\nAnd this is a second line, which wraps around" 156 frame .f -width 10 -height 6 -bg $color 157 .t window create 2.2 -window .f -align baseline -padx 1 -pady 2 158 update 159 list [.t window configure .f -padx 14 -pady 15] \ 160 [.t window configure .f -padx] [.t window configure .f -pady] 161} {{} {-padx {} {} 0 14} {-pady {} {} 0 15}} 162test textWind-2.14 {TkTextWindowCmd procedure} { 163 list [catch {.t window create} msg] $msg 164} {1 {wrong # args: should be ".t window create index ?option value ...?"}} 165test textWind-2.15 {TkTextWindowCmd procedure} { 166 list [catch {.t window create gorp} msg] $msg 167} {1 {bad text index "gorp"}} 168test textWind-2.16 {TkTextWindowCmd procedure, don't insert after end} { 169 .t delete 1.0 end 170 .t insert end "Line 1\nLine 2" 171 frame .f -width 20 -height 10 -bg $color 172 .t window create end -window .f 173 .t index .f 174} {2.6} 175test textWind-2.17 {TkTextWindowCmd procedure} { 176 .t delete 1.0 end 177 list [catch {.t window create 1.0} msg] $msg [.t window configure 1.0] 178} {0 {} {{-align {} {} center center} {-create {} {} {} {}} {-padx {} {} 0 0} {-pady {} {} 0 0} {-stretch {} {} 0 0} {-window {} {} {} {}}}} 179test textWind-2.18 {TkTextWindowCmd procedure} { 180 .t delete 1.0 end 181 frame .f -width 10 -height 6 -bg $color 182 list [catch {.t window create 1.0 -window .f -gorp stupid} msg] $msg \ 183 [winfo exists .f] [.t index 1.end] [catch {.t index .f}] 184} {1 {unknown option "-gorp"} 0 1.0 1} 185test textWind-2.19 {TkTextWindowCmd procedure} { 186 .t delete 1.0 end 187 frame .f -width 10 -height 6 -bg $color 188 list [catch {.t window create 1.0 -gorp -window .f stupid} msg] $msg \ 189 [winfo exists .f] [.t index 1.end] [catch {.t index .f}] 190} {1 {unknown option "-gorp"} 1 1.0 1} 191test textWind-2.20 {TkTextWindowCmd procedure} { 192 list [catch {.t window c} msg] $msg 193} {1 {bad window option "c": must be cget, configure, create, or names}} 194destroy .f 195test textWind-2.21 {TkTextWindowCmd procedure, "names" option} { 196 list [catch {.t window names foo} msg] $msg 197} {1 {wrong # args: should be ".t window names"}} 198test textWind-2.22 {TkTextWindowCmd procedure, "names" option} { 199 .t delete 1.0 end 200 .t window names 201} {} 202test textWind-2.23 {TkTextWindowCmd procedure, "names" option} { 203 .t delete 1.0 end 204 foreach i {.f .f2 .t.f .t.f2} { 205 frame $i -width 20 -height 20 206 .t window create end -window $i 207 } 208 set result [.t window names] 209 destroy .f .f2 .t.f .t.f2 210 lsort $result 211} {.f .f2 .t.f .t.f2} 212 213test textWind-3.1 {EmbWinConfigure procedure} { 214 .t delete 1.0 end 215 frame .f -width 10 -height 6 -bg $color 216 .t window create 1.0 -window .f 217 list [catch {.t window configure 1.0 -foo bar} msg] $msg 218} {1 {unknown option "-foo"}} 219test textWind-3.2 {EmbWinConfigure procedure} {fonts} { 220 .t delete 1.0 end 221 .t insert 1.0 "Some sample text" 222 frame .f -width 10 -height 20 -bg $color 223 .t window create 1.3 -window .f 224 update 225 .t window configure 1.3 -window {} 226 update 227 list [catch {.t index .f} msg] $msg [winfo ismapped .f] [.t bbox 1.4] 228} {1 {bad text index ".f"} 0 {26 5 7 13}} 229catch {destroy .f} 230test textWind-3.3 {EmbWinConfigure procedure} {fonts} { 231 .t delete 1.0 end 232 .t insert 1.0 "Some sample text" 233 frame .t.f -width 10 -height 20 -bg $color 234 .t window create 1.3 -window .t.f 235 update 236 .t window configure 1.3 -window {} 237 update 238 list [catch {.t index .t.f} msg] $msg [winfo ismapped .t.f] [.t bbox 1.4] 239} {1 {bad text index ".t.f"} 0 {26 5 7 13}} 240catch {destroy .t.f} 241test textWind-3.4 {EmbWinConfigure procedure} {fonts} { 242 .t delete 1.0 end 243 .t insert 1.0 "Some sample text" 244 frame .f -width 10 -height 20 -bg $color 245 .t window create 1.3 246 update 247 .t window configure 1.3 -window .f 248 update 249 list [catch {.t index .f} msg] $msg [winfo ismapped .f] [.t bbox 1.4] 250} {0 1.3 1 {36 8 7 13}} 251test textWind-3.5 {EmbWinConfigure procedure} { 252 .t delete 1.0 end 253 .t insert 1.0 "Some sample text" 254 frame .f 255 frame .f.f -width 15 -height 20 -bg $color 256 pack .f.f 257 list [catch {.t window create 1.3 -window .f.f} msg] $msg 258} {1 {can't embed .f.f in .t}} 259catch {destroy .f} 260test textWind-3.6 {EmbWinConfigure procedure} { 261 .t delete 1.0 end 262 .t insert 1.0 "Some sample text" 263 toplevel .t2 -width 20 -height 10 -bg $color 264 .t window create 1.3 265 list [catch {.t window configure 1.3 -window .t2} msg] $msg \ 266 [.t window configure 1.3 -window] 267} {1 {can't embed .t2 in .t} {-window {} {} {} {}}} 268catch {destroy .t2} 269test textWind-3.7 {EmbWinConfigure procedure} { 270 .t delete 1.0 end 271 .t insert 1.0 "Some sample text" 272 .t window create 1.3 273 list [catch {.t window configure 1.3 -window .t} msg] $msg 274} {1 {can't embed .t in .t}} 275test textWind-3.8 {EmbWinConfigure procedure} { 276 # This test checks for various errors when the text claims 277 # a window away from itself. 278 .t delete 1.0 end 279 .t insert 1.0 "Some sample text" 280 button .t.b -text "Hello!" 281 .t window create 1.4 -window .t.b 282 .t window create 1.6 -window .t.b 283 update 284 .t index .t.b 285} {1.6} 286 287.t delete 1.0 end 288frame .f -width 10 -height 20 -bg $color 289.t window create 1.0 -window .f 290test textWind-4.1 {AlignParseProc and AlignPrintProc procedures} { 291 .t window configure 1.0 -align baseline 292 .t window configure 1.0 -align 293} {-align {} {} center baseline} 294test textWind-4.2 {AlignParseProc and AlignPrintProc procedures} { 295 .t window configure 1.0 -align bottom 296 .t window configure 1.0 -align 297} {-align {} {} center bottom} 298test textWind-4.3 {AlignParseProc and AlignPrintProc procedures} { 299 .t window configure 1.0 -align center 300 .t window configure 1.0 -align 301} {-align {} {} center center} 302test textWind-4.4 {AlignParseProc and AlignPrintProc procedures} { 303 .t window configure 1.0 -align top 304 .t window configure 1.0 -align 305} {-align {} {} center top} 306test textWind-4.5 {AlignParseProc and AlignPrintProc procedures} { 307 .t window configure 1.0 -align top 308 list [catch {.t window configure 1.0 -align gorp} msg] $msg \ 309 [.t window configure 1.0 -align] 310} {1 {bad alignment "gorp": must be baseline, bottom, center, or top} {-align {} {} center top}} 311 312test textWind-5.1 {EmbWinStructureProc procedure} {fonts} { 313 .t delete 1.0 end 314 .t insert 1.0 "Some sample text" 315 frame .f -width 10 -height 20 -bg $color 316 .t window create 1.2 -window .f 317 update 318 destroy .f 319 list [catch {.t index .f} msg] $msg [.t bbox 1.2] [.t bbox 1.3] 320} {1 {bad text index ".f"} {19 11 0 0} {19 5 7 13}} 321test textWind-5.2 {EmbWinStructureProc procedure} {fonts} { 322 .t delete 1.0 end 323 .t insert 1.0 "Some sample text" 324 frame .f -width 10 -height 20 -bg $color 325 .t window create 1.2 -align bottom 326 .t window configure 1.2 -window .f 327 update 328 destroy .f 329 list [catch {.t index .f} msg] $msg [.t bbox 1.2] [.t bbox 1.3] 330} {1 {bad text index ".f"} {19 18 0 0} {19 5 7 13}} 331test textWind-5.3 {EmbWinStructureProc procedure} {fonts} { 332 .t delete 1.0 end 333 .t insert 1.0 "Some sample text" 334 .t window create 1.2 -create {frame .f -width 10 -height 20 -bg $color} 335 update 336 .t window configure 1.2 -create {frame .f -width 20 -height 10 -bg $color} 337 destroy .f 338 update 339 list [catch {.t index .f} msg] $msg [.t bbox 1.2] [.t bbox 1.3] 340} {0 1.2 {19 6 20 10} {39 5 7 13}} 341 342test textWind-6.1 {EmbWinRequestProc procedure} {fonts} { 343 .t delete 1.0 end 344 .t insert 1.0 "Some sample text" 345 frame .f -width 10 -height 20 -bg $color 346 .t window create 1.2 -window .f 347 set result {} 348 lappend result [.t bbox 1.2] [.t bbox 1.3] 349 .f configure -width 25 -height 30 350 lappend result [.t bbox 1.2] [.t bbox 1.3] 351} {{19 5 10 20} {29 8 7 13} {19 5 25 30} {44 13 7 13}} 352 353test textWind-7.1 {EmbWinLostSlaveProc procedure} {fonts} { 354 .t delete 1.0 end 355 .t insert 1.0 "Some sample text" 356 frame .f -width 10 -height 20 -bg $color 357 .t window create 1.2 -window .f 358 update 359 place .f -in .t -x 100 -y 50 360 update 361 list [winfo geom .f] [.t bbox 1.2] 362} {10x20+104+54 {19 11 0 0}} 363test textWind-7.2 {EmbWinLostSlaveProc procedure} {fonts} { 364 .t delete 1.0 end 365 .t insert 1.0 "Some sample text" 366 frame .t.f -width 10 -height 20 -bg $color 367 .t window create 1.2 -window .t.f 368 update 369 place .t.f -x 100 -y 50 370 update 371 list [winfo geom .t.f] [.t bbox 1.2] 372} {10x20+104+54 {19 11 0 0}} 373catch {destroy .f} 374catch {destroy .t.f} 375 376test textWind-8.1 {EmbWinDeleteProc procedure} {fonts} { 377 .t delete 1.0 end 378 .t insert 1.0 "Some sample text" 379 frame .f -width 10 -height 20 -bg $color 380 .t window create 1.2 -window .f 381 bind .f <Destroy> {set x destroyed} 382 set x XXX 383 .t delete 1.2 384 list $x [.t bbox 1.2] [.t bbox 1.3] [catch {.t index .f} msg] $msg \ 385 [winfo exists .f] 386} {destroyed {19 5 7 13} {26 5 7 13} 1 {bad text index ".f"} 0} 387 388test textWind-9.1 {EmbWinCleanupProc procedure} { 389 .t delete 1.0 end 390 .t insert 1.0 "Some sample text\nA second line." 391 frame .f -width 10 -height 20 -bg $color 392 .t window create 2.3 -window .f 393 .t delete 1.5 2.1 394 .t index .f 395} 1.7 396 397proc bgerror args { 398 global msg 399 set msg $args 400} 401 402test textWind-10.1 {EmbWinLayoutProc procedure} { 403 .t delete 1.0 end 404 .t insert 1.0 "Some sample text" 405 .t window create 1.5 -create { 406 frame .f -width 10 -height 20 -bg $color 407 } 408 update 409 list [winfo exists .f] [winfo geom .f] [.t index .f] 410} {1 10x20+40+5 1.5} 411test textWind-10.2 {EmbWinLayoutProc procedure, error in creating window} {fonts} { 412 .t delete 1.0 end 413 .t insert 1.0 "Some sample text" 414 .t window create 1.5 -create { 415 error "couldn't create window" 416 } 417 set msg xyzzy 418 update 419 list $msg [.t bbox 1.5] 420} {{{couldn't create window}} {40 11 0 0}} 421test textWind-10.3 {EmbWinLayoutProc procedure, error in creating window} {fonts} { 422 .t delete 1.0 end 423 .t insert 1.0 "Some sample text" 424 .t window create 1.5 -create { 425 concat gorp 426 } 427 set msg xyzzy 428 update 429 list $msg [.t bbox 1.5] 430} {{{bad window path name "gorp"}} {40 11 0 0}} 431test textWind-10.4 {EmbWinLayoutProc procedure, error in creating window} {fonts} { 432 .t delete 1.0 end 433 .t insert 1.0 "Some sample text" 434 .t window create 1.5 -create { 435 frame .t.f 436 frame .t.f.f -width 10 -height 20 -bg $color 437 } 438 set msg xyzzy 439 update 440 list $msg [.t bbox 1.5] [winfo exists .t.f.f] 441} {{{can't embed .t.f.f relative to .t}} {40 11 0 0} 1} 442catch {destroy .t.f} 443test textWind-10.5 {EmbWinLayoutProc procedure, error in creating window} {fonts} { 444 .t delete 1.0 end 445 .t insert 1.0 "Some sample text" 446 .t window create 1.5 -create { 447 concat .t 448 } 449 set msg xyzzy 450 update 451 list $msg [.t bbox 1.5] 452} {{{can't embed .t relative to .t}} {40 11 0 0}} 453test textWind-10.6 {EmbWinLayoutProc procedure, error in creating window} {fonts} { 454 .t delete 1.0 end 455 .t insert 1.0 "Some sample text" 456 .t window create 1.5 -create { 457 toplevel .t2 -width 100 -height 150 458 wm geom .t2 +0+0 459 concat .t2 460 } 461 set msg xyzzy 462 update 463 list $msg [.t bbox 1.5] 464} {{{can't embed .t2 relative to .t}} {40 11 0 0}} 465test textWind-10.7 {EmbWinLayoutProc procedure, steal window from self} { 466 .t delete 1.0 end 467 .t insert 1.0 ABCDEFGHIJKLMNOP 468 button .t.b -text "Hello!" 469 .t window create 1.5 -window .t.b 470 update 471 .t window create 1.3 -create {concat .t.b} 472 update 473 .t index .t.b 474} {1.3} 475catch {destroy .t2} 476test textWind-10.8 {EmbWinLayoutProc procedure, doesn't fit on line} {fonts} { 477 .t configure -wrap char 478 .t delete 1.0 end 479 .t insert 1.0 "Some sample text" 480 frame .f -width 125 -height 20 -bg $color -bd 2 -relief raised 481 .t window create 1.12 -window .f 482 list [.t bbox .f] [.t bbox 1.13] 483} {{89 5 126 20} {5 25 7 13}} 484test textWind-10.9 {EmbWinLayoutProc procedure, doesn't fit on line} {fonts} { 485 .t configure -wrap char 486 .t delete 1.0 end 487 .t insert 1.0 "Some sample text" 488 frame .f -width 126 -height 20 -bg $color -bd 2 -relief raised 489 .t window create 1.12 -window .f 490 update 491 list [.t bbox .f] [.t bbox 1.13] 492} {{89 5 126 20} {5 25 7 13}} 493test textWind-10.10 {EmbWinLayoutProc procedure, doesn't fit on line} {fonts} { 494 .t configure -wrap char 495 .t delete 1.0 end 496 .t insert 1.0 "Some sample text" 497 frame .f -width 127 -height 20 -bg $color -bd 2 -relief raised 498 .t window create 1.12 -window .f 499 update 500 list [.t bbox .f] [.t bbox 1.13] 501} {{5 18 127 20} {132 21 7 13}} 502test textWind-10.11 {EmbWinLayoutProc procedure, doesn't fit on line} { 503 .t configure -wrap none 504 .t delete 1.0 end 505 .t insert 1.0 "Some sample text" 506 frame .f -width 130 -height 20 -bg $color -bd 2 -relief raised 507 .t window create 1.12 -window .f 508 update 509 list [.t bbox .f] [.t bbox 1.13] 510} {{89 5 126 20} {}} 511test textWind-10.12 {EmbWinLayoutProc procedure, doesn't fit on line} {fonts} { 512 .t configure -wrap none 513 .t delete 1.0 end 514 .t insert 1.0 "Some sample text" 515 frame .f -width 130 -height 220 -bg $color -bd 2 -relief raised 516 .t window create 1.12 -window .f 517 update 518 list [.t bbox .f] [.t bbox 1.13] 519} {{89 5 126 78} {}} 520test textWind-10.13 {EmbWinLayoutProc procedure, doesn't fit on line} {fonts} { 521 .t configure -wrap char 522 .t delete 1.0 end 523 .t insert 1.0 "Some sample text" 524 frame .f -width 250 -height 220 -bg $color -bd 2 -relief raised 525 .t window create 1.12 -window .f 526 update 527 list [.t bbox .f] [.t bbox 1.13] 528} {{5 18 210 65} {}} 529 530test textWind-11.1 {EmbWinDisplayProc procedure, geometry transforms} { 531 .t delete 1.0 end 532 .t insert 1.0 "Some sample text" 533 pack forget .t 534 place .t -x 30 -y 50 535 frame .f -width 30 -height 20 -bg $color 536 .t window create 1.12 -window .f 537 update 538 winfo geom .f 539} {30x20+119+55} 540place forget .t 541pack .t 542test textWind-11.2 {EmbWinDisplayProc procedure, geometry transforms} { 543 .t delete 1.0 end 544 .t insert 1.0 "Some sample text" 545 pack forget .t 546 place .t -x 30 -y 50 547 frame .t.f -width 30 -height 20 -bg $color 548 .t window create 1.12 -window .t.f 549 update 550 winfo geom .t.f 551} {30x20+89+5} 552place forget .t 553pack .t 554test textWind-11.3 {EmbWinDisplayProc procedure, configuration optimization} { 555 .t delete 1.0 end 556 .t insert 1.0 "Some sample text" 557 frame .f -width 30 -height 20 -bg $color 558 .t window create 1.12 -window .f 559 update 560 bind .f <Configure> {set x ".f configured"} 561 set x {no configures} 562 .t delete 1.0 563 .t insert 1.0 "X" 564 update 565 set x 566} {no configures} 567test textWind-11.4 {EmbWinDisplayProc procedure, horizontal scrolling} {fonts} { 568 .t delete 1.0 end 569 .t insert 1.0 "xyzzy\nFirst window here: " 570 .t configure -wrap none 571 frame .f -width 30 -height 20 -bg $color 572 .t window create end -window .f 573 .t insert end " and second here: " 574 frame .f2 -width 40 -height 10 -bg $color 575 .t window create end -window .f2 576 .t insert end " with junk after it." 577 .t xview moveto 0 578 .t xview scroll 5 units 579 update 580 list [winfo ismapped .f] [winfo geom .f] [.t bbox .f] [winfo ismapped .f2] 581} {1 30x20+103+18 {103 18 30 20} 0} 582test textWind-11.5 {EmbWinDisplayProc procedure, horizontal scrolling} {fonts} { 583 .t delete 1.0 end 584 .t insert 1.0 "xyzzy\nFirst window here: " 585 .t configure -wrap none 586 frame .f -width 30 -height 20 -bg $color 587 .t window create end -window .f 588 .t insert end " and second here: " 589 frame .f2 -width 40 -height 10 -bg $color 590 .t window create end -window .f2 591 .t insert end " with junk after it." 592 update 593 .t xview moveto 0 594 .t xview scroll 25 units 595 update 596 list [winfo ismapped .f] [winfo ismapped .f2] [winfo geom .f2] [.t bbox .f2] 597} {0 1 40x10+119+23 {119 23 40 10}} 598.t configure -wrap char 599 600test textWind-12.1 {EmbWinUndisplayProc procedure, mapping/unmapping} { 601 .t delete 1.0 end 602 .t insert 1.0 "Some sample text" 603 frame .f -width 30 -height 20 -bg $color 604 .t window create 1.2 -window .f 605 bind .f <Map> {lappend x mapped} 606 bind .f <Unmap> {lappend x unmapped} 607 set x created 608 update 609 lappend x modified 610 .t delete 1.0 611 update 612 lappend x replaced 613 .t window configure .f -window {} 614 .t delete 1.1 615 .t window create 1.4 -window .f 616 update 617 lappend x off-screen 618 .t configure -wrap none 619 .t insert 1.0 "Enough text to make the line run off-screen" 620 update 621 set x 622} {created mapped modified replaced unmapped mapped off-screen unmapped} 623 624test textWind-13.1 {EmbWinBboxProc procedure} { 625 .t delete 1.0 end 626 .t insert 1.0 "Some sample text" 627 frame .f -width 5 -height 5 -bg $color 628 .t window create 1.2 -window .f -align top -padx 2 -pady 1 629 update 630 list [winfo geom .f] [.t bbox .f] 631} {5x5+21+6 {21 6 5 5}} 632test textWind-13.2 {EmbWinBboxProc procedure} { 633 .t delete 1.0 end 634 .t insert 1.0 "Some sample text" 635 frame .f -width 5 -height 5 -bg $color 636 .t window create 1.2 -window .f -align center -padx 2 -pady 1 637 update 638 list [winfo geom .f] [.t bbox .f] 639} {5x5+21+9 {21 9 5 5}} 640test textWind-13.3 {EmbWinBboxProc procedure} {fonts} { 641 .t delete 1.0 end 642 .t insert 1.0 "Some sample text" 643 frame .f -width 5 -height 5 -bg $color 644 .t window create 1.2 -window .f -align baseline -padx 2 -pady 1 645 update 646 list [winfo geom .f] [.t bbox .f] 647} {5x5+21+10 {21 10 5 5}} 648test textWind-13.4 {EmbWinBboxProc procedure} {fonts} { 649 .t delete 1.0 end 650 .t insert 1.0 "Some sample text" 651 frame .f -width 5 -height 5 -bg $color 652 .t window create 1.2 -window .f -align bottom -padx 2 -pady 1 653 update 654 list [winfo geom .f] [.t bbox .f] 655} {5x5+21+12 {21 12 5 5}} 656test textWind-13.5 {EmbWinBboxProc procedure} {fonts} { 657 .t delete 1.0 end 658 .t insert 1.0 "Some sample text" 659 frame .f -width 5 -height 5 -bg $color 660 .t window create 1.2 -window .f -align top -padx 2 -pady 1 -stretch 1 661 update 662 list [winfo geom .f] [.t bbox .f] 663} {5x11+21+6 {21 6 5 11}} 664test textWind-13.6 {EmbWinBboxProc procedure} {fonts} { 665 .t delete 1.0 end 666 .t insert 1.0 "Some sample text" 667 frame .f -width 5 -height 5 -bg $color 668 .t window create 1.2 -window .f -align center -padx 2 -pady 1 -stretch 1 669 update 670 list [winfo geom .f] [.t bbox .f] 671} {5x11+21+6 {21 6 5 11}} 672test textWind-13.7 {EmbWinBboxProc procedure} {fonts} { 673 .t delete 1.0 end 674 .t insert 1.0 "Some sample text" 675 frame .f -width 5 -height 5 -bg $color 676 .t window create 1.2 -window .f -align baseline -padx 2 -pady 1 -stretch 1 677 update 678 list [winfo geom .f] [.t bbox .f] 679} {5x9+21+6 {21 6 5 9}} 680test textWind-13.8 {EmbWinBboxProc procedure} {fonts} { 681 .t delete 1.0 end 682 .t insert 1.0 "Some sample text" 683 frame .f -width 5 -height 5 -bg $color 684 .t window create 1.2 -window .f -align bottom -padx 2 -pady 1 -stretch 1 685 update 686 list [winfo geom .f] [.t bbox .f] 687} {5x11+21+6 {21 6 5 11}} 688test textWind-13.9 {EmbWinBboxProc procedure, spacing options} { 689 .t configure -spacing1 5 -spacing3 2 690 .t delete 1.0 end 691 .t insert 1.0 "Some sample text" 692 frame .f -width 5 -height 5 -bg $color 693 .t window create 1.2 -window .f -align center -padx 2 -pady 1 694 update 695 list [winfo geom .f] [.t bbox .f] 696} {5x5+21+14 {21 14 5 5}} 697.t configure -spacing1 0 -spacing2 0 -spacing3 0 698 699test textWind-14.1 {EmbWinDelayedUnmap procedure} { 700 .t delete 1.0 end 701 .t insert 1.0 "Some sample text" 702 frame .f -width 30 -height 20 -bg $color 703 .t window create 1.2 -window .f 704 update 705 bind .f <Unmap> {lappend x unmapped} 706 set x modified 707 .t insert 1.0 x 708 lappend x removed 709 .t window configure .f -window {} 710 lappend x updated 711 update 712 set x 713} {modified removed unmapped updated} 714catch {destroy .f} 715test textWind-14.2 {EmbWinDelayedUnmap procedure} { 716 .t delete 1.0 end 717 .t insert 1.0 "Some sample text" 718 frame .f -width 30 -height 20 -bg $color 719 .t window create 1.2 -window .f 720 update 721 bind .f <Unmap> {lappend x unmapped} 722 set x modified 723 .t insert 1.0 x 724 lappend x deleted 725 .t delete .f 726 lappend x updated 727 update 728 set x 729} {modified deleted updated} 730test textWind-14.3 {EmbWinDelayedUnmap procedure} { 731 .t delete 1.0 end 732 .t insert 1.0 "Some sample text\nAnother line\n3\n4\n5\n6\n7\n8\n9" 733 frame .f -width 30 -height 20 -bg $color 734 .t window create 1.2 -window .f 735 update 736 .t yview 2.0 737 set result [winfo ismapped .f] 738 update 739 list $result [winfo ismapped .f] 740} {1 0} 741test textWind-14.4 {EmbWinDelayedUnmap procedure} { 742 .t delete 1.0 end 743 .t insert 1.0 "Some sample text\nAnother line\n3\n4\n5\n6\n7\n8\n9" 744 frame .t.f -width 30 -height 20 -bg $color 745 .t window create 1.2 -window .t.f 746 update 747 .t yview 2.0 748 set result [winfo ismapped .t.f] 749 update 750 list $result [winfo ismapped .t.f] 751} {1 0} 752catch {destroy .t.f} 753catch {destroy .f} 754 755test textWind-15.1 {TkTextWindowIndex procedure} { 756 list [catch {.t index .foo} msg] $msg 757} {1 {bad text index ".foo"}} 758test textWind-15.2 {TkTextWindowIndex procedure} {fonts} { 759 .t configure -wrap none 760 .t delete 1.0 end 761 .t insert 1.0 "Some sample text" 762 frame .f -width 30 -height 20 -bg $color 763 .t window create 1.6 -window .f 764 .t tag add a 1.1 765 .t tag add a 1.3 766 list [.t index .f] [.t bbox 1.7] 767} {1.6 {77 8 7 13}} 768 769test textWind-16.1 {EmbWinTextStructureProc procedure} { 770 .t configure -wrap none 771 .t delete 1.0 end 772 .t insert 1.0 "Some sample text" 773 frame .f -width 30 -height 20 -bg $color 774 .t window create 1.6 -window .f 775 update 776 pack forget .t 777 update 778 winfo ismapped .f 779} 0 780pack .t 781test textWind-16.2 {EmbWinTextStructureProc procedure} { 782 .t configure -wrap none 783 .t delete 1.0 end 784 .t insert 1.0 "Some sample text" 785 frame .f -width 30 -height 20 -bg $color 786 .t window create 1.6 -window .f 787 update 788 set result {} 789 lappend result [winfo geom .f] [.t bbox .f] 790 frame .f2 -width 150 -height 30 -bd 2 -relief raised 791 pack .f2 -before .t 792 update 793 lappend result [winfo geom .f] [.t bbox .f] 794} {30x20+47+5 {47 5 30 20} 30x20+47+35 {47 5 30 20}} 795catch {destroy .f2} 796test textWind-16.3 {EmbWinTextStructureProc procedure} { 797 .t configure -wrap none 798 .t delete 1.0 end 799 .t insert 1.0 "Some sample text" 800 .t window create 1.6 801 update 802 pack forget .t 803 update 804} {} 805pack .t 806test textWind-16.4 {EmbWinTextStructureProc procedure} { 807 .t configure -wrap none 808 .t delete 1.0 end 809 .t insert 1.0 "Some sample text" 810 frame .t.f -width 30 -height 20 -bg $color 811 .t window create 1.6 -window .t.f 812 update 813 pack forget .t 814 update 815 list [winfo ismapped .t.f] [.t bbox .t.f] 816} {1 {47 5 30 20}} 817pack .t 818 819catch {destroy .t} 820option clear 821 822# cleanup 823::tcltest::cleanupTests 824return 825 826 827 828 829 830 831 832 833 834 835 836 837 838