!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! @author Jay Hallam
!
! Tests out the textdisplay function in libg.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
startmacro

switch INTERACTIVE interAct GET DEF=TRUE
if interAct then

  result status 1

  pipe init
    panel/msgid=MAIN/setup/controls=gc
    gcontrol label macro "MACRO"
    gcontrol menu main "Exit with Status = " "PASS,FAIL" /tleft
    set gc.main.itemcolors {PASS=GREEN,FAIL=RED}
    gcontrol text directions "Instructions" &
                              "Expected:\n&
                              'Hello!' in the TEXTDISPLAY window.\n\n&
                              Press the TESTS buttons to perform tests." 20 10 /title

    gcontrol menu test "Tests" "Table,Large Text" 0 /button /nc=2
    gcontrol button textColors "Selected Text Color" "Blue,Green,Red,White"  "Blue"   ! /nc=2
    gcontrol button bgColors "Selected Text BG Color" "Blue,Green,Red,White" "Red"    ! /nc=2
    
    textdisplay/id=td/scroll=V/exit=none/title="Text Display Box" text="Hello!"
    
    ! intial settings
    set reg.td.SelectedTextColor "BLUE"
    set reg.td.selectionColor "RED"
  pipe off

endif

endmacro


procedure processMessage

  if msg.name eqs "MAIN" then
	  if msg.data eqs "PASS" then
	    assert/text="^reg.main.name: user indicated" true
	  else
	    assert/text="^reg.main.name: user indicated" false
	  endif
	  pipe stop
	elseif msg.name eqs "TEXTCOLORS" then
	  set reg.td.SelectedTextColor ^msg.data
	  invoke ,, reg.td.mw.refresh()
	elseif msg.name eqs "BGCOLORS" then
	  set reg.td.selectionColor ^msg.data
	  invoke ,, reg.td.mw.refresh()
  elseif msg.name eqs "TEST" then
    if msg.data EQS "TABLE" then
    ! Table test
    result t:tab {LEVEL=1,STRING="String not indented"}
    result tab.level2 {LEVEL=2,STRING="String indented"}
    result tab.level2.level3 {LEVEL=3,STRING="String indented twice"}
    message send TD ,,REPLACE,,tab
    set msgString "Should see a TABLE with 3 levels, indented at each level."
    set gc.directions.value msgString
    else
      ! Large text
      set largeText "A very long string &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx &
	      xxxxxxxxxxxxxxxxxxxxxx"
	    message send TD ,,REPLACE,,largeText
	    set msgString "A scrollbar should appear.\n\n&
	                   The display should be a string &
	                   with a carriage return before the long string of xxx's\n\n&
	                   1) Change the color of the\n   &
	                      highlighted text\n&
	                   2) Highlight some text and observe."
	    set gc.directions.value msgString
	
	  endif
	else
  !!!say "Got msg ^msg.name"

	endif
return
