!******************************************************************************!
! Tests scrolling for the MENU type of GCONTROL
!
! @bug 2825 PLOT: Features menu needs a scrollbar
! @author  Jeanette McCall
! @version $Id: test_gcontrol_menu_scroll.mm,v 1.5 2015/12/12 01:48:53 jtm Exp $
!******************************************************************************!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE  ! for normal interactive test(s)

  ! Create GMenu with 400 items
  res items "Item1"
  res index 1
  res numItems 400
  while index lt numItems
    calc L:index index 1 +
    res  nextItem ",Item^{index}"
    invoke items items.concat(nextItem) 
  endwhile

  res gmenuTitle "GMENU_TITLE"
  set instructions "1) 'Many Choices' should have ^numItems items and a scrollbar\n&
                   2) 'Few Choices' should have 7 items and NO scrollbar\n&
                   3) Below those you should see a GMenu with ^numItems items, a scrollbar, and the title &
                   \"^gmenuTitle\" on each side (top, left, bottom, and right). Try scrolling &
                   both by paging (clicking above/below scrollbar) and by dragging knob.\n&
                   4) In a separate terminal, run %test_gcontrol_menu_scroll_noparent and notice the &
                   lines between the titles and the menu.  To exit the noparent macro select a menu item."


  if interAct 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}

      gcontrol/title TEXT instructions INSTRUCTIONS &
             ^instructions 48 9
      gcontrol choice manychoices "Many Choices" items "Item34"
      gcontrol choice fewchoices  "Few  Choices" "Choice1,Choice2,Choice3,Choice4,Choice5,Choice6,Choice7" "Choice3"
      gcontrol menu gcMenu1  ^gmenuTitle items "Item1" /tleft /tright /ttop /tbottom /WH=200

    pipe off
  endif
endmacro

!******************************************************************************!
procedure processMessage m:msg
  if msg.name eqs "MAIN"
    assert/text="^reg.main.name: user indicated" msg.data eqs "PASS"
    pipe stop
  elseif msg.name eqs "MANYCHOICES" then
    ! Create a popup message with Choice item selected
    popup/WPOS=(100,300,400,200)/blocking=none popup OK &
       "Many Choices selection: ^{msg.data}" "INFO"
  elseif msg.name eqs "FEWCHOICES" then
    ! Create a popup message with Choice item selected
    popup/WPOS=(100,300,400,200)/blocking=none popup OK &
       "Few Choices selection: ^{msg.data}" "INFO"
  elseif msg.name eqs "GCMENU1" then
    ! Create a popup message with Menu item selected
    popup/WPOS=(100,300,400,200)/blocking=none popup OK &
       "^gMenuTitle selection: ^{msg.data}" "INFO"
  else
    ! do nothing
    !say "Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return