!******************************************************************************!
!  DR500257-4
!  Test to show that the legend switch for plot did not correctly position legend
!  relative to plot when attached to panel.
!  (Originally, this is the Macro to implement box drawing feature using shift-drag)
!  @version $Id: test_dr500257-4.mm,v 1.4 2011/06/01 14:52:46 ntn Exp $
!******************************************************************************!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE  ! for normal interactive test(s)

if interAct then

  pipe init

  panel/setup

  ! start a plot
  plot/id=plot1/msgid=main/win=pane1/legend world

  !add the feature
  FEATURE label=box1 table={NAME=BOX1,TYPE=BOX,COLOR=WHITE,ENABLE=1} plot=plot1

  gcontrol label macro "TEST"
  gcontrol text info "InfoString" &
    "This test shows that the legend switch for plot &
     now correctly positions legend relative &
     to plot when attached to a panel." 24 4
  gcontrol menu main "Exit with Status" "PASS,FAIL" 1 /tleft
  pipe off

endif

endmacro
!******************************************************************************!
procedure processMessage
  if msg.name eqs "MAIN" then
    assert/text="^reg.main.name: User indicated tests" msg.data eqss "PASS"
    pipe stop
  elseif msg.fid eqs "PLOT1"  then
    if msg.name eqs "DRAGBOX" then
      result xmin msg.data(0)
      result xmax msg.data(1)
      result ymin msg.data(2)
      result ymax msg.data(3)
      calc centerx ^xmin ^xmax + 2 /
      calc centery ^ymin ^ymax + 2 /
      set box1.x ^centerx
      set box1.y ^centery
      calc deltax ^xmax ^xmin -
      calc deltay ^ymax ^ymin -
      set box1.dx ^deltax
      set box1.dy ^deltay
    endif
  endif
return
