home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / tls / tls074c.sunsparc.Z / tls074c.sunsparc / lib / vtcl / examples / short.tcl < prev   
Encoding:
Text File  |  1995-07-20  |  2.4 KB  |  77 lines

  1. #!/bin/vtcl
  2. # ---------------------------------------------------------------------
  3. # Copyright 1994 by SCO, Inc.
  4. # Permission to use, copy, modify, distribute, and sell this software
  5. # and its documentation for any purpose is hereby granted without fee,
  6. # provided that the above copyright notice appear in all copies and that
  7. # both that copyright  notice  and  this  permission  notice  appear  in
  8. # supporting documentation, and that the name  of  SCO  not  be used  in
  9. # advertising or publicity pertaining  to distribution of  the  software
  10. # without   specific,   written  prior   permission.    SCO   makes   no
  11. # representations  about  the  suitability  of  this  software  for  any
  12. # purpose.  It is provided "as is" without express or implied warranty.
  13. # ---------------------------------------------------------------------
  14.  
  15. # Demo        : short.tcl
  16. # Description    : Silly demo of how to use point help a la the
  17. #          -shortHelpCallback option.
  18. #  
  19.  
  20. # Close connection and exit Vtcl interpreter.
  21. proc CloseCB { cbs } {
  22.     VtClose; exit 0
  23. }
  24.  
  25. # We need to deal with case when vtcl is not in a standard place
  26. if { [ catch { set pixDir $env(VTCL_HOME)/pixmaps } errorMsg ] != 0 } {
  27.     # VTCL_HOME is not set; assume standard place
  28.     set pixDir /lib/vtcl/pixmaps
  29.  
  30. set pixList  [list check.px dir.px file.px newicon.px odir.px exec.px]
  31. set origExpressionsList [list oops! umph! uh-oh! "on no!" phooey! whoa! bummer!]
  32. set expressionsList $origExpressionsList  
  33.  
  34. proc SwitchPixMapCB {cbs} {
  35.     global pixList expressionsList origExpressionsList oopsLbl pixDir
  36.     set newPix [lvarpop pixList]
  37.     set widget [keylget cbs widget] 
  38.     VtSetValues $widget -pixmap $pixDir/$newPix
  39.     lvarpush pixList $newPix len
  40.     if { [llength $expressionsList] != 0 } {
  41.         VtSetValues $oopsLbl -label [lvarpop expressionsList]
  42.     } else {
  43.         # re-load
  44.         set expressionsList $origExpressionsList  
  45.     }
  46. }
  47.  
  48. set app [VtOpen joe]
  49. set mainForm [VtFormDialog $app.mainForm \
  50.     -title "Short Stuff" \
  51.     -ok \
  52.     -okCallback CloseCB \
  53.     ]
  54.  
  55. set lbl [VtLabel $mainForm.lbl \
  56.     -label "Put your mouse over\nan elusive pixmap!" \
  57.     ]
  58. set rowCol [VtRowColumn $mainForm.rowcol \
  59.     -topSide $lbl \
  60.     -numColumns 3 \
  61.     -vertical \
  62.     ]
  63. foreach item $pixList {
  64.     set itemName [lindex [split $item . ] 0 ]
  65.     VtLabel $rowCol.$itemName \
  66.         -pixmap $pixDir/$item  \
  67.         -shortHelpCallback SwitchPixMapCB 
  68. }
  69. set oopsLbl [VtLabel $mainForm.oops \
  70.     -topSide $rowCol \
  71.     -label "    " \
  72.     -xmArgs "background white" \
  73.     ]
  74. VtShow $mainForm
  75. VtMainLoop
  76.