|
Class: MenuPanel
Object
|
+--GraphicsMedium
|
+--DisplaySurface
|
+--SimpleView
|
+--View
|
+--MenuPanel
|
+--ColorMenu
|
+--FontMenu
- Package:
- stx:libwidg2
- Category:
- Views-Menus
- Version:
- rev:
1.832
date: 2024/04/26 11:40:21
- user: cg
- file: MenuPanel.st directory: libwidg2
- module: stx stc-classLibrary: libwidg2
a menu panel used for both pull-down-menus and pop-up-menus.
Due to some historic leftover, there are two mechanisms for menus:
1) the (very) old MenuView (which inherits from SelectionInListView)
2) this new MenuPanel.
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 can generate
menu specifications, from which a MenuPanel can be dynamically created.
Notice:
This is going to replace the obsolete MenuView.
cg: this code is so ugly - needs a complete rewrite...
copyrightCOPYRIGHT (c) 1997 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
class initialization
-
initialize
-
self initialize
default icons
-
delayedMenuIndicator
-
This resource specification was automatically generated
by the ImageEditor of ST/X.
Usage example(s):
self delayedMenuIndicator inspect
ImageEditor openOnClass:self andSelector:#delayedMenuIndicator
Icon flushCachedIcons
|
-
iconIndicationDisabledOff
-
This resource specification was automatically generated
by the ImageEditor of ST/X.
Usage example(s):
self iconIndicationDisabledOff inspect
ImageEditor openOnClass:self andSelector:#iconIndicationDisabledOff
Icon flushCachedIcons
|
-
iconIndicationDisabledOn
-
This resource specification was automatically generated
by the ImageEditor of ST/X.
Usage example(s):
self iconIndicationDisabledOn inspect
ImageEditor openOnClass:self andSelector:#iconIndicationDisabledOn
Icon flushCachedIcons
|
-
iconIndicationOff
-
This resource specification was automatically generated
by the ImageEditor of ST/X.
Usage example(s):
self iconIndicationOff inspect
ImageEditor openOnClass:self andSelector:#iconIndicationOff
Icon flushCachedIcons
|
-
iconIndicationOn
-
This resource specification was automatically generated
by the ImageEditor of ST/X.
Usage example(s):
self iconIndicationOn inspect
ImageEditor openOnClass:self andSelector:#iconIndicationOn
Icon flushCachedIcons
|
-
iconRadioGroupDisabledOff
-
This resource specification was automatically generated
by the ImageEditor of ST/X.
Usage example(s):
self iconRadioGroupDisabledOff inspect
ImageEditor openOnClass:self andSelector:#iconRadioGroupDisabledOff
|
-
iconRadioGroupDisabledOn
-
This resource specification was automatically generated
by the ImageEditor of ST/X.
Usage example(s):
self iconRadioGroupDisabledOn inspect
ImageEditor openOnClass:self andSelector:#iconRadioGroupDisabledOn
Icon flushCachedIcons
|
-
iconRadioGroupEnteredOff
-
-
iconRadioGroupEnteredOn
-
-
iconRadioGroupOff
-
This resource specification was automatically generated
by the ImageEditor of ST/X.
Usage example(s):
self iconRadioGroupOff inspect
ImageEditor openOnClass:self andSelector:#iconRadioGroupOff
|
-
iconRadioGroupOn
-
This resource specification was automatically generated
by the ImageEditor of ST/X.
Usage example(s):
self iconRadioGroupOn inspect
ImageEditor openOnClass:self andSelector:#iconRadioGroupOn
|
-
menuIndicator
-
This resource specification was automatically generated
by the ImageEditor of ST/X.
Usage example(s):
self menuIndicator inspect
ImageEditor openOnClass:self andSelector:#menuIndicator
Icon flushCachedIcons
|
defaults
-
defaultBackgroundColor
-
(comment from inherited method)
return the default background color for drawing - usually,
that is the same as the viewBackgroundColor.
-
defaultLevel
-
self defaultLevel
-
delayedMenuIndicatorOffset
-
returns an additional offset between the label and the
delayedMenu indication (i.e. the down-arrow icon)
-
maxShortCutSearchLevel
-
1 means: only search in top items.
2 means: search one level of menus.
used to be 10
-
maxShortCutSearchLevel: anInteger
-
1 means: only search in top items.
2 means: search one level of menus.
-
menuIndicatorOffset
-
returns an additional offset between the label and the
delayedMenu indication (i.e. the down-arrow icon)
-
mnemonicIdentifier
-
returns the identifier each mnemonic starts with;
ex:
&File mnemonic := Cmdf
F&ile mnemonic := Cmdi
.....
-
updateStyleCache
-
extract values from the styleSheet and cache them in class variables
Usage example(s):
image registration
-
image: anImage onDevice: aDevice
-
Images := nil
-
lightenedImage: anImage onDevice: aDevice
-
LigthenedImages := nil
-
releaseCachedImagesFromDevice: aGraphicsDevice
-
flush cached resources before saving a snapshot
(do not save them in the image)
instance creation
-
fromSpec: aSpec
-
-
fromSpec: aSpec receiver: aReceiver
-
-
labels: labels
-
-
labels: labels nameKeys: nameKeys
-
-
labels: labels nameKeys: nameKeys receiver: aReceiver
-
-
labels: labels receiver: aReceiver
-
-
menu: aMenu
-
-
menu: aMenu receiver: aReceiver
-
cg: the reasoning behind this code is absolutely unclear.
private
-
subMenu: aSubMenu
-
create a submenu; can be redefined in derived classes
startup & release
-
preSnapshot
-
flush cached resources before saving a snapshot
(do not save them in the image)
utilities
-
processAmpersandCharactersFor: aLabel withAccessCharacterPosition: accessCharacterPositionOrNil
-
replace &x by the short-key attribute (i.e. remove & and underline x)
The position is either specified by an accessCharacter position (useful if computed
or fix), or by an ampersand escape.
Double ampersands are replaced by a single one.
accepting
-
accept
-
(comment from inherited method)
accept the current contents by executing the accept-action and/or changeMessage.
-
accept: anItemOrNil
-
this is the topMenu: close the menu and accept the item (if not nil)
-
accept: anItem index: anIndex toggle: aState receiver: aReceiver
-
really accept an item
-
accept: anItemOrNil isUserAction: isUserAction
-
this is the topMenu: close the menu and accept the item (if not nil)
Usage example(s):
acceptAction := [ self accept:itemAcceptedOrNil index:itemIdx toggle:tgState receiver:recv ].
|
-
acceptIsUserAction: isUserAction
-
accept the current selected item;
isUserAction is false, if indirectly accepted
(only when coming via a dialog's ok button)
-
acceptItem: anItemOrNil inMenu: aMenu
-
-
acceptItem: anItemOrNil inMenu: aMenu isUserAction: isUserAction
-
toggle if accepting due to a button release or return-key;
-
lastItemAccepted
-
returns last item selected or nil
-
lastValueAccepted
-
returns last value accepted or nil
accessing
-
args
-
returns a collection of arguments or nil
-
args: something
-
define arguments for each item
-
argsAt: stringOrNumber
-
gets the argument of an item or nil
-
argsAt: stringOrNumber put: anArgument
-
sets the argument of an item
-
labelAt: stringOrNumber
-
gets the label of an item or nil
-
labelAt: stringOrNumber put: aLabel
-
sets the label of an item
-
labels
-
returns a collection of labels's or nil
-
labels: labels
-
define labels for each item
-
nameKeyAt: stringOrNumber
-
gets the nameKey of an item or nil
-
nameKeyAt: stringOrNumber put: aNameKey
-
sets the nameKey of an item
-
nameKeys
-
returns a collection of nameKeyss or nil
-
nameKeys: something
-
define nameKeys for each item
-
originator
-
-
valueAt: stringOrNumber
-
gets value of an item; a block, valueHolder, ...
-
valueAt: stringOrNumber put: aBlockOrValueHolderOrSelector
-
sets value of an item; a block, valueHolder, ...
-
values: something
-
define values for each item
accessing-behavior
-
disableAll
-
disable all items; not the menu in case of enabled
-
disableAll: collectionOfIndicesOrNames
-
disable an collection of items
-
doAccessCharacterTranslation
-
true if &-chars in a label are to be treated as accessCharacter indicators.
Can be set to false to leave accessCharacter unchanged
-
doAccessCharacterTranslation: aBoolean
-
true if &-chars in a label are to be treated as accessCharacter indicators.
Can be set to false to leave accessCharacter unchanged
-
enableAll
-
enable all items; not the menu in case of disabled
-
enableAll: collectionOfIndicesOrNames
-
enable an collection of items
-
enabled
-
returns enabled state
-
enabled: aBooleanOrNil
-
change enabled state of menu
-
enabledAt: stringOrNumber
-
gets the enabled state of an item (given by name or index)
-
enabledAt: stringOrNumber put: aBoolean
-
sets the enabled state of an item
-
exclusivePointer: aBoolean
-
Do nothing here. Compatibility with PopUpListController
-
hideOnRelease
-
-
hideOnRelease: aBoolean
-
-
isEnabled: stringOrNumber
-
gets the enabled state of an item (given by name or index)
-
menuPerformer: anObject
-
set the menu-receiver. That's the one who gets the messages ( both from myself and
from all submenus no specific receiver is defined ).
-
receiver
-
get the menu-receiver. That's the one who gets the messages ( both from myself and
from all submenus no specific receiver is defined ).
-
receiver: anObject
-
set the menu-receiver. That's the one who gets the messages ( both from myself and
from all submenus no specific receiver is defined ).
-
shortcutKeyAt: stringOrNumber
-
gets the shortCutKey of an item or nil
-
shortcutKeyAt: stringOrNumber put: aKey
-
sets the shortCutKey of an item
-
shortcutKeys
-
returns a collection of shortcutKeys or nil
-
shortcutKeys: something
-
define shortcutKeys for each item
accessing-channels
-
enableChannel: aValueHolder
-
set my enableChannel
-
menuChannel
-
-
menuHolder: aValueHolder
-
set my menuHolder
accessing-color & font
-
activeBackgroundColor
-
get the background drawing color used to highlight selection
-
activeForegroundColor
-
get the foreground color used to highlight selections
-
backgroundColor: aColor
-
set the background drawing color. You should not use this method;
instead, leave the value as defined in the styleSheet.
-
buttonActiveBackgroundColor
-
get the background drawing color used to highlight button selection
-
buttonActiveForegroundColor
-
get the foreground drawing color used to highlight button selection
-
buttonEdgeStyle
-
get the button edge style
-
buttonEnteredBackgroundColor
-
get the background drawing color used to highlight entered button items
-
buttonEnteredFrameColor
-
get the frame color used to highlight entered button items
-
buttonEnteredLevel
-
get the 3D-level used to highlight entered button items
-
buttonHalfLightColor
-
get the background drawing color used to half light button frame
-
buttonHalfShadowColor
-
get the background drawing color used to half shadow button frame
-
buttonLightColor
-
get the background drawing color used to light button frame
-
buttonPassiveBackgroundColor
-
get the background drawing color used for button
-
buttonShadowColor
-
get the background drawing color used to shadow button frame
-
disabledEtchedForegroundColor
-
return the color used for etching disabled items.
If nil, no 3D effect is drawn.
-
disabledForegroundColor
-
return the foreground color used by disabled items
-
enteredBackgroundColor
-
return the background color for entered items
-
enteredForegroundColor
-
return the foreground color for entered items
-
font: aFont
-
set the font
-
foregroundColor
-
return the passive foreground color
-
foregroundColor: aColor
-
set the foregroundColor drawing color. You should not use this method;
instead leave the value as defined in the styleSheet.
-
maxAbsoluteButtonLevel
-
returns the maximum absolute button level; used to compute the preferred
extent of a button
-
selectionFrameBrightColor
-
get the selection frame bright color
-
selectionFrameDarkColor
-
get the selection frame dark color
-
setFont: aFont
-
set the font if the argument is nonNil;
Return nil, if the font was unchanged; otherwise, return the old font
-
suppressSeparatingLines
-
accessing-dimensions
-
computePreferredExtent
-
compute and returns my preferred extent
-
height
-
default height
-
maxExtent
-
notice, the position-dependent query: if there is a larger secondary screen,
Usage example(s):
don't know, assume there is no maxExtent
|
-
origin: origin
-
changed due to menu in horizontal panel, if the origin
changed we have to rearrange the menu items if size not fixed
-
preferredExtentOfItems
-
compute and returns my preferred extent including all items
!!! changes have influence on method #rearrangeItems !!!
-
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.
-
shortKeyInset
-
left inset of shortcutKey
-
sizeFixed: aBoolean
-
set/clear the fix-size attribute.
If true (the default), the menuPanel will not change its size when items become visible/invisible.
If false, it will resize itself to adapt to the number of visible items
-
stringOffsetXfor: anItem
-
return the x offset for a MenuItem where to draw the text
-
subMenuIndicationWidth
-
accessing-interactors
-
iconIndicationDisabledOff
-
-
iconIndicationDisabledOn
-
-
iconIndicationOff
-
-
iconIndicationOn
-
-
iconRadioGroupDisabledOff
-
-
iconRadioGroupDisabledOn
-
-
iconRadioGroupEnteredOff
-
-
iconRadioGroupEnteredOn
-
-
iconRadioGroupOff
-
-
iconRadioGroupOn
-
accessing-items
-
enteredItem
-
return the item over which the mouse pointer is located;
nil if the mouse is not over any item
-
hasItems
-
return true, if I have items
-
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
-
itemAt: stringOrNumber do: aOneArgBlock ifAbsent: exceptionBlock
-
evaluate the block for an item and return the result from the block.
In case that the item does not exist,
the value from exception block is returned (no arguments)
-
itemAtIndex: anIndex
-
returns item at an index or nil
-
items
-
returns the list of items or nil.
Warning: do not change this list - it is mine !
-
numberOfItems
-
gets number of items
accessing-look
-
accessCharacterPositionAt: stringOrNumber
-
get the access character position for a textLabel
-
accessCharacterPositionAt: stringOrNumber put: anIndexOrNil
-
get the access character position for a textLabel
-
accessCharacterPositions
-
returns a collection of accessCharacterPositions or nil
-
accessCharacterPositions: something
-
define accessCharacterPositions for each item
-
buttonActiveLevel
-
get the buttons active level
-
buttonPassiveLevel
-
get the buttons passive level
-
centerItems
-
-
centerItems: aBoolean
-
-
fitFirstPanel
-
gets true if the first panel in the menu hierarchy must be fit
to the extent of its superView
NOT SUPPORTED
-
fitFirstPanel: aBoolean
-
NOT SUPPORTED.
should return true if the first panel in the menu hierarchy must fit
to the extent of its superView
-
groupSizes
-
gets collection of group sizes
-
groupSizes: aGroupSizes
-
sets collection of group sizes
-
hasVerticalLayout
-
return true if the layout is vertical
-
hasVerticalLayout: aBoolean
-
set the layout: vertical( true ) or horizontal( false )
-
level: anInt
-
(comment from inherited method)
set my 3D effect level relative to superView in nr of pixels
-
rightArrow
-
-
rightArrowShadow
-
-
showGroupDivider
-
get the enabled flag for showing groupDiveders
-
showGroupDivider: aBoolean
-
set the enabled flag for showing groupDiveders
-
showSeparatingLines
-
gets true if drawing of separating lines is enabled.
-
showSeparatingLines: aBoolean
-
turn on/off drawing of separating lines.
-
verticalLayout
-
return true if the layout is vertical
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
verticalLayout: aBoolean
-
set to true if the layout is vertical; false for horizontal
** This is an obsolete interface - do not use it (it may vanish in future versions) **
accessing-style
-
buttonInsetX
-
returns the verical button space
-
buttonInsetY
-
returns the verical button space
-
delayInSecondsBeforeOpeningSubmenu
-
answer the seconds a submenu will be delayed before
open; an already open submenu than will be closed
-
drawMenuIndicatorSeparatorLine
-
^ styleSheet at:#'menu.drawMenuIndicatorSeparatorLine' default:false
-
enteredLevel
-
returns the enter-level for an unselected item moved through
-
groupDividerSize
-
returns the width of a group divider
-
itemMargin
-
returns the margin of an item
-
itemSpace
-
returns the additional space for an item in a (vertical) panel
-
menuIndicatorVerticalPosition
-
#center, #top or #bottom
Usage example(s):
^ styleSheet at:#'menu.menuIndicatorVerticalPosition' default:#bottom
|
-
selectionFollowsMouse
-
returns true if the selection follows the mouse
-
shortcutKeyOffset
-
returns the offset for a shortcutKey
accessing-submenu
-
subMenuAt: stringOrNumber
-
gets the current submenu of an item; if the submenu is nil, the
submenu is generated if specified otherwise nil is returned.
-
subMenuAt: stringOrNumber put: aSubMenu
-
sets the submenu of an item
-
subMenuShown
-
return the currently visible submenu - or nil if there is none
activation & deactivation
-
closeMenus
-
close all menus without accepting
-
hide
-
hide the view, leave its modal event loop
-
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)
-
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)
-
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.
-
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)
-
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)
-
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)
-
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)
-
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)
-
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
-
addItem: aMenuItem
-
add a menuItem at the end;
useful to build a menu programmatically (or, to add more items dynamically)
-
addSeparator
-
-
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.
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
createItemAtIndex: 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.
-
remove: stringOrNumber
-
remove the first item which is assigned to stringOrNumber;
if found, remove and return it
-
removeAll
-
remove all items and submenus
change & update
-
update: something with: aParameter from: changedObject
-
changed due to menu in horizontal panel
converting
-
asMenu
-
convert contents to a menu
-
fromSpec: aMenuSpec
-
build from spec
-
menu: aMenu
-
setup from a menu
dependents access
-
addDependencies
-
add all dependencies
-
removeDependencies
-
remove all dependencies
drawing
-
delayedInvalidateItem: anItem repairNow: aBool
-
an item changed; invalidate the item's layout
-
disabledRedrawDo: aBlock
-
evaluate a block without redrawing within the block; after processing
of the block a redraw might be performed
-
drawButtonEdgesFor: anItem level: aLevel
-
-
drawFocusForItem: anItem
-
draw a dotted rectangle around an item to indicate that it has the keyboard focus
-
drawGroupDividerFor: item inset: groupDivInset
-
draw a group divider
-
drawItemsX: x y: y width: w height: h
-
redraw items and groups
-
drawLabelEdgeFor: anItem selected: isSelected
-
-
drawScrollButtonAt: aDirection bounds: bounds
-
draw a scroll button
-
invalidateItem: anItem repairNow: aBool
-
an item changed; invalidate the item's layout
-
mustRearrange
-
force rearrange (i.e. set the rearrange flag)
-
rearrangeGroups
-
implements the groupIdentifier #right/#conditionalRight in a horizontal menu
-
rearrangeItems
-
recompute the layout of each item
!!! changes have influence on method #preferredExtentOfItems !!!
-
rearrangeItemsIfItemVisibilityChanged
-
check for items which can change its visibility;
if at least one item exists, rearrange all items
-
redrawX: x y: y width: w height: h
-
redraw a damage
-
updateEnteredItem
-
enumerating & searching
-
collect: aOneArgBlock
-
evaluate the argument, aOneArgBlock for every item in the menuPanel
and return a collection of the results
-
detectItem: aBlock
-
returns the item for which aBlock returns true.
-
detectItemForKey: aKey
-
returns the item assigned to a key, accessCharacter or starts with.
if no item is detected nil is returned.
-
detectItemForLabel: aLabel
-
-
detectItemForNameKey: aKey
-
-
do: aOneArgBlock
-
evaluate the argument, aOneArgBlock for every item in the menuPanel.
-
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.
-
findLast: aOneArgBlock
-
find the last item, for which evaluation of the argument, aOneArgBlock
returns true; return its index or 0 if none detected.
-
firstItemSelectable
-
returns the first item which is selectable or nil
-
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
-
indexOfItem: anItem
-
returns the index of the item or 0
-
itemForWhich: checkBlock
-
-
itemsDo: aBlock
-
-
itemsDoWithIndex: aBlock
-
-
keysAndValuesDo: aTwoArgBlock
-
evaluate the argument, aTwoArgBlock for every item in the menuPanel.
event handling
-
buttonMotion: state x: x y: y
-
open or close the corresponding submenu
-
buttonPress: button x: x y: y
-
any button pressed; open or close the corresponding submenus
-
buttonRelease: button x: x y: y
-
button release action; accept selection and close all views
-
exposeX: x y: y width: w height: h
-
e'=================== expose **** {x} x {y} -> {w}/{h}' printCR.
-
handleSizeChanged: how from: oldExtentOrNil
-
if a rearrange is already pending...
-
keyPress: key x: x y: y
-
any key is pressed
-
mapped
-
if I come up with a pressed button, react on release instead.
-
mouseWheelMotion: buttonState x: x y: y amount: amount deltaTime: dTime
-
mousewheel action
-
pointerLeave: state
-
I'have the focus; if no button pressed, than keep the selection
-
sizeChanged: how from: oldExtentOrNil
-
my view has changed the size (not the contents)
Usage example(s):
event handling-processing
-
clearImplicitGrab
-
-
dispatchEvent: ev withFocusOn: focusView delegate: doDelegate
-
dispatch and handle an event
-
handleButtonMotion: state atPoint: motionPoint
-
invalidate affected menu items
and possibly open or close corresponding submenus.
If I am a sub(sub-) menu, this message is forwarded from the
top level menu to me
-
handleButtonPress: button atPoint: aPoint
-
a button pressed; open or close the corresponding submenus
-
handleCursorKey: aKey
-
handle a cursor key
-
handleKeyPress: key
-
any key is pressed
-
handlePointerLeave: state
-
-
handleReturnPressed
-
return (or space) key is pressed
-
handleScrollerEvent: ev
-
handle a scroller event;
because I have grabbed the pointer, the event's coordinate
is relative to my view, and must be xlated to the scroller.
Return true if the event is handled (i.e. a scroller event)
-
pointerEntersItem: anItemOrNil
-
the pointer moves over an item or nil;
restore the old item and redraw the new item highlighted.
-
processHideMenuEvent: ev
-
to be filled...
-
processMenuEnterItemEvent: ev
-
to be filled...
-
processMenuSelectItemEvent: ev
-
if I was started as a modal Dialog, the activating windowGroup
has already been nilled after the Menu disappeared
(mustNilWindowGroup in SimpleView >> #openModal:inGroup:asPopup:).
-
updateHelpForItem: anItemOrNil
-
give the app a chance to present the help text in its info line
focus handling
-
canTab
-
depends whether I'am a toolbar and selectable items exists
-
focusComesByTab
-
returns true if focus comes by tab and should be drawn
-
focusComesByTab: aBoolean
-
only handled for toolBars
-
hasKeyboardFocus: aBoolean
-
notification from the windowGroup that I got/lost the keyboard focus.
-
showFocus: focusComesByTab
-
(comment from inherited method)
highlight myself somehow to tell user that I have the focus.
If explicit is true, the focus came via focusStepping (i.e. tabbing);
if false, it came via the window manager (i.e. pointer entering).
Only change my border, if this is an explicit focusChange.
-
showNoFocus: focusByTab
-
(comment from inherited method)
undo the effect of showFocus.
Explicit tells if the focus came via focusStepping (i.e. tabbing)
or via the window manager (i.e. pointer entering).
Only change my border, if this is an explicit focusChange.
-
supportsFocusOnTab
-
returns true if focus is supported
-
wantsFocusWithButtonPress
-
needs only the focus if I'am a toolbar; all events are delegated
to my subMenus
grabbing
-
doGrab
-
-
doUngrab: forceDo
-
-
grabKeyboard
-
grap the keyboard; keep previous grab
-
grabMouseAndKeyboard
-
get exclusive access to pointer and keyboard
-
grabPointerWithCursor: aCursorOrNil
-
grap the pointer; keep previous grab
-
ungrabKeyboard
-
ungrap the keyboard; restore previous grab
-
ungrabMouseAndKeyboard
-
ungrab resources (mouse and keyboard)
-
ungrabPointer
-
ungrap the pointer; restore previous grab
help
-
helpSpecProvider: aSpecProvider
-
pluggable helpspec provider
-
helpText
-
return the helpText for the currently selected item (empty if none).
Usage example(s):
^ self helpTextForItem:selection
|
-
helpTextAt: aPoint
-
return the helpText for aPoint (i.e. when mouse-pointer is moved over an item).
If there is a selection, that item's helpText is used (ignoring the given point).
cg: this is wrong - should (and does) always show the helptext under the pointer
-
helpTextForItem: anItem
-
returns the helpText for an item (nil if none)
-
helpTextForKey: aKey
-
first try my application to provide the text,
then, in case I have a pluggable helpSpec, try that
help specs
-
helpSpec
-
allows subclasses to provide texts
image registration
-
imageOnMyDevice: anImage
-
returns image registered on device
-
lightenedImageOnDevice: anImage
-
returns lightened image registered on device
initialization & release
-
addToCurrentProject
-
ignored here
-
create
-
maybe create the shadow view for a popUp menu
-
createVisibleScroller
-
create a scroller (like a scrollbar, but without step-buttons) if neccessary
-
destroy
-
destroy items and shadowView; remove dependencies
-
fetchDeviceResources
-
fetch device colors, to avoid reallocation at redraw time
-
initStyle
-
initialize style specific stuff
-
initialize
-
set default configuration
-
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.
-
realize
-
realize menu and shadowView
Usage example(s):
Because of #saveUnder of ShadowView the order of realize is significant:
shadowView must be realized before self
|
-
recreate
-
this is called after a snapin or a migration.
If the image was saved with an active menu, hide the menu
-
reinitStyle
-
handle style change while being open (win32 only - for now)
-
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.
-
updateLevelAndBorder
-
update level & border
keyboard control
-
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.
-
openMenusFromItemIndices: anItemIndiceList
-
open all menus derived from sequence of item indices
-
processCollectedShortcutIndices: indices
-
first lookup in current open submenus
-
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.
-
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
-
raiseDeiconified
-
-
superMenu
-
returns supermenu or nil
-
topMenu
-
returns the topMenu; the one having no superMenu
printing & storing
-
printOn: aStream
-
(comment from inherited method)
append a user printed representation of the receiver to aStream.
The format is suitable for a human - not meant to be read back.
The default here is to output the receiver's class name.
BUT: this method is heavily redefined for objects which
can print prettier.
private
-
application
-
optimize access to retrive the application
-
onEachPerform: aSelector withArgList: aList
-
on each item perform selector with an argument derived from aList
-
registerImageOnDevice: anImage
-
|image|
-
superMenu: aSuperMenu
-
set my supermenu from which i'am activated
-
withMenuAndItemAt: srcPoint do: aBlock
-
private-activation
-
activeMenu
-
returns the current active menu or self (the top menu)
-
activeMenu: aMenu
-
set the current active menu
-
becomesActiveMenu
-
submenu becomes the active menu
-
clearLastActiveMenu
-
reset the current active menu
-
mapTime
-
get the time the menu was activated or nil
-
mapTime: aTimestamp
-
set the time the menu was activated
private-scrolling
-
autoScroll: delta
-
-
hasScrollButtonAt: aDirectionSymbol
-
returns true if a visible scroll button at aDirectionSymbol exists
-
hasScrollButtons
-
marked as obsolete by cg at 24-Aug-2021
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
hasScrollerAt: aDirection
-
marked as obsolete by cg at 24-Aug-2021
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
hasScrollers
-
marked as obsolete by cg at 24-Aug-2021
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
indexOfFirstItemShown
-
answer the index of the first shown item or 0 if there is none
-
indexOfItemAtScroller: aDirection
-
returns the index of the item under the scroller or 0
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
indexOfLastItemShown
-
answer the index of the last shown item or 0
-
installAutoScroll
-
Transcript showCR: e'{Timestamp now} y: {y}'.
-
makeItemVisible: anItem
-
make an item visible
-
needScrollButtonAt: aDirectionSymbol
-
returns true if a visible scroll button at aDirectionSymbol is needed
-
needScrollButtons
-
returns true if any scroll button is needed
-
offsetForScroller
-
marked as obsolete by cg at 24-Aug-2021
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
pageDown
-
scroll one page down
-
pageUp
-
scroll one page up
-
scrollActivity
-
returns the one and only per-menu scrollActivity
-
scrollActivityIsActive
-
-
scrollActivityOrNil
-
-
scrollButtonBoundsAt: aDirectionSymbol
-
returns the bounds of the scroller at aDirectionSymbol,
which is #NEXT or #PREV
Warning: this is the current state, based upon the current view's extent
THUS: you cannot ask in a sizeChange for this info.
-
scrollButtonDirectionAtPoint: aPoint
-
returns the scroller-direction-symbol at aPoint, #PREV, #NEXT or nil
-
scrollDown
-
scroll one line down
Usage example(s):
if there is no scroller and no scrollDown button, then do nothing
|
-
scrollTo: aNewOrigin redraw: doRedraw allowScrollBeyondContents: allowScrollBeyondContents
-
change origin to have newOrigin be visible at the top-left.
-
scrollToBottom
-
scroll to last visible item
-
scrollToTop
-
scroll to first visible item
-
scrollUp
-
scroll one line up
Usage example(s):
if there is no scroller and no scrollUp button, then do nothing
|
-
scrollerBoundsAt: aDirectionSymbol
-
marked as obsolete by cg at 24-Aug-2021
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
scrollerDirectionAtPoint: aPoint
-
marked as obsolete by cg at 24-Aug-2021
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
scrollerInstanceOrNil
-
answer the scroller instance if there is one
-
stopScrollActivity
-
-
updateScroller
-
scroller thumbHeight: (self innerHeight asPercentFrom:(self heightOfContents)).
-
viewOrigin
-
return the viewOrigin;
that's the coordinate of the first shown item
-
widthOfScroller
-
answer the width for a (vertical) scroller
or 0 if no scroller is needed; i.e. possibly scroll buttons.
private-searching
-
detectGrabMenu
-
returns the menu which is responsible for the grap; the last opened menu
-
detectMenuAtGrabPoint: aGrabPoint
-
returns the menu which contains the grab-point
-
grabMenuItemAtPoint: aPoint
-
returns the item in the active menu at aPoint or nil if none detected.
aPoint is relative to myself and might be outside, if I have gabbed the mouse
and a submenu is currently active)
-
itemAt: stringOrNumberOrPoint
-
returns item assigned to an index, nameKey, textLabel or value if symbol.
If no item match nil is returned.
-
itemAtPoint: aPoint
-
returns the item at aPoint or nil if none detected.
aPoint is within myself
(which might be outside, if I have gabbed the mouse
and a submenu is currently active)
-
superMenuAtPoint: aPoint
-
returns the superMenu which contains aPoint, or nil if none detected
queries
-
container: aView
-
I am no longer a popUpView
-
containsPoint: aPoint
-
returns true if the argument, aPoint is contained by the view
-
containsPointX: x y: y
-
returns true if point is contained by the view
-
hasGroupDividerAt: anIndex
-
returns true if a divider is defined at an index
-
hasGroupDividers
-
returns true if any group divider exists
-
hasPerformed
-
-
isFitPanel
-
returns true if the panel is the first in the menu hierarchy
and must be fit to the extent of its superView;
Obsolete: NO LONGER SUPPORTED
-
isPopUpView
-
return true, if I want to come up without decoration
and raise to top immediately.
-
isVerticalLayout
-
marked as obsolete by cg at 24-Aug-2021
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
isViewWrapper
-
-
type
-
queries-contents
-
heightOfContents
-
return the height of the (visible) contents in pixels.
selection
-
hasSelection
-
returns true if a selection exists
-
openDelayed: anItem
-
-
openDelayed: anItemOrNil afterSeconds: seconds
-
-
selectAndOpenDelayed: anItemOrNil
-
change selection to an item or nil
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
selectAndOpenDelayed: anItemOrNil after: delayTimeInSeconds
-
change selection to an item or nil;
If the item has a submenu, open it after some delay time.
The delay time is needed, in case you try to move into the
just opened submenu, and come across another item (if the supermenu)
while doing so (i.e. moving to down-east from the selected item)
-
selection
-
returns current selected item or nil
-
selection: anItemOrNil
-
change selection to an item or nil
if the item has a submenu, the first item might be auto selected (style-sheet)
-
selection: anItemOrNil openMenu: openMenu
-
change selection to an item or nil
-
selectionIndex
-
returns index of current selection or 0
-
selectionIndex: anIndex
-
set selection at an index
-
setSelection: anItemOrNil
-
anItemOrNil ~~ selection ifTrue:[
testing
-
isMenu
-
true if this is a menu panel
translation
-
translateGrabPoint: aGrabPoint
-
translate the grab point into self
-
translateMenuPoint: aPoint toMenu: aMenu
-
translate a point into another menu its point
Item
ScrollActivity
a PullDownMenu
|top mview labels|
top := StandardSystemView new.
labels := #( 'foo' 'bar' 'baz' 'test') copy.
labels at:4 put:(LabelAndIcon label:'test' icon:(ToolbarIconLibrary cutIcon)).
mview := MenuPanel in:top.
mview labels:labels.
(mview itemAt:1) enabled:false.
(mview itemAt:4) enabled:false.
top extent:(mview preferredExtent + 20).
top open.
|
|top 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 hasVerticalLayout: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.
|
a PullDownMenu with applications
|top menu view item|
top := StandardSystemView extent:240@100.
menu := MenuPanel in:top.
menu labels:#( 'foo' 'Application' 'Clock' ).
menu hasVerticalLayout: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 := ImageView new.
view image:(Image fromScreen:(0@0 corner:200@200)).
view preferredExtent:(200@200).
item := menu itemAt:2.
item submenu:view.
menu origin:0@0 corner:1.0@30.
top open.
|
a PopUpMenu
|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
|
a 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 hasVerticalLayout:false.
Transcript showCR:(menu startUp).
| many items; menuPanel embedded in another (top) view:
|top mview labels|
top := StandardSystemView new.
labels := (1 to:50) collect:[:n | e'item{n}'].
mview := MenuPanel in:top.
mview labels:labels.
mview hasVerticalLayout:true.
(mview itemAt:1) enabled:false.
(mview itemAt:4) enabled:false.
mview extent:(mview preferredExtent x @ 1.0).
top extent:(mview preferredExtent + 20).
top open.
| huge number of items; menuPanel embedded in another (top) view:
|top mview labels|
top := StandardSystemView new.
labels := (1 to:150) collect:[:n | e'item{n}'].
mview := MenuPanel in:top.
mview labels:labels.
mview hasVerticalLayout:true.
(mview itemAt:1) enabled:false.
(mview itemAt:4) enabled:false.
mview extent:(mview preferredExtent x @ 1.0).
top extent:(mview preferredExtent + 20).
top open.
| many items; menuPanel as popup:
|mview labels|
labels := (1 to:50) collect:[:n | e'item{n}'].
mview := MenuPanel new.
mview labels:labels.
mview hasVerticalLayout:true.
(mview itemAt:1) enabled:false.
(mview itemAt:4) enabled:false.
mview open.
| huge number of items; menuPanel as popup:
|mview labels|
labels := (1 to:150) collect:[:n | e'item{n}'].
mview := MenuPanel new.
mview labels:labels.
mview hasVerticalLayout:true.
(mview itemAt:1) enabled:false.
(mview itemAt:4) enabled:false.
mview extent:(mview preferredExtent x @ 1.0).
mview open.
|
|