--- a/MenuView.st Thu Aug 03 03:35:39 1995 +0200
+++ b/MenuView.st Tue Aug 08 03:07:33 1995 +0200
@@ -15,7 +15,7 @@
disabledFgColor onOffFlags subMenus
subMenuShown superMenu checkColor
lineLevel lineInset masterView hilightStyle
- needResize'
+ needResize hideOnRelease'
classVariableNames:'DefaultFont DefaultCheckColor DefaultViewBackground
DefaultForegroundColor DefaultBackgroundColor
DefaultDisabledForegroundColor
@@ -32,7 +32,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libwidg/MenuView.st,v 1.31 1995-08-03 01:35:10 claus Exp $
+$Header: /cvs/stx/stx/libwidg/MenuView.st,v 1.32 1995-08-08 01:07:18 claus Exp $
'!
!MenuView class methodsFor:'documentation'!
@@ -53,7 +53,7 @@
version
"
-$Header: /cvs/stx/stx/libwidg/MenuView.st,v 1.31 1995-08-03 01:35:10 claus Exp $
+$Header: /cvs/stx/stx/libwidg/MenuView.st,v 1.32 1995-08-08 01:07:18 claus Exp $
"
!
@@ -251,6 +251,7 @@
|style|
super initialize.
+ hideOnRelease := false.
(((style := styleSheet name) ~~ #normal)
and:[style ~~ #mswindows]) ifTrue:[
@@ -443,7 +444,113 @@
! !
-!MenuView methodsFor:'accessing'!
+!MenuView methodsFor:'accessing-behavior'!
+
+hideOnRelease:aBoolean
+ hideOnRelease := aBoolean
+!
+
+disable:indexOrName
+ "disable an entry"
+
+ self setEnable:indexOrName to:false
+!
+
+enable:indexOrName
+ "enable an entry"
+
+ self setEnable:indexOrName to:true
+!
+
+disableAll:collectionOfIndicesOrNames
+ "disable an collection of entries"
+
+ collectionOfIndicesOrNames do:[:entry |
+ self disable:entry
+ ]
+!
+
+enableAll:collectionOfIndicesOrNames
+ "enable an collection of entries"
+
+ collectionOfIndicesOrNames do:[:entry |
+ self enable:entry
+ ]
+!
+
+isEnabled:indexOrName
+ |index|
+
+ index := self indexOf:indexOrName.
+ index ~~ 0 ifTrue:[
+ enableFlags isNil ifTrue:[^ true].
+ ^ enableFlags at:index
+ ].
+ "ask submenus for convenience"
+ (indexOrName isNumber not and:[subMenus notNil]) ifTrue:[
+ subMenus do:[:m |
+ m notNil ifTrue:[
+ m enable:indexOrName
+ ]
+ ]
+ ]
+!
+
+setEnable:indexOrName to:aBoolean
+ "enable/disable an entry"
+
+ |index|
+
+ index := self indexOf:indexOrName.
+ index ~~ 0 ifTrue:[
+ (enableFlags at:index) ~~ aBoolean ifTrue:[
+ enableFlags at:index put:aBoolean.
+ shown ifTrue:[
+ self redrawLine:index
+ ]
+ ]
+ ] ifFalse:[
+ "try submenus for convenience"
+ (indexOrName isNumber not and:[subMenus notNil]) ifTrue:[
+ subMenus do:[:m |
+ m notNil ifTrue:[
+ m setEnable:indexOrName to:aBoolean
+ ]
+ ]
+ ]
+ ]
+! !
+
+!MenuView methodsFor:'accessing-look'!
+
+font:aFont
+ "adjust size for new font"
+
+ super font:(aFont on:device).
+ shown ifTrue:[
+ self resize
+ ] ifFalse:[
+ needResize := true
+ ]
+! !
+
+!MenuView methodsFor:'accessing-misc'!
+
+selection:index
+ |sel line|
+
+ sel := index.
+ sel notNil ifTrue:[
+ line := self listAt:index.
+ (self isGraphicItem:line) ifTrue:[
+ "
+ not really selectable, but a separating line
+ "
+ sel := nil
+ ]
+ ].
+ super selection:sel
+!
superMenu:aMenu
"set the menu I am contained in
@@ -469,13 +576,9 @@
"set the popup-masterview I am contained in."
masterView := aPopUpView
-!
+! !
-subMenuShown
- "return the currently visible submenu - or nil if there is none"
-
- ^ subMenuShown
-!
+!MenuView methodsFor:'accessing-items'!
labels
"return the menu-labels"
@@ -509,6 +612,15 @@
]
!
+labels:text selectors:selArray args:argArray receiver:anObject
+ "set all relevant stuff"
+
+ self labels:text.
+ selectors := selArray.
+ args := argArray.
+ receiver := anObject
+!
+
labelAt:indexOrName put:aString
"change the label at index to be aString"
@@ -537,17 +649,6 @@
]
!
-font:aFont
- "adjust size for new font"
-
- super font:(aFont on:device).
- shown ifTrue:[
- self resize
- ] ifFalse:[
- needResize := true
- ]
-!
-
addSeparatingLine
"add a separating line"
@@ -880,77 +981,6 @@
^ nil
!
-setEnable:indexOrName to:aBoolean
- "disable an entry"
-
- |index|
-
- index := self indexOf:indexOrName.
- index ~~ 0 ifTrue:[
- (enableFlags at:index) ~~ aBoolean ifTrue:[
- enableFlags at:index put:aBoolean.
- shown ifTrue:[
- self redrawLine:index
- ]
- ]
- ] ifFalse:[
- "try submenus for convenience"
- (indexOrName isNumber not and:[subMenus notNil]) ifTrue:[
- subMenus do:[:m |
- m notNil ifTrue:[
- m setEnable:indexOrName to:aBoolean
- ]
- ]
- ]
- ]
-!
-
-disable:indexOrName
- "disable an entry"
-
- self setEnable:indexOrName to:false
-!
-
-enable:indexOrName
- "enable an entry"
-
- self setEnable:indexOrName to:true
-!
-
-disableAll:collectionOfIndicesOrNames
- "disable an collection of entries"
-
- collectionOfIndicesOrNames do:[:entry |
- self disable:entry
- ]
-!
-
-enableAll:collectionOfIndicesOrNames
- "enable an collection of entries"
-
- collectionOfIndicesOrNames do:[:entry |
- self enable:entry
- ]
-!
-
-isEnabled:indexOrName
- |index|
-
- index := self indexOf:indexOrName.
- index ~~ 0 ifTrue:[
- enableFlags isNil ifTrue:[^ true].
- ^ enableFlags at:index
- ].
- "ask submenus for convenience"
- (indexOrName isNumber not and:[subMenus notNil]) ifTrue:[
- subMenus do:[:m |
- m notNil ifTrue:[
- m enable:indexOrName
- ]
- ]
- ]
-!
-
receiver
"return the receiver of the message"
@@ -1029,15 +1059,6 @@
]
!
-labels:text selectors:selArray args:argArray receiver:anObject
- "set all relevant stuff"
-
- self labels:text.
- selectors := selArray.
- args := argArray.
- receiver := anObject
-!
-
checkToggleAt:indexOrName
"return a check-toggles boolean state"
@@ -1064,6 +1085,14 @@
shown ifTrue:[
self redrawLine:index
]
+! !
+
+!MenuView methodsFor:'accessing-submenus'!
+
+subMenuShown
+ "return the currently visible submenu - or nil if there is none"
+
+ ^ subMenuShown
!
subMenuAt:indexOrName
@@ -1097,22 +1126,6 @@
]
].
subMenus at:i put:aPopUpMenu
-!
-
-selection:index
- |sel line|
-
- sel := index.
- sel notNil ifTrue:[
- line := self listAt:index.
- (self isGraphicItem:line) ifTrue:[
- "
- not really selectable, but a separating line
- "
- sel := nil
- ]
- ].
- super selection:sel
! !
!MenuView methodsFor:'private'!
@@ -1811,6 +1824,9 @@
]
].
(superMenu notNil and:[superMenu shown not]) ifTrue:[
- superView notNil ifTrue:[superView hide].
- ]
+ (superView notNil and:[superView shown]) ifTrue:[superView hide].
+ ].
+ hideOnRelease ifTrue:[
+ superView hide
+ ].
! !