!------------------------------------------------------------------------------!
! Tests for LIST2 command.
!
!   Author : J. Czechowski IV
!------------------------------------------------------------------------------!
startmacro/tsetup=nxm.sys.test.test_list2_setup.tbl
  switch INTERACTIVE  interAct     GET DEF=TRUE
  switch standalone   standalone   GET DEF=TRUE
  switch COREGRAPHICS coregraphics GET DEF=FALSE SDEF=TRUE  ! for a quick check of graphics - more extreme tests - since 3.8.1

  if interAct OR coreGraphics then
    set instructions "Test of a custom renderer. This renderer will cause all values &
                      in the second column to be the reverse of what is in the first &
                      column (e.g. 'ABC' -> 'CBA')."

    set fileName test_file{AUX=RAM,FG=CSV,HEADERROWS=1}
    set template {FORWARD={},REVERSE={RENDERER="nxm.sys.test.BackwardsTextCellRenderer"}}

    file open/n tag fileName{COLUMNNAMES="FORWARD,REVERSE"}
      set tag.insertData(-1) {FORWARD="ABC",REVERSE="ABC"}
      set tag.insertData(-1) {FORWARD="123",REVERSE="123"}
      set tag.insertData(-1) {FORWARD="DOG",REVERSE="DOG"}
      set tag.insertData(-1) {FORWARD="COD",REVERSE="COD"}
    file close tag

    pipe init
      panel/msgid=MAIN/id=panel/controls=gc
      list2/grid=on/msgid=MAIN/id=idlist fileName template
      if standalone isTrue then
        gcontrol label  macro   "MACRO"
        gcontrol menu MAIN "Exit with Status = " "PASS,FAIL" /tleft
        set gc.MAIN.itemColors {PASS=GREEN,FAIL=RED}
      endif
      
      gcontrol text   idtext    "Instructions" "^{instructions}" 24 14 /title

    pipe off
  endif
endmacro

!------------------------------------------------------------------------------!
procedure processMessage m:msg
!
! Procedure for handling all messages
!
  if msg.name EQS "MAIN" then
    if msg.data EQS "EXIT" then
      pipe stop
    else
      assert/text="LIST2 tests" "PASS" SUBS msg.data
      pipe stop
    endif
  elseif msg.fid EQS "IDLIST" then
    !say "Got ^msg.name from ^msg.fid"
  
  elseif msg.name EQS "FONTSIZE" then
    invoke ,, reg.idlist.updateTemplate({_GLOBAL_={FONTSIZE=^{msg.data}}})

  elseif msg.name EQS "FONTSTYLE" then
    invoke ,, reg.idlist.updateTemplate({_GLOBAL_={FONTSTYLE=^{gc.fontStyle.value}}})

  elseif msg.name EQS "ROWHEIGHT" then
    if msg.data neq 0 then
      invoke ,, reg.idlist.updateTemplate({_GLOBAL_={ROWHEIGHT=^{msg.data}}})
    endif

  else
    say "Unhandled messagename: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif


return
