startmacro
!
! Test using a popup color chooser result on a feature (BUG 2030)
!
! Author:  J. Hallam / J. Bauer
! Version: $Id: test_feature_popup_color.mm,v 1.3 2013/03/08 20:54:29 jwb Exp $
!
switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE
switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE

set defaultInstructions &
    "Use the 'Set Color' button to create a color chooser popup. Choose a color &
    and click 'Ok'. The text feature  on the plot to the color you selected."

set oldColor "RED"
set newColor "#ff33bb"


if interAct then
  pipe init

  panel/msgid=MAIN/setup/controls=gc

  plot/id=idplot world
  feature label=feat1 table={NAME="FEAT1",TYPE=SYMBOL,X=7,Y=50,COLOR="^oldColor",&
                               LINE={SYMBOL="ASCII-TEXT_FEATURE",FONTSIZE=20,FONTSTYLE=BOLD|ITALIC}} plot=idplot

  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" "^defaultInstructions" 40 16 /title

  gcontrol/noedit prompt featColor "Feature Should be:" "^oldColor"

  gcontrol button popup "" "Set Color"

  pipe off

endif

endmacro

procedure open
  ! Automatically called
return

!******************************************************************************!
procedure processMessage m:msg

!say "msg.name ^msg.name, data ^msg.data"

call setInstructions "^defaultInstructions"

if msg.name eqs "MAIN" then
  assert/text="^reg.main.name: User indicated tests" msg.data eqss "PASS"
  pipe stop
elseif msg.name eqs "POPUP" then
  popup/blocking=MACRO result=newColor func=color
  invoke ,, reg.idplot.features.feat1.color(^newColor)
  set gc.featColor.value "^newColor"
else
  ! do nothing
  say "^reg.main.name: Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
endif

return

!******************************************************************************!
procedure setInstructions s:msgString
  set reg.panel.controls.idtext.value msgString
return
