home *** CD-ROM | disk | FTP | other *** search
- #!/bin/vtcl
- # ---------------------------------------------------------------------
- # Copyright 1994 by SCO, Inc.
- # Permission to use, copy, modify, distribute, and sell this software
- # and its documentation for any purpose is hereby granted without fee,
- # provided that the above copyright notice appear in all copies and that
- # both that copyright notice and this permission notice appear in
- # supporting documentation, and that the name of SCO not be used in
- # advertising or publicity pertaining to distribution of the software
- # without specific, written prior permission. SCO makes no
- # representations about the suitability of this software for any
- # purpose. It is provided "as is" without express or implied warranty.
- # ---------------------------------------------------------------------
-
- # Demo : align.tcl
- # Description : Example usage of "WxAlignedForm"
- # Comments : This demo shows how to use the convenience function
- # "WxAlignedForm" to group a series of "label - widget"
- # These convenience functions are stored in wserver.tlib
- # located in ./lib/vtcl or ./lib/wserver.
- # pairs to get a nice aligned, organized presentation.
- # Notes: - look at the use of VtInfo to get display info.
- #
-
- # Close connection and exit Vtcl interpreter.
- proc CloseCB { cbs } {
- VtClose; exit
- }
-
- # Callback that will echo (to stdout) the "type" of user
- # as indicated when using a toggle button in our form.
- proc EchoTypeCB {cbs} {
- set widget [keylget cbs selectedWidget]
-
- # Don't echo to stdout if in character environment.
- if { ! [VtInfo -charm] } {
- echo "Type: [WxGetShortName $widget]"
- }
- }
-
- #
- # Open connection with Visual Tcl display engine
- #
- set app [VtOpen alignedDemo]
-
- set dlog [VtFormDialog $app.dialog\
- -title "Demo: Use of WxAlignedForm" \
- -ok \
- -okCallback CloseCB \
- ]
-
- # Pass a list of lists, where each list contains
- # 1) the label, e.g. "Name:", and
- # 2) the widget command the label is to be associated with.
- #
- set form [WxAlignedForm $dlog.align\
- { {"Name:" {VtText -columns 15 -value "John Doe"}}
- {"Address:" {VtText -value "123 Hickory Street"}}
- {"Phone Number:" {VtText -value "800-555-1212"}}
- {"Status:" {VtRadioBox -numColumns 3 -borderWidth 1}}}]
-
- # attach the resulting form to the main dialog edges.
- VtSetValues $form \
- -leftSide FORM \
- -rightSide FORM
-
- # Note that the radiobox doesn't contain any buttons, yet.
- # To do so, we retrieve the name of the radiobox widget that was
- # assigned within the WxAlignedForm, using the index name "widget4"
- # since it was the 4th widget passed on the line. (See the doc
- # on WxAlignedForm!)
- #
- set statusbox [WxGetVar $form "widget4"]
-
- # assign a callback to the radiobox
- VtSetValues $statusbox \
- -callback EchoTypeCB
-
- # assign togglebuttons and their labels
- VtToggleButton $statusbox.friend \
- -label "Friend" \
- -value 1
- VtToggleButton $statusbox.enemy \
- -label "Enemy"
- VtToggleButton $statusbox.turkey\
- -label "Turkey"
-
- VtShow $dlog
- VtMainLoop
-