!------------------------------------------------------------------------------!
! Tests for LABEL in GCONTROL
!
!   Author : J. Czechowski IV
!------------------------------------------------------------------------------!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE  ! for normal interactive test(s)

  set instructions "You should be able to open/close the labels via the SETs &
                    or by clicking the label (when not in Always Open/Closed). &
                    Controls should be hidden when the label is Hidden or Closed. &
                    To hide/show LABEL 4 change its show state. Changing the state &
                    by clicking on the label itself should update the display above the labels."

  invoke states nxm.sys.libg.GLabel.activeList
  set initialState "Closed"

  set L:initialShowState 1

  if interAct then
    pipe on
      panel/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 idtext "Instructions" "^instructions" 24 12 /title

      gcontrol choice  state1    "set gc.label1.value" "^states" "^initialState" /tleft
      gcontrol choice  state2    "set gc.label2.value" "^states" "^initialState" /tleft
      gcontrol choice  state3    "set gc.label3.value" "^states" "^initialState" /tleft

      gcontrol choice  hideShowState    "set gc.label4.show"  "0,1" "^initialShowState" /tleft

      gcontrol label   label1   "Label  1" "^initialState"  /msg=y
      gcontrol prompt  prompt1  "Prompt 1" "Num 1" /edit=n /tleft
      gcontrol dval    dval1    "DVal   1" 1 -1e9 1e9    /edit=n

      gcontrol label   label2   "Label  2" "^initialState"  /msg=y
      gcontrol prompt  prompt2  "Prompt 2" "Num 2" /edit=n /tleft
      gcontrol dval    dval2    "DVal   2" 2 -1e9 1e9    /edit=n

      gcontrol label   label3   "Label  3" "^initialState"  /msg=y
      gcontrol prompt  prompt3  "Prompt 3" "Num 3" /edit=n /tleft
      gcontrol dval    dval3    "DVal   3" 3 -1e9 1e9    /edit=n

      gcontrol label   hideShowLab   "Label  4" "Open"  /msg=y
      gcontrol prompt  prompt4  "Prompt 4" "Num 4"      /edit=n /tleft
      gcontrol dval    dval4    "DVal   4" 4 -1e9 1e9   /edit=n


      set gc.HIDESHOWLAB.show ^initialShowState ! hide at startup

    pipe off
  endif
endmacro

!******************************************************************************!
! Procedure for handling all messages
procedure processMessage m:msg
  if msg.name EQS "MAIN" then
    assert/text="^reg.main.name: User indicated tests" msg.data eqss "PASS"
    pipe stop

  elseif msg.name eqss "STATE" then
    set num msg.name.substring(5)
    set gc.label^{num}.value gc.state^{num}.value

  elseif msg.name eqss "LABEL" then
    set num msg.name.substring(5)
    set gc.state^{num}.value gc.label^{num}.value

  elseif msg.name eqs "HIDESHOWSTATE" then
    set gc.HIDESHOWLAB.show ^msg.data

  else
    ! say "^reg.main.name: Unhandled messagename: ^msg.name from fid: ^msg.fid"
  endif
return

