451
|
1 |
Object subclass:#MenuItem
|
458
|
2 |
instanceVariableNames:'enabled label value nameKey adornment'
|
451
|
3 |
classVariableNames:''
|
|
4 |
poolDictionaries:''
|
|
5 |
category:'Views-Support'
|
|
6 |
!
|
|
7 |
|
|
8 |
Object subclass:#MenuItemAdornment
|
578
|
9 |
instanceVariableNames:'color indication submenu shortcutKey labelText'
|
451
|
10 |
classVariableNames:''
|
|
11 |
poolDictionaries:''
|
|
12 |
privateIn:MenuItem
|
|
13 |
!
|
|
14 |
|
|
15 |
!MenuItem class methodsFor:'documentation'!
|
|
16 |
|
|
17 |
documentation
|
|
18 |
"
|
|
19 |
not yet finished MenuItem class - this will eventually replace
|
|
20 |
most of the MenuView and PopUpMenu stuff.
|
|
21 |
(and hopefully be ST-80 compatible ...)
|
|
22 |
|
|
23 |
For now, only a subset of the full protocol is implemented.
|
|
24 |
|
|
25 |
[author:]
|
|
26 |
Claus Gittinger
|
|
27 |
|
|
28 |
[see also:]
|
|
29 |
MenuItem
|
|
30 |
PopUpMenu
|
|
31 |
"
|
|
32 |
|
|
33 |
! !
|
|
34 |
|
490
|
35 |
!MenuItem class methodsFor:'instance creation'!
|
|
36 |
|
|
37 |
labeled:aString
|
|
38 |
^ self new label:aString
|
|
39 |
! !
|
|
40 |
|
451
|
41 |
!MenuItem methodsFor:'accessing'!
|
|
42 |
|
455
|
43 |
accessCharacterPosition:index
|
|
44 |
"ignored for now"
|
|
45 |
|
|
46 |
"Modified: 25.2.1997 / 20:27:12 / cg"
|
|
47 |
!
|
|
48 |
|
451
|
49 |
disable
|
|
50 |
enabled := false
|
|
51 |
|
|
52 |
"Created: 25.2.1997 / 19:39:09 / cg"
|
|
53 |
!
|
|
54 |
|
|
55 |
enable
|
|
56 |
enabled := true
|
|
57 |
|
|
58 |
"Created: 25.2.1997 / 19:39:00 / cg"
|
|
59 |
!
|
|
60 |
|
|
61 |
enabled:aBoolean
|
|
62 |
enabled := aBoolean
|
|
63 |
|
|
64 |
"Created: 25.2.1997 / 19:39:27 / cg"
|
|
65 |
!
|
|
66 |
|
490
|
67 |
hasSubmenu
|
578
|
68 |
^ self subMenu notNil
|
490
|
69 |
|
|
70 |
"Created: 25.2.1997 / 20:56:20 / cg"
|
|
71 |
!
|
|
72 |
|
451
|
73 |
isEnabled
|
|
74 |
^ enabled ? true
|
|
75 |
|
|
76 |
"Created: 25.2.1997 / 19:39:17 / cg"
|
|
77 |
!
|
|
78 |
|
|
79 |
label
|
|
80 |
^ label
|
|
81 |
|
|
82 |
"Created: 25.2.1997 / 19:48:16 / cg"
|
|
83 |
!
|
|
84 |
|
453
|
85 |
label:aString
|
|
86 |
label := aString
|
|
87 |
|
|
88 |
"Created: 25.2.1997 / 19:55:16 / cg"
|
|
89 |
!
|
|
90 |
|
578
|
91 |
nameKey
|
|
92 |
^ nameKey
|
|
93 |
|
|
94 |
|
|
95 |
!
|
|
96 |
|
|
97 |
nameKey:aNameKey
|
|
98 |
nameKey := aNameKey
|
|
99 |
|
|
100 |
|
|
101 |
!
|
|
102 |
|
490
|
103 |
rawLabel
|
|
104 |
^ label
|
|
105 |
|
|
106 |
"Created: 25.2.1997 / 19:48:16 / cg"
|
|
107 |
!
|
|
108 |
|
451
|
109 |
rawLabel:aString
|
|
110 |
label := aString
|
|
111 |
|
|
112 |
"Created: 25.2.1997 / 19:11:02 / cg"
|
|
113 |
!
|
|
114 |
|
490
|
115 |
shortcutKeyCharacter
|
|
116 |
"ignored for now"
|
|
117 |
|
578
|
118 |
adornment notNil ifTrue:[
|
|
119 |
^ adornment shortcutKeyCharacter
|
|
120 |
].
|
490
|
121 |
^ nil
|
|
122 |
!
|
|
123 |
|
578
|
124 |
shortcutKeyCharacter:aKey
|
|
125 |
"set the key to press to select the menu item from the keyboard
|
|
126 |
"
|
|
127 |
self adornment shortcutKeyCharacter:aKey
|
|
128 |
!
|
|
129 |
|
458
|
130 |
submenu
|
578
|
131 |
adornment notNil ifTrue:[
|
|
132 |
^ adornment submenu
|
|
133 |
].
|
|
134 |
^ nil
|
458
|
135 |
|
|
136 |
"Created: 25.2.1997 / 20:57:24 / cg"
|
|
137 |
!
|
|
138 |
|
|
139 |
submenu:aMenu
|
|
140 |
self adornment submenu:aMenu
|
|
141 |
|
|
142 |
"Created: 25.2.1997 / 20:56:20 / cg"
|
|
143 |
!
|
|
144 |
|
451
|
145 |
value
|
|
146 |
^ value
|
|
147 |
|
|
148 |
"Created: 25.2.1997 / 19:50:14 / cg"
|
|
149 |
!
|
|
150 |
|
|
151 |
value:something
|
|
152 |
value := something
|
|
153 |
|
|
154 |
"Created: 25.2.1997 / 19:11:13 / cg"
|
|
155 |
! !
|
|
156 |
|
|
157 |
!MenuItem methodsFor:'converting'!
|
|
158 |
|
|
159 |
fromLiteralArrayEncoding:aLiteralEncodedArray
|
|
160 |
"read my contents from a aLiteralEncodedArray"
|
|
161 |
|
|
162 |
2 to:aLiteralEncodedArray size by:2 do:[:i |
|
|
163 |
|selector value|
|
|
164 |
|
|
165 |
selector := aLiteralEncodedArray at:i.
|
|
166 |
value := (aLiteralEncodedArray at:i+1) decodeAsLiteralArray.
|
|
167 |
|
|
168 |
self perform:selector with:value
|
|
169 |
].
|
|
170 |
|
|
171 |
"
|
578
|
172 |
#( #MenuItem #rawLabel: 'left' #nameKey: 'identifier' #value: #left )
|
451
|
173 |
decodeAsLiteralArray
|
|
174 |
"
|
|
175 |
|
|
176 |
"Modified: 25.2.1997 / 19:24:22 / cg"
|
490
|
177 |
!
|
|
178 |
|
|
179 |
literalArrayEncoding
|
|
180 |
"return myself encoded as a literal array"
|
|
181 |
|
|
182 |
|coll|
|
|
183 |
|
|
184 |
coll := OrderedCollection new.
|
|
185 |
coll add:#MenuItem.
|
|
186 |
coll add:#label: ; add:(label literalArrayEncoding).
|
|
187 |
coll add:#value: ; add:(value literalArrayEncoding).
|
578
|
188 |
coll add:#nameKey: ; add:(nameKey literalArrayEncoding).
|
490
|
189 |
coll add:#enabled: ; add:(enabled literalArrayEncoding).
|
|
190 |
^ coll asArray
|
451
|
191 |
! !
|
|
192 |
|
458
|
193 |
!MenuItem methodsFor:'private - accessing'!
|
|
194 |
|
|
195 |
adornment
|
|
196 |
adornment isNil ifTrue:[
|
|
197 |
adornment := MenuItemAdornment new
|
|
198 |
].
|
|
199 |
^ adornment
|
|
200 |
|
|
201 |
"Created: 25.2.1997 / 20:57:05 / cg"
|
|
202 |
! !
|
|
203 |
|
|
204 |
!MenuItem::MenuItemAdornment methodsFor:'accessing'!
|
|
205 |
|
|
206 |
color
|
|
207 |
"return the value of the instance variable 'color' (automatically generated)"
|
|
208 |
|
|
209 |
^ color
|
|
210 |
|
|
211 |
"Created: 25.2.1997 / 20:59:28 / cg"
|
|
212 |
!
|
|
213 |
|
|
214 |
color:something
|
|
215 |
"set the value of the instance variable 'color' (automatically generated)"
|
|
216 |
|
|
217 |
color := something.
|
|
218 |
|
|
219 |
"Created: 25.2.1997 / 20:59:28 / cg"
|
|
220 |
!
|
|
221 |
|
|
222 |
indication
|
|
223 |
"return the value of the instance variable 'indication' (automatically generated)"
|
|
224 |
|
|
225 |
^ indication
|
|
226 |
|
|
227 |
"Created: 25.2.1997 / 20:59:28 / cg"
|
|
228 |
!
|
|
229 |
|
|
230 |
indication:something
|
|
231 |
"set the value of the instance variable 'indication' (automatically generated)"
|
|
232 |
|
|
233 |
indication := something.
|
|
234 |
|
|
235 |
"Created: 25.2.1997 / 20:59:28 / cg"
|
|
236 |
!
|
|
237 |
|
578
|
238 |
labelText
|
|
239 |
"get the text appear as the menu label
|
|
240 |
"
|
|
241 |
^ labelText
|
|
242 |
!
|
|
243 |
|
|
244 |
labelText:something
|
|
245 |
"set the text appear as the menu label
|
|
246 |
"
|
|
247 |
labelText := something.
|
|
248 |
!
|
|
249 |
|
|
250 |
shortcutKeyCharacter
|
|
251 |
"get the key to press to select the menu item from the keyboard
|
|
252 |
"
|
|
253 |
^ shortcutKey
|
|
254 |
!
|
|
255 |
|
|
256 |
shortcutKeyCharacter:something
|
|
257 |
"set the key to press to select the menu item from the keyboard
|
|
258 |
"
|
|
259 |
shortcutKey := something.
|
|
260 |
!
|
|
261 |
|
458
|
262 |
submenu
|
578
|
263 |
"get the submenu or nil
|
|
264 |
"
|
458
|
265 |
^ submenu
|
|
266 |
|
|
267 |
"Created: 25.2.1997 / 20:59:28 / cg"
|
|
268 |
!
|
|
269 |
|
|
270 |
submenu:something
|
578
|
271 |
"set the submenu or nil
|
|
272 |
"
|
458
|
273 |
submenu := something.
|
|
274 |
|
|
275 |
"Created: 25.2.1997 / 20:59:28 / cg"
|
|
276 |
! !
|
|
277 |
|
451
|
278 |
!MenuItem class methodsFor:'documentation'!
|
|
279 |
|
|
280 |
version
|
578
|
281 |
^ '$Header: /cvs/stx/stx/libview2/MenuItem.st,v 1.6 1997-05-20 07:07:22 ca Exp $'
|
451
|
282 |
! !
|