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
|
|
9 |
instanceVariableNames:'color indication submenu'
|
|
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
|
|
68 |
^ self adornment submenu notNil
|
|
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 |
|
490
|
91 |
rawLabel
|
|
92 |
^ label
|
|
93 |
|
|
94 |
"Created: 25.2.1997 / 19:48:16 / cg"
|
|
95 |
!
|
|
96 |
|
451
|
97 |
rawLabel:aString
|
|
98 |
label := aString
|
|
99 |
|
|
100 |
"Created: 25.2.1997 / 19:11:02 / cg"
|
|
101 |
!
|
|
102 |
|
490
|
103 |
shortcutKeyCharacter
|
|
104 |
"ignored for now"
|
|
105 |
|
|
106 |
^ nil
|
|
107 |
!
|
|
108 |
|
458
|
109 |
submenu
|
|
110 |
^ self adornment submenu
|
|
111 |
|
|
112 |
"Created: 25.2.1997 / 20:57:24 / cg"
|
|
113 |
!
|
|
114 |
|
|
115 |
submenu:aMenu
|
|
116 |
self adornment submenu:aMenu
|
|
117 |
|
|
118 |
"Created: 25.2.1997 / 20:56:20 / cg"
|
|
119 |
!
|
|
120 |
|
451
|
121 |
value
|
|
122 |
^ value
|
|
123 |
|
|
124 |
"Created: 25.2.1997 / 19:50:14 / cg"
|
|
125 |
!
|
|
126 |
|
|
127 |
value:something
|
|
128 |
value := something
|
|
129 |
|
|
130 |
"Created: 25.2.1997 / 19:11:13 / cg"
|
|
131 |
! !
|
|
132 |
|
|
133 |
!MenuItem methodsFor:'converting'!
|
|
134 |
|
|
135 |
fromLiteralArrayEncoding:aLiteralEncodedArray
|
|
136 |
"read my contents from a aLiteralEncodedArray"
|
|
137 |
|
|
138 |
2 to:aLiteralEncodedArray size by:2 do:[:i |
|
|
139 |
|selector value|
|
|
140 |
|
|
141 |
selector := aLiteralEncodedArray at:i.
|
|
142 |
value := (aLiteralEncodedArray at:i+1) decodeAsLiteralArray.
|
|
143 |
|
|
144 |
self perform:selector with:value
|
|
145 |
].
|
|
146 |
|
|
147 |
"
|
|
148 |
#( #MenuItem #rawLabel: 'left' #value: #left )
|
|
149 |
decodeAsLiteralArray
|
|
150 |
"
|
|
151 |
|
|
152 |
"Modified: 25.2.1997 / 19:24:22 / cg"
|
490
|
153 |
!
|
|
154 |
|
|
155 |
literalArrayEncoding
|
|
156 |
"return myself encoded as a literal array"
|
|
157 |
|
|
158 |
|coll|
|
|
159 |
|
|
160 |
coll := OrderedCollection new.
|
|
161 |
coll add:#MenuItem.
|
|
162 |
coll add:#label: ; add:(label literalArrayEncoding).
|
|
163 |
coll add:#value: ; add:(value literalArrayEncoding).
|
|
164 |
"/ coll add:#nameKey: ; add:(nameKey literalArrayEncoding).
|
|
165 |
coll add:#enabled: ; add:(enabled literalArrayEncoding).
|
|
166 |
^ coll asArray
|
451
|
167 |
! !
|
|
168 |
|
458
|
169 |
!MenuItem methodsFor:'private - accessing'!
|
|
170 |
|
|
171 |
adornment
|
|
172 |
adornment isNil ifTrue:[
|
|
173 |
adornment := MenuItemAdornment new
|
|
174 |
].
|
|
175 |
^ adornment
|
|
176 |
|
|
177 |
"Created: 25.2.1997 / 20:57:05 / cg"
|
|
178 |
! !
|
|
179 |
|
|
180 |
!MenuItem::MenuItemAdornment methodsFor:'accessing'!
|
|
181 |
|
|
182 |
color
|
|
183 |
"return the value of the instance variable 'color' (automatically generated)"
|
|
184 |
|
|
185 |
^ color
|
|
186 |
|
|
187 |
"Created: 25.2.1997 / 20:59:28 / cg"
|
|
188 |
!
|
|
189 |
|
|
190 |
color:something
|
|
191 |
"set the value of the instance variable 'color' (automatically generated)"
|
|
192 |
|
|
193 |
color := something.
|
|
194 |
|
|
195 |
"Created: 25.2.1997 / 20:59:28 / cg"
|
|
196 |
!
|
|
197 |
|
|
198 |
indication
|
|
199 |
"return the value of the instance variable 'indication' (automatically generated)"
|
|
200 |
|
|
201 |
^ indication
|
|
202 |
|
|
203 |
"Created: 25.2.1997 / 20:59:28 / cg"
|
|
204 |
!
|
|
205 |
|
|
206 |
indication:something
|
|
207 |
"set the value of the instance variable 'indication' (automatically generated)"
|
|
208 |
|
|
209 |
indication := something.
|
|
210 |
|
|
211 |
"Created: 25.2.1997 / 20:59:28 / cg"
|
|
212 |
!
|
|
213 |
|
|
214 |
submenu
|
|
215 |
"return the value of the instance variable 'submenu' (automatically generated)"
|
|
216 |
|
|
217 |
^ submenu
|
|
218 |
|
|
219 |
"Created: 25.2.1997 / 20:59:28 / cg"
|
|
220 |
!
|
|
221 |
|
|
222 |
submenu:something
|
|
223 |
"set the value of the instance variable 'submenu' (automatically generated)"
|
|
224 |
|
|
225 |
submenu := something.
|
|
226 |
|
|
227 |
"Created: 25.2.1997 / 20:59:28 / cg"
|
|
228 |
! !
|
|
229 |
|
451
|
230 |
!MenuItem class methodsFor:'documentation'!
|
|
231 |
|
|
232 |
version
|
490
|
233 |
^ '$Header: /cvs/stx/stx/libview2/MenuItem.st,v 1.5 1997-03-05 16:06:31 ca Exp $'
|
451
|
234 |
! !
|