!******************************************************************************!
! Tests the DragZoom plot option (BUG 2183)
!
! @author  J. Bauer
!******************************************************************************!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE

  call setDatDir

  set inst "1. Click the 'Zoom' button.\n&
            2. Move the mouse to the top-right corner of the plot.\n&
            3. Hold down the right mouse button and drag the mouse towards the bottom-left corner.\n&
            4. The plot should ZOOM in/out with the mouse movements.\n\n&
            5. Release the mouse button and click the 'Toggle DragZoom' button.\n&
            6. Repeat steps 2-4, the plot should NOT zoom with DragZoom off."
  if interAct then
    pipe on
    panel/msgid=MAIN/setup/controls=gc
      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" "^inst" 24 20 /title

    gcontrol button zoomin "" "Zoom"
    gcontrol button dzoom  "" "Toggle DragZoom" 1 /FLAGS="ChkBox|Toggle"

    plot/id=idplot/msgid=main ^{datDir}.apenny.prm

  endif

endmacro

!******************************************************************************!
procedure processMessage m:msg
  !res msg /all
  if msg.name eqs "MAIN" then
    assert/text="^reg.main.name: User indicated tests" msg.data eqss "PASS"
    pipe stop
  elseif msg.name eqs "ZOOMIN" then
    message sendw id=idplot name=ZOOM data={XMIN=D:56,XMAX=D:92,YMIN=D:60,YMAX=D:87}
  elseif msg.name eqs "DZOOM" then
    set reg.idplot.options "~DRAGZOOM"
  elseif msg.name EQS "ZOOM" OR msg.name EQS "PANXY" then
    invoke CTRL_DOWN_MASK java.awt.event.InputEvent.CTRL_DOWN_MASK
    calc bitSet msg.quals.MODIFIERS CTRL_DOWN_MASK BAND
    if bitSet NEQ 0 then
      INFO "^{msg.name} with CTRL key down"
    endif
  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
