!******************************************************************************!
! Tests the panel tabs.
! @author  J. Czechowski IV
!******************************************************************************!
startmacro/msgid=main/theme=gear2
  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)

  call setDatDir

  call getTime

  pipe on
    set instructions "PANEL pop/push test:\n\n(1) Press the PUSHPOP icon (NE SW arrows) in the title bar &
                      of the panes/tabs to pop the window out, press it again &
                      to push it back.\n\n(2) Use Ctrl+P to push/pop the &
                      panes/tabs.\n\n(3) When the pane/tab is popped out, use &
                      the 'X' on the popped-window to push it back into the &
                      pane/tab.\n\n(4) For one of the plots, press the MMB to bring &
                      up the plot menu when it is POPPED from the panel.\n\n(5) Try &
                      clicking on the 'X' at the upper corner of this window, &
                      when you click on it you should get a popup."

    panel/setup/controls=gc/wmsgid=main/options=-rotatetabs/exit=none

    ! Put these in tabs
    plot/id=worldTab ^{datDir}.world.prm  options=+bstore view=mercator
    plot/id=pennyTab ^{datDir}.apenny.prm axis=frame
    list2/id=fftTab  ^{datDir}.fftdemo.prm
    shellgui/id=termTab

    ! Put these in regular panes
    plot/id=world ^{datDir}.world.prm  options=+bstore view=geo
    plot/id=penny ^{datDir}.apenny.prm axis=frame     type=cont
    list2/id=fft  ^{datDir}.fftdemo.prm
    shellgui/id=term

    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 25 /title
    gcontrol prompt time  "Time:" timeStr
    gcontrol panel  apan  "Map" 400 200 ! Allows test for Bug 272 and Bug 234

    plot/id=apan ^{datDir}.world.prm|^{datDir}.cities.prm

    set reg.panel.timer(0) 1

  pipe off

  %test_panel_pop_advanced  ! added for Bug 2458

endmacro

!******************************************************************************!
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 "WINDOW" and msg.data eqs "CLOSING" then
    popup/blocking=none popup OK "You clicked the close button!" "INFO"

  elseif msg.name EQS "TIMER" then
    call getTime
    if reg.panel.controls.time rexists then
      ! The next two lines cause a refresh problem in NeXtMidas 2.1.0 - Bug 269
      set reg.panel.controls.time.show  1
      set reg.panel.controls.time.value timeStr
    endif

  else
     !say "Unhandled message ^msg.name from ^msg.fid"
  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

!******************************************************************************!
procedure getTime
  timex now mjs=curTime
  invoke timeStr nxm.sys.lib.Time.toString(curTime)
return
