!
!
! Tests the panel /THEME switch
!
! Author:  JPH
!
!
startmacro/theme={CBG=BLACK,CFG=RED,CWBG=GRAY,CWTS=BLUE,CWBS=AQUA,CWFH=YELLOW,CWFG=BLACK,CWTI=PURPLE}
  switch INTERACTIVE  interAct          GET DEF=TRUE  SDEF=TRUE
  switch BASELINE     baseline         GET DEF=FALSE SDEF=TRUE

  pipe on
    set instructions "Pass should still be GREEN and Fail should be RED.  \n\n&
                      The rest of the colors should match the colors indicated. \n\n&
                      Change the colors indicated and the widgets should reflect the change."

    panel/setup/controls=gc
    if /SHELLGUI then shellgui
    gcontrol label macro "MACRO"
    gcontrol menu main "Exit with Status = " "PASS,FAIL" /tleft
    set gc.main.itemcolors {PASS=GREEN,FAIL=RED}

    set colorList "BLACK,RED,GRAY,BLUE,AQUA,YELLOW,PURPLE"
    invoke cbgName     nxm.sys.libg.MColor.toString(reg.panel.theme.cbg)
    invoke cfgName     nxm.sys.libg.MColor.toString(reg.panel.theme.cfg)
    invoke cwbgName    nxm.sys.libg.MColor.toString(reg.panel.theme.cwbg)
    invoke cwtsName    nxm.sys.libg.MColor.toString(reg.panel.theme.cwts)
    invoke cwbsName    nxm.sys.libg.MColor.toString(reg.panel.theme.cwbs)
    invoke cwfhName    nxm.sys.libg.MColor.toString(reg.panel.theme.cwfh)
    invoke cwfgName    nxm.sys.libg.MColor.toString(reg.panel.theme.cwfg)
    invoke cwtitleName nxm.sys.libg.MColor.toString(reg.panel.theme.cwti)

    assert/text="^reg.main.name: background color"               "^cbgName"     EQS "BLACK"
    assert/text="^reg.main.name: foreground color"               "^cfgName"     EQS "RED"
    assert/text="^reg.main.name: widget background color"        "^cwbgName"    EQS "GRAY"
    assert/text="^reg.main.name: widget top shade color"         "^cwtsName"    EQS "BLUE"
    assert/text="^reg.main.name: widget bottom shade color"      "^cwbsName"    EQS "AQUA"
    assert/text="^reg.main.name: widget FG highlight (rolldown names)" "^cwfhName"    EQS "YELLOW"
    assert/text="^reg.main.name: widget foreground color"        "^cwfgName"    EQS "BLACK"
    assert/text="^reg.main.name: widget title color"             "^cwtitleName" EQS "PURPLE"
    gcontrol text idtext  "INSTRUCTIONS" "^instructions" 8 5 /title
    gcontrol label themeLab "Theme Colors"
      set gc.colors {}
      gcontrol choice colors.CBG     "Background color"               "^colorList" cbgName
      gcontrol choice colors.CFG     "Foreground color"               "^colorList" cfgName
      gcontrol choice colors.CWBG    "Widget background"              "^colorList" cwbgName
      gcontrol choice colors.CWTS    "Widget top shadow"              "^colorList" cwtsName
      gcontrol choice colors.CWBS    "Widget bottom shadow"           "^colorList" cwbsName
      gcontrol choice colors.CWFH    "Widget FG highlight (rolldown names)" "^colorList" cwfhName
      gcontrol choice colors.CWFG    "Widget foreground"              "^colorList" cwfgName
      gcontrol choice colors.CWTI    "Widget title"                   "^colorList" cwtitleName

  pipe off
endmacro

!**************************************************************************************************!
procedure processMessage m:msg
  !say "Msg ^msg.name = ^msg.data"
  if msg.name EQS "MAIN" then
    lookandfeel gear3 ! reset theme
    assert/text="Panel configuration" "PASS" SUBS msg.data
    pipe stop
  elseif msg.name EQSS "COLORS." then
    sedit msg.name key SUBS "COLORS." ""
    invoke color nxm.sys.libg.MColor.getColor(msg.data)
    set reg.panel.theme.^key color
    call refreshColors
  else
    say "Unhandled message ^msg.name from ^msg.fid"
  endif
return

procedure refreshColors
  ! changed the refresh calls below in 3.3.0 since it works better this way
  invoke ,, reg.panel.resize()
  invoke ,, reg.panel.refreshAll()
return
