!******************************************************************************!
! Test preventing GControls from updating title bar
!
! @bug      2681 GControl: Suppress title bar status updates
! @author:  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)

  call setDatDir

  if interAct then
    set instructions "None of the GControls or the PLOT in this macro should update the title/status bar by default.\n\n&
                      To verify this, move the mouse over the PLOT and the controls and observe the status bar.\n\n&
                      Click the Toggle button to toggle the PLOT and GControls' ability to update the status bar.\n\n&
                      Enter some text in the bottom prompt to verify you can still change the title manually. "
                      
    pipe on
      panel/msgid=MAIN/setup/controls=gc/noAltTitle
      
      invoke cbgName     nxm.sys.libg.MColor.toString(reg.panel.theme.cbg)
      
      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 12 /title

      plot/id=plot1 ^{datDir}.world.prm 

      gcontrol prompt prompt1 "PROMPT 1" "Hovers SHOULD NOT change status bar readout" 
      gcontrol line line1 "SomeWorthlessText" "^cbgName" 14 ,, "CENTER"    ! Transparent spacer
      gcontrol button myButt "Toggle allowing updates from hovers" "Toggle" 
      gcontrol line line1 "SomeWorthlessText" "^cbgName" 14 ,, "CENTER"    ! Transparent spacer
      gcontrol prompt promptTitle "Change TITLE text:" "Title text goes here" 
      
    pipe off

  endif
endmacro

!******************************************************************************!
! Main process message for this macro. Should be right after the 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 "MYBUTT" then
    if reg.panel.mw.noAltTitle isTrue then
      set reg.panel.mw.noAltTitle false
      set gc.prompt1.value "Mouse Hovers SHOULD change status bar readout"
    else 
      set reg.panel.mw.noAltTitle true
      set gc.prompt1.value "Hovers SHOULD NOT change status bar readout"
    endif
    
  elseif msg.name eqs "PROMPTTITLE" then
    set reg.panel.mw.title msg.data
    
  else
    say "Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return

!******************************************************************************!
! If an unexpected exception is caught, mark test as failed, unless it is expected
!******************************************************************************!
procedure processException m:emsg
  if expectedException REXISTS then
    assert/text="^reg.main.name: Expected ERROR starts with: ^{expectedException}" expectedException EQSS emsg.data.message
    remove expectedException
  else
    assert/text="^reg.main.name: Caught unexpected exception ^{emsg.data}" "FALSE" isTrue
    if "Trace" SUBS ENV.DEBUG then invoke ,, emsg.data.printStackTrace()
  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
