!
! GCalendar test macro
!
! Author : Jay Hallam
!
startmacro

switch INTERACTIVE interAct      GET DEF=TRUE
switch COREGRAPHICS coreGraphics GET DEF=FALSE SDEF=TRUE ! for a quick check of graphics - more extreme tests - since 3.8.1

if interAct or coreGraphics then

  pipe on
    panel/msgid=main/setup/theme=gear3/controls=gc
    gcontrol label macro "MACRO"
    gcontrol menu main "Exit with Status = " "PASS,FAIL" /tleft
    set gc.main.itemcolors {PASS=GREEN,FAIL=RED}
    set instructions "Click in calendar, on PickDate and OneShotDetached control. &
                      Also, click on title and outside the dates making sure no &
                      exceptions are thrown."
    gcontrol text idtext "Instructions" "^instructions" 24 6 /title

    gcontrol/WW=800/WH=100 calendar mycal
    gcontrol menu SETDATE      "" "SetDate" 0
    gcontrol menu PICKDATE     "" "PickDate" 0
    gcontrol menu ONESHOTDETACHED    "" "OneShotDetached" 0
  pipe off
endif
endmacro


procedure processMessage m:msg
  if msg.name eqs "MAIN"
    assert/text="^reg.main.name: user indicated" msg.data EQSS "PASS"
    pipe stop
  elseif msg.name eqs "SETDATE" then
    invoke ,, gc.mycal.setValue(2004,05,02)
    set gc.IDTEXT.value "The calendar should now display Sunday, 02-May-2004."
    assert/text="^reg.main.name: Check year=2004" gc.mycal.YEAR  eq 2004
    assert/text="^reg.main.name: Check month=5"   gc.mycal.MONTH eq 5
    assert/text="^reg.main.name: Check day=2"     gc.mycal.DAY   eq 2


  elseif msg.name eqs "PICKDATE" then
    set gc.IDTEXT.value "Is current selection: &
                              DAY = ^gc.mycal.DAY, &
                              MONTH ^gc.mycal.MONTH, &
                              YEAR, ^gc.mycal.YEAR"
  elseif msg.name eqs "ONESHOTDETACHED" then
    ! One Shot: brings up a detached calendar
    set gc.IDTEXT.value "Did a new calendar come up with the CURRENT date selected?"
    gcontrol/panel=panel/temp/wait/WW=1000 calendar mycal,test
    set gc.IDTEXT.value "Did you click on the date: ^mycal?"

  elseif msg.name eqs "MYCAL" then
    set gc.IDTEXT.value "Did you click on the date: ^msg.data?"

  elseif msg.name eqs "SHOWN" then
    ! Do not process this
  else
    say "PROC Unhandled message ^msg.name from ^msg.fid  ^msg.data"
  endif
return
