home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / tls / tls074c.sunsparc.Z / tls074c.sunsparc / lib / vtcl / tests / baseline.tcl < prev    next >
Encoding:
Text File  |  1995-07-20  |  2.5 KB  |  106 lines

  1. # CVS $Id: baseline.tcl,v 1.1 1995/02/03 17:15:11 zibi Exp $
  2. #@(#) baseline.tcl 11.4 95/01/31 
  3. # This tests VtGetValues on the following options.
  4. #    -baseLineList 
  5. #    -width
  6. #    -height
  7. #
  8.  
  9.  
  10. proc QuitCB { cbs } {
  11.     VtClose 
  12. }
  13.  
  14. proc TestCB {junk} {
  15.     global txt
  16.  
  17.     set str [ VtGetValues $txt -value ]
  18.  
  19.     if { [ VtInfo -charm ] } { 
  20.         set OKstr "Text baseLineList is <0>\n   width - <42> height <4>\nLabel baseLineList is <0>\n   width - <8> height <1>"
  21.         VtClose
  22.         if { ! [string compare $str $OKstr ]} \
  23.         { puts PASS } else { puts FAILED }
  24.         exit 0
  25.     } \
  26.     else \
  27.     {
  28. #        set OKstr "Text baseLineList is <20 33 46 59>\n   width - <240> height <52>\nLabel baseLineList is <13>\n   width - <52> height <14>"
  29.  
  30.     set OKstr "Text baseLineList is <21 36 51 66>\n   width - <360> height <60>\nLabel baseLineList is <15>\n   width - <63> height <16>"
  31.         if { ! [string compare $str $OKstr ]} \
  32.         { puts PASS } else { puts FAILED }
  33.     echo  $OKstr
  34.    
  35.         VtClose
  36.     }
  37.  
  38. }
  39.  
  40.     
  41. set ap [VtOpen geometry]
  42.  
  43. set dlog [VtFormDialog $ap.form ]
  44.  
  45. set label [VtLabel $dlog.lbl -label "Address:"]
  46. set txt [VtText $dlog.txt -rows 4 -columns 40 \
  47.      -leftSide $label -topSide FORM]
  48.  
  49. VtPushButton $dlog.t  -label "Test"    -callback TestCB 
  50.  
  51. VtSeparator  $dlog.s -leftSide FORM -rightSide FORM
  52. VtPushButton $dlog.q  -label "Quit"     -callback QuitCB \
  53.     -bottomSide FORM \
  54.     -leftSide 40 \
  55.         -rightSide 60 
  56.  
  57.  
  58. set baseLineList [VtGetValues $txt -baseLineList]
  59. set width      [VtGetValues $txt -width]
  60. set height      [VtGetValues $txt -height]
  61.  
  62. set txtBaseLine [lindex $baseLineList 0]
  63.  
  64. set str "Text baseLineList is <$baseLineList>"
  65. set str "$str\n   width - <$width> height <$height>"
  66.  
  67. VtShow $dlog
  68.  
  69.  
  70. set baseLineList [VtGetValues $label -baseLineList]
  71. set width      [VtGetValues $label -width]
  72. set height      [VtGetValues $label -height]
  73.  
  74. set str "$str\nLabel baseLineList is <$baseLineList>"
  75. set str "$str\n   width - <$width> height <$height>"
  76. VtSetValues $txt -value $str
  77.  
  78. set lblBaseLine [lindex $baseLineList 0]
  79.  
  80. if {$txtBaseLine > $lblBaseLine} {
  81.     set diff [expr $txtBaseLine - $lblBaseLine]
  82.  
  83.     VtSetValues $txt -topOffset 4
  84.     VtSetValues $label -topOffset [expr 4 + $diff]
  85. } else {
  86.     set diff [expr $lblBaseLine - $txtBaseLine]
  87.  
  88.     VtSetValues $label -topOffset 4 
  89.     VtSetValues $txt -topOffset [expr 4 + $diff]  
  90. }
  91.  
  92. #
  93.  
  94. # baselines don't work in charm
  95. if {[VtInfo -charm]} {
  96.     VtSetValues $label -topOffset 1
  97.     VtSetValues $txt   -topOffset 0
  98.  
  99.  
  100.  
  101. # UnComment this for automatic behaviour
  102. #VtAddTimeOut -interval 2000 -callback TestCB
  103.  
  104. VtMainLoop
  105.