!******************************************************************************!
! Test setting title colors on widgets
!
! @bug      2398 GControl / GWidget: would like option to control title color (to keep as theme)
! @bug      2543 GCONTROL: Ignores /WTHEME= if /THEME= is set
! @author:  J Bauer
! @version: $Id: test_gcontrol_theme_color.mm,v 1.4 2012/01/11 16:41:32 ntn Exp $
!******************************************************************************!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE  ! for normal interactive test(s)

  set instructions "The Button group below should have a title bar with the current &
                    theme and buttons with red text. Click the buttons to change the &
                    button's text color. The title text should not change color."

  if interAct then
    pipe on

      panel/msgid=MAIN/setup/controls=gc
        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 7 /title

        ! since 3.1.1, added /title=WoB to test BUG 2543
        gcontrol button myButt "This Title Color Should Remain White On Black" "RED,BLUE,GREEN" "RED" &
          /wtheme={CWFG=RED,CWTI=_THEME_CWTI} /theme=WoB

        ! get GCONTROL theme's widget title color (so that is the WoB theme)
        invoke gcThemeCWTIColor gc.myButt.theme.cwti.getRgb()
    pipe off
  endif

endmacro

!******************************************************************************!
! Main process message for this macro.
!******************************************************************************!
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
    ! Old school (pre-2398) method for keeping the title color intact shown below
    set t:newTheme {}
    set newTheme.CWFG ^msg.data
    set newTheme.CWTI gcThemeCWTIColor
    set gc.myButt.widgetTheme newTheme

  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
