--- a/PullDownMenu.st Sat Jan 13 16:51:50 1996 +0100
+++ b/PullDownMenu.st Sun Jan 14 13:02:38 1996 +0100
@@ -11,17 +11,17 @@
"
SimpleView subclass:#PullDownMenu
- instanceVariableNames:'receiver menus titles selectors activeMenuNumber
+ instanceVariableNames:'receiver menus titles selectors activeMenuNumber
showSeparatingLines topMargin fgColor bgColor activeFgColor
activeBgColor onLevel offLevel edgeStyle keepMenu toggleKeep
raiseTopWhenActivated'
- classVariableNames:'DefaultFont DefaultViewBackground DefaultForegroundColor
+ classVariableNames:'DefaultFont DefaultViewBackground DefaultForegroundColor
DefaultBackgroundColor DefaultHilightForegroundColor
DefaultHilightBackgroundColor DefaultLevel DefaultHilightLevel
DefaultShadowColor DefaultLightColor DefaultEdgeStyle
DefaultKeepMenu DefaultToggleKeep DefaultSeparatingLines'
- poolDictionaries:''
- category:'Views-Menus'
+ poolDictionaries:''
+ category:'Views-Menus'
!
!PullDownMenu class methodsFor:'documentation'!
@@ -384,6 +384,55 @@
!PullDownMenu methodsFor:'accessing'!
+add:label selector:selector
+ "add a new title-item at the end.
+ The corresponding label can later be set with #at:putMenu:
+ or #at:putLabels:selectors:..."
+
+ self add:label selector:selector after:nil
+!
+
+add:label selector:selector after:indexOrString
+ "add a new title-item after an existing item, indexOrString,
+ or at the end if the after-arg is nil.
+ The corresponding label can later be set with #at:putMenu:
+ or #at:putLabels:selectors:..."
+
+ |idx|
+
+ indexOrString isNil ifTrue:[
+ idx := titles size
+ ] ifFalse:[
+ idx := self indexOf:indexOrString.
+ ].
+
+ titles isNil ifTrue:[
+ menus := Array with:nil.
+ titles := Array with:label.
+ selectors := Array with:nil.
+ ] ifFalse:[
+ menus := (menus copyTo:idx) , #(nil) , (menus copyFrom:idx+1).
+ titles := ((titles copyTo:idx) copyWith:label) , (titles copyFrom:idx+1).
+ selectors := ((selectors copyTo:idx) copyWith:selector) , (selectors copyFrom:idx+1).
+ ].
+
+ "
+ |top m|
+
+ top := StandardSystemView new.
+ m := PullDownMenu in:top.
+ m labels:#('file' 'edit').
+ m selectors:#(file #edit).
+
+ m add:'help' selector:#help after:#file.
+ m at:#help putMenu:(MenuView labels:#('foo' 'bar')
+ selectors:#(foo bar)
+ receiver:nil).
+
+ top open
+ "
+!
+
at:aString putLabels:labels selector:selector args:args receiver:anObject
"create and set the menu under the title, aString"
@@ -429,14 +478,15 @@
index := self indexOf:aString.
(index == 0) ifTrue:[
- self error:'no such menu entry'.
- ^ nil
+ self error:'no such menu entry'.
+ ^ nil
].
"/ not needed:
"/ aMenu origin:((left + (self titleLenUpTo:index))
"/ @
"/ (height + aMenu borderWidth)).
+ aMenu superView:(self superView).
aMenu hiddenOnRealize:true.
menus at:index put:aMenu.
aMenu masterView:self.
@@ -517,12 +567,19 @@
]
!
+selectors
+ "return the menu-selectors"
+
+ ^ selectors
+!
+
selectors:selectorArray
"define the menu-selectors. These are used as accesskey only
in menuAt: accesses. This makes PullDownMenu accesss
somewhat more compatible to PopUpMenus."
selectors := selectorArray.
+
! !
!PullDownMenu methodsFor:'accessing-look'!
@@ -1248,5 +1305,5 @@
!PullDownMenu class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/PullDownMenu.st,v 1.29 1995-12-11 17:03:27 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/PullDownMenu.st,v 1.30 1996-01-14 12:02:38 ca Exp $'
! !