home *** CD-ROM | disk | FTP | other *** search
- #Variables
- global lab1 menu
-
- # setup pixmap directory
-
- #Procedures
-
- #Procedure to set scale values
- proc setFields {form} {
- global scale1 scale2
-
- set value [VtGetValues $scale1 -value]
-
- VtSetValues $form.value_txt -value $value
- }
-
- proc valueCB {option cbs} {
-
- global scale1 scale2
-
- set widget_value [keylget cbs value]
- VtSetValues $scale1 $option $widget_value
- VtSetValues $scale2 $option $widget_value
- }
-
- proc scaleCB {option form cbs} {
- valueCB $option $cbs
- setFields $form
- }
-
- #Procedure to show scale values
- proc showValueCB {option cbs} {
-
- global scale1 scale2
-
- #
- #toggle button uses "set" not "value"
- #
- set widget_value [keylget cbs set]
-
- VtSetValues $scale1 $option $widget_value
- VtSetValues $scale2 $option $widget_value
- }
-
- #List procedure to carry list value into ComboBox widget.
- proc listCB { cbs } {
- global combo
- set selectedItemList [keylget cbs selectedItemList]
- set listItem [lvarpop selectedItemList]
- set list [VtGetValues $combo -itemList]
- set list [concat $list $listItem]
- VtSetValues $combo -itemList $list
- }
-
- #Procedure to get the selected value from the ComboBox
- #and create a message dialog containing the string.
- proc optMenuCB { cbs } {
- set value [keylget cbs value]
- set parent [keylget cbs widget]
- set message [VtMessageDialog $parent.message -message $value]
- VtShow $message
- }
-
- #Procedure to get selected value from options Menu widget and
- #create a information dialog box containing the string.
- proc infoCB {car cbs} {
- set parent [keylget cbs widget]
- set info [VtInformationDialog $parent.info -message $car]
- VtShow $info
- }
-
- #Procedure to display an information dialog box
- proc info2CB { cbs } {
- set parent [keylget cbs widget]
- set info [VtInformationDialog $parent.info \
- -message "This is an Information Dialog Box" \
- ]
- VtShow $info
- }
-
- #Procedure to display an error dialog box
- proc errorCB { cbs } {
- set parent [keylget cbs widget]
- set error [VtErrorDialog $parent.error \
- -message "This is an Error Dialog Box" \
- ]
- VtShow $error
- }
-
- #Procedure to display a message dialog box
- proc messageCB { cbs } {
- set parent [keylget cbs widget]
- set message [VtMessageDialog $parent.message \
- -message "This is a message Dialog Box" \
- ]
- VtShow $message
- }
-
- #Procedure to display a warning dialog box
- proc warningCB { cbs } {
- set parent [keylget cbs widget]
- set warning [VtWarningDialog $parent.warning \
- -message "This is a Warning Dialog Box" \
- ]
- VtShow $warning
- }
-
- #Procedure to display a working dialog box
- proc workingCB { cbs } {
- set parent [keylget cbs widget]
- set working [VtWorkingDialog $parent.working \
- -message "This is a Working Dialog Box" \
- ]
- VtShow $working
- }
-
- #Procedure to display a question dialog box
- proc questionCB { cbs } {
- set parent [keylget cbs widget]
- set question [VtQuestionDialog $parent.question \
- -message "This is a Question Dialog Box" \
- ]
- VtShow $question
- }
-
- #Procedure to display a working dialog box
- #envoked from within Pulldown widget option
- proc working2CB { cbs } {
- set parent [keylget cbs widget]
- set working [VtWorkingDialog $parent.working \
- -message "Searching for records..." \
- ]
- VtShow $working
- }
-
- #Procedure to display an information dialog box
- #envoked from Baud pulldown menu option
- proc baudCB { baud cbs } {
- set parent [keylget cbs widget]
- set info [VtInformationDialog $parent.info \
- -message $baud \
- ]
- VtShow $info
- }
-
- #Procedure to display an information dialog box
- #envoked from Port pulldown menu option
- proc portCB { port cbs } {
- set parent [keylget cbs widget]
- set info [VtInformationDialog $parent.info \
- -message $port \
- ]
- VtShow $info
- }
-
- #Procedure to display an error dialog box
- #envoked from comm port 3 Port pulldown menu option
- proc badPortCB { port cbs } {
- set parent [keylget cbs widget]
- set error [VtErrorDialog $parent.error \
- -message $port \
- ]
- VtShow $error
- }
-
- #Procedure to sound a high pitch beep
- proc beepCB { cbs } {
- VtBeep -duration 200 \
- -pitch 500 \
- -volume 10 \
- }
-
- #Procedure to sound a low pitch beep
- proc beep2CB { cbs } {
- VtBeep -duration 400 \
- -pitch 100 \
- -volume 10 \
- }
-
- #procedure to close application Periodic
- proc closeCB { cbs } {
- VtClose
- }
-
- #Procedure to envoke the file selection dialog box
- proc fileCB { cbs } {
- set parent [keylget cbs widget]
- set dialog [VtFileSelectionDialog $parent.file \
- -dirListLabel "Top Secret Directories" \
- -fileListLabel "Top Secret Files" \
- ]
- VtShow $dialog
- }
-
- #Procedure to envoke the selection dialog box
- proc selectCB {cbs } {
- set parent [keylget cbs widget]
- set dialog [VtSelectionDialog $parent.select \
- -itemList {EmailAddress1 EmailAddress2 EmailAddress3 EmailAddress4} \
- -selection "EmailAddress1" \
- ]
- VtShow $dialog
- }
-
- proc genericCB { cbs } {
- set target [keylget cbs widget]
- }
-
- #set the main environment and the Form window
- set appShell [VtOpen Periodical]
-
- VtSetAppValues $appShell -versionString "Visual Tcl Periodic Table v1.0 C1"
-
- set mainForm [VtForm $appShell.mainForm \
- -horizontalSpacing 50 \
- -verticalSpacing 50 \
- -resizable TRUE \
- ]
-
- #set the menubar options
- set menuList1 {
- { pd File F }
- {bt "Open" O "Ctrl<Key>O" "Crtl+O" fileCB}
- {bt "New.." N "Ctrl<Key>N" "Ctrl+N"}
- {bt Exit E "Ctrl<Key>E" "Ctrl+E" closeCB}
- { pd Edit E }
- {bt Cut C "Ctrl<Key>X" "Ctrl+X"}
- {bt Copy o "Ctrl<Key>C" "Ctrl+C"}
- {bt Paste P "Ctrl<Key>V" "Ctrl+V"}
- {bt Select All A "Ctrl<Key>A" "Ctrl+A"}
- { sp }
- {bt Delete D "<key>Delete" Delete }
- {pd View V }
- {bt Some S "Ctrl<Key>S" "Ctrl+S" }
- {bt Parts P "" }
- { pd Printer P }
- {bt "New Printer" N }
- { sp }
- {tb "Printer 1: Dot Matrix"}
- {tb "Printer 2: Ink Jet"}
- {tb "Printer 3: Laser Jet"}
- { pd Test T }
- {bt "Sensitive Target..."}
- {bt "Make UnSensitive"}
- {bt "Make Sensitive"}
- }
-
- #MenuBar Widget
- set menubar [VtMenuBar $mainForm.menubar \
- -helpMenuItemList {ON_VERSION INDEX TUTORIAL} \
- ]
-
- VxMenu $mainForm $menubar $menuList1 "genericCB"
-
- #Set Row Column Widget
- set rowcol [VtRowColumn $mainForm.rowcol \
- -numColumns 3 \
- -horizontal \
- -packing COLUMN \
- -spacing 5 \
- -topSide FORM \
- -topOffset 30 \
- -bottomSide FORM \
- -rightSide FORM \
- -leftSide FORM \
- ]
-
- #Scale Widget
- set frame2 [VtFrame $rowcol.frame2 \
- -shadowType ETCHED_IN \
- -title "Scale Widget" \
- ]
-
- set rc2 [VtRowColumn $frame2.rc2]
-
- set fm [VtForm $rc2.fm]
-
- set scale1 \
- [VtScale $fm.scale_horz \
- -callback "scaleCB -value $fm" \
- -horizontal \
- -min 0 \
- -max 50 \
- -value 25]
-
- set scale2 \
- [VtScale $fm.scale_vert \
- -callback "scaleCB -value $fm" \
- -vertical \
- -min 0 \
- -max 50 \
- -value 25 \
- -topOffset 5 \
- -topSide $fm.scale_horz ]
-
- set value_lab \
- [VtLabel $fm.value_lab -label "Value:" \
- -topSide FORM \
- -leftSide $scale1 \
- -labelRight]
-
- set value_txt \
- [VtText $fm.value_txt \
- -topSide FORM \
- -callback "valueCB -value" \
- -columns 3 \
- -leftSide $value_lab]
-
- set showValue \
- [VtToggleButton $fm.showValue \
- -label "show value" \
- -value 1 \
- -callback "showValueCB -showValue" \
- -topOffset 25 \
- -topSide $value_txt \
- -leftOffset 100 \
- -rightSide FORM \
- ]
-
- #Toggle Button Widget
- set frame3 [VtFrame $rowcol.frame3 \
- -shadowType ETCHED_IN \
- -title "Toggle Button Widget" \
- ]
-
- set rc3 [VtRowColumn $frame3.rc3]
-
- set tbutton [VtToggleButton $rc3.tbutton \
- -callback beepCB \
- -set TRUE \
- -font largeBoldFont \
- -value FALSE \
- -label "High Tone Beep" \
- ]
-
- set tbutton2 [VtToggleButton $rc3.tbutton2 \
- -callback selectCB \
- -set TRUE \
- -font largeItalicFont \
- -label "Selection Dialog...?" \
- -value FALSE \
- ]
- #Push Button Widget
- set frame4 [VtFrame $rowcol.frame4 \
- -shadowType ETCHED_IN \
- -title "Push Button Widget" \
- ]
-
- set rc4 [VtRowColumn $frame4.rc4]
-
- set pbutton [VtPushButton $rc4.pbutton \
- -callback beep2CB \
- -font monoBoldFont \
- -label "Low Tone Beep" \
- ]
-
- set pbutton2 [VtPushButton $rc4.pbutton2 \
- -callback fileCB \
- -font largeBoldFont \
- -label "Open File...?" \
- ]
-
- #Options Menu Widget
- set frame5 [VtFrame $rowcol.frame5 \
- -shadowType ETCHED_IN \
- -title "Label and Options Menu Widget" \
- ]
-
- set rc5 [VtRowColumn $frame5.rc5]
-
- set label [VtLabel $rc5.label \
- -font largeItalicFont \
- -label "A BIG LABEL" \
- ]
-
- set menu [VtOptionMenu $rc5.optmenu \
- -label "Pick One:" \
- ]
-
- set but1 [VtPushButton $menu.but1 \
- -font monoItalicFont \
- -label Ford \
- -callback { infoCB "Ford is a type of car" }
- ]
-
- set but2 [VtPushButton $menu.but2 \
- -font monoItalicFont \
- -label Vauxhall \
- -callback { infoCB "Vauxhall is a type of car" }
- ]
-
- set but3 [VtPushButton $menu.but3 \
- -font monoItalicFont \
- -label Rover \
- -callback { infoCB "Rover is a type of car" }
- ]
-
- set but4 [VtPushButton $menu.but4 \
- -font monoItalicFont \
- -label Ferrari \
- -callback { infoCB "Ferrari is a type of FAST car" }
- ]
-
- VtSetValues $menu -selectedWidget $but2
-
-
-
- #ComboBox Widget
- set frame6 [VtFrame $rowcol.frame6 \
- -shadowType ETCHED_IN \
- -title "ComboBox Widget" \
- ]
-
- set rc6 [VtRowColumn $frame6.rc6]
-
- set combo [VtComboBox $rc6.combo \
- -callback optMenuCB \
- -font largeItalicFont \
- -columns 10 \
- -rows 10 \
- -itemList {TimesRoman Helvetica Ariel Courier} \
- ]
-
- set combo2 [VtComboBox $rc6.combo2 \
- -callback optMenuCB \
- -font largeItalicFont \
- -columns 10 \
- -rows 10 \
- -readOnly \
- -itemList {TimesRoman Helvetica Ariel Courier} \
- ]
-
- #List Widget
- set frame7 [VtFrame $rowcol.frame7 \
- -shadowType ETCHED_IN \
- -title "List Widget" \
- ]
-
- set form7 [VtForm $frame7.form7]
-
- set list [VtList $form7.list \
- -font smallBoldFont \
- -columns 6 \
- -rows 5 \
- -itemList {file1 file2 file3 file4 file5 file6 file7} \
- -scrollBar TRUE \
- -bottomSide FORM \
- -rightSide FORM \
- ]
-
- #Text Widget
- set frame8 [VtFrame $rowcol.frame8 \
- -shadowType ETCHED_IN \
- -title "Text Widget" \
- ]
-
- set form8 [VtForm $frame8.form8]
-
- set text [VtText $form8.text \
- -columns 15 \
- -horizontalScrollBar TRUE \
- -verticalScrollBar TRUE \
- -rows 5 \
- -value "An example of text that can be edited" \
- -wordWrap \
- -bottomSide FORM \
- -rightSide FORM \
- ]
-
- #CheckBox Widget
- set frame9 [VtFrame $rowcol.frame9 \
- -shadowType ETCHED_IN \
- -title "CheckBox Widget" \
- ]
-
- set form [VtForm $frame9.form]
-
- set cbox [VtCheckBox $form.cbox \
- -vertical
- ]
-
- set tb1 [VtToggleButton $cbox.tb1 \
- -font smallItalicFont \
- -label "ScrollBars" \
- ]
-
- set tb2 [VtToggleButton $cbox.tb2 \
- -font smallItalicFont \
- -label "Auto Save" \
- ]
- set tb3 [VtToggleButton $cbox.tb3 \
- -font smallItalicFont \
- -label "Reverse Video" \
- ]
-
- VtSetValues $form.cbox -valueList {$tb1 $tb2 $tb3}
-
- #RadioBox Wodget
- set frame10 [VtFrame $rowcol.frame10 \
- -shadowType ETCHED_IN \
- -title "RadioBox Widget" \
- ]
-
- set form2 [VtForm $frame10.form2]
-
- set rbox [VtRadioBox $form2.rbox \
- -vertical
- ]
-
- set tb4 [VtToggleButton $rbox.tb4 \
- -font smallItalicFont \
- -label "Fast" \
- ]
-
- set tb5 [VtToggleButton $rbox.tb5 \
- -font smallItalicFont \
- -label "Medium" \
- ]
- set tb6 [VtToggleButton $rbox.tb6 \
- -font smallItalicFont \
- -label "Slow" \
- ]
-
- VtSetValues $form2.rbox -value $tb4
-
- #Frame 11 contains all six dialog boxes
- set frame11 [VtFrame $rowcol.frame11 \
- -shadowType ETCHED_IN \
- -title "Dialog Box Widget" \
- ]
-
- set rc11 [VtRowColumn $frame11.rc11 \
- -numColumns 2 \
- ]
-
- set pb1 [VtPushButton $rc11.pb1 \
- -width 30 \
- -labelCenter \
- -label "Error Dialog" \
- -callback errorCB \
- ]
-
- set pb2 [VtPushButton $rc11.pb2 \
- -width 30 \
- -labelCenter \
- -label "Message Dialog" \
- -callback messageCB \
- ]
-
- set pb3 [VtPushButton $rc11.pb3 \
- -width 30 \
- -labelCenter \
- -label "Information Dialog" \
- -callback info2CB \
- ]
-
- set pb4 [VtPushButton $rc11.pb4 \
- -width 30 \
- -labelCenter \
- -label "Warning Dialog" \
- -callback warningCB \
- ]
-
- set pb5 [VtPushButton $rc11.pb5 \
- -width 30 \
- -labelCenter \
- -label "Working Dialog" \
- -callback workingCB \
- ]
-
- set pb6 [VtPushButton $rc11.pb6 \
- -width 30 \
- -labelCenter \
- -label "Question Dialog" \
- -callback questionCB \
- ]
-
- #Pull Down Widget
- set frame12 [VtFrame $rowcol.frame12 \
- -shadowType ETCHED_IN \
- -title "Pulldown Menu Widget" \
- ]
-
- set rc12 [VtRowColumn $frame12.rc12]
-
- set menubar2 [VtMenuBar $rc12.menubar2]
-
- set pm [VtPulldown $menubar2.dial \
- -label "Dial" \
- ]
-
- set home [VtPulldown $pm.home \
- -label "Home" \
- ]
-
- set abroad [VtPulldown $pm.abroad \
- -label "Abroad" \
- ]
-
- set AtoM [VtPushButton $home.AtoM \
- -label "A - M" \
- -callback working2CB \
- ]
-
- set NtoZ [VtPushButton $home.NtoZ \
- -label "N - Z" \
- -callback working2CB \
- ]
-
-
- set aTOm [VtPushButton $abroad.aTOm \
- -label "A - M" \
- -callback working2CB \
- ]
-
- set nTOz [VtPushButton $abroad.nTOz \
- -label "N - Z" \
- -callback working2CB \
- ]
-
- set pm2 [VtPulldown $menubar2.settings \
- -label "Settings" \
- ]
-
- set baud [VtPulldown $pm2.baud \
- -label "Baud Rate" \
- ]
-
- set port [VtPulldown $pm2.port \
- -label "Comm Port" \
- ]
-
- set slow [VtPushButton $baud.slow \
- -label "2400 bps" \
- -callback {baudCB "2400 bps has been selected"} \
- ]
-
- set medium [VtPushButton $baud.medium \
- -label "9600 bps" \
- -callback {baudCB "9600 bps has been selected"} \
- ]
-
- set fast [VtPushButton $baud.fast \
- -label "14400 bps" \
- -callback {baudCB "14400 bps has been selected"} \
- ]
-
- set comm1 [VtPushButton $port.comm1 \
- -label "Comm Port 1"\
- -callback {portCB "Comm Port 1 is in operation"} \
- ]
-
- set comm2 [VtPushButton $port.comm2 \
- -label "Comm Port 2"\
- -callback {portCB "Comm Port 2 is in operation"} \
- ]
-
- set comm3 [VtPushButton $port.comm3 \
- -label "Comm Port 3"\
- -callback {badPortCB "Comm Port 3 cannot be located - Try another port"} \
- ]
-
- #Drawn List Widget
- set frame13 [VtFrame $rowcol.frame13 \
- -shadowType ETCHED_IN \
- -title "Drawn List Widget" \
- ]
-
- set form13 [VtForm $frame13.form13]
-
- set dlist [VtDrawnList $form13.dlist \
- -columns 20 \
- -rows 5 \
- -iconList {../tests/enemy.px ../tests/friend.px ../tests/turkey.px ../tests/exec.px ../tests/enemy.px } \
- -horizontalScrollBar TRUE \
- -formatList {{ICON 2} {STRING 15} {STRING 15}} \
- -selection MULTIPLE \
- -bottomSide FORM \
- -rightSide FORM \
- ]
-
- VtDrawnListAddItem $dlist \
- -fieldList [list 0 "Mark Hurst" "01954-781042"] \
- -itemBorder SOLID
-
- VtDrawnListAddItem $dlist \
- -fieldList [list 1 "Paul Marsh" "01954-780941"] \
- -itemBorder SOLID
-
- VtDrawnListAddItem $dlist \
- -fieldList [list 2 "Russell Mitchell" "01954-780642"] \
- -itemBorder SOLID
-
- VtDrawnListAddItem $dlist \
- -fieldList [list 3 "David Simpson" "01954-780558"] \
- -itemBorder SOLID
-
- VtDrawnListAddItem $dlist \
- -fieldList [list 4 "Ali Balentine" "01223-62890"] \
- -itemBorder SOLID
-
- #Show whole form with all widgets
- VtShow $mainForm
- VtMainLoop
-