home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / tls / tls035c.1 / lib / vtcl / examples / beep.tcl / beep.tcl
Encoding:
Text File  |  1995-03-23  |  3.2 KB  |  135 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. # Demo of the use of "VtBeep"
  15. # - Set the pitch, duration and volume.
  16. #
  17. proc DoQuit {cbs} {
  18.     VtClose
  19.     exit 0
  20. }
  21.  
  22. proc SetPitch {value cbs} {
  23.     global pitch 
  24.     set pitch $value
  25. }
  26. proc SetVolume {value cbs} {
  27.     global volume 
  28.     set volume $value
  29. }
  30. proc SetDuration {value cbs} {
  31.     global duration 
  32.     set duration $value
  33. }
  34. #
  35. # Callback that invokes VtBeep with the current values.
  36. #
  37. proc beep {cbs} {
  38.     global pitch duration volume
  39.     echo pitch:$pitch duration:$duration volume:$volume
  40.     VtBeep -duration $duration \
  41.     -pitch $pitch \
  42.     -volume $volume
  43. }
  44.  
  45. # Open connection to Widget Server
  46. set app [VtOpen joe]
  47. set mainF [VtFormDialog $app.mainF -title "beep program"]
  48.  
  49. # Create radiobox for setting the Pitch value
  50. #
  51. set pitchFR [VtFrame $mainF.pitchFR \
  52.     -title "Pitch" \
  53.     -shadowType ETCHED_OUT \
  54.     ]
  55. set pitchRB [VtRadioBox $pitchFR.pitchRB \
  56.     ]
  57. VtToggleButton $pitchRB.pitchLow \
  58.     -label Low \
  59.     -callback "SetPitch 100"
  60. VtToggleButton $pitchRB.pitchMed \
  61.     -label Medium \
  62.     -callback "SetPitch 500" \
  63.     -set 1
  64. VtToggleButton $pitchRB.pitchHigh \
  65.     -label High \
  66.     -callback "SetPitch 1000"
  67. set pitch 500
  68.  
  69. # Create radiobox for setting the volume value
  70. #
  71. set volFR [VtFrame $mainF.volFR \
  72.     -title "Volume" \
  73.     -shadowType ETCHED_OUT \
  74.     -leftSide $pitchFR \
  75.     -alignTop $pitchFR \
  76.     ]
  77. set volRB [VtRadioBox $volFR.volRB \
  78.     ]
  79. VtToggleButton $volRB.volLow \
  80.     -label Off \
  81.     -xmArgs "XmNforeground red" \
  82.     -callback {SetVolume {-100}}
  83. VtToggleButton $volRB.volMed \
  84.     -label Normal \
  85.     -callback {SetVolume 50} \
  86.     -set 1
  87. VtToggleButton $volRB.volHigh \
  88.     -label Loud \
  89.     -callback {SetVolume 100}
  90. set volume 50
  91.  
  92. # Create radiobox for setting the duration value
  93. #
  94. set durationFR [VtFrame $mainF.durationFR \
  95.     -title "Duration" \
  96.     -shadowType ETCHED_OUT \
  97.     -leftSide $volFR \
  98.     -rightSide FORM \
  99.     -alignTop $volFR \
  100.     ]
  101. set durationRB [VtRadioBox $durationFR.durationRB \
  102.     ]
  103. VtToggleButton $durationRB.durationLow \
  104.     -label "Short (.1 sec)" \
  105.     -callback {SetDuration 100}
  106. VtToggleButton $durationRB.durationMed \
  107.     -label "Normal (.5 sec)" \
  108.     -callback {SetDuration 500} \
  109.     -set 1
  110. VtToggleButton $durationRB.durationHigh \
  111.     -label "Long (1 sec)" \
  112.     -callback {SetDuration 1000}
  113. set duration 500
  114.  
  115. set rc [VtRowColumn $mainF.rc\
  116.      -leftSide FORM    \
  117.      -rightSide FORM    \
  118.     -topSide $volFR\
  119.     -packing COLUMN\
  120.     -bottomSide FORM\
  121.     -horizontal \
  122.     ]
  123. set pb [VtPushButton $rc.pb \
  124.     -label "Beep" \
  125.     -callback beep \
  126.     ]
  127. set quit [VtPushButton $rc.quit \
  128.     -label "Quit" \
  129.     -callback DoQuit \
  130.     ]
  131.  
  132. VtShow $mainF
  133. VtMainLoop
  134.  
  135.