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 : decor.tcl
- # Description : Example usage of "-wmDecoration" option for dialogs.
- # Comments : This demo allows the user to configure the window
- # decoration of child pop-up forms.
- # Highlights - use of associative array
- # - lsearch, linsert for finding and removing list items.
- # - modeless child dialogs
- #
-
- # Build an array of explanations using the name of the decor parameter
- # as the index.
- #
- set decorArray(BORDER) \
- "Creates the border around the form.\nUse middle mouse button to move"
- set decorArray(TITLE) "Turns on the title bar at the top of the form."
- set decorArray(RESIZE) "Allows the form to be resized."
- set decorArray(MENU) "Makes the menu pulldown available at the top left corner."
- set decorArray(MINIMIZE) "Allows the form window to be minimized."
- set decorArray(MAXIMIZE) "Allows the form window to be maximized."
- set decorArray(ALL) \
- "Turns on BORDER, TITLE, RESIZE, MENU, MINIMIZE and MAXIMIZE."
- set decorationList {}
-
- # Close the display engine connection; exit the vtcl interpreter.
- #
- proc QuitProgramCB {cbs} {
- # You can put multiple commands on the same line using ';'
- VtClose; exit 0
- }
-
- proc DestroyFormCB {cbs} {
- VtDestroyDialog [keylget cbs dialog]
- }
-
- # Build the list of selected option parameters by appending to a
- # globally-known list.
- #
- proc SetDecorList {cbs} {
- global decorationList
- set decorItem [WxGetShortName [keylget cbs widget]]
- set tmpList $decorationList
- set position [lsearch $tmpList $decorItem]
- if {$position > -1} {
- set tmpList [lreplace $tmpList $position $position]
- } else {
- set tmpList [linsert $tmpList 0 $decorItem]
- }
- set decorationList [lsort $tmpList]
- if { ! [VtInfo -charm] } {
- echo name:$decorItem
- echo list:$decorationList
- }
- }
-
- #
- # - Uses the "-modeless" option so that the user can generate
- # a series of child dialogs in order to compare their window
- # decoration.
- #
- proc MakeForm {cbs} {
- global decorationList decorArray
- set parent [keylget cbs dialog]
- set form [VtFormDialog parent.decForm \
- -title "Directive: $decorationList" \
- -wmDecoration $decorationList \
- -modeless \
- -okCallback DestroyFormCB \
- -xmArgs "XmNbackground white" \
- ]
- set lbl [VtLabel $form.lbl \
- -label "This dialog has the following decoration:" \
- -xmArgs "XmNbackground white" \
- ]
- set rowCol [VtRowColumn $form.rowCol \
- -numColumns 1 \
- -topSide $lbl \
- ]
-
- if {$decorationList == {}} {
- VtLabel $rowCol.lbl \
- -allowDuplicateName \
- -xmArgs "XmNbackground white" \
- -label "You're looking at bare bones window dressing."
- } else {
- foreach decor $decorationList {
- VtLabel $rowCol.lbl \
- -allowDuplicateName \
- -xmArgs "XmNbackground white" \
- -label "$decor:\n$decorArray($decor)"
- }
- }
- VtShow $form
- }
-
- proc PostCharmInfo {parent} {
- VtShow [VtInformationDialog $parent.ibox \
- -message "Because there is no Motif window manager\n \
- in the character environment, this demo \n \
- is only useful in the X/Motif environment." \
- -ok \
- -okCallback QuitProgramCB \
- ]
- VtMainLoop
- }
-
- set decorationList {}
- # Make connection with the display engine
- #
- set appShell [VtOpen decor]
-
- if { [VtInfo -charm] } {
- PostCharmInfo $appShell
- }
-
- set dlog [VtFormDialog $appShell.form \
- -title "Demo: Window Decoration" \
- -wmDecoration ALL \
- -wmCloseCallback QuitProgramCB \
- ]
-
- set labelW [VtLabel $dlog.label \
- -label "Select a button to see the effect\nthat each property has on\na newly-created form" \
- -rightSide FORM \
- -font largeBoldFont \
- ]
-
- set rcW [VtRowColumn $dlog.rowcol\
- -topSide $labelW\
- -rightSide FORM \
- -numColumns 4 \
- ]
-
- foreach button {ALL RESIZE TITLE BORDER MENU MINIMIZE MAXIMIZE} {
- set ${button}TogB [VtToggleButton $rcW.${button} \
- -label $button \
- -callback SetDecorList \
- ]
- }
- set makeFormPushB [ VtPushButton $dlog.makeFormPushB \
- -topSide $rcW \
- -label "Construct Form" \
- -labelCenter \
- -width 100 \
- -font medBoldFont \
- -rightSide FORM \
- -callback MakeForm \
- ]
-
- VtPushButton $dlog.quitPushB \
- -topSide $makeFormPushB \
- -topOffset 0 \
- -label "Quit" \
- -labelCenter \
- -font medBoldFont \
- -rightSide FORM \
- -bottomSide FORM \
- -callback QuitProgramCB
-
- VtShow $dlog
- VtMainLoop
-