!------------------------------------------------------------------------------!
! DRs addressed:
!   Bug #   GBug #    Description
!   ------- --------  -----------
!   NA      11902     
!   173     508244-3  Set row does not maintain enumerations.
!                     The column shows the number instead of enumeration name.
!
! NOTE:  this is an interactive test and requires operator verification
!        in order to determine test success.
!
!   Author : ?
!------------------------------------------------------------------------------!
startmacro
  ! NXM-3845 since NeXtMidas 4.1.1
  pipe on
    panel/id=panel/setup/msgid=main/controls=gc
    res data_file template_color_enum_data_ram{AUX=RAM}
    res key_file template_color_enum_ram.key{AUX=RAM}
    res template_file template_color_enum_ram{AUX=RAM}
    file copy nxm.sys.test.template_color_enum_data.prm data_file
    file copy nxm.sys.test.template_color_enum.key key_file
    header/create template_file

    keyword template_file fset
    list/id=idlist/win=pane1/msgid=main data_file template_file hilite=back hcolor=blue autoselect=no

    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" "First select ADD ROWS from ACTION menu..." 24 10 /title
    gcontrol label options OPTIONS AlwaysOpen
    gcontrol choice "ACTION"     "Action" "Add Rows,Change Color,Change BG,Set Row" 0
    set reg.panel.MW.setTitle "TEST_LIST_TEMPLATE_COLOR_ENUM"
  pipe off
endmacro

procedure processMessage
  if msg.name eqs "ACTION" then
    if msg.data eqss "ADD ROW" then
      set reg.idlist.addrow {NAME=BAH,FLD1=2,COLR=2}
      set reg.idlist.addrow {NAME=BAH,FLD1=2,COLR="1"} ! DR 173 g508244-3
      set reg.idlist.addrow {NAME=BAH,FLD1="",COLR=1}  ! DR 266 g542564-1
      set gc.idtext.value "Should see 3 rows: first one green, second two yellow. &
                                           Values are:\n&
                                           BAH,2,GREEN and \n&
                                           BAH,2,YELLOW and \n&
                                           BAH,,YELLOW. \n&
                                           Next select Change Color from the ACTION menu, &
                                           and pick a color from the enumerated &
                                           popup in the COLOR column..."
      ! Note: Instructions updated to expect '2', since FLD1 is specified as a L: in the prm template file

    elseif msg.data eqs "CHANGE COLOR" then
      gcontrol/panel=panel/handle=colrs/wait menu "COLORPICK" "Color" "0-Red,1-Yellow,2-Green,3-Blue"
      set colrs.itemcolors {"0-Red"=RED,"1-Yellow"=YELLOW,"2-Green"=GREEN,"3-Blue"=BLUE}
      set gc.idtext.value "Colors should match your choices. Next select CHANGE BG from ACTION menu..."
      sedit COLORPICK colorNum TRIM ,, "-"
      set numRows reg.idlist.numRows
      do i 1 numRows
        set reg.idlist.setcell {ROW=^i,COLUMN="COLR",value=^colorNum}
      enddo

    elseif msg.data eqs "CHANGE BG" then
      gcontrol/handle=bgcolor/wait menu "BGCOLORPICK" "Color" "Red,Yellow,Green,Blue"
      set numRows reg.idlist.numRows
      do i 1 numRows
        set reg.idlist.setrowcolors {ROW=^i,BG=^bgcolorpick}
      enddo
      set gc.idtext.value "Background color should match your choice. Next select SET ROW from ACTION menu..."

    elseif msg.data eqs "SET ROW" then
      gcontrol/handle=bgcolor/wait menu "COLORPICK" "Color" "0-Red,1-Yellow,2-Green,3-Blue"
      sedit COLORPICK colorNum TRIM ,, "-"
      set numRows reg.idlist.numRows
      do i 1 numRows
        calc oddEven i 2 MOD
        if oddEven EQ 0 then
          set reg.idlist.setrow(^i) {NAME=BAH,FLD1=2,COLR=^colorNum}
        else
          set reg.idlist.setrow(^i) {NAME=BAH,FLD1=2,COLR="^colorNum"}
        endif
      enddo
      set gc.idtext.value "Colors should match your choices.  &
                                           If you have selected all options from ACTION menu...&
                                           click EXIT with appropriate status"

    else 
      warning "^reg.main.name: Unrecognized msg ^msg.name"
    endif
  elseif msg.name eqs "MAIN" then
    assert/text="List tests - DR 11902 and 508244-3" "PASS" SUBS msg.data
    erase template_file
    pipe stop

  elseif msg.name EQS "SELECT"
    ! no action
  else 
    warning "^reg.main.name: Unrecognized msg ^msg.name"
  endif
return
