!******************************************************************************!
! Test implementation of the "graying out" of Menu items
!
! @bug      2326: GControl/ GMenu: option to disable ('gray out') items in a menu
! @bug      1364: XBC: need to map ID of 1 to MAIN
! @author:  J Hallam / J Bauer
!******************************************************************************!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE  ! for normal interactive test(s)
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE  ! for defects or more obscure test case(s)

  if interAct then
    set instructions "This macro is to test disabling items within GMenus. &
                      Use the color buttons to change the color of a disabled item. &
                      Add and remove items using the ADD/ Remove button. &
                      Click on a button in GROUP A and the corresponding button &
                      in GROUP B should change color. &
                      Click on the button that is disabled and there should not be a &
                      message in the Shellgui. Click on an enabled button in GROUP B &
                      and you should see a message. "
    res i:counter 0

    pipe on
      panel/msgid=main/setup/controls=gc
        gcontrol label macro "Test MACRO"
          gcontrol menu  main "Exit with Status =" "PASS,FAIL" TABLE={ItemColors={PASS="GREEN",FAIL="RED"}} /tleft
          gcontrol text  idtext "Instructions" instructions 24 8 /title
        gcontrol/nc=3 button disColor "Select color of disabled item text" "Gray,Red,Green,Blue,Yellow,White" "Gray" &
                TABLE={ItemColors={GRAY="GRAY",BLUE="BLUE",YELLOW="YELLOW",WHITE="WHITE",GREEN="GREEN",RED="RED"}}
        gcontrol button changeButt "Add / Remove Buttons" "Add,Remove"
        gcontrol/nc=3 button selGrp "GROUP A: Click to Gray Out Choice Below" "A,B,C"
        gcontrol/nc=3 button graGrp "GROUP B: Item selected above should be grayed out below" "A,B,C"
        shellgui/id=idshellgui/attach

    pipe off

  endif
endmacro

!******************************************************************************!
! Main process message for this macro.
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 eqs "DISCOLOR" then
    set gc.graGrp.disabledItemColor ^msg.data
  elseif msg.name eqs "CHANGEBUTT" then
    if msg.data eqs "ADD" then
      calc l:counter counter 1 +
      invoke gc.selGrp.addItem("^counter")
      invoke gc.graGrp.addItem("^counter")
    else
      invoke gc.selGrp.remItem("^counter")
      invoke gc.graGrp.remItem("^counter")
      calc l:counter counter 1 -
    endif
  elseif msg.name eqs "SELGRP" then
    invoke enabled gc.graGrp.isItemEnabled("^msg.data")
    if enabled then
      set gc.graGrp.disableItem "^msg.data"
    else
      set gc.graGrp.enableItem "^msg.data"
    endif
  elseif msg.name eqs "GRAGRP" then
    invoke enabled gc.graGrp.isItemEnabled("^msg.data")
    if enabled then
      say "Item ^msg.data is ENABLED"
    else
      say "Item ^msg.data is DISABLED"
    endif
  else
    say "Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return

