home *** CD-ROM | disk | FTP | other *** search
- # wtest
- # This is a demonstration file giving simple examples of the w commands
-
-
- #This loads the standard font and colour names.
-
- source {<tcl$Dir>.!Choices}
-
-
- #This initialises the w system. "wtest" will be used for the name of the program
- # in the Tasks display window
- #The sprite file "testsprites" is loaded into a user sprite area from the
- # application directory.
-
- w_init wtest testsprite
-
-
- # Load a library to report errors
-
- source {<tcl$Dir>.library.debug}
-
-
- # load tests for w_text w_draw w_box
-
- source {<wtest$Dir>.texttest}
- source {<wtest$Dir>.drawtest}
- source {<wtest$Dir>.dboxtest}
-
-
- # load tests for w_task w_send
-
- source {<wtest$Dir>.tasktest}
-
- # Make a dialog box for the info entry on the iconbar menu
- # It is called "progInfo"
- # Its title is "About this program"
- # It has a vertical list of four info boxes displaying text.
-
- w_box progInfo create "About this program"\
- { vlist {info Name wtest}
- {info Purpose "w example"}
- {info Author C.T.Stretch}
- {info Version 0.01}
- }
-
-
- #Put the "!wtest" icon on the iconbar
- #Give it a menu, and a procedure to run if it clicked on.
- #The menu has title "wtest".
- #It has two entries, one opens the progInfo dialog box created above,
- #The other runs the script "exit" if it is clicked on.
- #If the icon is clicked the procedure clickproc will be called
- #with a string representing the button used
-
- w_bar -menu " wtest {Info -dbox progInfo}
- $commsentry
- {Text -click textopen}
- {Draw -click drawopen}
- {Box -click boxopen}
- {Quit -click exit}
- "\
- -click {clickproc %b}\
- -drag {dragproc %t}
-
- #Create a text document to display results of various actions.
- #proc noclose is called if you attempt to close the window,
- #it displays a wimp error box. If you select OK the program quits.
- #If you select Cancel noclose returns, the close script returns "show"
- #so the window is not closed.
-
- w_text woutput create -title "Output from wtest"\
- -close { noclose %w
- return show
- }
-
- proc noclose {winname}\
- { set xit [w_error "wtest will quit if you close this window" -ok -cancel]
- show "Close window" "Window name (%w) = $winname"
- if $xit exit
- }
-
-
- #Open a window on this document
-
- w_text woutput open
-
-
- #procedure to display output in document
-
- proc show {where args}\
- { w_text woutput print
- w_text woutput options -pon
- w_text woutput print |cred|$where
- w_text woutput options -poff
- foreach what $args\
- { w_text woutput write $what
- }
- }
-
-
- #This procedure is called when the iconbar icon is clicked on.
- # button will be set to "s" if select was used and "a" if alter was used.
- # "S" or "C" will be added if the shift or control keys were held down.
-
- proc clickproc {button}\
- { show "Iconbar click" "button string (%b) = $button"
- }
-
-
- #This procedure is called if a file is dragged to the iconbar icon.
- #type is set to the file type.
- #w_where is set to the file name.
-
- proc dragproc {type}\
- { global w_file
- show "Iconbar drag" "type string (%t) = $type" "filename (w_file) = $w_file"
- }
-
-
-