1# This file is a Tcl script to test the procedures in the file 2# tkGeometry.c (generic support for geometry managers). It is 3# organized in the standard fashion for Tcl tests. 4# 5# Copyright (c) 1994 The Regents of the University of California. 6# Copyright (c) 1994 Sun Microsystems, Inc. 7# Copyright (c) 1998-1999 by Scriptics Corporation. 8# All rights reserved. 9# 10# RCS: @(#) $Id: geometry.test,v 1.4 2002/07/13 21:52:34 dgp Exp $ 11 12package require tcltest 2.1 13namespace import -force tcltest::configure 14namespace import -force tcltest::testsDirectory 15configure -testdir [file join [pwd] [file dirname [info script]]] 16configure -loadfile [file join [testsDirectory] constraints.tcl] 17tcltest::loadTestedCommands 18 19wm geometry . 300x300 20raise . 21update 22 23frame .f -bd 2 -relief raised 24frame .f.f -bd 2 -relief sunken 25frame .f.f.f -bd 2 -relief raised 26button .b1 -text .b1 27button .b2 -text .b2 28button .b3 -text .b3 29button .f.f.b4 -text .b4 30 31test geometry-1.1 {Tk_ManageGeometry procedure} { 32 place .b1 -x 120 -y 80 33 update 34 list [winfo x .b1] [winfo y .b1] 35} {120 80} 36test geometry-1.2 {Tk_ManageGeometry procedure} { 37 foreach w {.f .f.f .f.f.f .b1 .b2 .b3} { 38 place forget $w 39 } 40 place .f -x 20 -y 30 -width 200 -height 200 41 place .b1 -in .f -x 40 -y 30 42 update 43 pack .b1 -side top -anchor w 44 place .f -x 30 -y 40 45 update 46 list [winfo x .b1] [winfo y .b1] 47} {0 0} 48 49test geometry-2.1 {Tk_GeometryRequest procedure} { 50 frame .f2 51 set result [list [winfo reqwidth .f2] [winfo reqheight .f2]] 52 .f2 configure -width 150 -height 300 53 update 54 lappend result [winfo reqwidth .f2] [winfo reqheight .f2] \ 55 [winfo geom .f2] 56 place .f2 -x 10 -y 20 57 update 58 lappend result [winfo geom .f2] 59 .f2 configure -width 100 -height 80 60 update 61 lappend result [winfo geom .f2] 62} {1 1 150 300 1x1+0+0 150x300+10+20 100x80+10+20} 63catch {destroy .f2} 64 65test geometry-3.1 {Tk_SetInternalBorder procedure} { 66 foreach w {.f .f.f .f.f.f .b1 .b2 .b3} { 67 place forget $w 68 } 69 place .f -x 20 -y 30 -width 200 -height 200 70 place .b1 -in .f -x 50 -y 5 71 update 72 set x [list [winfo x .b1] [winfo y .b1]] 73 .f configure -bd 5 74 update 75 lappend x [winfo x .b1] [winfo y .b1] 76} {72 37 75 40} 77.f configure -bd 2 78 79test geometry-4.1 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} { 80 foreach w {.f .f.f .f.f.f .b1 .b2 .b3} { 81 place forget $w 82 } 83 place .f -x 20 -y 30 -width 200 -height 200 84 place .f.f -x 15 -y 5 -width 150 -height 120 85 place .f.f.f -width 100 -height 80 86 place .b1 -in .f.f.f -x 50 -y 5 87 update 88 list [winfo x .b1] [winfo y .b1] 89} {91 46} 90test geometry-4.2 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} { 91 foreach w {.f .f.f .f.f.f .b1 .b2 .b3} { 92 place forget $w 93 } 94 place .f -x 20 -y 30 -width 200 -height 200 95 place .f.f -x 15 -y 5 -width 150 -height 120 96 place .f.f.f -width 100 -height 80 97 place .b1 -in .f.f.f -x 50 -y 5 98 place .b2 -in .f.f.f -x 10 -y 25 99 place .b3 -in .f.f.f -x 50 -y 25 100 update 101 place .f -x 30 -y 25 102 update 103 list [winfo x .b1] [winfo y .b1] [winfo x .b2] [winfo y .b2] \ 104 [winfo x .b3] [winfo y .b3] 105} {101 41 61 61 101 61} 106test geometry-4.3 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} { 107 foreach w {.f .f.f .f.f.f .b1 .b2 .b3} { 108 place forget $w 109 } 110 place .f -x 20 -y 30 -width 200 -height 200 111 place .f.f -x 15 -y 5 -width 150 -height 120 112 place .f.f.f -width 100 -height 80 113 place .b1 -in .f.f.f -x 50 -y 5 114 place .b2 -in .f.f.f -x 10 -y 25 115 place .b3 -in .f.f.f -x 50 -y 25 116 update 117 destroy .b1 118 button .b1 -text .b1 119 place .f.f -x 10 -y 25 120 update 121 list [winfo x .b1] [winfo y .b1] [winfo x .b2] [winfo y .b2] \ 122 [winfo x .b3] [winfo y .b3] 123} {0 0 46 86 86 86} 124test geometry-4.4 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} { 125 foreach w {.f .f.f .f.f.f .b1 .b2 .b3} { 126 place forget $w 127 } 128 place .f -x 20 -y 30 -width 200 -height 200 129 place .f.f -x 15 -y 5 -width 150 -height 120 130 place .f.f.f -width 100 -height 80 131 place .b1 -in .f.f.f -x 50 -y 5 132 place .b2 -in .f.f.f -x 10 -y 25 133 place .b3 -in .f.f.f -x 50 -y 25 134 update 135 destroy .b2 136 button .b2 -text .b2 137 place .f.f.f -x 2 -y 3 138 update 139 list [winfo x .b1] [winfo y .b1] [winfo x .b2] [winfo y .b2] \ 140 [winfo x .b3] [winfo y .b3] 141} {93 49 0 0 93 69} 142test geometry-4.5 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} { 143 foreach w {.f .f.f .f.f.f .b1 .b2 .b3} { 144 place forget $w 145 } 146 place .f -x 20 -y 30 -width 200 -height 200 147 place .f.f -x 15 -y 5 -width 150 -height 120 148 place .f.f.f -width 100 -height 80 149 place .b1 -in .f.f.f -x 50 -y 5 150 place .b2 -in .f.f.f -x 10 -y 25 151 place .b3 -in .f.f.f -x 50 -y 25 152 update 153 destroy .b3 154 button .b3 -text .b3 155 place .f.f.f -x 2 -y 3 156 update 157 list [winfo x .b1] [winfo y .b1] [winfo x .b2] [winfo y .b2] \ 158 [winfo x .b3] [winfo y .b3] 159} {93 49 53 69 0 0} 160test geometry-4.6 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} { 161 foreach w {.f .f.f .f.f.f .b1 .b2 .b3 .f.f.b4} { 162 place forget $w 163 } 164 place .f -x 20 -y 30 -width 200 -height 200 165 place .f.f -x 15 -y 5 -width 150 -height 120 166 place .f.f.f -width 100 -height 80 167 place .f.f.b4 -in .f.f.f -x 50 -y 5 168 place .b2 -in .f.f.f -x 10 -y 25 169 update 170 place .f -x 25 -y 35 171 update 172 list [winfo x .f.f.b4] [winfo y .f.f.b4] [winfo x .b2] [winfo y .b2] 173} {54 9 56 71} 174test geometry-4.7 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} { 175 foreach w {.f .f.f .f.f.f .b1 .b2 .b3 .f.f.b4} { 176 place forget $w 177 } 178 bind .b1 <Configure> {lappend x configure} 179 place .f -x 20 -y 30 -width 200 -height 200 180 place .f.f -x 15 -y 5 -width 150 -height 120 181 place .f.f.f -width 100 -height 80 182 place .f.f.b4 -in .f.f.f -x 50 -y 5 183 place .b1 -in .f.f.f -x 10 -y 25 184 update 185 set x init 186 place .f -x 25 -y 35 187 update 188 lappend x | 189 place .f -x 30 -y 40 190 place .f.f -x 10 -y 0 191 update 192 bind .b1 <Configure> {} 193 set x 194} {init configure |} 195test geometry-4.8 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} { 196 foreach w {.f .f.f .f.f.f .b1 .b2 .b3} { 197 place forget $w 198 } 199 place .f -x 20 -y 30 -width 200 -height 200 200 place .f.f -x 15 -y 5 -width 150 -height 120 201 place .f.f.f -width 100 -height 80 202 place .b1 -in .f.f.f -x 50 -y 5 203 place .b2 -in .f.f.f -x 10 -y 25 204 place .b3 -in .f.f.f -x 50 -y 25 205 update 206 destroy .f.f 207 frame .f.f -bd 2 -relief raised 208 frame .f.f.f -bd 2 -relief raised 209 place .f -x 30 -y 25 210 update 211 list [winfo x .b1] [winfo y .b1] [winfo ismapped .b1] \ 212 [winfo x .b2] [winfo y .b2] [winfo ismapped .b2] \ 213 [winfo x .b3] [winfo y .b3] [winfo ismapped .b3] 214} {91 46 0 51 66 0 91 66 0} 215test geometry-4.9 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} { 216 foreach w {.f .f.f .f.f.f .b1 .b2 .b3} { 217 place forget $w 218 } 219 place .f -x 20 -y 30 -width 200 -height 200 220 place .f.f -x 15 -y 5 -width 150 -height 120 221 place .f.f.f -width 100 -height 80 222 place .b1 -in .f.f.f -x 50 -y 5 223 update 224 set result [winfo ismapped .b1] 225 place forget .f.f 226 update 227 lappend result [winfo ismapped .b1] 228 place .f.f -x 15 -y 5 -width 150 -height 120 229 update 230 lappend result [winfo ismapped .b1] 231} {1 0 1} 232test geometry-4.10 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} { 233 toplevel .t 234 wm geometry .t +0+0 235 tkwait visibility .t 236 update 237 frame .t.f 238 pack .t.f 239 button .t.quit -text Quit -command exit 240 pack .t.quit -in .t.f 241 wm iconify .t 242 set x 0 243 after 500 {set x 1} 244 tkwait variable x 245 wm deiconify .t 246 update 247 winfo ismapped .t.quit 248} {1} 249 250catch {destroy .t} 251 252# cleanup 253::tcltest::cleanupTests 254return 255 256 257 258 259 260 261 262 263 264 265 266 267 268