!**************************************************************************************************!
! purpose: test list2 column resizing (BUG 1380)
!
! author : JWB
!**************************************************************************************************!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE

  call setDatDir

  if interAct then
    set instructions "Note the column width then press the first button to start the tests."

    ! the 4th city has a short name in cities.prm
    thin ^{datDir}.cities.prm junkcities.tmp{aux=ram}  4  5
    ! the 1st city has a long name in cities.prm
    thin ^{datDir}.cities.prm junkcities2.tmp{aux=ram} 2 3
    file open tag ^{datDir}.cities.prm
    res newcity  tag.getdata(2,"NAME")
    res origcity tag.getdata(4,"NAME")
    file close tag

    pipe on
      panel/msgid=MAIN/controls=gc/setup

      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" 40 9 /title

      gcontrol button openlist  "" "1. LIST NEXT FILE"
      gcontrol button opentempl "" "2. OPEN TEMPLATE"
      gcontrol button openorig  "" "3. LIST ORIG FILE"

      list2/id=idlist junkcities.tmp {NAME={}}
    pipe off

  endif

endmacro

procedure processMessage m:msg

  if msg.name eqs "MAIN"
    assert/text="^reg.main.name: user indicated" msg.data eqs "PASS"
    pipe stop

  elseif msg.name eqs "OPENLIST" then
    message send idlist,,"OPENFILE" ,, "junkcities2.tmp"
    set gc.idtext.value "The 'NAME' column in the list &
                    should expand to be wide enough to display the entire name &
                    of the new city (^{newcity})."

  elseif msg.name eqs "OPENORIG" then
    message send idlist,,"OPENFILE" ,, "junkcities.tmp"
    set gc.idtext.value "The original file (with ^{origcity}) should be back but keep the wide column width."

  elseif msg.name eqs "OPENTEMPL" then
    message send idlist,,"OPENTEMPLATE" ,, {NAME={WIDTH=30}}
    set gc.idtext.value "Should see the width of the name column increase."

  else
    ! do nothing
    !say "Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif

return

!******************************************************************************!
! Set the dat directory
!******************************************************************************!
procedure setDatDir
  invoke nxmMajor env.nmversion.subString(0,1)
  invoke major java.lang.Integer.valueOf(nxmMajor)
  if major GE 4 then
    invoke s:datDir           nxm.sys.test.DatLocator.getDatDirLocation()
    invoke s:datDirSlash      nxm.sys.test.DatLocator.getDatDirSlashLocation()
    invoke z:sysDatFull       nxm.sys.test.DatLocator.sysDatFull()
    invoke z:sysTestDatExists nxm.sys.test.DatLocator.sysTestDatExists()
  else
    set s:datDir           "nxm.sys.dat"
    set s:datDirSlash      "nxm/sys/dat"
    set z:sysDatFull       true
    set z:sysTestDatExists false
  endif
return
