--- a/MenuPanel.st Wed Dec 21 12:40:16 2005 +0100
+++ b/MenuPanel.st Wed Dec 21 18:42:21 2005 +0100
@@ -5000,14 +5000,14 @@
!MenuPanel::Item class methodsFor:'defaults'!
halfSeparatorSize
- "returns size of a space-separator
- "
+ "returns the size of a space-separator"
+
^ 5
!
separatorSize
- "returns size of a separator
- "
+ "returns the size of a separator"
+
^ 10
!
@@ -5041,7 +5041,7 @@
item := self new in:aSuperMenu.
item label:aLabel.
- ^ item
+ ^ item
!
in:aSuperMenu menuItem:aMenuItem
@@ -5049,7 +5049,7 @@
item := self in:aSuperMenu.
item menuItem:aMenuItem.
- ^ item.
+ ^ item.
!
new
@@ -5059,8 +5059,8 @@
!MenuPanel::Item methodsFor:'accepting'!
canAccept
- "returns true if item is acceptable
- "
+ "returns true if item is acceptable"
+
self enabled ifFalse:[ ^ false].
self hasSubmenu ifFalse:[ ^ true ].
@@ -5069,8 +5069,8 @@
!
toggleIndication
- "toggle indication or choice
- "
+ "toggle indication or choice"
+
|arg|
indication notNil ifTrue:[
@@ -5088,44 +5088,44 @@
!MenuPanel::Item methodsFor:'accessing'!
accessCharacter
- "returns my accessCharacter or nil
- "
+ "returns my accessCharacter or nil"
+
^ accessCharacter
!
accessCharacterPosition
- "get the access character position or nil
- "
+ "get the access character position or nil"
+
^ menuItem accessCharacterPosition
!
accessCharacterPosition:anIndex
- "set the access character position or nil
- "
+ "set the access character position or nil"
+
menuItem accessCharacterPosition:anIndex.
!
argument
- "gets the argument
- "
+ "gets the argument"
+
^ menuItem argument
!
argument:anArgument
- "sets the argument
- "
+ "sets the argument"
+
menuItem argument:anArgument.
!
displayLabel
- "returns my printable Label
- "
+ "returns my printable Label"
+
^ displayLabel
!
displayLabelExtent
- "returns the labelExtent
- "
+ "returns the labels extent"
+
|prevFont w h|
displayLabelExtent notNil ifTrue:[
@@ -5166,8 +5166,8 @@
!
font
- "returns the user configured font or nil (default menu font)
- "
+ "returns the user configured font or nil (default menu font)"
+
|font|
menuPanel isNil ifTrue:[^ nil].
@@ -5182,57 +5182,57 @@
!
font:aFont
- "returns the user configured font or nil (default menu font)
- "
+ "returns the user configured font or nil (default menu font)"
+
menuItem font:aFont.
!
ignoreMnemonicKeys
- "if true, mnemonic (access character) in the submenus under the item are ignored
- "
+ "if true, mnemonic (access character) in the submenus under the item are ignored"
+
^ menuItem ignoreMnemonicKeys
!
ignoreMnemonicKeys:aBoolean
- "if true, mnemonic (access character) in the submenus under the item are ignored
- "
+ "if true, mnemonic (access character) in the submenus under the item are ignored"
+
menuItem ignoreMnemonicKeys:aBoolean.
!
ignoreShortcutKeys
- "if true, shortcutKeys (accelerators) in the submenus under the item are ignored
- "
+ "if true, shortcutKeys (accelerators) in the submenus under the item are ignored"
+
^ menuItem ignoreShortcutKeys
!
ignoreShortcutKeys:aBoolean
- "if true, shortcutKeys (accelerators) in the submenus under the item are ignored
- "
+ "if true, shortcutKeys (accelerators) in the submenus under the item are ignored"
+
menuItem ignoreShortcutKeys:aBoolean.
!
itemValue
- "gets value
- "
+ "gets the items value"
+
^ menuItem itemValue
!
itemValue:aValue
- "argument could be a value holder, an action or selector
- "
+ "argument could be a value holder, an action or selector"
+
menuItem itemValue:aValue.
!
label
- "returns the label
- "
+ "returns the label"
+
^ label
!
label:aLabel
"set a new label; if the label changed, a redraw is performed;
- handle characters $& (ST-80 compatibility)
- "
+ handle characters $& (ST-80 compatibility)"
+
|size char oldExtent|
oldExtent := displayLabelExtent.
@@ -5291,40 +5291,40 @@
!
menuPanel
- "returns my menuPanel
- "
+ "returns my menuPanel"
+
^ menuPanel
!
nameKey
- "gets the nameKey
- "
+ "gets the nameKey"
+
^ menuItem nameKey
!
nameKey:aNameKey
- "sets the nameKey
- "
+ "sets the nameKey"
+
menuItem nameKey:aNameKey.
!
rawLabel
- "returns my raw, unprocessed label
- "
+ "returns my raw, unprocessed label"
+
^ menuItem rawLabel
!
shortcutKey
"get the key to press to select the submenu from the keyboard or if
- no submenu exists evaluate the action assigned to the item (accept).
- "
+ no submenu exists evaluate the action assigned to the item (accept)."
+
^ menuItem shortcutKey
!
shortcutKey:aKey
"set the key to press to select the submenu from the keyboard or if
- no submenu exists evaluate the action assigned to the item (accept).
- "
+ no submenu exists evaluate the action assigned to the item (accept)."
+
menuItem shortcutKey ~= aKey ifTrue:[
menuItem shortcutKey:aKey.
self invalidate.
@@ -5333,29 +5333,29 @@
startGroup
"start group #left #right #center ... or nil
- at the moment only #right is implemented
- "
+ at the moment only #right is implemented"
+
^ menuItem startGroup
!
startGroup:aSymbol
"start group #left #right #center ...
- at the moment only #right is implemented
- "
+ at the moment only #right is implemented"
+
menuItem startGroup:aSymbol.
!
submenu
- "returns my submenu or nil
- "
+ "returns my submenu or nil"
+
subMenu notNil ifTrue:[^ subMenu].
^ self setupSubmenu
!
submenu:aSubMenu
- "set a new submenu; an existing submenu will be destroyed. This might lead
- to a redraw if 'hasSubmenu' changed
- "
+ "set a new submenu; an existing submenu will be destroyed.
+ This might lead to a redraw if 'hasSubmenu' changed"
+
|widget|
aSubMenu isNil ifTrue:[
@@ -5429,8 +5429,8 @@
!
triggerOnDown
- "trigger the action if pressed
- "
+ "return true if triggering the action if pressed"
+
menuItem triggerOnDown ifTrue:[
self hasSubmenu ifFalse:[^ true].
].
@@ -5438,28 +5438,28 @@
!
triggerOnDown:aBool
- "trigger the action if pressed
- "
+ "setup to trigger the action if pressed"
+
menuItem triggerOnDown:aBool.
!
value
- "gets value
- Left here for ST80 compatibility - value is a bad name
- "
+ "gets the items value
+ Left here for ST80 compatibility - value is a bad name"
+
^ menuItem itemValue
!
value:aValue
"could be a value holder, an action or selector
- Left here for ST80 compatibility - value: is a bad name
- "
+ Left here for ST80 compatibility - value: is a bad name"
+
menuItem itemValue:aValue.
!
value:aValue argument:anArgument
- "set the value and an argument
- "
+ "set the value and an argument"
+
menuItem itemValue:aValue.
menuItem argument:anArgument.
! !
@@ -5467,42 +5467,41 @@
!MenuPanel::Item methodsFor:'accessing-behavior'!
choice
- "implements a radio group; the field
- "
+ "implements a radio group; the field"
+
^ choice
-
!
choice:something
- "set choice indication
- "
+ "set choice indication"
+
choice == something ifTrue:[^ self].
choice isValueModel ifTrue:[
- choice removeDependent:self
+ choice removeDependent:self
].
(choice := something) notNil ifTrue:[
- choice isSymbol ifTrue:[
- (choice := self aspectAt:choice) isNil ifTrue:[
- choice := something
- ]
- ].
- choice isValueModel ifTrue:[
- choice addDependent:self
- ]
+ choice isSymbol ifTrue:[
+ (choice := self aspectAt:choice) isNil ifTrue:[
+ choice := something
+ ]
+ ].
+ choice isValueModel ifTrue:[
+ choice addDependent:self
+ ]
].
!
choiceValue
- "implements a radio group; the value writen to the choice if selected
- "
+ "implements a radio group; the value writen to the choice if selected"
+
^ menuItem choiceValue
!
choiceValue:something
- "implements a radio group; the value writen to the choice if selected
- "
+ "implements a radio group; the value writen to the choice if selected"
+
menuItem choiceValue ~= something ifTrue:[
menuItem choiceValue:something.
choice notNil ifTrue:[ self invalidate ].
@@ -5510,8 +5509,8 @@
!
enabled
- "returns the enabled state
- "
+ "returns the enabled state"
+
|state|
menuPanel enabled ifFalse:[^ false].
@@ -5539,47 +5538,47 @@
!
enabled:something
- "change the enabled state; if the state changed, a redraw is performed
- "
+ "change the enabled state; if the state changed, a redraw is performed"
+
|oldState newState|
enableChannel isNil ifTrue:[
- oldState := true
+ oldState := true
] ifFalse:[
- oldState := enableChannel value.
- enableChannel isValueModel ifTrue:[
- enableChannel removeDependent:self
- ]
+ oldState := enableChannel value.
+ enableChannel isValueModel ifTrue:[
+ enableChannel removeDependent:self
+ ]
].
enableChannel := something.
enableChannel isNil ifTrue:[
- menuPanel shown ifFalse:[^ self].
- newState := true
+ menuPanel shown ifFalse:[^ self].
+ newState := true
] ifFalse:[
- enableChannel isValueModel ifTrue:[
- enableChannel addDependent:self
- ] ifFalse:[
- enableChannel isSymbol ifTrue:[^ self]
- ].
- menuPanel shown ifFalse:[^ self].
- newState := enableChannel value.
+ enableChannel isValueModel ifTrue:[
+ enableChannel addDependent:self
+ ] ifFalse:[
+ enableChannel isSymbol ifTrue:[^ self]
+ ].
+ menuPanel shown ifFalse:[^ self].
+ newState := enableChannel value.
].
newState ~~ oldState ifTrue:[
- self invalidate
+ self invalidate
].
!
hideMenuOnActivated
- "hide the menu when the item was activated; the default is true
- "
+ "hide the menu when the item was activated; the default is true"
+
^ menuItem hideMenuOnActivated
!
hideMenuOnActivated:aBool
- "hide the menu when the item was activated; the default is true
- "
+ "hide the menu when the item was activated; the default is true"
+
menuItem hideMenuOnActivated:aBool.
!
@@ -5596,39 +5595,39 @@
!
indication
- "get on/off indication
- "
+ "get on/off indication"
+
^ indication
!
indication:something
- "set on/off indication
- "
+ "set on/off indication"
+
indication == something ifTrue:[^ self].
indication isValueModel ifTrue:[
- indication removeDependent:self
+ indication removeDependent:self
].
(indication := something) notNil ifTrue:[
- indication isValueModel ifTrue:[
- indication addDependent:self
- ] ifFalse:[
- "/ to force an update of the value
- self indicationValue
- ]
+ indication isValueModel ifTrue:[
+ indication addDependent:self
+ ] ifFalse:[
+ "/ to force an update of the value
+ self indicationValue
+ ]
].
!
keepLinkedMenu
- "get the keepLinkedMenu flag
- "
+ "get the keepLinkedMenu flag"
+
^ menuItem keepLinkedMenu
!
keepLinkedMenu:aBool
- "get the keepLinkedMenu flag
- "
+ "get the keepLinkedMenu flag"
+
menuItem keepLinkedMenu:aBool.
!
@@ -5647,28 +5646,28 @@
!
submenuChannel
- "get the submenu channel
- "
+ "get the submenu channel"
+
^ menuItem submenuChannel
!
submenuChannel:aSelectorOrNil
- "returns the submenu channel
- "
+ "returns the submenu channel"
+
menuItem submenuChannel:aSelectorOrNil.
! !
!MenuPanel::Item methodsFor:'accessing-dimension'!
moveBy:aPoint
- "move layout origin
- "
+ "move the layouts origin"
+
layout moveBy:aPoint.
!
preferredExtent
- "compute my preferred extent excluding the shortCutKey and the menu identifier
- "
+ "compute my preferred extent excluding the shortCutKey and the menu identifier"
+
|isVertical icon wIcon isButton labelExtent
x "{ Class:SmallInteger }"
y "{ Class:SmallInteger }"
@@ -5740,21 +5739,20 @@
!MenuPanel::Item methodsFor:'accessing-help'!
activeHelpKey
- "get the active helpKey; the key to retrieve the helpText from the application
- "
+ "get the active helpKey; the key to retrieve the helpText from the application"
+
^ menuItem activeHelpKey
!
activeHelpKey:aHelpKey
- "set the active helpKey; the key to retrieve the helpText from the application
- "
+ "set the active helpKey; the key to retrieve the helpText from the application"
+
menuItem activeHelpKey:aHelpKey.
activeHelpText := nil.
!
activeHelpText
- "get the active helpText or nil if not yet resolved
- "
+ "get the active helpText or nil if not yet resolved"
|app key|
@@ -5768,14 +5766,13 @@
!
activeHelpText:aText
- "set the active helpText
- "
+ "set the active helpText"
+
activeHelpText := aText.
!
flyByHelpText
- "get the flyBy helpText or nil.
- "
+ "get the flyBy helpText or nil."
|text key app|
@@ -5831,8 +5828,8 @@
!
flyByHelpText:aText
- "exlicitly set the flyBy helpText. For example, to dynamically change it.
- "
+ "exlicitly set the flyBy helpText. For example, to dynamically change it."
+
flyByHelpText := aText.
! !
@@ -5840,27 +5837,27 @@
horizontalLayout
"on default submenus has a vertical layout;
- true, the submenu has a horizontal layout.
- "
+ true, the submenu has a horizontal layout."
+
^ menuItem horizontalLayout ? false
!
horizontalLayout:aBoolean
"on default submenus has a vertical layout;
- true, the submenu has a horizontal layout.
- "
+ true, the submenu has a horizontal layout."
+
menuItem horizontalLayout:aBoolean.
!
isButton
- "returns whether item looks like a Button
- "
+ "returns whether the item looks like a Button"
+
^ menuItem isButton
!
isButton:aBool
- "sets whether item looks like a Button
- "
+ "set/clear the item to look like a Button"
+
menuItem isButton ~~ aBool ifTrue:[
menuItem isButton:aBool.
self invalidate.
@@ -5868,53 +5865,49 @@
!
layout
- "returns my layout ( Rectangle )
- "
+ "returns my layout ( Rectangle )"
+
^ layout
!
layout:aLayout
- "set a new layout ( Rectangle )
- "
+ "set a new layout ( Rectangle )"
+
layout := aLayout.
self invalidate.
-
!
showBusyCursorWhilePerforming
"get the flag which controls if a busy cursor is to be shown
- while performing the menu action. Defaults to false.
- "
+ while performing the menu action. Defaults to false."
+
^ menuItem showBusyCursorWhilePerforming
!
showBusyCursorWhilePerforming:aBoolean
"set/clear the flag which controls if a busy cursor is to be shown
- while performing the menu action. Defaults to false.
- "
+ while performing the menu action. Defaults to false."
+
menuItem showBusyCursorWhilePerforming:aBoolean.
! !
!MenuPanel::Item methodsFor:'activation & deactivation'!
currentSubmenu
- "returns the current submenu or nil
- "
+ "returns the current submenu or nil"
+
^ subMenu
-
-
-
!
hideSubmenu
- "hide submenu
- "
+ "hide submenu"
+
self hideSubmenu:subMenu.
!
hideSubmenu:aSubmenu
- "hide submenu
- "
+ "hide submenu"
+
|id|
aSubmenu isNil ifTrue:[^ self].
@@ -5927,7 +5920,7 @@
aSubmenu hide
].
- aSubmenu windowGroup:nil.
+ aSubmenu windowGroup:nil.
menuPanel windowGroup removeView:aSubmenu.
"/ release menu if derived from channel
@@ -5939,8 +5932,8 @@
!
openDelayedSubmenu
- "called to open now my delayed submenu
- "
+ "called to open now my delayed submenu"
+
|subm|
(self isSelected and:[menuPanel shown]) ifFalse:[^ self].
@@ -5965,8 +5958,8 @@
openSubmenu
"opens the submenu; make sure, that the submenu and the menPanel
is fully visible by shifting it into the visible screen area if
- nescessary.
- "
+ nescessary."
+
|p o device isVertical topMenu windGrp prefExtent
devBot "{ Class:SmallInteger }"
devRight "{ Class:SmallInteger }"
@@ -6061,38 +6054,33 @@
!
toggleSubmenuVisibility
- "toggle the visibility of the submenu
- "
+ "toggle the visibility of the submenu"
+
subMenu notNil ifTrue:[
- subMenu shown ifTrue:[^ self hideSubmenu]
+ subMenu shown ifTrue:[^ self hideSubmenu]
] ifFalse:[
- (subMenu := self setupSubmenu) isNil ifTrue:[
- "/ cannot open a submenu
- ^ self
- ]
+ (subMenu := self setupSubmenu) isNil ifTrue:[
+ "/ cannot open a submenu
+ ^ self
+ ]
].
self openSubmenu.
-
-
!
visibleSubmenu
- "returns the current visible submenu or nil
- "
+ "returns the current visible submenu or nil"
+
subMenu notNil ifTrue:[
- subMenu shown ifTrue:[^ subMenu].
+ subMenu shown ifTrue:[^ subMenu].
].
^ nil
-
-
-
! !
!MenuPanel::Item methodsFor:'building'!
aspectAt:aKey
- "retursns value assigned to key or nil
- "
+ "retursns value assigned to key or nil"
+
|appl value|
appl := menuPanel receiver.
@@ -6132,8 +6120,8 @@
!MenuPanel::Item methodsFor:'change & update'!
fontChanged
- "called whenever the font changed
- "
+ "called whenever the font changed"
+
displayLabel notNil ifTrue:[
displayLabelExtent := nil.
@@ -6191,21 +6179,21 @@
!
updateIndicators
- "update indicators
- "
+ "update indicators "
+
(indication notNil and:[indication isSymbol]) ifTrue:[
- " indication is a selector otherwise a change notification
- is raised from the model !!!!
- "
- self update:nil with:nil from:indication
+ " indication is a selector otherwise a change notification
+ is raised from the model !!!!
+ "
+ self update:nil with:nil from:indication
]
! !
!MenuPanel::Item methodsFor:'converting'!
asMenuItem
- "convert to a MenuItem
- "
+ "convert to a MenuItem"
+
^ menuItem
!
@@ -6214,8 +6202,8 @@
!
menuItem:aMenuItem
- "setup attributes from a MenuItem
- "
+ "setup attributes from a MenuItem"
+
|lbl|
menuPanel disabledRedrawDo:[
@@ -6246,8 +6234,8 @@
!MenuPanel::Item methodsFor:'dependents access'!
addDependencies
- "add all dependencies
- "
+ "add all dependencies"
+
enableChannel isValueModel ifTrue:[enableChannel addDependent:self].
isVisible isValueModel ifTrue:[isVisible addDependent:self].
indication isValueModel ifTrue:[indication addDependent:self].
@@ -6255,8 +6243,8 @@
!
removeDependencies
- "remove all dependencies
- "
+ "remove all dependencies"
+
enableChannel isValueModel ifTrue:[enableChannel removeDependent:self].
isVisible isValueModel ifTrue:[isVisible removeDependent:self].
indication isValueModel ifTrue:[indication removeDependent:self].
@@ -6266,8 +6254,8 @@
!MenuPanel::Item methodsFor:'drawing'!
choiceForm
- "returns choice form or nil
- "
+ "returns choice form or nil"
+
|isOn|
choice isNil ifTrue:[^ nil].
@@ -6282,8 +6270,8 @@
!
draw
- "redraw item
- "
+ "redraw this item"
+
|isSelected ownBgCol paint bgColor
x "{ Class:SmallInteger }"
y "{ Class:SmallInteger }"
@@ -6346,8 +6334,8 @@
!
drawButton
- "draw as button
- "
+ "draw as button"
+
|drawObject fg etchFg level isEnabled isSelected bg ownBgCol showSelected
x "{ Class:SmallInteger }"
y "{ Class:SmallInteger }"
@@ -6432,8 +6420,8 @@
!
drawLabel
- "draw a labeled entry; no button, no separator.
- "
+ "draw a labeled entry; no button, no separator."
+
|scKey cLb cLa drawObject fg etchFg arrow
isSelected isEnabled form
h "{ Class:SmallInteger }"
@@ -6523,8 +6511,8 @@
!
drawMenuIndicator
- "draw a menu indicator if the item has a menu or delayed menu.
- "
+ "draw a menu indicator if the item has a menu or delayed menu."
+
|x y icon bAbsLevel|
self hasDelayedMenuIndicator ifTrue:[
@@ -6571,8 +6559,8 @@
!
drawRawLabel:aLabel atX:x yOffset:yOffset paint:fg
- "draw a labeled entry; no button, no separator.
- "
+ "draw a labeled entry; no button, no separator."
+
|mfont labelExtent
y "{ Class:SmallInteger }"
y0 "{ Class:SmallInteger }"
@@ -6616,8 +6604,8 @@
!
drawSeparatingLines
- "draw separating lines
- "
+ "draw separating lines"
+
|myIndex lfSep rtSep items prevItem nextItem
lightColor shadowColor
l "{ Class:SmallInteger }"
@@ -6636,7 +6624,7 @@
rtSep := nextItem notNil and:[nextItem isButton not].
(lfSep or:[rtSep]) ifFalse:[
- ^ self
+ ^ self
].
lightColor := menuPanel lightColor.
@@ -6650,25 +6638,25 @@
b := layout bottom.
menuPanel verticalLayout ifTrue:[
- lfSep ifTrue:[menuPanel displayLineFromX:l y:t-1 toX:r y:t-1].
- rtSep ifTrue:[menuPanel displayLineFromX:l y:b-1 toX:r y:b-1].
-
- menuPanel paint:shadowColor.
- lfSep ifTrue:[menuPanel displayLineFromX:l y:t-2 toX:r y:t-2].
- rtSep ifTrue:[menuPanel displayLineFromX:l y:b-2 toX:r y:b-2].
+ lfSep ifTrue:[menuPanel displayLineFromX:l y:t-1 toX:r y:t-1].
+ rtSep ifTrue:[menuPanel displayLineFromX:l y:b-1 toX:r y:b-1].
+
+ menuPanel paint:shadowColor.
+ lfSep ifTrue:[menuPanel displayLineFromX:l y:t-2 toX:r y:t-2].
+ rtSep ifTrue:[menuPanel displayLineFromX:l y:b-2 toX:r y:b-2].
] ifFalse:[
- lfSep ifTrue:[menuPanel displayLineFromX:l-1 y:t toX:l-1 y:b].
- rtSep ifTrue:[menuPanel displayLineFromX:r-1 y:t toX:r-1 y:b].
-
- menuPanel paint:shadowColor.
- lfSep ifTrue:[menuPanel displayLineFromX:l-2 y:t toX:l-2 y:b].
- rtSep ifTrue:[menuPanel displayLineFromX:r-2 y:t toX:r-2 y:b].
+ lfSep ifTrue:[menuPanel displayLineFromX:l-1 y:t toX:l-1 y:b].
+ rtSep ifTrue:[menuPanel displayLineFromX:r-1 y:t toX:r-1 y:b].
+
+ menuPanel paint:shadowColor.
+ lfSep ifTrue:[menuPanel displayLineFromX:l-2 y:t toX:l-2 y:b].
+ rtSep ifTrue:[menuPanel displayLineFromX:r-2 y:t toX:r-2 y:b].
]
!
drawSeparator
- "draw as separator
- "
+ "draw as separator"
+
|type lightColor shadowColor isDouble
left top
x0 "{ Class:SmallInteger }"
@@ -6679,7 +6667,7 @@
type := self separatorType.
(type isNil or:[type == #blankLine]) ifTrue:[
- ^ self
+ ^ self
].
isDouble := type == #doubleLine.
@@ -6692,49 +6680,49 @@
top := layout top.
menuPanel verticalLayout ifTrue:[
- x0 := left + HorizontalInset.
- x1 := layout right - HorizontalInset.
- y0 := top - 1 + (layout height // 2).
- isDouble ifTrue:[y0 := y0 - 2].
-
- menuPanel displayLineFromX:x0 y:y0 toX:x1 y:y0.
- isDouble ifTrue:[menuPanel displayLineFromX:x0 y:y0+4 toX:x1 y:y0+4].
-
- menuPanel paint:lightColor.
- menuPanel displayLineFromX:x0 y:y0+1 toX:x1 y:y0+1.
- isDouble ifTrue:[menuPanel displayLineFromX:x0 y:y0+5 toX:x1 y:y0+5].
+ x0 := left + HorizontalInset.
+ x1 := layout right - HorizontalInset.
+ y0 := top - 1 + (layout height // 2).
+ isDouble ifTrue:[y0 := y0 - 2].
+
+ menuPanel displayLineFromX:x0 y:y0 toX:x1 y:y0.
+ isDouble ifTrue:[menuPanel displayLineFromX:x0 y:y0+4 toX:x1 y:y0+4].
+
+ menuPanel paint:lightColor.
+ menuPanel displayLineFromX:x0 y:y0+1 toX:x1 y:y0+1.
+ isDouble ifTrue:[menuPanel displayLineFromX:x0 y:y0+5 toX:x1 y:y0+5].
] ifFalse:[
- y1 := layout bottom.
- x0 := left - 1 + (layout width // 2).
- y0 := top.
- isDouble ifTrue:[x0 := x0 - 2].
-
- menuPanel displayLineFromX:x0 y:y0 toX:x0 y:y1.
- isDouble ifTrue:[menuPanel displayLineFromX:x0+4 y:y0 toX:x0+4 y:y1].
-
- menuPanel paint:lightColor.
- menuPanel displayLineFromX:x0+1 y:y0 toX:x0+1 y:y1.
- isDouble ifTrue:[menuPanel displayLineFromX:x0+5 y:y0 toX:x0+5 y:y1].
+ y1 := layout bottom.
+ x0 := left - 1 + (layout width // 2).
+ y0 := top.
+ isDouble ifTrue:[x0 := x0 - 2].
+
+ menuPanel displayLineFromX:x0 y:y0 toX:x0 y:y1.
+ isDouble ifTrue:[menuPanel displayLineFromX:x0+4 y:y0 toX:x0+4 y:y1].
+
+ menuPanel paint:lightColor.
+ menuPanel displayLineFromX:x0+1 y:y0 toX:x0+1 y:y1.
+ isDouble ifTrue:[menuPanel displayLineFromX:x0+5 y:y0 toX:x0+5 y:y1].
]
!
indicatorForm
- "returns indication form or nil
- "
+ "returns indication form or nil"
+
|val|
indication isNil ifTrue:[^ nil].
val := self indicationValue.
self enabled ifFalse:[
- ^ val == true
- ifTrue:[menuPanel iconIndicationDisabledOn]
- ifFalse:[menuPanel iconIndicationDisabledOff]
+ ^ val == true
+ ifTrue:[menuPanel iconIndicationDisabledOn]
+ ifFalse:[menuPanel iconIndicationDisabledOff]
].
^ val == true
- ifTrue:[menuPanel iconIndicationOn]
- ifFalse:[menuPanel iconIndicationOff]
+ ifTrue:[menuPanel iconIndicationOn]
+ ifFalse:[menuPanel iconIndicationOff]
!
invalidate
@@ -6749,8 +6737,8 @@
!MenuPanel::Item methodsFor:'initialization'!
destroy
- "destroy submenus, remove dependencies
- "
+ "destroy submenus, remove dependencies"
+
self submenu:nil.
self removeDependencies.
@@ -6758,8 +6746,8 @@
!
in:aPanel
- "create item in a menuPanel
- "
+ "create item in a menuPanel"
+
menuPanel := aPanel.
menuItem isNil ifTrue:[
@@ -6785,8 +6773,8 @@
!MenuPanel::Item methodsFor:'label basics'!
disabledRawLabel
- "returns the label used if the item is disabled
- "
+ "returns the label used if the item is disabled"
+
|block form image|
disabledDisplayLabel notNil ifTrue:[^ disabledDisplayLabel].
@@ -6837,8 +6825,8 @@
!
fetchImages
- "fetch images
- "
+ "fetch my icon images"
+
|icon|
(displayLabel isNil or:[displayLabel isString]) ifTrue:[
@@ -6932,8 +6920,8 @@
!MenuPanel::Item methodsFor:'private'!
activeBackgroundColor
- "returns the active background color derived from menuPanel
- "
+ "returns the active background color derived from menuPanel"
+
menuItem isButton ifTrue:[
^ menuPanel buttonActiveBackgroundColor
].
@@ -6941,15 +6929,14 @@
!
activeForegroundColor
- "returns the active foreground color derived from menuPanel
- "
+ "returns the active foreground color derived from menuPanel"
^menuPanel activeForegroundColor
!
backgroundColor
- "returns the background color derived from menuPanel
- "
+ "returns the background color derived from menuPanel"
+
menuItem isButton ifTrue:[
^ menuPanel buttonPassiveBackgroundColor
].
@@ -6957,8 +6944,8 @@
!
backgroundColorFromLabel
- "returns the background color derived from label or nil
- "
+ "returns the background color derived from label or nil"
+
|run|
label isText ifFalse:[^ nil ].
@@ -6968,23 +6955,23 @@
run := run first.
run size == 0 ifTrue:[
- (run value isColor and:[run key == #backgroundColor]) ifTrue:[
- ^ run value
- ]
+ (run value isColor and:[run key == #backgroundColor]) ifTrue:[
+ ^ run value
+ ]
] ifFalse:[
- run do:[:r|
- (r value isColor and:[r key == #backgroundColor]) ifTrue:[
- ^ r value
- ]
- ]
+ run do:[:r|
+ (r value isColor and:[r key == #backgroundColor]) ifTrue:[
+ ^ r value
+ ]
+ ]
].
^ nil
!
buttonEnteredBackgroundColor
"returns the background color to use when thhe mouse has entered
- derived from menuPanel
- "
+ derived from menuPanel"
+
menuItem isButton ifTrue:[
^ menuPanel buttonEnteredBackgroundColor
].
@@ -7044,8 +7031,8 @@
!
indicationValue
- "returns indication value or nil in case of no indication
- "
+ "returns indication value or nil in case of no indication"
+
|numArgs sel recv|
indication isNil ifTrue:[^ nil]. "no indication specified"
@@ -7089,8 +7076,8 @@
!
indicationValue:aValue
- "set the indication value
- "
+ "set the indication value"
+
|numArgs recv|
indication isNil ifTrue:[^ self]. "no indication specified"
@@ -7129,16 +7116,16 @@
!
isEntered
- "returns true if the mouse pointer is over the item
- "
+ "returns true if the mouse pointer is over the item"
+
^ menuPanel enteredItem == self
"Created: / 20.8.1998 / 13:11:50 / cg"
!
separatorType
- "returns type of separator line or nil
- "
+ "returns type of separator line or nil"
+
|c lbl|
self isSeparator ifFalse:[
@@ -7219,16 +7206,16 @@
canChangeVisibility
"return true if I am not always visible; can only be changed by a selector
- otherwise there is a change notification raised if the model changed
- "
+ otherwise there is a change notification raised if the model changed"
+
^ isVisible isSymbol
"/ ^ isVisible notNil and:[isVisible ~~ true]
!
canSelect
"returns true if item is selectable; no separator, visible and enabled.
- in case of a choice (RadioButton) i have to check for the choiceValue
- "
+ in case of a choice (RadioButton) i have to check for the choiceValue"
+
self isSeparator ifTrue:[^ false].
(self isVisible and:[self enabled]) ifTrue:[
@@ -7240,10 +7227,10 @@
!
containsPoint:aPoint
- "returns true if aPoint is contained in my layout
- "
+ "returns true if aPoint is contained in my layout"
+
(self isVisible and:[layout notNil]) ifTrue:[
- ^ layout containsPoint:aPoint
+ ^ layout containsPoint:aPoint
].
^ false
@@ -7251,17 +7238,17 @@
!
containsPointX:x y:y
- "returns true if point is contained in my layout
- "
+ "returns true if point is contained in my layout"
+
(self isVisible and:[layout notNil]) ifTrue:[
- ^ layout containsPointX:x y:y
+ ^ layout containsPointX:x y:y
].
^ false
!
hasDelayedMenu
- "returns true if a delayed menu exists
- "
+ "returns true if a delayed menu exists"
+
self hasSubmenu ifFalse:[
^ false
].
@@ -7275,8 +7262,8 @@
hasDelayedMenuIndicator
"returns true if the item has a delayed menu
- and is in the topMenuPanel (because submenuIndicator is already drawn in popUpViews)
- "
+ and is in the topMenuPanel (because submenuIndicator is already drawn in popUpViews)"
+
menuPanel isPopUpView ifFalse:[
^ self hasDelayedMenu
].
@@ -7284,15 +7271,15 @@
!
hasIndication
- "returns true if on/off indication exists
- "
+ "returns true if on/off indication exists"
+
^ indication notNil
!
hasMenuIndicator
"returns true if the item has a delayed menu
- and is in the topMenuPanel (because submenuIndicator is already drawn in popUpViews)
- "
+ and is in the topMenuPanel (because submenuIndicator is already drawn in popUpViews)"
+
menuPanel isPopUpView ifFalse:[
^ self hasSubmenu and:[menuItem isButton]
].
@@ -7300,44 +7287,44 @@
!
hasSubmenu
- "returns true if the item is configured as an subMenu entry
- "
- ^ subMenu notNil or:[menuItem submenuChannel notNil]
+ "returns true if the item is configured as an subMenu entry"
+
+ ^ subMenu notNil or:[ menuItem submenuChannel notNil ]
!
isEnabled
- "returns enabled state
- "
+ "returns the enabled state"
+
^ self enabled
!
isSeparator
- "returns true if item is a separator
- "
+ "returns true if item is a separator"
+
^ displayLabel isNil
!
isToggle
- "returns true if on/off indication exists
- "
+ "returns true if on/off indication exists"
+
^ self hasIndication and:[ self isButton ]
!
isVisible
- "returns the visibility state
- "
+ "returns the visibility state"
+
|state|
isVisible isSymbol ifTrue:[
- state := self aspectAt:isVisible.
-
- state isValueModel ifTrue:[
- isVisible := state.
- isVisible addDependent:self.
- state := isVisible.
- ]
+ state := self aspectAt:isVisible.
+
+ state isValueModel ifTrue:[
+ isVisible := state.
+ isVisible addDependent:self.
+ state := isVisible.
+ ]
] ifFalse:[
- state := isVisible
+ state := isVisible
].
^ state value ~~ false
@@ -7345,34 +7332,34 @@
!
isVisible:something
- "change the state; if the state changed, a redraw is performed
- "
+ "change the visibility state; if the state changed, a redraw is performed"
+
|oldState newState|
isVisible isNil ifTrue:[
- oldState := true
+ oldState := true
] ifFalse:[
- oldState := isVisible value.
- isVisible isValueModel ifTrue:[
- isVisible removeDependent:self
- ]
+ oldState := isVisible value.
+ isVisible isValueModel ifTrue:[
+ isVisible removeDependent:self
+ ]
].
isVisible := something.
isVisible isNil ifTrue:[
- newState := true
+ newState := true
] ifFalse:[
- isVisible isValueModel ifTrue:[
- isVisible addDependent:self
- ] ifFalse:[
- isVisible isSymbol ifTrue:[^ self]
- ].
- menuPanel shown ifFalse:[^ self].
- newState := isVisible value.
+ isVisible isValueModel ifTrue:[
+ isVisible addDependent:self
+ ] ifFalse:[
+ isVisible isSymbol ifTrue:[^ self]
+ ].
+ menuPanel shown ifFalse:[^ self].
+ newState := isVisible value.
].
newState ~~ oldState ifTrue:[
- menuPanel mustRearrange
+ menuPanel mustRearrange
]
"Modified: / 5.10.1998 / 12:12:04 / cg"
@@ -7383,8 +7370,8 @@
!
shortcutKeyAsString
- "converts shortcutKey to a text object
- "
+ "converts shortcutKey to a text object"
+
|nm prefix shortcutKey|
shortcutKey := menuItem shortcutKey.
@@ -7425,13 +7412,13 @@
!
shortcutKeyPrefixFor:aModifier
- "returns prefix assigned to a modifier
- "
+ "returns the prefix assigned to a modifier"
+
|m|
m := menuPanel device modifierKeyTopFor:aModifier.
m notNil ifTrue:[
- ^ m , '-'
+ ^ m , '-'
].
^ aModifier , '-'.
@@ -7441,16 +7428,15 @@
!MenuPanel::Item methodsFor:'selection'!
isSelected
- "returns true if item is selected
- "
+ "returns true if item is selected"
^ menuPanel notNil and:[menuPanel selection == self]
!
isSelected:isSelected
"change selection to a state. Dependant on the state open or hide an existing
- submenu and perform a redraw
- "
+ submenu and perform a redraw"
+
(isSelected and:[menuPanel notNil]) ifFalse:[
self invalidate.
self hideSubmenu.
@@ -7515,14 +7501,14 @@
activeMenu
"returns the active menu the scrolling is activated on; nil
- is returned if scrolling is deactivated
- "
+ is returned if scrolling is deactivated"
+
^ activeMenu
!
direction
- "returns the scroll-direction
- "
+ "returns the scroll-direction"
+
^ direction
!
@@ -7564,16 +7550,16 @@
!MenuPanel::ScrollActivity methodsFor:'queries'!
isActive
- "returns true if scrolling is activated
- "
+ "returns true if scrolling is activated"
+
^ activeMenu notNil
! !
!MenuPanel::ScrollActivity methodsFor:'user operations'!
startIfRequiredAt:aDirection on:aMenu
- "start scrolling; returns true if scrolling is activated
- "
+ "start scrolling; returns true if scrolling is activated"
+
|bounds index isScrolledMenu|
isScrolledMenu := (aDirection notNil and:[aMenu notNil and:[aMenu hasScrollers]]).
@@ -7627,8 +7613,8 @@
!
stop
- "stop scrolling; returns true if the scrolling was activated otherwise false
- "
+ "stop scrolling; returns true if the scrolling was activated otherwise false"
+
|task resp|
activeMenu isNil ifTrue:[
@@ -7654,7 +7640,7 @@
!MenuPanel class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.415 2005-12-21 11:40:16 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.416 2005-12-21 17:42:21 cg Exp $'
! !
MenuPanel initialize!