eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Menu':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: Menu


Inheritance:

   Object
   |
   +--Model
      |
      +--Menu

Package:
stx:libview2
Category:
Views-Support
Version:
rev: 1.125 date: 2023/04/18 10:43:00
user: stefan
file: Menu.st directory: libview2
module: stx stc-classLibrary: libview2

Description:


Menu (aka MenuSpec, that's what it is!).

similar to UISpecifications, this describes the look, feel and behavior of
popUpMenus, toolbarMenus and window menus.

Instances of me are usually created from menuSpec methods, which return a literal
array description of me.
Instances of me are processed by MenuBuilders, which create a real MenuView/MenuPanel
from that into a window. 

Should be relatively VisualWorks compatible (clean room development, by emulating the
protocol needed by some public domain VW applications)


copyright

COPYRIGHT (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 protocol:

instance creation
o  labelArray: arrayOfStrings
return a menu with menu items built with labels from arrayOfStrings (not Symbols)

o  labelArray: arrayOfString lines: linesArray values: valueArrayOrNil
return a menu with menu items built with labels from arrayOfString (not Symbols).
The linesArray describes which menu items are the last menu item in their group.
The valueArray contains value objects for each menu item
(or is nil if no value objects are specified).

o  labelArray: arrayOfStrings values: valueArrayOrNil
return a menu with menu items built with labels from arrayOfStrings (not Symbols).
The valueArray contains value objects for each menu item
(or is nil if no value objects are specified).

o  labelList: arrayOfGroupStrings values: valueArrayOrNil

o  labels: aString

o  labels: aString lines: linesArray values: valueArrayOrNil

o  labels: aString values: valueArrayOrNil


Instance protocol:

Compatibility-ST80
o  addLine

o  indexOfMenuItem: anItem

o  indexOfMenuItemForWhich: aBlock

o  menuButtons
ST-80 seems to use a special menuButton class here.
Here, kludge a collection of menuItems.

Compatibility-Squeak
o  add: label target: target selector: selector

o  balloonTextForLastItem: aString

o  labels: labels lines: lines selections: selections

accessing
o  atMenuItemLabeled: aString putSubmenu: aMenu visible: visible

o  atNameKey: aNameKey
return the menuItem for the given nameKey; nil if no such item is in the menu.
Searches in allItems (i.e. also in subMenus)

o  atNameKey: aNameKey ifPresentDo: aBlock
look for a menuItem with the given nameKey. If one is found, aBlock is evaluated for it.
If not, nothing is done.
Searches in allItems (i.e. also in subMenus).
Returns the item or nil.

o  groupSizes

o  groupSizes: something

o  itemAtValue: aValue
gets the item which has aValue as value

o  items

o  items: aCollectionOfMenuItems

o  labelAt: anIndex
gets the label of the menu item at the given index or nil

o  labelAtValue: aValue
gets the label of the menu item which has aValue as value

o  labels
return a collection of labels from my items

o  lastItem
returns the last item or nil, if there are none

o  lines
return the indexes of the menu items that are the last menu item in their group (except the very last).

o  menuItemAt: index
gets the menu item at the given index.
When the index is out of bounds, nil is returned

o  menuItemLabeled: anItemLabel
return the menuItem for the given label string; nil if no such item is in the menu.
Searches all items (i.e. also submenu items)

o  menuItemWithArgument: aValue
return the menuItem for the given argument; nil if no such item is in the menu.
Searches all items (i.e. also submenu items)

o  menuItemWithKey: aNameKey
return the menuItem for the given key; nil if no such item is in the menu.
Searches all items (i.e. also submenu items)

o  menuItemWithValue: aValue
return the menuItem for the given itemValue; nil if no such item is in the menu.
Searches all items (i.e. also submenu items)

o  menuItems

o  menuItems: aCollectionOfMenuItems menuItemGroups: sizes values: values

o  menuPerformer: something
set the receiver of the menu messages

o  numberOfItems
return the number of items in this menu

o  receiver
return the receiver of the menu messages

o  receiver: something
set the receiver of the menu messages

o  valueAt: index
return the value of an item

o  valueAt: anIndex put: aValue
put value at an index

o  values
return a collection of values from my items

o  values: aCollectionOfValues
set the collection of values in my items

o  visibleMenuItemGroups
Remove the hidden items.

accessing-resource
o  findGuiResourcesIn: aResourceContainerOrApplication
resolve national language translations from aResourceContainerOrApplication.
Unless already set, remember aResourceContainerOrApplication as menu receiver

o  findGuiResourcesIn: aResourceContainerOrApplication for: aViewOrNil
resolve national language translations from aResourceContainerOrApplication.
Unless already set, remember aResourceContainerOrApplication as menu receiver

o  findGuiResourcesIn: aResourceContainerOrApplication for: aViewOrNil rememberResourcesIn: aValueHolderOrNil
resolve national language translations from aResourceContainerOrApplication

o  findGuiResourcesIn: aResourceContainerOrApplication rememberResourcesIn: aValueHolderOrNil
resolve national language translations from aResourceContainerOrApplication

adding & removing
o  addItem: aMenuItem
add a menuItem at the end;
useful to build a menu programmatically (or, to add more items dynamically)

o  addItem: aMenuItem beforeIndex: anIndex
add a menuItem at some position;
useful to build a menu programmatically (or, to add more items dynamically)

o  addItem: aMenuItem value: aValue

o  addItemGroup: aGroup
add a group of items at the end;
useful to build a menu programmatically (or, to add more items dynamically)

o  addItemGroup: aGroup values: values
add a group of items at the end;
useful to build a menu programmatically (or, to add more items dynamically)

o  addItemGroupLabels: labels values: values
add a group of items at the end;
useful to build a menu programmatically (or, to add more items dynamically)

o  addItemLabel: label value: value
add an item at the end;
useful to build a menu programmatically (or, to add more items dynamically)

o  addItemLabel: label value: value enabled: enabled
add an item at the end;
useful to build a menu programmatically (or, to add more items dynamically)

o  addItems: collection
Add all items in given collection.
Useful to build a menu programmatically (or, to add more items dynamically)

o  addItemsFrom: anotherMenu
Add all items from another menu.
Useful to build a menu programmatically (or, to add more items dynamically)

o  addLabel: aLabel selector: aSelector action: aBlock

o  addSeparator
add a separating line item at the end;
useful to build a menu programmatically (or, to add more items dynamically)

o  addSeparatorIfAppropriate
add a separator, but avoid consecutive separators.

o  removeItem: aMenuItem
remove an item from the menu

o  removeItemAt: anIndex
remove item at an index

converting
o  asOldStylePopUpMenuFor: anApplicationOrNil
a temporary kludge - will vanish, when oldStyle MenuView and PopUpMenu are gone

o  fromLiteralArrayEncoding: aLiteralEncodedArray
read my contents from a aLiteralEncodedArray

o  literalArrayEncoding
return myself encoded as a literal array

enumerating
o  allItemsBreadthFirstDo: aOneArgBlock
recursively evaluate block on each item and submenu items.
This searches in breadth first order

o  allItemsDepthsFirstDo: aOneArgBlock
recursively evaluate block on each item and submenu items.
This searches in depth first order

o  allItemsDetect: aOneArgBlock ifNone: exceptionalValue
recursively find an element amongst each item and submenu items

o  allItemsDo: aOneArgBlock
recursively evaluate block on each item and submenu items.
This searches higher level items first

o  detectItem: aBlock
evaluate the argument, aBlock for each item in the menu until the
block returns true; in this case return the item which caused the
true evaluation.
If none of the evaluations returns true, return the result of the
evaluation of the exceptionBlock

o  detectItem: aBlock ifNone: exceptionValue
evaluate the argument, aBlock for each item in the menu until the
block returns true; in this case return the item which caused the
true evaluation.
If none of the evaluations returns true, return the value from exceptionValue

o  detectItemForLabel: aLabel

o  detectItemForNameKey: aKey

o  do: aOneArgBlock
recursively evaluate block on each item and submenu items

o  itemsDo: aOneArgBlock
evaluate the block for each item in the current menu

o  menuAndSubmenusDetectItem: aOneArgBlock
evaluate the block for each item in the current menu and all
submenus. In case that the block returns a non nil argument,
the item will be returned

kludged fixes
o  destroy
dummy to allow a menu to be used where a MenuView used to be

menu items
o  removeAllAccelerators

o  someMenuItemLabeled: aLabel
get the menu item with that label; in case that the label
is not found, nil is returned

o  someMenuItemLabeled: aLabel ifNone: exceptionBlock
get the menu item labeled aLabel; in case that the value
is not found, the given exceptionBlock is executed and its value returned

o  someMenuItemWithValue: aValue
get the menu item assigned with the value; in case that the value
is not found nil is returned

o  someMenuItemWithValue: aValue ifNone: exceptionBlock
get the menu item assigned with the value; in case that the value
is not found, the given exceptionBlock is executed and returned

queries
o  hasHiddenItems
test whether any item is hidden

o  hasItems
test whether there are any menu-items

o  hasSubMenuAt: anIndex
test whether the menu item at the given index has a submenu

startup
o  show
realize the menu at its last position; returns the value associated with the
selected item, 0 if none was selected

o  showAt: aPoint
realize the menu at aPoint; returns the value associated with the
selected item, 0 if none was selected

o  showAt: aPoint resizing: aBoolean
realize the menu at aPoint; returns the value associated with the
selected item, 0 if none was selected

o  showAtPointer
realize the menu at the current pointer position;
returns the value associated with the selected item, 0 if none was selected

o  showCenteredIn: aView
realize the menu visible at the aView center; returns the value associated with the
selected item, 0 if none was selected

o  startUp
display the menu as a popUp; returns the value associated with the
selected item, nil if none was selected.
(should we return 0 form ST-80 compatibility ?)

Usage example(s):

     |m|

     m := #(#Menu #(
                     #(#MenuItem 
                             #rawLabel: 'left' 
                             #value: #left ) 
                     #(#MenuItem 
                             #rawLabel: 'center' 
                             #value: #center ) 
                     #(#MenuItem 
                             #rawLabel: 'right' 
                             #value: #right ) ) 
              #(2) 
             nil 
     ) decodeAsLiteralArray.

   Transcript showCR:(m startUp)        

o  startUpAt: aPoint
display the menu as a popUp at aPoint; returns the value associated with the
selected item, 0 if none was selected

Usage example(s):

     |m|

     m := #(#Menu #(
                     #(#MenuItem 
                             #rawLabel: 'left' 
                             #value: #left ) 
                     #(#MenuItem 
                             #rawLabel: 'center' 
                             #value: #center ) 
                     #(#MenuItem 
                             #rawLabel: 'right' 
                             #value: #right ) ) 
              #(2) 
             nil 
     ) decodeAsLiteralArray.

   Transcript showCR:(m startUpAt:100@100)        

o  startUpFor: originatingWidget
display the menu as a popUp; returns the value associated with the
selected item, nil if none was selected.
(should we return 0 for ST-80 compatibility ?)

o  startUpOrNil
display the menu as a popUp; returns the value associated with the
selected item, nil if none was selected

utilities
o  replaceArgument: oldValue with: newValue
Recusively Replace argument in menu items where
current argument is equal to oldValue by newValue


Private classes:

    NeedResourcesQuery


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 14 Dec 2024 20:20:53 GMT