home *** CD-ROM | disk | FTP | other *** search
- # Test of the w_text document facilities
-
- #create a paragraph to be written by "write"
- #include font change sequences |f<fontname>|
- # colour change seqences |c<colourname>|
- # vertical bars ||
- # you can see the unprocessed string by writing with processing off
-
- set teststring "Some vertical bars:- |||||||| "
- set cnames [array names colours]
- set fnames [array names fonts]
- foreach f $fnames\
- { lappend teststring |f$f||cblack| $fonts($f)
- foreach c $cnames\
- { lappend teststring |c$c| $c
- }
- }
-
- #set up some variables to hold the tick status of menu entries
- #set up trace procedures to call when they are changed
-
- set lmargin 1
- set rmargin 0
- set justify 0
- set process 0
- trace variable lmargin w setlmargin
- trace variable rmargin w setrmargin
- trace variable justify w setjustify
- trace variable process w setprocess
-
-
- #set the left margin using the -l<length> option
-
- proc setlmargin {name element op}\
- { global lmargin
- w_text document options -l${lmargin}i
- }
-
-
- #set the right margin with the -r<length> option
-
- proc setrmargin {name element op}\
- { global rmargin
- w_text document options -r${rmargin}i
- }
-
-
- #set whether to justify or not using -j0 or -j1
-
- proc setjustify {name element op}\
- { global justify
- w_text document options -j$justify
- }
-
-
- #set whether to process || sequences using -p0 or -p1
-
- proc setprocess {name element op}\
- { global process
- w_text document options -p$process
- }
-
-
- #data for the menu
- #excercises print and write commands
- #and the -L -R and -C options for print
-
- set docmenu\
- { Document
- {Print -click {w_text document print "Hello World"}}
- {Write -click {w_text document write $teststring}}
- {Left -click {w_text document options -L}}
- {Center -click {w_text document options -C}}
- {Right -click {w_text document options -R}}
- {LMargin -tick lmargin}
- {RMargin -tick rmargin}
- {Justfy -tick justify}
- {Process -tick process}
- }
-
-
- #Create a text document called "document"
- #It has title "A text window"
- #If you close a window on it it the script "expr 2" will be run, as this
- # returns 2 the window will be closed but the document will still exist.
- #As yet there is no text in the window.
-
- w_text document create -title "A text window"\
- -fg black\
- -bg white\
- -width 6i\
- -height 30p\
- -size 20p\
- -close {expr 2}\
- -menu $docmenu
-
-
- #start with a 1 inch left margin
-
- w_text document options -l${lmargin}i
-
- #open a window on " document"
- #you can open several windows but the all show the same document.
-
- proc textopen {}\
- { w_text document open
- }