eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'MenuPanel':

Home

everywhere
www.exept.de
for:
[back]

Class: MenuPanel


Inheritance:

   Object
   |
   +--GraphicsContext
      |
      +--DeviceGraphicsContext
         |
         +--GraphicsMedium
            |
            +--DisplaySurface
               |
               +--SimpleView
                  |
                  +--View
                     |
                     +--MenuPanel
                        |
                        +--ColorMenu
                        |
                        +--FontMenu

Package:
stx:libwidg2
Category:
Views-Menus
Version:
rev: 1.503 date: 2010/03/09 12:10:03
user: cg
file: MenuPanel.st directory: libwidg2
module: stx stc-classLibrary: libwidg2
Author:
Claus Atzkern

Description:


a menu panel used for both pull-down-menus and pop-up-menus.

this will eventually replace most of the MenuView and PopUpMenu stuff.
(and hopefully be ST-80 compatible ...)

To create a menu, there exists a MenuEditor which will generate
a menu specification.


Notice:
    This is going to replace the obsolete MenuView.



cg: this code is so ugly - needs a complete rewrite...


Related information:

    Menu
    MenuItem
    MenuEditor

Class protocol:

class initialization
o  initialize

o  preSnapshot
remove all resources

default icons
o  delayedMenuIndicator
This resource specification was automatically generated
by the ImageEditor of ST/X.

o  iconIndicationDisabledOff
This resource specification was automatically generated
by the ImageEditor of ST/X.

o  iconIndicationDisabledOn
This resource specification was automatically generated
by the ImageEditor of ST/X.

o  iconIndicationOff
This resource specification was automatically generated
by the ImageEditor of ST/X.

o  iconIndicationOn
This resource specification was automatically generated
by the ImageEditor of ST/X.

o  iconRadioGroupDisabledOff
This resource specification was automatically generated
by the ImageEditor of ST/X.

o  iconRadioGroupDisabledOn
This resource specification was automatically generated
by the ImageEditor of ST/X.

o  iconRadioGroupEnteredOff

o  iconRadioGroupEnteredOn

o  iconRadioGroupOff
This resource specification was automatically generated
by the ImageEditor of ST/X.

o  iconRadioGroupOn
This resource specification was automatically generated
by the ImageEditor of ST/X.

o  menuIndicator
This resource specification was automatically generated
by the ImageEditor of ST/X.

defaults
o  defaultBackgroundColor

o  defaultLevel

o  delayedMenuIndicatorOffset
returns an additional offset between the label and the
delayedMenu indication (i.e. the down-arrow icon)

o  maxShortCutSearchLevel
1 means: only search in top items.
2 means: search one level of menus.
used to be 10

o  maxShortCutSearchLevel: anInteger
1 means: only search in top items.
2 means: search one level of menus.

o  menuIndicatorOffset
returns an additional offset between the label and the
delayedMenu indication (i.e. the down-arrow icon)

o  mnemonicIdentifier
returns the identifier each mnemonic starts with;
ex:
&File mnemonic := Cmdf
F&ile mnemonic := Cmdi
.....

o  updateStyleCache
extract values from the styleSheet and cache them in class variables

image registration
o  image: anImage onDevice: aDevice
Images := nil

o  lightenedImage: anImage onDevice: aDevice
LigthenedImages := nil

instance creation
o  fromSpec: aSpec

o  fromSpec: aSpec receiver: aReceiver

o  labels: labels

o  labels: labels nameKeys: nameKeys

o  labels: labels nameKeys: nameKeys receiver: aReceiver

o  labels: labels receiver: aReceiver

o  menu: aMenu

o  menu: aMenu receiver: aReceiver

private
o  subMenu: aSubMenu
create a submenu; can be redifined in derived classes


Instance protocol:

accepting
o  accept
accept current selected item

o  accept: anItem
this is the topMenu: accept item

o  accept: anItem index: anIndex toggle: aState receiver: aReceiver
accept an item

o  acceptItem: anItem inMenu: aMenu

o  lastItemAccepted
returns last item selected or nil

o  lastValueAccepted
returns last value accepted or nil

accessing
o  accessCharacterPositionAt: stringOrNumber
get the access character position for a textLabel

o  accessCharacterPositionAt: stringOrNumber put: anIndexOrNil
get the access character position for a textLabel

o  accessCharacterPositions
returns a collection of accessCharacterPositions or nil

o  accessCharacterPositions: something
define accessCharacterPositions for each item

o  args
returns a collection of arguments or nil

o  args: something
define arguments for each item

o  argsAt: stringOrNumber
gets the argument of an item or nil

o  argsAt: stringOrNumber put: anArgument
sets the argument of an item

o  doAccessCharacterTranslation
true if &-chars in a label are to be treated as accessCharacter indicators.
Can be set to false to leave labels unchanged

o  doAccessCharacterTranslation: aBoolean
true if &-chars in a label are to be treated as accessCharacter indicators.
Can be set to false to leave labels unchanged

o  enteredItem
return the item over which the mouse pointer is located;
nil if the mouse is not over any item

o  groupSizes
gets collection of group sizes

o  groupSizes: aGroupSizes
sets collection of group sizes

o  hideOnRelease

o  hideOnRelease: aBoolean

o  labelAt: stringOrNumber
gets the label of an item or nil

o  labelAt: stringOrNumber put: aLabel
sets the label of an item

o  labels
returns a collection of labels's or nil

o  labels: labels
define labels for each item

o  menuPerformer: anObject
set the menu-receiver. Thats the one who gets the messages ( both from myself and
from all submenus no specific receiver is defined ).

o  nameKeyAt: stringOrNumber
gets the nameKey of an item or nil

o  nameKeyAt: stringOrNumber put: aNameKey
sets the nameKey of an item

o  nameKeys
returns a collection of nameKeyss or nil

o  nameKeys: something
define nameKeys for each item

o  numberOfItems
gets number of items

o  originator

o  receiver
get the menu-receiver. Thats the one who gets the messages ( both from myself and
from all submenus no specific receiver is defined ).

o  receiver: anObject
set the menu-receiver. Thats the one who gets the messages ( both from myself and
from all submenus no specific receiver is defined ).

o  shortcutKeyAt: stringOrNumber
gets the shortCutKey of an item or nil

o  shortcutKeyAt: stringOrNumber put: aKey
sets the shortCutKey of an item

o  shortcutKeys
returns a collection of shortcutKeys or nil

o  shortcutKeys: something
define shortcutKeys for each item

o  valueAt: stringOrNumber
gets value of an item; a block, valueHolder, ...

o  valueAt: stringOrNumber put: someThing
sets value of an item; a block, valueHolder, ...

o  values: something
define values for each item

accessing-behavior
o  disableAll
disable all items; not the menu in case of enabled

o  disableAll: collectionOfIndicesOrNames
disable an collection of items

o  enableAll
enable all items; not the menu in case of disabled

o  enableAll: collectionOfIndicesOrNames
enable an collection of items

o  enabled
returns enabled state

o  enabled: aState
change enabled state of menu

o  enabledAt: stringOrNumber
gets the enabled state of an item or false

o  enabledAt: stringOrNumber put: aState
sets the enabled state of an item

o  exclusivePointer: aBoolean
Do nothing here. Compatibility with PopUpListController

o  isEnabled: stringOrNumber
gets the enabled state of an item or false

accessing-channels
o  enableChannel: aValueHolder
set my enableChannel

o  menuChannel

o  menuHolder: aValueHolder
set my menuHolder

accessing-color & font
o  activeBackgroundColor
get the background drawing color used to highlight selection

o  activeForegroundColor
get the foreground color used to highlight selections

o  backgroundColor
return the background color

o  backgroundColor: aColor
set the background drawing color. You should not use this method;
instead, leave the value as defined in the styleSheet.

o  buttonActiveBackgroundColor
get the background drawing color used to highlight button selection

o  buttonActiveForegroundColor
get the foreground drawing color used to highlight button selection

o  buttonEdgeStyle
get the button edge style

o  buttonEnteredBackgroundColor
get the background drawing color used to highlight entered button items

o  buttonEnteredLevel
get the 3D-level used to highlight entered button items

o  buttonHalfLightColor
get the background drawing color used to half light button frame

o  buttonHalfShadowColor
get the background drawing color used to half shadow button frame

o  buttonLightColor
get the background drawing color used to light button frame

o  buttonPassiveBackgroundColor
get the background drawing color used for button

o  buttonShadowColor
get the background drawing color used to shadow button frame

o  disabledEtchedForegroundColor
return the color used for etching disabled items.
If nil, no 3D effect is drawn.

o  disabledForegroundColor
return the foreground color used by disabled items

o  enteredBackgroundColor
return the background color for entered items

o  enteredForegroundColor
return the foreground color for entered items

o  font: aFont
set the font

o  foregroundColor
return the passive foreground color

o  foregroundColor: aColor
set the foregroundColor drawing color. You should not use this method;
instead leave the value as defined in the styleSheet.

o  maxAbsoluteButtonLevel
returns the maximum absolute button level; used to compute the preferred
extent of a button

o  selectionFrameBrightColor
get the selection frame bright color

o  selectionFrameDarkColor
get the selection frame dark color

o  setFont: aFont
set the font if the argument is nonNil;
Return nil, if the font was unchanged; otherwise, return the old font

o  viewBackground: aColor

accessing-dimensions
o  height
default height

o  maxExtent

o  preferredExtent
compute and returns my preferred extent

o  preferredExtentOfItems
compute and returns my preferred extent including all items
!!! changes have influence on method #rearrangeItems !!!

o  preferredWidth: aWidthOrNil
used for example by combo box to setup the preferred width for the popup menu.
If nil (default), the width is computed from the contained items.
If not nil, the width is the maximum from the contained items and the required width.

o  shortKeyInset
left inset of shortcutKey

o  stringOffsetXfor: anItem
return the x offset for a MenuItem where to draw the text

o  subMenuIndicationWidth

accessing-interactors
o  iconIndicationDisabledOff

o  iconIndicationDisabledOn

o  iconIndicationOff

o  iconIndicationOn

o  iconRadioGroupDisabledOff

o  iconRadioGroupDisabledOn

o  iconRadioGroupEnteredOff

o  iconRadioGroupEnteredOn

o  iconRadioGroupOff

o  iconRadioGroupOn

accessing-items
o  itemAt: stringOrNumber do: aOneArgBlock
evaluate the block for an item and return the result from the block. In case that
the item does not exist nil is returned

o  itemAt: stringOrNumber do: aOneArgBlock ifAbsent: exceptionBlock
evaluate teh block for an item and return the result from the block. In case that
the item does not exists the result of the exception block is returned (no arguments)

o  itemAtIndex: anIndex
returns item at an index or nil

o  items
returns list of items or nil

accessing-look
o  buttonActiveLevel
get the buttons active level

o  buttonPassiveLevel
get the buttons passive level

o  centerItems

o  centerItems: aBoolean

o  fitFirstPanel
gets true if the first panel in the menu hierarchy must be fit
to the extent of its superView

NOT SUPPORTED

o  fitFirstPanel: aState
sets true if the first panel in the menu hierarchy must be fit
to the extent of its superView

NOT SUPPORTED

o  level: anInt

o  rightArrow

o  rightArrowShadow

o  showGroupDivider
get the enabled flag for showing groupDiveders

o  showGroupDivider: aState
set the enabled flag for showing groupDiveders

o  showSeparatingLines
gets true if drawing of separating lines is enabled.

o  showSeparatingLines: aState
turn on/off drawing of separating lines.

o  verticalLayout
get the layout: vertical( true ) or horizontal( false )

o  verticalLayout: aState
set the layout: vertical( true ) or horizontal( false )

accessing-style
o  buttonInsetX
returns the verical button space

o  buttonInsetY
returns the verical button space

o  drawMenuIndicatorSeparatorLine

o  enteredLevel
returns the enter-level for an unselected item moved through

o  groupDividerSize
returns the width of a group divider

o  itemMargin
returns the margin of an item

o  itemSpace
returns the additional space for an item in a (vertical) panel

o  menuIndicatorVerticalPosition
#center, #top or #bottom

o  selectionFollowsMouse
returns true if the selection follows the mouse

o  shortcutKeyOffset
returns the offset for a shortcutKey

accessing-submenu
o  subMenuAt: stringOrNumber
gets the current submenu of an item; if the submenu is nil, the
submenu is generated if specified otherwise nil is returned.

o  subMenuAt: stringOrNumber put: aSubMenu
sets the submenu of an item

o  subMenuShown
return the currently visible submenu - or nil if there is none

activation & deactivation
o  closeMenus
close all menus without accepting

o  hide
hide the view, leave its modal event loop

o  show
realize the view at its last position;
return the value of the selectedItem or nil, of none was selected
(unless the menu has already performed its action, by sending an appropriate message
to some performer)

o  showAt: aPoint
realize the view at aPoint.
return the value of the selectedItem or nil, of none was selected
(unless the menu has already performed its action, by sending an appropriate message
to some performer)

o  showAt: aPoint resizing: aBoolean
realize the view at aPoint; return nil if no item was selected,
or if I have already performed.
Return the items value, otherwise.
Notice, that this is returned back to the one who started this
menu (i.e. the view or controller), which will perform the action
if a non-nil is returned.

o  showAtPointer
realize the view at the current pointer position.
return the value of the selectedItem or nil, of none was selected
(unless the menu has already performed its action, by sending an appropriate message
to some performer)

o  showCenteredIn: aView
make myself visible at the screen center.
return the value of the selectedItem or nil, of none was selected
(unless the menu has already performed its action, by sending an appropriate message
to some performer)

o  startUp
realize the menu at the current pointer position
return the value of the selectedItem or nil, of none was selected
(unless the menu has already performed its action, by sending an appropriate message
to some performer)

o  startUpAt: aPoint
realize the menu at aPoint
return the value of the selectedItem or nil, of none was selected
(unless the menu has already performed its action, by sending an appropriate message
to some performer)

o  startUpFor: originatingWidget
realize the menu at the current pointer position
return the value of the selectedItem or nil, of none was selected
(unless the menu has already performed its action, by sending an appropriate message
to some performer)

o  startUpOrNil
realize the menu at the current pointer position
return the value of the selectedItem or nil, of none was selected
(unless the menu has already performed its action, by sending an appropriate message
to some performer)

adding & removing
o  createAtIndex: anIndexOrNil
create an item and add this item to the index. In case of nil, the item
is added to the end. If the index is not valid nil is returned;
otherwise the new created item is returned.

o  remove: stringOrNumber
remove the first item which is assigned to stringOrNumber;
if found, remove and return it

o  removeAll
remove all items and submenus

change & update
o  update: something with: aParameter from: changedObject

converting
o  asMenu
convert contents to a menu

o  fromSpec: aMenuSpec
build from spec

o  menu: aMenu
convert to Menu

dependents access
o  addDependencies
add all dependencies

o  removeDependencies
remove all dependencies

drawing
o  disabledRedrawDo: aBlock
evaluate a block without redrawing within the block; after processing
of the block a redraw might be performed

o  drawButtonEdgesFor: anItem level: aLevel

o  drawFocusForItem: anItem

o  drawItemsX: x y: y width: w height: h
redraw items and groups in a damage

o  drawLabelEdgeFor: anItem selected: isSelected

o  drawScrollerAt: aDirection bounds: bounds
draw a scroller

o  invalidateItem: anItem repairNow: aBool
an item changed; invalidate the items layout

o  mustRearrange
force rearrange (i.e. set the rearrange flag)

o  rearrangeGroups
implements the groupIdentifier #right/#conditionalRight in a horizontal menu

o  rearrangeItems
recompute the layout of each item
!!! changes have influence on method #preferredExtentOfItems !!!

o  rearrangeItemsIfItemVisibilityChanged
check for items which can change its visibility;
if at least one item exists, rearrange all items

o  redrawX: x y: y width: w height: h
redraw a damage

o  updateEnteredItem

enumerting & searching
o  collect: aOneArgBlock
evaluate the argument, aOneArgBlock for every item in the menuPanel
and return a collection of the results

o  do: aOneArgBlock
evaluate the argument, aOneArgBlock for every item in the menuPanel.

o  findFirst: aOneArgBlock
find the index of the first item, for which evaluation of the argument, aOneArgBlock
returns true; return its index or 0 if none detected.

o  findLast: aOneArgBlock
find the last item, for which evaluation of the argument, aOneArgBlock
returns true; return its index or 0 if none detected.

o  firstItemSelectable
returns the first item which is selectable or nil

o  indexOf: something
returns index of an item assigned to an index, nameKey, textLabel or value if symbol.
If no item match 0 is returned. No range checks are performed on a number argument

o  indexOfItem: anItem
returns the index of the item or 0

o  keysAndValuesDo: aTwoArgBlock
evaluate the argument, aTwoArgBlock for every item in the menuPanel.

event handling
o  buttonMotion: state x: x y: y
open or close the corresponding submenu

o  buttonPress: button x: x y: y
any button pressed; open or close the corresponding submenus

o  buttonRelease: button x: x y: y
button release action; accept selection and close all views

o  handleSizeChanged: how
used to handle the scrollers and groups in a none popUpView

o  keyPress: key x: x y: y
any key is pressed

o  mapped

o  mouseWheelMotion: buttonState x: x y: y amount: amount deltaTime: dTime
mousewheel action

o  pointerLeave: state

o  sizeChanged: how
redraw #right groups

event handling-processing
o  clearImplicitGrab

o  dispatchEvent: ev withFocusOn: focusView delegate: doDelegate
dispatch and handle an event

o  handleButtonMotion: state atPoint: motionPoint
open or close the corresponding submenus

o  handleButtonPress: button atPoint: aPoint
a button pressed; open or close the corresponding submenus

o  handleCursorKey: aKey
handle a cursor key

o  handleKeyPress: key
any key is pressed

o  handlePointerLeave: state

o  handleReturnPressed
any key is pressed

o  pointerEntersItem: anItemOrNil
the pointer moves over an item or nil; restore the old item and
redraw the new item highlighted.

focus handling
o  canTab
depends whether I'am a toolbar and selectable items exists

o  focusComesByTab
returns true if focus comes by tab and should be drawn

o  focusComesByTab: aBoolean
only handled for toolBars

o  hasKeyboardFocus: aBoolean
notification from the windowGroup that I got/lost the keyboard focus.

o  showFocus: focusComesByTab

o  showNoFocus: focusByTab

o  supportsFocusOnTab
returns true if focus is supported

o  wantsFocusWithButtonPress
needs only the focus if I'am a toolbar; all events are delegated
to my subMenus

grabbing
o  doGrab

o  doUngrab: forceDo

o  grabKeyboard
grap the keyboard; keep previous grab

o  grabMouseAndKeyboard
get exclusive access to pointer and keyboard

o  grabPointerWithCursor: aCursorOrNil
grap the pointer; keep previous grab

o  ungrabKeyboard
ungrap the keyboard; restore previous grab

o  ungrabMouseAndKeyboard
ungrab resources (mouse and keyboard)

o  ungrabPointer
ungrap the pointer; restore previous grab

help
o  flyByHelpSpec
allows subclasses to provide texts

o  flyByHelpTextAt: aPoint
return the helpText for aPoint (i.e. when mouse-pointer is moved over an item).
If there is a selection, that items helpText is used (ignoring the given point).

o  flyByHelpTextForItem: anItem
returns the helpText for an item (empty if none)

o  flyByHelpTextForKey: aKey

o  helpText
return the helpText for the currently selected item (empty if none)

o  helpTextAt: aPoint
return the helpText for aPoint (i.e. when mouse-pointer is moved over an item).
If there is a selection, that items helpText is used (ignoreing the given point).

o  helpTextForItem: anItem
returns the helpText for an item (empty if none)

o  withMenuAndItemAt: srcPoint do: aBlock

image registration
o  imageOnMyDevice: anImage
returns image registered on device

o  lightenedImageOnDevice: anImage
returns lightened image registered on device

initialization & release
o  addToCurrentProject
ignored here

o  create
create the shadow view for a none contained submenu

o  destroy
destroy items and shadowView; remove dependencies

o  fetchDeviceResources
fetch device colors, to avoid reallocation at redraw time

o  initStyle
initialize style specific stuff

o  initialize
set default configuration

o  map
grab the pointer here, when visible (but not if control has already been lost).
If the grab fails, try again and unmap myself if that fails too.

o  realize
realize menu and shadowView

o  recreate
this is called after a snapin or a migration.
If the image was saved with an active menu, hide the menu

o  reinitStyle
handle style change while being open (win32 only - for now)

o  unmap
unmap the view - the view stays created (but invisible), and can be remapped again later.
If we have a popup supermenu, it will get all keyboard and mouse events.

o  updateLevelAndBorder
update level & border

keyboard control
o  mnemonicViewNext: aKeyEvent
a mnemonicKey event as forwarded from the keyboardProcessor - if there
is the mnemonic-key defined for any menuItem, handle the menuItem and
return the topMenu otherwise nil.

o  openMenusFromItemIndices: anItemIndiceList
open all menus derived from sequence of item indices

o  processCollectedIndices: indices

o  processShortcut: aKeyEvent
a shortcutKey event as forwarded from the keyboardProcessor.
If there is a shortcut-key defined, process it and return true.
Otherwise return false.

o  selectItemIndicesFor: aOneArgBlock maxDepth: maxDepth from: aStart to: aStop ignoreSubmenuBlock: ignoreSubmenueBlock
returns the sequence of indices up to the item for which the block returns true.
The first entry is the topmenu, the last entry the item for which the block returns
true. If no item is detected, nil is returned.
If the ignoreSubmenueBlock is not nil, the menu under the item (argument to the block)
is created and passed through if the block returns false.
Otherwise the item is not asked for its submenu.

misc
o  raiseDeiconified

o  superMenu
returns supermenu or nil

o  topMenu
returns the topMenu; the one having no superMenu

printing & storing
o  printOn: aStream

private
o  application
optimize access to retrive the application

o  detectItem: aBlock
returns the item for which aBlock returns true.

o  detectItemForKey: aKey
returns the item assigned to a key, accessCharacter or starts with.
if no item is detected nil is returned.

o  detectItemForLabel: aLabel

o  detectItemForNameKey: aKey

o  menuAdornmentAt: aSymbol
returns a value derived from adornment

o  menuAdornmentAt: aSymbol put: something
sets a value for the specific menu

o  onEachPerform: aSelector withArgList: aList
on each item perform selector with an argument derived from aList

o  registerImageOnDevice: anImage

o  superMenu: aSuperMenu
set my supermenu from which i'am activated

private-activation
o  activeMenu
returns the current active menu or self (the top menu)

o  activeMenu: aMenu
set the current active menu

o  becomesActiveMenu
submenu becomes the active menu

o  clearLastActiveMenu
reset the current active menu

o  mapTime
get the time the menu was activated or nil

o  mapTime: aTimestamp
set the time the menu was activated

private-scrolling
o  hasScrollerAt: aDirection
returns true if a visible scroller at a direction exists

o  hasScrollers
returns true if scrollers are needed

o  indexOfItemAtScroller: aDirection
returns the index of the item under the scroller or 0

o  makeItemVisible: anItem
make an item visible

o  scrollActivity
returns the one and only scrollActivity - data holder
for a menu and all contained submenus

o  scrollerBoundsAt: aDirection
returns the bounds of the scroller at a direction

o  scrollerDirectionAtPoint: aPoint
returns the scroller-direction at aPoint, or nil

private-searching
o  detectGrabMenu
returns the menu which is responsible for the grap; the last opened menu

o  detectMenuAtGrabPoint: aGrabPoint
returns the menu which contains the grab-point

o  detectViewAtX: x y: y in: aTopView
detect view at x@y

o  itemAt: stringOrNumberOrPoint
returns item assigned to an index, nameKey, textLabel or value if symbol.
If no item match nil is returned.

o  itemAtPoint: aPoint
returns the item at aPoint or nil if none detected

o  superMenuAtPoint: aPoint
returns the superMenu which contains aPoint, or nil if none detected

queries
o  container: aView

o  containsPoint: aPoint
returns true if the argument, aPoint is contained by the view

o  containsPointX: x y: y
returns true if point is contained by the view

o  hasGroupDividerAt: anIndex
returns true if a divider is defined at an index

o  hasGroupDividers
returns true if any group divider exists

o  isActive
true, if I have the focus (w.r.t the windowing system);
i.e. if one of my subViews actually has the real focus.
With click-to-focus behavior, this is obviously the current application.
Use this query with caution, for example, to suppress tooltips for inactive apps.

This should be only in TowView, but apparently MenuPanel is used as a TopView

o  isFitPanel
returns true if the panel is the first in the menu hierarchy in must
be fit to the extent of its superView;
NOT SUPPORTED

o  isPopUpView
return true if view is a popup view; without decoration
and popUp to top immediately

o  isVerticalLayout
returns true if vertical layout otherwise false( horizontal layout )

o  isViewWrapper

o  type

selection
o  hasSelection
returns true if a selection exists

o  openDelayed: anItem

o  openDelayed: anItem afterSeconds: seconds

o  selection
returns current selected item or nil

o  selection: anItemOrNil
change selection to an item or nil
if the item has a submenu the first item might be selected (style-sheet)

o  selection: anItemOrNil openMenu: openMenu
change selection to an item or nil

o  selectionIndex
returns index of current selection or 0

o  selectionIndex: anIndex
set selection at an index

translation
o  translateGrabPoint: aGrabPoint
translate the grab point into self

o  translateMenuPoint: aPoint toMenu: aMenu
translate a point into another menu its point

o  translatePoint: aPoint to: anotherWindowOrNilForScreen
translate a point in my window to anotherWindowOrNilForScreen (or root window if nil)


Private classes:

    Item
    ScrollActivity

Examples:


start as PullDownMenu


|top subView mview desc s1 s2 s3 img lbs labels|

top := StandardSystemView new.

mview := MenuPanel in:top.

labels := #( 'foo' 'bar' 'baz' 'test' 'claus' ).
mview level:2.
mview verticalLayout:false.
img := Image fromFile:'bitmaps/SBrowser.xbm'.
lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'test' with:'ludwig'.
mview labels:lbs.
mview shortcutKeyAt:2 put:#Cut.
mview accessCharacterPositionAt:1 put:1.
mview accessCharacterPositionAt:2 put:2.

mview enabledAt:5 put:false.
mview groupSizes:#( 2 2 ).
s1 := MenuPanel labels:labels.
s1 accessCharacterPositionAt:1 put:1.
s1 accessCharacterPositionAt:2 put:2.
s1 groupSizes:#( 2 2 ).
s2 := MenuPanel labels:#( '1' nil '2' '-' '3' '=' '4' ' ' '5' ).
s3 := MenuPanel labels:lbs.

s1 subMenuAt:2 put:s2.
s1 subMenuAt:3 put:(MenuPanel labels:lbs).
s2 subMenuAt:3 put:s3.
s3 subMenuAt:3 put:(MenuPanel labels:labels).
s3 shortcutKeyAt:3 put:$q.

mview subMenuAt:1 put:s1.
mview subMenuAt:4 put:(MenuPanel labels:lbs).
(mview subMenuAt:4) shortcutKeyAt:3 put:#Copy.
s1 shortcutKeyAt:1 put:#Copy.
s1 shortcutKeyAt:3 put:#Paste.

mview subMenuAt:2 put:(MenuPanel labels:labels).
top extent:(mview preferredExtent).
top open.


|top menu view item|

top  := StandardSystemView extent:240@100.
menu := MenuPanel in:top.
menu labels:#( 'foo' 'Application' 'Clock' ).
menu verticalLayout:false.

menu subMenuAt:1 put:(MenuPanel labels:#( 'bar' 'baz' )).
menu subMenuAt:2 put:(MenuPanel labels:#( 'foo' 'bar' 'baz' )).

view := ClockView new.
view preferredExtent:100@100.
item := menu itemAt:3.
item submenu:view.

view := SimpleView new.
view client:(CodingExamples_GUI::GUIDemoExtendedComboBox new).
view preferredExtent:(400@50).
item := menu itemAt:2.
item submenu:view.

menu origin:0@0 corner:1.0@30.
top open.
start as PopUpMenu


|subView mview desc s1 s2 s3 img lbs labels|

mview := MenuPanel new.
labels := #( 'foo' 'bar' 'baz' ).
mview level:2.

img := Image fromFile:'bitmaps/SBrowser.xbm'.
lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'test'.
mview labels:lbs.

s1 := MenuPanel labels:labels.
s2 := MenuPanel labels:#( '1' nil '2' '-' '3' '=' '4' ' ' '5' ).
s3 := MenuPanel labels:lbs.
s1 subMenuAt:2 put:s2.
s1 subMenuAt:3 put:(MenuPanel labels:lbs).
s2 subMenuAt:3 put:s3.
s3 subMenuAt:3 put:(MenuPanel labels:labels).
s3 shortcutKeyAt:3 put:$q.

mview subMenuAt:1 put:s1.
mview subMenuAt:4 put:(MenuPanel labels:lbs).
(mview subMenuAt:4) shortcutKeyAt:3 put:#Copy.
s1 shortcutKeyAt:1 put:#Copy.
s1 shortcutKeyAt:3 put:#Paste.

mview subMenuAt:2 put:(MenuPanel labels:labels).
mview startUp
start from menu spec


|menu|

menu := MenuPanel menu:
    #(#Menu #( #(#MenuItem 
                #label: 'File' 
                #submenu:
                  #(#Menu #(#(#MenuItem #label: 'quit' #value:#quit )     
                             (#MenuItem 
                                #label: 'edit' 
                                #submenu:
                                  #(#Menu #( #(#MenuItem #label: 'edit'  #value:#edit )     
                                             #(#MenuItem #label: 'close' #value:#close)     
                                           )
                                           nil
                                           nil
                                   )     
                              )
                             #(#MenuItem #label: 'help' #value:#help )     
                           )
                           nil
                           nil
                   )     
             ) 
            #(#MenuItem #label: 'Inspect' #value:#inspectMenu ) 
            #(#MenuItem #label: 'Bar' 
                        #submenu:
                           #(#Menu #( #(#MenuItem #label: 'bar 1' #value:#bar1 )     
                                      #(#MenuItem #label: 'bar 2' #value:#bar2 )     
                                    )
                                    nil
                                    nil
                            )     
             ) 
          ) 
          #( 2 )
          nil
     ) decodeAsLiteralArray.  

menu verticalLayout:false.
Transcript showCR:(menu startUp).


ST/X 6.1.1; WebServer 1.620 at exept:8081; Tue, 22 May 2012 21:10:06 GMT