!******************************************************************************!
! Tests the SHELLGUI command.
!
! Author:  J Bauer / Neon Ngo
!******************************************************************************!
startmacro
  switch INTERACTIVE   interAct     GET DEF=TRUE  SDEF=TRUE
  switch BASELINE      baseline     GET DEF=FALSE SDEF=TRUE
  switch COREGRAPHICS  coregraphics GET DEF=FALSE SDEF=TRUE  ! for a quick check of graphics - more extreme tests - since 3.8.1
  set wpos (25,450)

  if interAct OR coreGraphics then
    pipe on
      panel/msgid=MAIN/setup/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 "This macro will open a series of shellguis, each created &
        with different exit parameters. Each shellgui created should only be able &
        to be closed by the method indicated on the button. A button to send the &
        EXIT message has been provided.\n&
        --> In any of the SHELLGUI, press CTRL-C without any text selected. INFO &
        message should be displayed in that SHELLGUI (not in the console)."
      gcontrol text idtext  "Instructions" "^instructions" 24 6 /title

      gcontrol/nc=2 button sgbutton "/EXIT=" "WINDOW,COMMAND,MESSAGE,MENU"
      gcontrol button exitmessage "" "SEND EXIT MESSAGE"

      set methods "&
        WINDOW:  Click on the 'X' at the top right of the window.\n&
        COMMAND: Type the word 'exit' at the prompt.\n&
        MESSAGE: Send an EXIT message to the shellgui.\n&
        MENU:    Click 'exit' from the right-click popup menu."
      gcontrol text text2 "METHODS TO CLOSE A SHELLGUI" "^METHODS" 24 5 /title

    pipe off
    if coregraphics ISFALSE then
      %test_shellgui_keyboard/interactive=^interAct
      %test_shellgui_scroll_wrap ! added for Bug 2872 and Bug 2887
    endif
  endif

endmacro

!******************************************************************************!
! process messages for interactive tests
!******************************************************************************!
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 "SGBUTTON" then
    ! added /wtitle= to test BUG 2496 (since 3.1.0)
    shellgui/id=sg1/bg/wpos=wpos/wtitle="exit with ^msg.data"/exit=msg.data

  elseif msg.name eqs "EXITMESSAGE" then
    message func=sendx id=sg1 name=EXIT info=0

  else
    say "^reg.main.name: Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return
