home *** CD-ROM | disk | FTP | other *** search
/ Ultra Pack / UltraComputing Partner Applications.iso / SunLabs / tclTK / src / tk4.0 / tests / geometry.test < prev    next >
Encoding:
Text File  |  1995-02-22  |  7.4 KB  |  251 lines

  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. #
  8. # See the file "license.terms" for information on usage and redistribution
  9. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  10. #
  11. # @(#) geometry.test 1.5 95/02/21 16:36:58
  12.  
  13. if {[info procs test] != "test"} {
  14.     source defs
  15. }
  16.  
  17. foreach i [winfo children .] {
  18.     destroy $i
  19. }
  20. wm geometry . 300x300
  21. raise .
  22. update
  23.  
  24. frame .f -bd 2 -relief raised
  25. frame .f.f -bd 2 -relief sunken
  26. frame .f.f.f -bd 2 -relief raised
  27. button .b1 -text .b1
  28. button .b2 -text .b2
  29. button .b3 -text .b3
  30. button .f.f.b4 -text .b4
  31.  
  32. test geometry-1.1 {Tk_ManageGeometry procedure} {
  33.     place .b1 -x 120 -y 80
  34.     update
  35.     list [winfo x .b1] [winfo y .b1]
  36. } {120 80}
  37. test geometry-1.2 {Tk_ManageGeometry procedure} {
  38.     foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
  39.     place forget $w
  40.     }
  41.     place .f -x 20 -y 30 -width 200 -height 200
  42.     place .b1 -in .f -x 40 -y 30
  43.     update
  44.     pack .b1 -side top -anchor w
  45.     place .f -x 30 -y 40
  46.     update
  47.     list [winfo x .b1] [winfo y .b1]
  48. } {0 0}
  49.  
  50. test geometry-2.1 {Tk_GeometryRequest procedure} {
  51.     frame .f2
  52.     set result [list [winfo reqwidth .f2] [winfo reqheight .f2]]
  53.     .f2 configure -width 200 -height 300
  54.     update
  55.     lappend result [winfo reqwidth .f2] [winfo reqheight .f2] \
  56.         [winfo geom .f2]
  57.     place .f2 -x 10 -y 20
  58.     update
  59.     lappend result [winfo geom .f2]
  60.     .f2 configure -width 100 -height 80
  61.     update
  62.     lappend result [winfo geom .f2]
  63. } {1 1 200 300 1x1+0+0 200x300+10+20 100x80+10+20}
  64. catch {destroy .f2}
  65.  
  66. test geometry-3.1 {Tk_SetInternalBorder procedure} {
  67.     foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
  68.     place forget $w
  69.     }
  70.     place .f -x 20 -y 30 -width 200 -height 200
  71.     place .b1 -in .f -x 50 -y 5
  72.     update
  73.     set x [list [winfo x .b1] [winfo y .b1]]
  74.     .f configure -bd 5
  75.     update
  76.     lappend x [winfo x .b1] [winfo y .b1]
  77. } {72 37 75 40}
  78. .f configure -bd 2
  79.  
  80. test geometry-4.1 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
  81.     foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
  82.     place forget $w
  83.     }
  84.     place .f -x 20 -y 30 -width 200 -height 200
  85.     place .f.f -x 15 -y 5 -width 150 -height 120
  86.     place .f.f.f -width 100 -height 80
  87.     place .b1 -in .f.f.f -x 50 -y 5
  88.     update
  89.     list [winfo x .b1] [winfo y .b1]
  90. } {91 46}
  91. test geometry-4.2 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
  92.     foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
  93.     place forget $w
  94.     }
  95.     place .f -x 20 -y 30 -width 200 -height 200
  96.     place .f.f -x 15 -y 5 -width 150 -height 120
  97.     place .f.f.f -width 100 -height 80
  98.     place .b1 -in .f.f.f -x 50 -y 5
  99.     place .b2 -in .f.f.f -x 10 -y 25
  100.     place .b3 -in .f.f.f -x 50 -y 25
  101.     update
  102.     place .f -x 30 -y 25
  103.     update
  104.     list [winfo x .b1] [winfo y .b1] [winfo x .b2] [winfo y .b2] \
  105.         [winfo x .b3] [winfo y .b3]
  106. } {101 41 61 61 101 61}
  107. test geometry-4.3 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
  108.     foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
  109.     place forget $w
  110.     }
  111.     place .f -x 20 -y 30 -width 200 -height 200
  112.     place .f.f -x 15 -y 5 -width 150 -height 120
  113.     place .f.f.f -width 100 -height 80
  114.     place .b1 -in .f.f.f -x 50 -y 5
  115.     place .b2 -in .f.f.f -x 10 -y 25
  116.     place .b3 -in .f.f.f -x 50 -y 25
  117.     update
  118.     destroy .b1
  119.     button .b1 -text .b1
  120.     place .f.f -x 10 -y 25
  121.     update
  122.     list [winfo x .b1] [winfo y .b1] [winfo x .b2] [winfo y .b2] \
  123.         [winfo x .b3] [winfo y .b3]
  124. } {0 0 46 86 86 86}
  125. test geometry-4.4 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
  126.     foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
  127.     place forget $w
  128.     }
  129.     place .f -x 20 -y 30 -width 200 -height 200
  130.     place .f.f -x 15 -y 5 -width 150 -height 120
  131.     place .f.f.f -width 100 -height 80
  132.     place .b1 -in .f.f.f -x 50 -y 5
  133.     place .b2 -in .f.f.f -x 10 -y 25
  134.     place .b3 -in .f.f.f -x 50 -y 25
  135.     update
  136.     destroy .b2
  137.     button .b2 -text .b2
  138.     place .f.f.f -x 2 -y 3
  139.     update
  140.     list [winfo x .b1] [winfo y .b1] [winfo x .b2] [winfo y .b2] \
  141.         [winfo x .b3] [winfo y .b3]
  142. } {93 49 0 0 93 69}
  143. test geometry-4.5 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
  144.     foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
  145.     place forget $w
  146.     }
  147.     place .f -x 20 -y 30 -width 200 -height 200
  148.     place .f.f -x 15 -y 5 -width 150 -height 120
  149.     place .f.f.f -width 100 -height 80
  150.     place .b1 -in .f.f.f -x 50 -y 5
  151.     place .b2 -in .f.f.f -x 10 -y 25
  152.     place .b3 -in .f.f.f -x 50 -y 25
  153.     update
  154.     destroy .b3
  155.     button .b3 -text .b3
  156.     place .f.f.f -x 2 -y 3
  157.     update
  158.     list [winfo x .b1] [winfo y .b1] [winfo x .b2] [winfo y .b2] \
  159.         [winfo x .b3] [winfo y .b3]
  160. } {93 49 53 69 0 0}
  161. test geometry-4.6 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
  162.     foreach w {.f .f.f .f.f.f .b1 .b2 .b3 .f.f.b4} {
  163.     place forget $w
  164.     }
  165.     place .f -x 20 -y 30 -width 200 -height 200
  166.     place .f.f -x 15 -y 5 -width 150 -height 120
  167.     place .f.f.f -width 100 -height 80
  168.     place .f.f.b4 -in .f.f.f -x 50 -y 5
  169.     place .b2 -in .f.f.f -x 10 -y 25
  170.     update
  171.     place .f -x 25 -y 35
  172.     update
  173.     list [winfo x .f.f.b4] [winfo y .f.f.b4] [winfo x .b2] [winfo y .b2]
  174. } {54 9 56 71}
  175. test geometry-4.7 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
  176.     foreach w {.f .f.f .f.f.f .b1 .b2 .b3 .f.f.b4} {
  177.     place forget $w
  178.     }
  179.     bind .b1 <Configure> {lappend x configure}
  180.     place .f -x 20 -y 30 -width 200 -height 200
  181.     place .f.f -x 15 -y 5 -width 150 -height 120
  182.     place .f.f.f -width 100 -height 80
  183.     place .f.f.b4 -in .f.f.f -x 50 -y 5
  184.     place .b1 -in .f.f.f -x 10 -y 25
  185.     update
  186.     set x init
  187.     place .f -x 25 -y 35
  188.     update
  189.     lappend x |
  190.     place .f -x 30 -y 40
  191.     place .f.f -x 10 -y 0
  192.     update
  193.     bind .b1 <Configure> {}
  194.     set x
  195. } {init configure |}
  196. test geometry-4.8 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
  197.     foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
  198.     place forget $w
  199.     }
  200.     place .f -x 20 -y 30 -width 200 -height 200
  201.     place .f.f -x 15 -y 5 -width 150 -height 120
  202.     place .f.f.f -width 100 -height 80
  203.     place .b1 -in .f.f.f -x 50 -y 5
  204.     place .b2 -in .f.f.f -x 10 -y 25
  205.     place .b3 -in .f.f.f -x 50 -y 25
  206.     update
  207.     destroy .f.f
  208.     frame .f.f -bd 2 -relief raised
  209.     frame .f.f.f -bd 2 -relief raised
  210.     place .f -x 30 -y 25
  211.     update
  212.     list [winfo x .b1] [winfo y .b1] [winfo ismapped .b1] \
  213.         [winfo x .b2] [winfo y .b2] [winfo ismapped .b2] \
  214.         [winfo x .b3] [winfo y .b3] [winfo ismapped .b3]
  215. } {91 46 0 51 66 0 91 66 0}
  216. test geometry-4.9 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
  217.     foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
  218.     place forget $w
  219.     }
  220.     place .f -x 20 -y 30 -width 200 -height 200
  221.     place .f.f -x 15 -y 5 -width 150 -height 120
  222.     place .f.f.f -width 100 -height 80
  223.     place .b1 -in .f.f.f -x 50 -y 5
  224.     update
  225.     set result [winfo ismapped .b1]
  226.     place forget .f.f
  227.     update
  228.     lappend result [winfo ismapped .b1]
  229.     place .f.f -x 15 -y 5 -width 150 -height 120
  230.     update
  231.     lappend result [winfo ismapped .b1]
  232. } {1 0 1}
  233. test geometry-4.10 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
  234.     toplevel .t
  235.     wm geometry .t +0+0
  236.     tkwait visibility .t
  237.     update
  238.     frame .t.f 
  239.     pack .t.f
  240.     button .t.quit -text Quit -command exit
  241.     pack .t.quit -in .t.f
  242.     wm iconify .t
  243.     set x 0
  244.     after 500 {set x 1}
  245.     tkwait variable x
  246.     wm deiconify .t
  247.     winfo ismapped .t.quit
  248. } {1}
  249. catch {destroy .t}
  250. concat
  251.