--- a/NewLauncher.st Sat Feb 13 12:05:22 1999 +0100
+++ b/NewLauncher.st Sat Feb 13 12:11:51 1999 +0100
@@ -2123,39 +2123,41 @@
!NewLauncher methodsFor:'menu configuration'!
-addUserTool: toolName action: action icon: icon
+addUserTool:toolName action:actionBlock icon:iconOrNil
"adds a menu item labeled toolName, and action and icon both to the
sub menu 'Tools' and the tool bar.
This can be invoked by a classes #initialize method, to add an item
for itself to the toolbar.
"
- self addUserTool: toolName action: action in: nil icon: icon space: true
-
+ self addUserTool:toolName action:actionBlock in:nil icon:iconOrNil space:true
+
+ "
+ Transcript topView application
+ addUserTool:'Foo'
+ action:[Transcript showCR:'foo']
+ icon:nil
+ "
!
-addUserTool: toolName action: action in: what icon: icon space: space
- "adds a menu item labeled toolName, and action and icon;
+addUserTool:toolName action:actionBlock in:what icon:icon space:space
+ "adds a menu item labeled toolName, and actionBlock and icon;
for what == #menu menu item is added at the end of the sub menu 'Tools',
for what == #toolbar menu item is added at the end of the tool bar,
+ If space is true, some empty space is inserted.
This can be invoked by a classes #initialize method, to add an item
for itself to the toolbar or menu.
"
|menuPanel freeMenuIndex|
- (what isNil or: [what == #toolbar])
- ifTrue:
- [
+ (what isNil or: [what == #toolbar]) ifTrue:[
menuPanel := builder namedComponents at: #menuToolbarView.
(menuPanel findFirst: [:i| i activeHelpKey = toolName]) == 0
- ifTrue:
- [
+ ifTrue:[
freeMenuIndex := menuPanel numberOfItems + 1.
- space
- ifTrue:
- [
+ space ifTrue:[
(menuPanel createAtIndex: freeMenuIndex) menuItem: (MenuItem labeled: '').
freeMenuIndex := freeMenuIndex + 1.
].
@@ -2163,24 +2165,19 @@
(menuPanel createAtIndex: freeMenuIndex) menuItem:
(MenuItem new
label: toolName;
- value: action;
+ value: actionBlock;
isButton: true;
labelImage: icon;
activeHelpKey: toolName)
].
].
- (what isNil or: [what== #menu])
- ifTrue:
- [
+ (what isNil or: [what== #menu]) ifTrue:[
menuPanel := ((self builder window subViews at: 1 ifAbsent: [^self]) itemAt: 4) submenu.
(menuPanel findFirst: [:i| i activeHelpKey = toolName]) == 0
- ifTrue:
- [
+ ifTrue:[
freeMenuIndex := menuPanel numberOfItems + 1.
- space
- ifTrue:
- [
+ space ifTrue:[
(menuPanel createAtIndex: freeMenuIndex) menuItem: (MenuItem labeled: '-').
freeMenuIndex := freeMenuIndex + 1.
].
@@ -2188,17 +2185,35 @@
(menuPanel createAtIndex: freeMenuIndex) menuItem:
(MenuItem new
label: toolName;
- value: action;
+ value: actionBlock;
labelImage: (LabelAndIcon icon: icon string: toolName);
activeHelpKey: toolName)
].
].
UserAddedTools isNil ifTrue: [UserAddedTools := Dictionary new].
- UserAddedTools at: toolName put: (Array with: action with: what with: icon with: space)
+ UserAddedTools at:toolName put:(Array with:actionBlock with:what with:icon with:space)
+
+ "
+ Transcript topView application
+ addUserTool:'Foo'
+ action:[Transcript showCR:'foo']
+ in:#menu
+ icon:nil
+ space:false
+ "
+ "
+ Transcript topView application
+ addUserTool:'Bar'
+ action:[Transcript showCR:'bar']
+ in:#menu
+ icon:nil
+ space:false
+ "
+
!
-removeUserTool: toolName
+removeUserTool:toolName
"removes a menu item labeled toolName
This can be invoked by a classes #deinitialize method,
to remove its item from the toolbar or menu.
@@ -2223,9 +2238,17 @@
removeInMenuBlock value: (builder namedComponents at: #menuToolbarView).
removeInMenuBlock value: ((self builder window subViews at: 1 ifAbsent: [^self]) itemAt: 4) submenu.
-
UserAddedTools removeKey: toolName
+ "
+ Transcript topView application
+ removeUserTool:'Foo'
+ "
+ "
+ Transcript topView application
+ removeUserTool:'Bar'
+ "
+
! !
!NewLauncher methodsFor:'private'!
@@ -2627,5 +2650,5 @@
!NewLauncher class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/NewLauncher.st,v 1.123 1999-02-13 11:05:22 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/NewLauncher.st,v 1.124 1999-02-13 11:11:51 cg Exp $'
! !