#! /usr/local/bin/wish

source "TkVSform.tcl"


set a(b) "  This is an updateable label"
set a(c) 0
set a(d) ""
set a(e) "This is an example of
a multiline text display
through a formMESSAGE widget."
set a(f) ""
set a(g) ""
set a(h) {This is an example of a
formTEXT widget.  The documented interface to the formTEXT
widget is:

formTEXT fvar statetag var [elem] [width] [height] [tkopts]
 
  Create a multi-line scrollable text input / output region widget
  on the current line of the form associated with the "fvar" global
  array variable.  "statetag" can be an arbitrary string (no white
  space) for managing enabling or disabling of this widget, or ""
  if not important.  "var" is the global variable to associate with
  the scrollable text region ("var" for this widget acts as if a Tk
  text widget had a "-textvariable" option [which it doesn't]).  If
  "var" is a global array variable, "elem" specifies the element in
  the array to associate with the widget.  "width" specifies the
  width of this widget is characters (defaults to 45) and "height"
  specifies the height of the widget in lines of text (defaults to 8).
  "tkopts" is a string containing any additional Tk options that you
  might want to optionally set for the text widget.  Should you wish
  to not allow input into this widget, but make it read-only, specify
  the "tkopts" string "-state disabled".
}
 


set a(i) "apples banannas grapes oranges mangos strawberries"
set a(z) ""

proc xxx {abc} {puts stderr "\nproc xxx:  argument is \[$abc\]\n"}

proc filllist {args} {
	puts stderr "\nproc filllist: arguments are"
	foreach x $args {puts stderr "  arg = \[$x\]"}
	puts stderr " "
	return "apples bannanas pears peaches kiwi oranges grapes cranberries"
}

proc gotlistset {args} {
	puts stderr "\nproc gotlistset:  arguments are"
	foreach arg $args {
		puts stderr "    argument = $arg"
	}
}

proc disappear {fvar {secs 5}} {
    global $fvar
    formSHOW $fvar off
    after [expr $secs * 1000] formSHOW $fvar on
}

proc validatepw {fvar path var elem} {
	puts stderr "\nproc validatepw:  arguments are"
	global $var
	set tvar $var
	if {$elem != ""} {set tvar "${tvar}($elem)"}
    puts stderr "  fvar = $fvar"
	puts stderr "  path = $path"
	puts stderr "  var  = $var"
    puts stderr "  elem = $elem"
	puts stderr "  password to validate = [set $tvar]\n\n"

}
formBEGIN f "Test of Form Features" "+100+100" "" MAIN
  formGROUP f
    formNEWLINE f
      formLABEL f "" "Label Test:  "
    formNEWLINE f
      formLABEL f "" "This is a label prompt" a b 45
  formGROUP f
    formNEWLINE f
      formLABEL f "" "Checkbox test:  "
    formNEWLINE f
      formCHECK f ""  "Voluntary donation to Steve?" a c
  formGROUP f
    formNEWLINE f
      formLABEL f "" "Radio Buttons Test:  "
    formNEWLINE f
      formRADIO f "" "Helvetica" a d
    formNEWLINE f
      formRADIO f "" "Times Roman" a d
  formGROUP f
    formNEWLINE f
      formLABEL f "test" "Button Test:  "
      formBUTTON f "test" "Push Here" xxx "{this is a test}" 15
  formGROUP f
    formNEWLINE f
      formLABEL f "test" "Message area Test:  "
      formMESSAGE f "test" a e
  formGROUP f
    formNEWLINE f
      formLABEL f "test" "Entry and Password Test:  "
    formNEWLINE f
      formLABEL f "test" "Give username:  "
      formENTRY f "test" a f 20
    formNEWLINE f
      formLABEL f "test" "Give password:  "
      formPASSWORD f "test" a g 20 validatepw 
  formGROUP f
    formNEWLINE f
      formLABEL f "" "Text area Test:  "
      formTEXT f "" a h 45 10
  formGROUP f
    formNEWLINE f
      formLABEL f "" "List Test:  "
      formLIST f "" filllist "" gotlistset "" 20 5
  formGROUP f
    formNEWLINE f
      formBUTTON f "test" "Disable State" formSTATE "f test off"
      formBUTTON f "" "Enable State" formSTATE "f test on"
      formBUTTON f "test" "Disappear for 5 seconds" disappear "f 5" 
      formBUTTON f "test" "Print contents of \"a\"" parray a
    formNEWLINE f
      formLABEL f "" " "
      set fitem [formBUTTON f "" "EXIT" "formDIE f; exit" 8]

formEND f on $fitem




