!------------------------------------------------------------------------------!
! Test the setting of dRangeUnits (BUG 910).
!
! Author:  J. Bauer
!------------------------------------------------------------------------------!
startmacro

  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE

  set instructions &
      "Should see a blank plot.\n\n&
      1) Press the 'Plot World' button:\n&
      -> brings up world plot with the nations colored\n&
      -> plot left boundary is around the middle of the US.\n\n&
      2) Click anywhere on the map:\n&
      - observe the Azimuth and dRange units in the Readout\n   &
       at the bottom of the plot\n&
       - default dRange units should be 'm' (meters)\n\n&
       3) Click on buttons below\n\n&
       4) Move the mouse back over the plot area\n&
       -> dRange Units should change to match name on button"

  if interAct then
    pipe init

    panel/msgid=MAIN/setup/controls=gc
    plot/id=idplot/READOUT="+OnAxis|azimuth" 

    gcontrol label mainLabel "Main"
      gcontrol menu main "Exit with Status = " "PASS,FAIL" /tleft
      set gc.main.itemColors {PASS=GREEN,FAIL=RED}
    gcontrol text idtext "Instructions" "^instructions" 24 19 /title

		gcontrol button showplot "" "Plot World"
    gcontrol button units "dRange Units" "KM,NMI,M"

    pipe off

  endif

endmacro

!******************************************************************************!
procedure processMessage m:msg
  if msg.name eqs "MAIN" then
    assert/text="Plot dRangeUnit tests" msg.data eqss "PASS" 
    pipe stop
  elseif msg.name EQS "SHOWPLOT" then
    message send idplot name=openfile data="world.shp" quals={outerlimits={x1=-100}} ! tests BUG 1520
  elseif msg.name EQS "UNITS" then
    message send idplot ,,drangeunits,,msg.data
  else
    ! do nothing
    say "^reg.main.name: Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return
