author | Claus Gittinger <cg@exept.de> |
Sat, 11 May 2019 12:15:03 +0200 | |
changeset 6578 | 60be865bd75a |
parent 6496 | 4d669e93efd0 |
child 6584 | f3cd1f8f31a9 |
permissions | -rw-r--r-- |
6318 | 1 |
"{ Encoding: utf8 }" |
2 |
||
0 | 3 |
" |
5 | 4 |
COPYRIGHT (c) 1989 by Claus Gittinger |
59 | 5 |
All Rights Reserved |
0 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
2258 | 14 |
"{ Package: 'stx:libwidg' }" |
15 |
||
5355 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
0 | 18 |
SelectionInListView subclass:#MenuView |
2498 | 19 |
instanceVariableNames:'selectors args receiver enableFlags disabledFgColor |
20 |
disabledEtchedFgColor onOffFlags subMenus subMenuShown superMenu |
|
21 |
checkColor lineLevel lineInset masterView needResize |
|
22 |
hideOnRelease sizeFixed shortKeys maxShortKeyStringLen actions |
|
4195
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
23 |
checkOnImage checkOffImage blockOfSubMenuShown |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
24 |
delayedSubmenuHideOrShowAction lastMousePoint' |
405
39b9b0f04ccc
allow checkmarks at any position
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
25 |
classVariableNames:'DefaultCheckColor DefaultViewBackground DefaultForegroundColor |
39b9b0f04ccc
allow checkmarks at any position
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
26 |
DefaultBackgroundColor DefaultDisabledForegroundColor |
2498 | 27 |
DefaultDisabledEtchedForegroundColor |
405
39b9b0f04ccc
allow checkmarks at any position
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
28 |
DefaultHilightForegroundColor DefaultHilightBackgroundColor |
39b9b0f04ccc
allow checkmarks at any position
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
29 |
DefaultHilightLevel DefaultHilightStyle DefaultHilightFrameColor |
39b9b0f04ccc
allow checkmarks at any position
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
30 |
DefaultLineLevel DefaultLineInset DefaultShadowColor |
1532 | 31 |
DefaultLightColor ShowAcceleratorKeys DefaultCheckOnImage |
32 |
DefaultCheckOffImage' |
|
269 | 33 |
poolDictionaries:'' |
34 |
category:'Views-Menus' |
|
0 | 35 |
! |
36 |
||
878 | 37 |
!MenuView class methodsFor:'documentation'! |
3 | 38 |
|
38 | 39 |
copyright |
40 |
" |
|
41 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
59 | 42 |
All Rights Reserved |
38 | 43 |
|
44 |
This software is furnished under a license and may be used |
|
45 |
only in accordance with the terms of that license and with the |
|
46 |
inclusion of the above copyright notice. This software may not |
|
47 |
be provided or otherwise made available to, or used by, any |
|
48 |
other person. No title to or ownership of the software is |
|
49 |
hereby transferred. |
|
50 |
" |
|
51 |
! |
|
52 |
||
3 | 53 |
documentation |
54 |
" |
|
1532 | 55 |
Notice: |
2498 | 56 |
MenuView is going to be obsoleted - use Menu & MenuItem, |
57 |
and display them in a MenuPanel for new applications. |
|
1532 | 58 |
|
63 | 59 |
a menu view used for both pull-down-menus and pop-up-menus (and also, |
831
8af010be0a02
Rename Launcher-->OldLauncher, NewLauncher-->Launcher.
Stefan Vogel <sv@exept.de>
parents:
799
diff
changeset
|
60 |
for nonModal menus, such as the OldLaunchers click-menu). |
38 | 61 |
the action to be performed can be defined either as: |
0 | 62 |
|
38 | 63 |
1) action:aBlockWithOneArg |
64 |
which defines a block to be called with the line number (1..n) |
|
65 |
of the selected line. |
|
0 | 66 |
|
119 | 67 |
2) selectors:selectorArray [args: argArray] [receiver:anObject] |
68 |
which defines the messages to be sent to the model or |
|
69 |
receiver. Giving an explicit receiver overrides the model. |
|
0 | 70 |
|
38 | 71 |
It is also possible to define both actionBlock and selectorArray. |
0 | 72 |
|
63 | 73 |
The wellknown popups are created by wrapping a MenuView into an instance of |
74 |
PopUpMenu (read the description of popupmenu). |
|
75 |
||
38 | 76 |
menu entries starting with '\c' are check-entries. |
131 | 77 |
menu entries starting with '\b' are checkBox-entries. |
78 |
menu entries starting with '\t' are thumbUp/Down-entries. |
|
38 | 79 |
menu entries conisting of '-' alone, are separating lines. |
63 | 80 |
menu entries conisting of '=' alone, are double separating lines. |
130 | 81 |
|
82 |
||
83 |
StyleSheet defaults: |
|
84 |
||
1532 | 85 |
menuFont font to use for menus |
86 |
||
87 |
menuViewBackground view background (should be same as menuBackgroundColor) |
|
88 |
menuForegroundColor foreground color |
|
89 |
menuBackgroundColor background color |
|
90 |
||
91 |
menuShadowColor shadow color for 3D effects |
|
92 |
menuLightColor lightColor for 3D effects |
|
93 |
menuHilightForegroundColor hilighted items foregroundColor |
|
94 |
menuHilightBackgroundColor hilighted items backgroundColor |
|
95 |
||
96 |
menuHilightFrameColor frame arounf hilighted items (or nil, if none) |
|
97 |
defaults to selectionHilightFrameColor |
|
98 |
menuHilightLevel 3D level of selected items |
|
99 |
menuHilightStyle #openwin or nil (special kludge) |
|
100 |
menuSeparatingLineLevel 3D level of sep. lines |
|
101 |
menuSeparatingLineInset left/right inset of sep. lines |
|
102 |
menuDisabledForegroundColor foreground color of disabled items |
|
103 |
menuCheckColor color to use for check marks |
|
104 |
menuFont font to use |
|
130 | 105 |
|
106 |
other values and some defaults are inherited via SelectionInListViews |
|
107 |
styles (i.e. look for selectionForegroundColor ...) |
|
586 | 108 |
|
109 |
[author:] |
|
1532 | 110 |
Claus Gittinger |
593 | 111 |
|
112 |
[see also:] |
|
1532 | 113 |
PopUpMenu PullDownMenu |
114 |
ClickMenuView |
|
115 |
LineMenu PatternMenu |
|
63 | 116 |
" |
117 |
! |
|
21 | 118 |
|
63 | 119 |
examples |
120 |
" |
|
405
39b9b0f04ccc
allow checkmarks at any position
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
121 |
See real examples in PopUpMenu & PullDownMenu |
39b9b0f04ccc
allow checkmarks at any position
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
122 |
|
45 | 123 |
Examples: |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
124 |
Notice: normally, menuviews are wrapped into either a popup- |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
125 |
menu or pulldown-menu. |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
126 |
But they can also be used stand-alone as in the following examples: |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
127 |
|
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
128 |
[exBegin] |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
129 |
|m| |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
130 |
m := MenuView |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
131 |
labels:#('foo' |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
132 |
'bar' |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
133 |
'baz') |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
134 |
selectors:#( |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
135 |
#foo |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
136 |
#bar |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
137 |
#baz) |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
138 |
receiver:nil. |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
139 |
m open |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
140 |
[exEnd] |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
141 |
|
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
142 |
[exBegin] |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
143 |
|m| |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
144 |
m := MenuView |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
145 |
labels:#('foo' |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
146 |
'bar' |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
147 |
'baz') |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
148 |
selectors:#foo: |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
149 |
args:#(1 2 3) |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
150 |
receiver:nil. |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
151 |
m open |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
152 |
[exEnd] |
3 | 153 |
" |
202 | 154 |
! ! |
155 |
||
878 | 156 |
!MenuView class methodsFor:'instance creation'! |
202 | 157 |
|
748 | 158 |
forMenu:aTopMenu |
159 |
"create and return a new menuView, which will be contained in |
|
160 |
aTopMenus superView" |
|
161 |
||
162 |
aTopMenu isNil ifTrue:[ |
|
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
163 |
^ self new |
748 | 164 |
]. |
165 |
^ self in:(aTopMenu superView). |
|
166 |
||
167 |
"Created: 5.6.1996 / 11:29:27 / cg" |
|
168 |
! |
|
169 |
||
202 | 170 |
labels:labels |
171 |
"create and return a new MenuView. The parent view, |
|
172 |
selectors and receiver should be set later." |
|
173 |
||
174 |
^ self labels:labels selectors:nil args:nil receiver:nil |
|
175 |
! |
|
176 |
||
177 |
labels:labels selector:aSelector args:argArray receiver:anObject for:aTopMenu |
|
178 |
"create and return a new MenuView |
|
179 |
- receiverObject gets message aSelector with argument from |
|
180 |
argArray for ALL entries" |
|
181 |
||
182 |
"OBSOLETE protocol: labels:selectors:args:receiver: knows how to handle a |
|
183 |
single symbol-arg for selectors ..." |
|
184 |
||
185 |
^ self labels:labels selectors:aSelector args:argArray receiver:anObject in:(aTopMenu superView) |
|
186 |
! |
|
187 |
||
188 |
labels:labels selector:aSelector args:argArray receiver:anObject in:aTopMenu |
|
189 |
"create and return a new MenuView |
|
190 |
- receiverObject gets message aSelector with argument from |
|
191 |
argArray for all entries" |
|
192 |
||
193 |
"OBSOLETE protocol: labels:selectors:args:receiver: knows how to handle a |
|
194 |
single symbol-arg for selectors ..." |
|
195 |
||
196 |
^ self labels:labels selectors:aSelector args:argArray receiver:anObject in:aTopMenu |
|
197 |
! |
|
198 |
||
199 |
labels:labels selectors:selArray |
|
200 |
"create and return a new MenuView. The parent veiw |
|
201 |
and receiver should be set later." |
|
202 |
||
203 |
^ self labels:labels selectors:selArray args:nil receiver:nil |
|
204 |
! |
|
205 |
||
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
206 |
labels:labels selectors:selArray accelerators:shorties |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
207 |
"create and return a new MenuView. The parent veiw |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
208 |
and receiver should be set later." |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
209 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
210 |
^ self labels:labels selectors:selArray accelerators:shorties args:nil receiver:nil |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
211 |
! |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
212 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
213 |
labels:labels selectors:selArray accelerators:shorties args:argArray receiver:anObject |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
214 |
"create and return a new MenuView. The parent view |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
215 |
should be set later." |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
216 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
217 |
^ (self new) |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
218 |
labels:labels |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
219 |
selectors:selArray |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
220 |
accelerators:shorties |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
221 |
args:argArray |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
222 |
receiver:anObject |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
223 |
! |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
224 |
|
750 | 225 |
labels:labels selectors:selArray accelerators:shorties args:argArray receiver:anObject for:aTopMenu |
226 |
"create and return a new MenuView for a topMenu" |
|
227 |
||
228 |
^ self labels:labels selectors:selArray accelerators:shorties args:argArray receiver:anObject in:(aTopMenu superView) |
|
229 |
||
230 |
"Created: 5.6.1996 / 16:51:46 / cg" |
|
231 |
! |
|
232 |
||
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
233 |
labels:labels selectors:selArray accelerators:shorties args:argArray receiver:anObject in:aView |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
234 |
"create and return a new MenuView in aView |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
235 |
- receiverObject gets message from selectorArray with argument |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
236 |
from argArray" |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
237 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
238 |
^ (self in:aView) |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
239 |
labels:labels |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
240 |
selectors:selArray |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
241 |
accelerators:shorties |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
242 |
args:argArray |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
243 |
receiver:anObject |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
244 |
! |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
245 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
246 |
labels:labels selectors:selArray accelerators:shorties receiver:anObject |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
247 |
"create and return a new MenuView. The parent view |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
248 |
should be set later." |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
249 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
250 |
^ self labels:labels selectors:selArray accelerators:shorties args:nil receiver:anObject |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
251 |
! |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
252 |
|
202 | 253 |
labels:labels selectors:selArray args:argArray |
254 |
"create and return a new MenuView. The parent view |
|
255 |
should be set later." |
|
256 |
||
257 |
^ self labels:labels selectors:selArray args:argArray |
|
258 |
! |
|
259 |
||
260 |
labels:labels selectors:selArray args:argArray receiver:anObject |
|
261 |
"create and return a new MenuView. The parent view |
|
262 |
should be set later." |
|
263 |
||
264 |
^ (self new) |
|
265 |
labels:labels |
|
266 |
selectors:selArray |
|
267 |
args:argArray |
|
268 |
receiver:anObject |
|
269 |
! |
|
270 |
||
271 |
labels:labels selectors:selArray args:argArray receiver:anObject for:aTopMenu |
|
272 |
"create and return a new MenuView for a topMenu" |
|
273 |
||
274 |
^ self labels:labels selectors:selArray args:argArray receiver:anObject in:(aTopMenu superView) |
|
275 |
! |
|
276 |
||
277 |
labels:labels selectors:selArray args:argArray receiver:anObject in:aView |
|
278 |
"create and return a new MenuView in aView |
|
279 |
- receiverObject gets message from selectorArray with argument |
|
280 |
from argArray" |
|
281 |
||
282 |
^ (self in:aView) |
|
283 |
labels:labels |
|
284 |
selectors:selArray |
|
285 |
args:argArray |
|
286 |
receiver:anObject |
|
287 |
! |
|
288 |
||
289 |
labels:labels selectors:selArray receiver:anObject |
|
290 |
"create and return a new MenuView. The parent view |
|
291 |
should be set later." |
|
292 |
||
293 |
^ self labels:labels selectors:selArray args:nil receiver:anObject |
|
294 |
! |
|
295 |
||
296 |
labels:labels selectors:selArray receiver:anObject for:aTopMenu |
|
297 |
^ self labels:labels selectors:selArray args:nil receiver:anObject for:aTopMenu |
|
298 |
! |
|
299 |
||
300 |
labels:labels selectors:selArray receiver:anObject in:aView |
|
301 |
"create and return a new MenuView in aView |
|
302 |
- receiverObject gets message from selectorArray without argument" |
|
303 |
||
304 |
^ self labels:labels selectors:selArray args:nil receiver:anObject in:aView |
|
3 | 305 |
! ! |
0 | 306 |
|
878 | 307 |
!MenuView class methodsFor:'defaults'! |
59 | 308 |
|
461
45282807f7fa
handle shortKey & submenu-arrow in one line; allow turning of of accelerator display
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
309 |
showAcceleratorKeys |
45282807f7fa
handle shortKey & submenu-arrow in one line; allow turning of of accelerator display
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
310 |
^ ShowAcceleratorKeys ~~ false |
45282807f7fa
handle shortKey & submenu-arrow in one line; allow turning of of accelerator display
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
311 |
|
45282807f7fa
handle shortKey & submenu-arrow in one line; allow turning of of accelerator display
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
312 |
"Created: 2.3.1996 / 14:52:34 / cg" |
45282807f7fa
handle shortKey & submenu-arrow in one line; allow turning of of accelerator display
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
313 |
"Modified: 2.3.1996 / 14:54:58 / cg" |
45282807f7fa
handle shortKey & submenu-arrow in one line; allow turning of of accelerator display
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
314 |
! |
45282807f7fa
handle shortKey & submenu-arrow in one line; allow turning of of accelerator display
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
315 |
|
45282807f7fa
handle shortKey & submenu-arrow in one line; allow turning of of accelerator display
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
316 |
showAcceleratorKeys:aBoolean |
45282807f7fa
handle shortKey & submenu-arrow in one line; allow turning of of accelerator display
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
317 |
ShowAcceleratorKeys := aBoolean |
45282807f7fa
handle shortKey & submenu-arrow in one line; allow turning of of accelerator display
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
318 |
|
45282807f7fa
handle shortKey & submenu-arrow in one line; allow turning of of accelerator display
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
319 |
"Created: 2.3.1996 / 14:52:43 / cg" |
45282807f7fa
handle shortKey & submenu-arrow in one line; allow turning of of accelerator display
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
320 |
! |
45282807f7fa
handle shortKey & submenu-arrow in one line; allow turning of of accelerator display
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
321 |
|
59 | 322 |
updateStyleCache |
445
f4c4d5c1be6b
parse style-resource directive
Claus Gittinger <cg@exept.de>
parents:
435
diff
changeset
|
323 |
"extract values from the styleSheet and cache them in class variables" |
f4c4d5c1be6b
parse style-resource directive
Claus Gittinger <cg@exept.de>
parents:
435
diff
changeset
|
324 |
|
2584
60387225f33c
disabledBGColor-from styleSheet fix
Claus Gittinger <cg@exept.de>
parents:
2575
diff
changeset
|
325 |
<resource: #style (#'menu.foregroundColor' #'menu.backgroundColor' |
1532 | 326 |
#'menu.viewBackground' |
2584
60387225f33c
disabledBGColor-from styleSheet fix
Claus Gittinger <cg@exept.de>
parents:
2575
diff
changeset
|
327 |
#'menu.shadowColor' #'menu.lightColor' |
1532 | 328 |
#'menu.hilightForegroundColor' #'menu.hilightBackgroundColor' |
2584
60387225f33c
disabledBGColor-from styleSheet fix
Claus Gittinger <cg@exept.de>
parents:
2575
diff
changeset
|
329 |
#'menu.hilightFrameColor' #'selection.hilightFrameColor' |
60387225f33c
disabledBGColor-from styleSheet fix
Claus Gittinger <cg@exept.de>
parents:
2575
diff
changeset
|
330 |
#'menu.hilightLevel' #'menu.hilightStyle' |
1532 | 331 |
#'menu.separatingLineLevel' #'menu.separatingLineInset' |
332 |
#'menu.disabledForegroundColor' |
|
333 |
#'menu.checkColor' #'menu.checkOnImage' #'menu.checkOffImage' |
|
334 |
#'menu.font' #'menu.showAccelerators')> |
|
1356 | 335 |
|
1870 | 336 |
DefaultViewBackground := StyleSheet colorAt:#'menu.viewBackground'. |
337 |
DefaultForegroundColor := StyleSheet colorAt:#'menu.foregroundColor'. |
|
338 |
DefaultBackgroundColor := StyleSheet colorAt:#'menu.backgroundColor'. |
|
339 |
DefaultShadowColor := StyleSheet colorAt:#'menu.shadowColor'. |
|
340 |
DefaultLightColor := StyleSheet colorAt:#'menu.lightColor'. |
|
341 |
DefaultHilightForegroundColor := StyleSheet colorAt:#'menu.hilightForegroundColor'. |
|
342 |
DefaultHilightBackgroundColor := StyleSheet colorAt:#'menu.hilightBackgroundColor'. |
|
343 |
DefaultHilightFrameColor := StyleSheet colorAt:#'menu.hilightFrameColor' |
|
344 |
default:(StyleSheet colorAt:#'selection.hilightFrameColor'). |
|
345 |
DefaultHilightLevel := StyleSheet at:#'menu.hilightLevel'. |
|
346 |
DefaultHilightStyle := StyleSheet at:#'menu.hilightStyle'. |
|
347 |
DefaultLineLevel := StyleSheet at:#'menu.separatingLineLevel'. |
|
348 |
DefaultLineInset := StyleSheet at:#'menu.separatingLineInset'. |
|
2584
60387225f33c
disabledBGColor-from styleSheet fix
Claus Gittinger <cg@exept.de>
parents:
2575
diff
changeset
|
349 |
DefaultDisabledForegroundColor := StyleSheet colorAt:#'menu.disabledForegroundColor' default:nil. |
60387225f33c
disabledBGColor-from styleSheet fix
Claus Gittinger <cg@exept.de>
parents:
2575
diff
changeset
|
350 |
DefaultDisabledForegroundColor isNil ifTrue:[ |
60387225f33c
disabledBGColor-from styleSheet fix
Claus Gittinger <cg@exept.de>
parents:
2575
diff
changeset
|
351 |
DefaultDisabledForegroundColor := StyleSheet colorAt:#'selection.disabledForegroundColor' default:Color darkGray. |
60387225f33c
disabledBGColor-from styleSheet fix
Claus Gittinger <cg@exept.de>
parents:
2575
diff
changeset
|
352 |
DefaultDisabledForegroundColor isNil ifTrue:[ |
60387225f33c
disabledBGColor-from styleSheet fix
Claus Gittinger <cg@exept.de>
parents:
2575
diff
changeset
|
353 |
DefaultDisabledForegroundColor := StyleSheet colorAt:#'button.disabledForegroundColor' default:Color darkGray. |
60387225f33c
disabledBGColor-from styleSheet fix
Claus Gittinger <cg@exept.de>
parents:
2575
diff
changeset
|
354 |
] |
60387225f33c
disabledBGColor-from styleSheet fix
Claus Gittinger <cg@exept.de>
parents:
2575
diff
changeset
|
355 |
]. |
2498 | 356 |
DefaultDisabledEtchedForegroundColor := StyleSheet colorAt:#'menu.disabledEtchedForegroundColor'. |
357 |
DefaultDisabledEtchedForegroundColor isNil ifTrue:[ |
|
358 |
DefaultDisabledEtchedForegroundColor := StyleSheet colorAt:#'button.disabledEtchedForegroundColor'. |
|
359 |
]. |
|
1870 | 360 |
DefaultCheckColor := StyleSheet colorAt:#'menu.checkColor'. |
361 |
DefaultCheckOnImage := StyleSheet at:#'menu.checkOnImage'. |
|
362 |
DefaultCheckOffImage := StyleSheet at:#'menu.checkOffImage'. |
|
363 |
DefaultFont := StyleSheet fontAt:#'menu.font'. |
|
364 |
ShowAcceleratorKeys := StyleSheet at:#'menu.showAccelerators' default:true. |
|
1356 | 365 |
|
1375 | 366 |
" |
367 |
self updateStyleCache |
|
368 |
" |
|
369 |
||
1532 | 370 |
"Modified: / 19.5.1998 / 22:02:30 / cg" |
0 | 371 |
! ! |
372 |
||
136 | 373 |
!MenuView methodsFor:'accessing-behavior'! |
374 |
||
687 | 375 |
action |
376 |
^ actionBlock |
|
377 |
||
378 |
"Created: 25.5.1996 / 15:11:51 / cg" |
|
379 |
! |
|
380 |
||
136 | 381 |
disable:indexOrName |
382 |
"disable an entry" |
|
383 |
||
384 |
self setEnable:indexOrName to:false |
|
385 |
! |
|
386 |
||
269 | 387 |
disableAll |
388 |
"disable all entries" |
|
389 |
||
390 |
self disableAll:selectors |
|
391 |
||
392 |
"Created: 23.12.1995 / 16:56:05 / cg" |
|
393 |
! |
|
394 |
||
136 | 395 |
disableAll:collectionOfIndicesOrNames |
396 |
"disable an collection of entries" |
|
397 |
||
398 |
collectionOfIndicesOrNames do:[:entry | |
|
399 |
self disable:entry |
|
400 |
] |
|
401 |
! |
|
402 |
||
202 | 403 |
enable:indexOrName |
404 |
"enable an entry" |
|
405 |
||
406 |
self setEnable:indexOrName to:true |
|
407 |
! |
|
408 |
||
136 | 409 |
enableAll:collectionOfIndicesOrNames |
410 |
"enable an collection of entries" |
|
411 |
||
412 |
collectionOfIndicesOrNames do:[:entry | |
|
413 |
self enable:entry |
|
414 |
] |
|
415 |
! |
|
416 |
||
202 | 417 |
hideOnRelease:aBoolean |
418 |
hideOnRelease := aBoolean |
|
419 |
! |
|
420 |
||
136 | 421 |
isEnabled:indexOrName |
1033 | 422 |
"return true, if the item at anIndexOrName is enabled" |
423 |
||
136 | 424 |
|index| |
425 |
||
4692 | 426 |
enableFlags isNil ifTrue:[^ true]. |
427 |
indexOrName isNumber ifTrue:[ ^ enableFlags at: indexOrName ]. |
|
428 |
||
136 | 429 |
index := self indexOf:indexOrName. |
430 |
index ~~ 0 ifTrue:[ |
|
2433 | 431 |
^ enableFlags at:index |
136 | 432 |
]. |
433 |
"ask submenus for convenience" |
|
434 |
(indexOrName isNumber not and:[subMenus notNil]) ifTrue:[ |
|
2433 | 435 |
subMenus do:[:m | |
436 |
m notNil ifTrue:[ |
|
437 |
(m isEnabled:indexOrName) ifTrue:[^ true]. |
|
438 |
] |
|
439 |
] |
|
440 |
]. |
|
441 |
^ false |
|
136 | 442 |
! |
443 |
||
444 |
setEnable:indexOrName to:aBoolean |
|
445 |
"enable/disable an entry" |
|
446 |
||
447 |
|index| |
|
448 |
||
4692 | 449 |
enableFlags isNil ifTrue:[ |
450 |
aBoolean ifTrue:[ ^ self ]. |
|
451 |
enableFlags := Array new: list size |
|
452 |
]. |
|
453 |
||
136 | 454 |
index := self indexOf:indexOrName. |
455 |
index ~~ 0 ifTrue:[ |
|
3980
941724541993
allow for a block given as submenu
Claus Gittinger <cg@exept.de>
parents:
3971
diff
changeset
|
456 |
(enableFlags at:index) ~~ aBoolean ifTrue:[ |
941724541993
allow for a block given as submenu
Claus Gittinger <cg@exept.de>
parents:
3971
diff
changeset
|
457 |
enableFlags at:index put:aBoolean. |
941724541993
allow for a block given as submenu
Claus Gittinger <cg@exept.de>
parents:
3971
diff
changeset
|
458 |
shown ifTrue:[ |
941724541993
allow for a block given as submenu
Claus Gittinger <cg@exept.de>
parents:
3971
diff
changeset
|
459 |
self redrawLine:index |
941724541993
allow for a block given as submenu
Claus Gittinger <cg@exept.de>
parents:
3971
diff
changeset
|
460 |
] |
941724541993
allow for a block given as submenu
Claus Gittinger <cg@exept.de>
parents:
3971
diff
changeset
|
461 |
] |
136 | 462 |
] ifFalse:[ |
3980
941724541993
allow for a block given as submenu
Claus Gittinger <cg@exept.de>
parents:
3971
diff
changeset
|
463 |
"try submenus for convenience" |
941724541993
allow for a block given as submenu
Claus Gittinger <cg@exept.de>
parents:
3971
diff
changeset
|
464 |
(indexOrName isNumber not and:[subMenus notNil]) ifTrue:[ |
941724541993
allow for a block given as submenu
Claus Gittinger <cg@exept.de>
parents:
3971
diff
changeset
|
465 |
subMenus do:[:m | |
941724541993
allow for a block given as submenu
Claus Gittinger <cg@exept.de>
parents:
3971
diff
changeset
|
466 |
(m notNil and:[m isBlock not]) ifTrue:[ |
941724541993
allow for a block given as submenu
Claus Gittinger <cg@exept.de>
parents:
3971
diff
changeset
|
467 |
m setEnable:indexOrName to:aBoolean |
941724541993
allow for a block given as submenu
Claus Gittinger <cg@exept.de>
parents:
3971
diff
changeset
|
468 |
] |
941724541993
allow for a block given as submenu
Claus Gittinger <cg@exept.de>
parents:
3971
diff
changeset
|
469 |
] |
941724541993
allow for a block given as submenu
Claus Gittinger <cg@exept.de>
parents:
3971
diff
changeset
|
470 |
] |
136 | 471 |
] |
472 |
! ! |
|
473 |
||
474 |
!MenuView methodsFor:'accessing-items'! |
|
7 | 475 |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
476 |
accelerators:collectionOfShortKeys |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
477 |
"set the accelerator keys collection. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
478 |
You should pass translated symbolic keys - the menu will automatically |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
479 |
show the untranslated original key sequences." |
0 | 480 |
|
604
04f04206a2fc
also copy selectors, args & shortKeys
Claus Gittinger <cg@exept.de>
parents:
603
diff
changeset
|
481 |
shortKeys := collectionOfShortKeys copy. |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
482 |
maxShortKeyStringLen := nil. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
483 |
shown ifTrue:[ |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
484 |
self resize |
0 | 485 |
] ifFalse:[ |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
486 |
needResize := true |
0 | 487 |
]. |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
488 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
489 |
"Created: 28.2.1996 / 17:15:31 / cg" |
604
04f04206a2fc
also copy selectors, args & shortKeys
Claus Gittinger <cg@exept.de>
parents:
603
diff
changeset
|
490 |
"Modified: 30.4.1996 / 15:55:14 / cg" |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
491 |
! |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
492 |
|
517
fc4ed55dcd35
added action-blocks (per menu item)
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
493 |
actionAt:indexOrName |
fc4ed55dcd35
added action-blocks (per menu item)
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
494 |
"return an individual action" |
fc4ed55dcd35
added action-blocks (per menu item)
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
495 |
|
fc4ed55dcd35
added action-blocks (per menu item)
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
496 |
|i| |
fc4ed55dcd35
added action-blocks (per menu item)
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
497 |
|
fc4ed55dcd35
added action-blocks (per menu item)
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
498 |
i := self indexOf:indexOrName. |
878 | 499 |
(actions notNil and:[i ~~ 0]) ifTrue:[^ actions at:i ifAbsent:nil]. |
517
fc4ed55dcd35
added action-blocks (per menu item)
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
500 |
^ nil |
fc4ed55dcd35
added action-blocks (per menu item)
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
501 |
|
fc4ed55dcd35
added action-blocks (per menu item)
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
502 |
"Created: 24.3.1996 / 17:17:22 / cg" |
fc4ed55dcd35
added action-blocks (per menu item)
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
503 |
! |
fc4ed55dcd35
added action-blocks (per menu item)
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
504 |
|
fc4ed55dcd35
added action-blocks (per menu item)
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
505 |
actionAt:indexOrName put:aBlock |
fc4ed55dcd35
added action-blocks (per menu item)
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
506 |
"set an individual action" |
fc4ed55dcd35
added action-blocks (per menu item)
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
507 |
|
fc4ed55dcd35
added action-blocks (per menu item)
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
508 |
|i| |
fc4ed55dcd35
added action-blocks (per menu item)
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
509 |
|
fc4ed55dcd35
added action-blocks (per menu item)
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
510 |
i := self indexOf:indexOrName. |
fc4ed55dcd35
added action-blocks (per menu item)
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
511 |
i ~~ 0 ifTrue:[ |
5355 | 512 |
actions isNil ifTrue:[ |
513 |
actions := OrderedCollection new. |
|
514 |
]. |
|
515 |
actions ensureSizeAtLeast:i. |
|
516 |
actions at:i put:aBlock |
|
517
fc4ed55dcd35
added action-blocks (per menu item)
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
517 |
] |
fc4ed55dcd35
added action-blocks (per menu item)
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
518 |
|
fc4ed55dcd35
added action-blocks (per menu item)
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
519 |
"Created: 24.3.1996 / 17:18:15 / cg" |
fc4ed55dcd35
added action-blocks (per menu item)
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
520 |
! |
fc4ed55dcd35
added action-blocks (per menu item)
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
521 |
|
3966 | 522 |
actions |
523 |
^ actions |
|
524 |
! |
|
525 |
||
774 | 526 |
actions:aCollectionOfActionBlocks |
527 |
"set all actions" |
|
528 |
||
529 |
actions := aCollectionOfActionBlocks |
|
530 |
||
531 |
"Created: 5.7.1996 / 11:33:09 / cg" |
|
532 |
! |
|
533 |
||
2868 | 534 |
addItemList:list after:itemNameOrSelector |
2923
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
535 |
self addItemList:list resources:nil after:itemNameOrSelector |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
536 |
! |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
537 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
538 |
addItemList:list resources:resources after:itemNameOrSelector |
2868 | 539 |
self |
6438 | 540 |
addLabels:(list collectColumn:1) |
541 |
selectors:(list collectColumn:2 ifAbsent:nil) |
|
542 |
accelerators:(list collectColumn:3 ifAbsent:nil) |
|
2923
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
543 |
resources:resources |
2868 | 544 |
after:itemNameOrSelector |
6438 | 545 |
|
546 |
"Modified: / 22-09-2018 / 11:25:35 / Claus Gittinger" |
|
2868 | 547 |
! |
548 |
||
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
549 |
addLabel:aLabel selector:aSelector |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
550 |
"add another label/selector pair at the end" |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
551 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
552 |
self addLabel:aLabel selector:aSelector after:nil |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
553 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
554 |
"Modified: 28.2.1996 / 17:54:11 / cg" |
0 | 555 |
! |
556 |
||
6318 | 557 |
addLabel:aLabel selector:aSelector action:aBlock |
558 |
"add another label/selector pair at the end" |
|
559 |
||
560 |
self |
|
561 |
addLabel:aLabel selector:aSelector after:nil; |
|
562 |
actionAt:aSelector put:aBlock |
|
563 |
! |
|
564 |
||
38 | 565 |
addLabel:aLabel selector:aSelector after:aLabelOrSelectorOrNumber |
566 |
"insert another label/selector pair at some place. |
|
567 |
Being very friendly here, allowing label-string, selector or numeric |
|
95 | 568 |
index for the argument aLabelOrSelectorOrNumber. |
569 |
||
570 |
To be independent of the entries label, we recommend you use the selector |
|
571 |
as index; in systems which translate strings for national variants, |
|
572 |
this makes your code easier to maintain." |
|
573 |
||
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
574 |
self |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
575 |
addLabels:(Array with:aLabel) |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
576 |
selectors:(Array with:aSelector) |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
577 |
after:aLabelOrSelectorOrNumber |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
578 |
|
95 | 579 |
" |
580 |
|v1 v2 v3 v4| |
|
581 |
||
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
582 |
v1 := CodeView new open. |
95 | 583 |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
584 |
v2 := CodeView new open. |
119 | 585 |
v2 middleButtonMenu: |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
586 |
(v2 editMenu addLabel:'new entry' selector:#foo after:#pasteSelection; yourself). |
95 | 587 |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
588 |
v3 := CodeView new open. |
119 | 589 |
v3 middleButtonMenu: |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
590 |
(v3 editMenu addLabel:'new entry' selector:#foo after:#others; yourself). |
95 | 591 |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
592 |
v4 := CodeView new open. |
119 | 593 |
v4 middleButtonMenu: |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
594 |
(v4 editMenu addLabel:'new entry' selector:#foo after:1; yourself). |
119 | 595 |
" |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
596 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
597 |
"Modified: 28.2.1996 / 18:04:35 / cg" |
119 | 598 |
! |
599 |
||
202 | 600 |
addLabel:aLabel selector:aSelector arg:anArg |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
601 |
"add another label/selector/argument trio. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
602 |
OBSOLETE" |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
603 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
604 |
|idx| |
202 | 605 |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
606 |
idx := list size + 1. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
607 |
self addLabel:aLabel selector:aSelector. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
608 |
args at:idx put:anArg |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
609 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
610 |
"Modified: 28.2.1996 / 18:08:39 / cg" |
202 | 611 |
! |
612 |
||
613 |
addLabel:aLabel selector:aSelector before:aLabelOrSelectorOrNumber |
|
614 |
"insert another label/selector pair at some place. |
|
615 |
Being very friendly here, allowing label-string, selector or numeric |
|
616 |
index for the argument aLabelOrSelectorOrNumber. |
|
617 |
||
618 |
To be independent of the entries label, we recommend you use the selector |
|
619 |
as index; in systems which translate strings for national variants, |
|
620 |
this makes your code easier to maintain." |
|
621 |
||
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
622 |
self |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
623 |
addLabels:(Array with:aLabel) |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
624 |
selectors:(Array with:aSelector) |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
625 |
before:aLabelOrSelectorOrNumber |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
626 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
627 |
" |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
628 |
|v1 v2 v3 v4 v5| |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
629 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
630 |
v1 := CodeView new open. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
631 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
632 |
v2 := CodeView new open. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
633 |
v2 middleButtonMenu: |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
634 |
(v2 editMenu addLabel:'new entry' selector:#foo before:'paste'; yourself). |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
635 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
636 |
v3 := CodeView new open. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
637 |
v3 middleButtonMenu: |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
638 |
(v3 editMenu addLabel:'new entry' selector:#foo before:#pasteOrReplace; yourself). |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
639 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
640 |
v4 := CodeView new open. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
641 |
v4 middleButtonMenu: |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
642 |
(v4 editMenu addLabel:'new entry' selector:#foo before:#again; yourself). |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
643 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
644 |
v5 := CodeView new open. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
645 |
v5 middleButtonMenu: |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
646 |
(v5 editMenu addLabel:'new entry' selector:#foo before:1; yourself). |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
647 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
648 |
Notice: v2 above is an example on how NOT to do it - it will not work with nationalized menus |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
649 |
" |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
650 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
651 |
"Modified: 28.2.1996 / 18:04:00 / cg" |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
652 |
! |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
653 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
654 |
addLabels:moreLabels selectors:moreSelectors |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
655 |
"add more labels and selectors at the END" |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
656 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
657 |
self addLabels:moreLabels selectors:moreSelectors after:nil |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
658 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
659 |
"Modified: 28.2.1996 / 17:46:50 / cg" |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
660 |
! |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
661 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
662 |
addLabels:moreLabels selectors:moreSelectors accelerators:shorties |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
663 |
"add more labels and selectors at the END" |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
664 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
665 |
self addLabels:moreLabels selectors:moreSelectors accelerators:shorties after:nil |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
666 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
667 |
"Modified: 28.2.1996 / 17:46:50 / cg" |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
668 |
"Created: 28.2.1996 / 17:47:17 / cg" |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
669 |
! |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
670 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
671 |
addLabels:moreLabels selectors:moreSelectors accelerators:shorties after:aLabelOrSelectorOrNumber |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
672 |
"insert more labels/selectors at some place. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
673 |
Being very friendly here, allowing label-string, selector or numeric |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
674 |
index for the argument aLabelOrSelectorOrNumber. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
675 |
If such an item is not found, insert the new items at the END. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
676 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
677 |
To be independent of the entries label, we recommend you use the selector |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
678 |
as index; in systems which translate strings for national variants, |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
679 |
this makes your code easier to maintain." |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
680 |
|
202 | 681 |
|idx| |
682 |
||
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
683 |
aLabelOrSelectorOrNumber isNil ifTrue:[ |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
684 |
idx := list size + 1 |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
685 |
] ifFalse:[ |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
686 |
idx := (self indexOf:aLabelOrSelectorOrNumber) + 1. |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
687 |
idx == 1 ifTrue:[ |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
688 |
idx := list size + 1 |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
689 |
] |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
690 |
]. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
691 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
692 |
^ self |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
693 |
addLabels:moreLabels |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
694 |
selectors:moreSelectors |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
695 |
accelerators:shorties |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
696 |
before:idx |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
697 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
698 |
"Created: 28.2.1996 / 17:48:24 / cg" |
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
463
diff
changeset
|
699 |
"Modified: 4.3.1996 / 23:26:02 / cg" |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
700 |
! |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
701 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
702 |
addLabels:moreLabels selectors:moreSelectors accelerators:shorties before:aLabelOrSelectorOrNumber |
3294
a3266e46b191
handle nonString items correctly
Stefan Vogel <sv@exept.de>
parents:
3153
diff
changeset
|
703 |
self |
a3266e46b191
handle nonString items correctly
Stefan Vogel <sv@exept.de>
parents:
3153
diff
changeset
|
704 |
addLabels:moreLabels |
a3266e46b191
handle nonString items correctly
Stefan Vogel <sv@exept.de>
parents:
3153
diff
changeset
|
705 |
selectors:moreSelectors |
a3266e46b191
handle nonString items correctly
Stefan Vogel <sv@exept.de>
parents:
3153
diff
changeset
|
706 |
accelerators:shorties |
a3266e46b191
handle nonString items correctly
Stefan Vogel <sv@exept.de>
parents:
3153
diff
changeset
|
707 |
resources:nil |
a3266e46b191
handle nonString items correctly
Stefan Vogel <sv@exept.de>
parents:
3153
diff
changeset
|
708 |
before:aLabelOrSelectorOrNumber |
131 | 709 |
! |
710 |
||
2923
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
711 |
addLabels:moreLabels selectors:moreSelectors accelerators:shorties resources:resources after:aLabelOrSelectorOrNumber |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
712 |
"insert more labels/selectors at some place. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
713 |
Being very friendly here, allowing label-string, selector or numeric |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
714 |
index for the argument aLabelOrSelectorOrNumber. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
715 |
If such an item is not found, insert the new items at the END. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
716 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
717 |
To be independent of the entries label, we recommend you use the selector |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
718 |
as index; in systems which translate strings for national variants, |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
719 |
this makes your code easier to maintain." |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
720 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
721 |
|idx| |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
722 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
723 |
aLabelOrSelectorOrNumber isNil ifTrue:[ |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
724 |
idx := list size + 1 |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
725 |
] ifFalse:[ |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
726 |
idx := (self indexOf:aLabelOrSelectorOrNumber) + 1. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
727 |
idx == 1 ifTrue:[ |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
728 |
idx := list size + 1 |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
729 |
] |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
730 |
]. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
731 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
732 |
^ self |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
733 |
addLabels:moreLabels |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
734 |
selectors:moreSelectors |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
735 |
accelerators:shorties |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
736 |
resources:resources |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
737 |
before:idx |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
738 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
739 |
"Created: 28.2.1996 / 17:48:24 / cg" |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
740 |
"Modified: 4.3.1996 / 23:26:02 / cg" |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
741 |
! |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
742 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
743 |
addLabels:moreLabels selectors:moreSelectors accelerators:shorties resources:resources before:aLabelOrSelectorOrNumber |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
744 |
"insert more labels/selectors at some place. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
745 |
Being very friendly here, allowing label-string, selector or numeric |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
746 |
index for the argument aLabelOrSelectorOrNumber. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
747 |
If such an item is not found, insert the new items at the beginning. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
748 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
749 |
To be independent of the entries label, we recommend you use the selector |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
750 |
as index; in systems which translate strings for national variants, |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
751 |
this makes your code easier to maintain." |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
752 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
753 |
|idx oldSize |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
754 |
i "{ Class: SmallInteger }" |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
755 |
nMore "{ Class: SmallInteger }"| |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
756 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
757 |
list isNil ifTrue:[ |
4215
a792c0e948b0
changed: #addLabels:selectors:accelerators:resources:before:
Claus Gittinger <cg@exept.de>
parents:
4198
diff
changeset
|
758 |
list := OrderedCollection new. |
a792c0e948b0
changed: #addLabels:selectors:accelerators:resources:before:
Claus Gittinger <cg@exept.de>
parents:
4198
diff
changeset
|
759 |
"/ ^ self addLabels:moreLabels selectors:moreSelectors resources:resources |
2923
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
760 |
]. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
761 |
" |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
762 |
be user friendly - allow both label or selector |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
763 |
to be passed |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
764 |
" |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
765 |
aLabelOrSelectorOrNumber isNil ifTrue:[ |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
766 |
idx := 1 |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
767 |
] ifFalse:[ |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
768 |
idx := self indexOf:aLabelOrSelectorOrNumber. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
769 |
(idx between:2 and:(list size + 1)) ifFalse:[ |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
770 |
"add to beginning" |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
771 |
idx := 1 |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
772 |
] |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
773 |
]. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
774 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
775 |
nMore := moreLabels size. |
3294
a3266e46b191
handle nonString items correctly
Stefan Vogel <sv@exept.de>
parents:
3153
diff
changeset
|
776 |
self assert:moreSelectors size == nMore. |
2923
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
777 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
778 |
oldSize := list size. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
779 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
780 |
list := list asOrderedCollection. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
781 |
i := idx. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
782 |
moreLabels do:[:aLabel | |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
783 |
|l| |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
784 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
785 |
resources notNil |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
786 |
ifTrue:[l := resources string:aLabel] |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
787 |
ifFalse:[l := aLabel]. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
788 |
|
4375
ad05f08df31f
refactored ampersand processing for more reusability.
Claus Gittinger <cg@exept.de>
parents:
4374
diff
changeset
|
789 |
"/ remove ampersands |
ad05f08df31f
refactored ampersand processing for more reusability.
Claus Gittinger <cg@exept.de>
parents:
4374
diff
changeset
|
790 |
l := MenuPanel |
ad05f08df31f
refactored ampersand processing for more reusability.
Claus Gittinger <cg@exept.de>
parents:
4374
diff
changeset
|
791 |
processAmpersandCharactersFor:l |
ad05f08df31f
refactored ampersand processing for more reusability.
Claus Gittinger <cg@exept.de>
parents:
4374
diff
changeset
|
792 |
withAccessCharacterPosition:nil. |
ad05f08df31f
refactored ampersand processing for more reusability.
Claus Gittinger <cg@exept.de>
parents:
4374
diff
changeset
|
793 |
|
4327 | 794 |
"/ wrong: needed for accelerators. |
795 |
"/ l := self labelWithoutDoubleAmpersands:l. |
|
2923
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
796 |
list add:l beforeIndex:i. i := i + 1. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
797 |
]. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
798 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
799 |
selectors := (selectors ? #()) asOrderedCollection. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
800 |
i := idx. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
801 |
moreSelectors do:[:sel | |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
802 |
selectors add:sel beforeIndex:i. i := i + 1. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
803 |
]. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
804 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
805 |
enableFlags := (enableFlags ? #()) asOrderedCollection. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
806 |
i := idx. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
807 |
nMore timesRepeat:[ |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
808 |
enableFlags add:true beforeIndex:i. i := i + 1. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
809 |
]. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
810 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
811 |
subMenus notNil ifTrue:[ |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
812 |
subMenus := subMenus asOrderedCollection. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
813 |
i := idx. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
814 |
i >= subMenus size ifTrue:[ |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
815 |
subMenus grow:i-1 |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
816 |
]. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
817 |
nMore timesRepeat:[ |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
818 |
subMenus add:nil beforeIndex:i. i := i + 1. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
819 |
]. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
820 |
]. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
821 |
args notNil ifTrue:[ |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
822 |
args := args asOrderedCollection. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
823 |
i := idx. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
824 |
i >= args size ifTrue:[ |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
825 |
args grow:i-1 |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
826 |
]. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
827 |
nMore timesRepeat:[ |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
828 |
args add:nil beforeIndex:i. i := i + 1. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
829 |
] |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
830 |
]. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
831 |
actions notNil ifTrue:[ |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
832 |
actions := actions asOrderedCollection. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
833 |
i := idx. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
834 |
i >= actions size ifTrue:[ |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
835 |
actions grow:i-1 |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
836 |
]. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
837 |
nMore timesRepeat:[ |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
838 |
actions add:nil beforeIndex:i. i := i + 1. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
839 |
] |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
840 |
]. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
841 |
onOffFlags notNil ifTrue:[ |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
842 |
onOffFlags := onOffFlags asOrderedCollection. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
843 |
i := idx. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
844 |
i >= onOffFlags size ifTrue:[ |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
845 |
onOffFlags grow:i-1 |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
846 |
]. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
847 |
nMore timesRepeat:[ |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
848 |
onOffFlags add:nil beforeIndex:i. i := i + 1. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
849 |
] |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
850 |
]. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
851 |
shortKeys isNil ifTrue:[ |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
852 |
shortKeys := OrderedCollection new:oldSize. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
853 |
shortKeys grow:oldSize |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
854 |
]. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
855 |
shortKeys := shortKeys asOrderedCollection. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
856 |
i := idx. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
857 |
shorties isNil ifTrue:[ |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
858 |
nMore timesRepeat:[ |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
859 |
shortKeys add:nil beforeIndex:i. i := i + 1. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
860 |
] |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
861 |
] ifFalse:[ |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
862 |
maxShortKeyStringLen := nil. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
863 |
shorties do:[:sel | |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
864 |
shortKeys add:sel beforeIndex:i. i := i + 1. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
865 |
] |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
866 |
]. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
867 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
868 |
shown ifTrue:[ |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
869 |
self resize |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
870 |
] ifFalse:[ |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
871 |
needResize := true |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
872 |
]. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
873 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
874 |
" |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
875 |
|v1 v2 v3 v4 v5 m| |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
876 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
877 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
878 |
v1 := CodeView new open. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
879 |
v1 contents:'original menu'. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
880 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
881 |
v2 := CodeView new open. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
882 |
v2 contents:'before copy'. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
883 |
m := v2 editMenu. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
884 |
m |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
885 |
addLabels:#('new entry1' 'new entry2') |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
886 |
selectors:#(foo bar) |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
887 |
before:#copySelection |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
888 |
accelerators:#(Copy Cut Paste). |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
889 |
v2 middleButtonMenu:m. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
890 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
891 |
v3 := CodeView new open. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
892 |
v3 contents:'before again '. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
893 |
m := v3 editMenu. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
894 |
m |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
895 |
addLabels:#('new entry1' 'new entry2') |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
896 |
selectors:#(foo bar) |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
897 |
before:#again. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
898 |
v3 middleButtonMenu:m. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
899 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
900 |
v4 := CodeView new open. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
901 |
v4 contents:'at beginning '. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
902 |
m := v4 editMenu. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
903 |
m |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
904 |
addLabels:#('new entry1' 'new entry2' '-') |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
905 |
selectors:#(foo bar nil) |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
906 |
before:1. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
907 |
v4 middleButtonMenu:m. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
908 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
909 |
v5 := CodeView new open. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
910 |
v5 contents:'at end '. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
911 |
m := v5 editMenu. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
912 |
m |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
913 |
addLabels:#('-' 'new entry1' 'new entry2') |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
914 |
selectors:#(nil foo bar). |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
915 |
v5 middleButtonMenu:m. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
916 |
" |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
917 |
|
4215
a792c0e948b0
changed: #addLabels:selectors:accelerators:resources:before:
Claus Gittinger <cg@exept.de>
parents:
4198
diff
changeset
|
918 |
"Created: / 28-02-1996 / 17:49:44 / cg" |
4375
ad05f08df31f
refactored ampersand processing for more reusability.
Claus Gittinger <cg@exept.de>
parents:
4374
diff
changeset
|
919 |
"Modified: / 15-02-2012 / 18:54:54 / cg" |
2923
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
920 |
! |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
921 |
|
119 | 922 |
addLabels:moreLabels selectors:moreSelectors after:aLabelOrSelectorOrNumber |
923 |
"insert more labels/selectors at some place. |
|
924 |
Being very friendly here, allowing label-string, selector or numeric |
|
925 |
index for the argument aLabelOrSelectorOrNumber. |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
926 |
If such an item is not found, insert the new items at the END. |
119 | 927 |
|
928 |
To be independent of the entries label, we recommend you use the selector |
|
929 |
as index; in systems which translate strings for national variants, |
|
930 |
this makes your code easier to maintain." |
|
931 |
||
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
932 |
^ self |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
933 |
addLabels:moreLabels |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
934 |
selectors:moreSelectors |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
935 |
accelerators:nil |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
936 |
after:aLabelOrSelectorOrNumber |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
937 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
938 |
"Modified: 28.2.1996 / 17:47:52 / cg" |
119 | 939 |
! |
940 |
||
941 |
addLabels:moreLabels selectors:moreSelectors before:aLabelOrSelectorOrNumber |
|
942 |
"insert more labels/selectors at some place. |
|
943 |
Being very friendly here, allowing label-string, selector or numeric |
|
944 |
index for the argument aLabelOrSelectorOrNumber. |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
945 |
If such an item is not found, insert the new items at the beginning. |
119 | 946 |
|
947 |
To be independent of the entries label, we recommend you use the selector |
|
948 |
as index; in systems which translate strings for national variants, |
|
949 |
this makes your code easier to maintain." |
|
950 |
||
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
951 |
self |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
952 |
addLabels:moreLabels |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
953 |
selectors:moreSelectors |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
954 |
accelerators:nil |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
955 |
before:aLabelOrSelectorOrNumber |
119 | 956 |
|
957 |
" |
|
958 |
|v1 v2 v3 v4 m| |
|
959 |
||
960 |
||
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
961 |
v1 := CodeView new open. |
119 | 962 |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
963 |
v2 := CodeView new open. |
119 | 964 |
m := v2 editMenu. |
965 |
m |
|
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
966 |
addLabels:#('new entry1' 'new entry2') |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
967 |
selectors:#(foo bar) |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
968 |
before:'paste'. |
119 | 969 |
v2 middleButtonMenu:m. |
970 |
||
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
971 |
v3 := CodeView new open. |
119 | 972 |
m := v3 editMenu. |
973 |
m |
|
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
974 |
addLabels:#('new entry1' 'new entry2') |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
975 |
selectors:#(foo bar) |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
976 |
before:#again. |
119 | 977 |
v3 middleButtonMenu:m. |
978 |
||
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
979 |
v4 := CodeView new open. |
119 | 980 |
m := v4 editMenu. |
981 |
m |
|
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
982 |
addLabels:#('new entry1' 'new entry2') |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
983 |
selectors:#(foo bar) |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
984 |
before:1. |
119 | 985 |
v4 middleButtonMenu:m. |
95 | 986 |
" |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
987 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
988 |
"Modified: 28.2.1996 / 17:49:30 / cg" |
95 | 989 |
! |
990 |
||
2923
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
991 |
addLabels:moreLabels selectors:moreSelectors resources:resources |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
992 |
"add more labels and selectors at the END" |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
993 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
994 |
self addLabels:moreLabels selectors:moreSelectors resources:resources after:nil |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
995 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
996 |
"Modified: 28.2.1996 / 17:46:50 / cg" |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
997 |
! |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
998 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
999 |
addLabels:moreLabels selectors:moreSelectors resources:resources accelerators:shorties |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1000 |
"add more labels and selectors at the END" |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1001 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1002 |
self addLabels:moreLabels selectors:moreSelectors accelerators:shorties resources:resources after:nil |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1003 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1004 |
"Modified: 28.2.1996 / 17:46:50 / cg" |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1005 |
"Created: 28.2.1996 / 17:47:17 / cg" |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1006 |
! |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1007 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1008 |
addLabels:moreLabels selectors:moreSelectors resources:resources after:aLabelOrSelectorOrNumber |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1009 |
"insert more labels/selectors at some place. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1010 |
Being very friendly here, allowing label-string, selector or numeric |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1011 |
index for the argument aLabelOrSelectorOrNumber. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1012 |
If such an item is not found, insert the new items at the END. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1013 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1014 |
To be independent of the entries label, we recommend you use the selector |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1015 |
as index; in systems which translate strings for national variants, |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1016 |
this makes your code easier to maintain." |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1017 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1018 |
^ self |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1019 |
addLabels:moreLabels |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1020 |
selectors:moreSelectors |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1021 |
accelerators:nil |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1022 |
resources:resources |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1023 |
after:aLabelOrSelectorOrNumber |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1024 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1025 |
"Modified: 28.2.1996 / 17:47:52 / cg" |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1026 |
! |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1027 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1028 |
addLabels:moreLabels selectors:moreSelectors resources:resources before:aLabelOrSelectorOrNumber |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1029 |
"insert more labels/selectors at some place. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1030 |
Being very friendly here, allowing label-string, selector or numeric |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1031 |
index for the argument aLabelOrSelectorOrNumber. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1032 |
If such an item is not found, insert the new items at the beginning. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1033 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1034 |
To be independent of the entries label, we recommend you use the selector |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1035 |
as index; in systems which translate strings for national variants, |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1036 |
this makes your code easier to maintain." |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1037 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1038 |
self |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1039 |
addLabels:moreLabels |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1040 |
selectors:moreSelectors |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1041 |
accelerators:nil |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1042 |
resources:resources |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1043 |
before:aLabelOrSelectorOrNumber |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1044 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1045 |
" |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1046 |
|v1 v2 v3 v4 m| |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1047 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1048 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1049 |
v1 := CodeView new open. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1050 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1051 |
v2 := CodeView new open. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1052 |
m := v2 editMenu. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1053 |
m |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1054 |
addLabels:#('new entry1' 'new entry2') |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1055 |
selectors:#(foo bar) |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1056 |
before:'paste'. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1057 |
v2 middleButtonMenu:m. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1058 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1059 |
v3 := CodeView new open. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1060 |
m := v3 editMenu. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1061 |
m |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1062 |
addLabels:#('new entry1' 'new entry2') |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1063 |
selectors:#(foo bar) |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1064 |
before:#again. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1065 |
v3 middleButtonMenu:m. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1066 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1067 |
v4 := CodeView new open. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1068 |
m := v4 editMenu. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1069 |
m |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1070 |
addLabels:#('new entry1' 'new entry2') |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1071 |
selectors:#(foo bar) |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1072 |
before:1. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1073 |
v4 middleButtonMenu:m. |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1074 |
" |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1075 |
|
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1076 |
"Modified: 28.2.1996 / 17:49:30 / cg" |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1077 |
! |
1eaa937f0568
added protocol to add an itemList with resource-translation
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
1078 |
|
202 | 1079 |
addSeparatingLine |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1080 |
"add a separating line at the END" |
60 | 1081 |
|
202 | 1082 |
self addLabel:'-' selector:nil |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1083 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1084 |
"Modified: 28.2.1996 / 17:50:08 / cg" |
60 | 1085 |
! |
1086 |
||
202 | 1087 |
addSeparatingLineAfter:aLabelOrSelectorOrNumber |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1088 |
"add a separating line after an item" |
133 | 1089 |
|
202 | 1090 |
self addLabel:'-' selector:nil after:aLabelOrSelectorOrNumber |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1091 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1092 |
"Modified: 28.2.1996 / 17:50:14 / cg" |
0 | 1093 |
! |
1094 |
||
6318 | 1095 |
addSeparator |
1096 |
"add a separating line at the END. |
|
1097 |
compatibility with Menu" |
|
1098 |
||
1099 |
self addSeparatingLine |
|
1100 |
! |
|
1101 |
||
0 | 1102 |
args |
1103 |
"return the argument array" |
|
1104 |
||
1105 |
^ args |
|
1106 |
! |
|
1107 |
||
1108 |
args:anArray |
|
1109 |
"set the argument array" |
|
1110 |
||
604
04f04206a2fc
also copy selectors, args & shortKeys
Claus Gittinger <cg@exept.de>
parents:
603
diff
changeset
|
1111 |
args := anArray copy |
04f04206a2fc
also copy selectors, args & shortKeys
Claus Gittinger <cg@exept.de>
parents:
603
diff
changeset
|
1112 |
|
04f04206a2fc
also copy selectors, args & shortKeys
Claus Gittinger <cg@exept.de>
parents:
603
diff
changeset
|
1113 |
"Modified: 30.4.1996 / 15:55:03 / cg" |
0 | 1114 |
! |
1115 |
||
1116 |
argsAt:indexOrName put:something |
|
1117 |
"set an individual selector" |
|
1118 |
||
3 | 1119 |
|i| |
1120 |
||
1121 |
i := self indexOf:indexOrName. |
|
1122 |
i ~~ 0 ifTrue:[args at:i put:something] |
|
0 | 1123 |
! |
1124 |
||
202 | 1125 |
checkFlags |
1126 |
"return an array filled with the check-mark flags. |
|
1127 |
Non check-menu items have a nil entry in this array." |
|
0 | 1128 |
|
202 | 1129 |
^ onOffFlags |
0 | 1130 |
! |
1131 |
||
3966 | 1132 |
checkFlags:aCollectionOfBooleansOrNils |
1133 |
onOffFlags := aCollectionOfBooleansOrNils |
|
1134 |
! |
|
1135 |
||
0 | 1136 |
checkToggleAt:indexOrName |
569
8c460366645e
checkToggleAt returns nil for non-check entries
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
1137 |
"return a check-toggles boolean state. |
8c460366645e
checkToggleAt returns nil for non-check entries
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
1138 |
If the item is not a check-item, return nil." |
0 | 1139 |
|
1140 |
|index| |
|
1141 |
||
1142 |
index := self indexOf:indexOrName. |
|
569
8c460366645e
checkToggleAt returns nil for non-check entries
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
1143 |
index == 0 ifTrue:[^ nil]. |
8c460366645e
checkToggleAt returns nil for non-check entries
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
1144 |
onOffFlags isNil ifTrue:[^ nil]. |
8c460366645e
checkToggleAt returns nil for non-check entries
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
1145 |
index > onOffFlags size ifTrue:[^ nil]. |
0 | 1146 |
^ onOffFlags at:index |
569
8c460366645e
checkToggleAt returns nil for non-check entries
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
1147 |
|
8c460366645e
checkToggleAt returns nil for non-check entries
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
1148 |
"Modified: 22.4.1996 / 10:51:54 / cg" |
0 | 1149 |
! |
1150 |
||
1151 |
checkToggleAt:indexOrName put:aBoolean |
|
1152 |
"set/clear a check-toggle" |
|
1153 |
||
1154 |
|index| |
|
1155 |
||
1156 |
index := self indexOf:indexOrName. |
|
475
ce306c6c6bc4
care for toggles when adding labels
Claus Gittinger <cg@exept.de>
parents:
465
diff
changeset
|
1157 |
index == 0 ifTrue:[ |
481 | 1158 |
"/ 'no item: ' print. indexOrName printNL. |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1159 |
^ self |
475
ce306c6c6bc4
care for toggles when adding labels
Claus Gittinger <cg@exept.de>
parents:
465
diff
changeset
|
1160 |
]. |
65 | 1161 |
|
1162 |
onOffFlags isNil ifTrue:[ |
|
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1163 |
onOffFlags := Array new:(list size) |
65 | 1164 |
]. |
0 | 1165 |
onOffFlags at:index put:aBoolean. |
1166 |
shown ifTrue:[ |
|
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1167 |
self redrawLine:index |
0 | 1168 |
] |
475
ce306c6c6bc4
care for toggles when adding labels
Claus Gittinger <cg@exept.de>
parents:
465
diff
changeset
|
1169 |
|
481 | 1170 |
"Modified: 6.3.1996 / 16:31:43 / cg" |
202 | 1171 |
! |
1172 |
||
4613 | 1173 |
hasItems |
1174 |
"return true, if I have items" |
|
1175 |
||
1176 |
^ list notEmptyOrNil |
|
1177 |
! |
|
1178 |
||
202 | 1179 |
indexOf:indexOrName |
6104 | 1180 |
"return the index of the label named:aName or , if it's a symbol |
593 | 1181 |
the index in the selector list. |
1182 |
If indexOrName is not a valid item, return 0." |
|
202 | 1183 |
|
1184 |
indexOrName isSymbol ifTrue:[ |
|
6104 | 1185 |
^ selectors indexOf:indexOrName |
202 | 1186 |
]. |
1187 |
indexOrName isString ifTrue:[ |
|
6104 | 1188 |
^ list indexOf:indexOrName |
202 | 1189 |
]. |
1190 |
indexOrName isNil ifTrue:[^ 0]. |
|
593 | 1191 |
|
1192 |
(indexOrName respondsTo:#string) ifTrue:[ |
|
6104 | 1193 |
^ list indexOf:indexOrName asString |
593 | 1194 |
]. |
202 | 1195 |
^ indexOrName |
593 | 1196 |
|
6104 | 1197 |
"Modified: / 27-04-1996 / 15:25:16 / cg" |
1198 |
"Modified (comment): / 13-02-2017 / 20:26:50 / cg" |
|
202 | 1199 |
! |
1200 |
||
6376 | 1201 |
items |
1202 |
"for menuPanel compatibility: return a list of menu items" |
|
1203 |
||
1204 |
^ (1 to:list size) |
|
6377 | 1205 |
collect:[:idx | |
6376 | 1206 |
|item| |
1207 |
item := MenuItem new. |
|
6377 | 1208 |
item label:(list at:idx). |
1209 |
item enabled:(self isEnabled:idx). |
|
6376 | 1210 |
item. |
1211 |
]. |
|
1212 |
||
1213 |
"Created: / 12-07-2018 / 21:42:39 / Claus Gittinger" |
|
6377 | 1214 |
"Modified: / 13-07-2018 / 11:10:16 / Claus Gittinger" |
6376 | 1215 |
! |
1216 |
||
202 | 1217 |
labelAt:indexOrName put:aString |
1218 |
"change the label at index to be aString" |
|
1219 |
||
1220 |
|i nItems| |
|
1221 |
||
1222 |
i := self indexOf:indexOrName. |
|
1223 |
i == 0 ifTrue:[^ self]. |
|
1224 |
list at:i put:aString. |
|
1225 |
||
1226 |
"create onOff flags, if this label has a check-mark" |
|
1227 |
(self isCheckItem:aString) ifTrue:[ |
|
1228 |
nItems := list size. |
|
1229 |
onOffFlags isNil ifTrue:[ |
|
1230 |
onOffFlags := Array new:nItems |
|
1231 |
] ifFalse:[ |
|
1232 |
[onOffFlags size < nItems] whileTrue:[ |
|
1233 |
onOffFlags := onOffFlags copyWith:nil |
|
1234 |
] |
|
1235 |
]. |
|
1236 |
onOffFlags at:i put:false |
|
1237 |
]. |
|
1238 |
shown ifTrue:[ |
|
1239 |
self resize |
|
1240 |
] ifFalse:[ |
|
1241 |
needResize := true |
|
1242 |
] |
|
1243 |
! |
|
1244 |
||
1245 |
labels |
|
1246 |
"return the menu-labels" |
|
1247 |
||
1248 |
^ list |
|
1249 |
! |
|
1250 |
||
1251 |
labels:text |
|
1252 |
"set the labels to the argument, text" |
|
1253 |
||
908 | 1254 |
|l nItems| |
202 | 1255 |
|
1256 |
(text isString) ifTrue:[ |
|
2953 | 1257 |
l := text asStringCollection |
202 | 1258 |
] ifFalse:[ |
2953 | 1259 |
l := text copy |
202 | 1260 |
]. |
4327 | 1261 |
"/ wrong: needed for accelerators. |
1262 |
"/ l := l collect:[:s | self labelWithoutDoubleAmpersands:s]. |
|
202 | 1263 |
"/ self list:l |
1264 |
self setList:l expandTabs:false. |
|
908 | 1265 |
nItems := list size. |
1266 |
enableFlags := Array new:nItems withAll:true. |
|
1267 |
onOffFlags := Array new:nItems. |
|
1048 | 1268 |
|
1269 |
text notNil ifTrue:[ |
|
2953 | 1270 |
text keysAndValuesDo:[:index :line | |
1271 |
(self isCheckItem:line) ifTrue:[ |
|
1272 |
onOffFlags at:index put:false |
|
1273 |
]. |
|
1274 |
]. |
|
202 | 1275 |
]. |
1276 |
shown ifTrue:[ |
|
2953 | 1277 |
self resize |
202 | 1278 |
] ifFalse:[ |
2953 | 1279 |
needResize := true |
202 | 1280 |
] |
603
9760b8c7f5de
create a copy of the labels (in case someone changes it later)
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
1281 |
|
4327 | 1282 |
"Modified: / 06-10-2011 / 16:45:57 / cg" |
202 | 1283 |
! |
1284 |
||
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1285 |
labels:text selectors:selArray accelerators:shorties args:argArray receiver:anObject |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1286 |
"set all relevant stuff" |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1287 |
|
604
04f04206a2fc
also copy selectors, args & shortKeys
Claus Gittinger <cg@exept.de>
parents:
603
diff
changeset
|
1288 |
self labels:text selectors:selArray args:argArray receiver:anObject. |
04f04206a2fc
also copy selectors, args & shortKeys
Claus Gittinger <cg@exept.de>
parents:
603
diff
changeset
|
1289 |
shortKeys := shorties copy. |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1290 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1291 |
"Created: 28.2.1996 / 18:56:38 / cg" |
604
04f04206a2fc
also copy selectors, args & shortKeys
Claus Gittinger <cg@exept.de>
parents:
603
diff
changeset
|
1292 |
"Modified: 30.4.1996 / 15:54:48 / cg" |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1293 |
! |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1294 |
|
202 | 1295 |
labels:text selectors:selArray args:argArray receiver:anObject |
1296 |
"set all relevant stuff" |
|
1297 |
||
1298 |
self labels:text. |
|
642 | 1299 |
selArray isSymbol ifTrue:[ |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1300 |
selectors := Array new:(text size) withAll:selArray |
642 | 1301 |
] ifFalse:[ |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1302 |
selectors := selArray copy. |
642 | 1303 |
]. |
604
04f04206a2fc
also copy selectors, args & shortKeys
Claus Gittinger <cg@exept.de>
parents:
603
diff
changeset
|
1304 |
args := argArray copy. |
202 | 1305 |
receiver := anObject |
604
04f04206a2fc
also copy selectors, args & shortKeys
Claus Gittinger <cg@exept.de>
parents:
603
diff
changeset
|
1306 |
|
642 | 1307 |
"Modified: 14.5.1996 / 15:30:10 / cg" |
202 | 1308 |
! |
1309 |
||
963 | 1310 |
menuPerformer:someone |
1311 |
"set the menuPerformer of the message. |
|
1312 |
This also sets the menuPerformer in all subMenus." |
|
1313 |
||
1314 |
menuPerformer := someone. |
|
1315 |
subMenus notNil ifTrue:[ |
|
3980
941724541993
allow for a block given as submenu
Claus Gittinger <cg@exept.de>
parents:
3971
diff
changeset
|
1316 |
subMenus do:[:aMenu | |
941724541993
allow for a block given as submenu
Claus Gittinger <cg@exept.de>
parents:
3971
diff
changeset
|
1317 |
(aMenu notNil and:[aMenu isBlock not]) ifTrue:[ |
941724541993
allow for a block given as submenu
Claus Gittinger <cg@exept.de>
parents:
3971
diff
changeset
|
1318 |
aMenu menuPerformer:someone |
941724541993
allow for a block given as submenu
Claus Gittinger <cg@exept.de>
parents:
3971
diff
changeset
|
1319 |
] |
941724541993
allow for a block given as submenu
Claus Gittinger <cg@exept.de>
parents:
3971
diff
changeset
|
1320 |
] |
963 | 1321 |
] |
1322 |
||
1323 |
"Created: 21.1.1997 / 15:42:00 / cg" |
|
1324 |
! |
|
1325 |
||
202 | 1326 |
receiver |
1327 |
"return the receiver of the message" |
|
1328 |
||
1329 |
^ receiver |
|
1330 |
! |
|
1331 |
||
1332 |
receiver:anObject |
|
963 | 1333 |
"set the receiver of the message. |
1334 |
This also sets the receiver in all subMenus." |
|
202 | 1335 |
|
1336 |
receiver := anObject. |
|
1337 |
subMenus notNil ifTrue:[ |
|
3980
941724541993
allow for a block given as submenu
Claus Gittinger <cg@exept.de>
parents:
3971
diff
changeset
|
1338 |
subMenus do:[:aMenu | |
941724541993
allow for a block given as submenu
Claus Gittinger <cg@exept.de>
parents:
3971
diff
changeset
|
1339 |
(aMenu notNil and:[aMenu isBlock not]) ifTrue:[ |
941724541993
allow for a block given as submenu
Claus Gittinger <cg@exept.de>
parents:
3971
diff
changeset
|
1340 |
aMenu receiver:anObject |
941724541993
allow for a block given as submenu
Claus Gittinger <cg@exept.de>
parents:
3971
diff
changeset
|
1341 |
] |
941724541993
allow for a block given as submenu
Claus Gittinger <cg@exept.de>
parents:
3971
diff
changeset
|
1342 |
] |
202 | 1343 |
] |
963 | 1344 |
|
1345 |
"Modified: 21.1.1997 / 15:41:32 / cg" |
|
202 | 1346 |
! |
1347 |
||
1348 |
remove:indexOrName |
|
1349 |
"remove the label at index" |
|
1350 |
||
1351 |
|i| |
|
1352 |
||
1353 |
i := self indexOf:indexOrName. |
|
1354 |
i == 0 ifTrue:[^ self]. |
|
1355 |
list := list asOrderedCollection removeIndex:i. |
|
1356 |
selectors := selectors asOrderedCollection removeIndex:i. |
|
4692 | 1357 |
enableFlags notNil ifTrue:[ enableFlags := enableFlags asOrderedCollection removeIndex:i ]. |
202 | 1358 |
subMenus notNil ifTrue:[ |
4692 | 1359 |
subMenus := subMenus asOrderedCollection removeIndex:i. |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1360 |
]. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1361 |
shortKeys notNil ifTrue:[ |
4692 | 1362 |
shortKeys := shortKeys asOrderedCollection removeIndex:i. |
1363 |
maxShortKeyStringLen := nil. |
|
202 | 1364 |
]. |
1365 |
shown ifTrue:[ |
|
4692 | 1366 |
self resize |
202 | 1367 |
] ifFalse:[ |
4692 | 1368 |
needResize := true |
202 | 1369 |
] |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1370 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1371 |
"Modified: 28.2.1996 / 18:27:57 / cg" |
202 | 1372 |
! |
1373 |
||
1374 |
selectorAt:indexOrName |
|
1375 |
"return an individual selector" |
|
1376 |
||
1377 |
|i| |
|
1378 |
||
1379 |
i := self indexOf:indexOrName. |
|
1380 |
i ~~ 0 ifTrue:[^ selectors at:i]. |
|
1381 |
^ nil |
|
1382 |
! |
|
1383 |
||
1384 |
selectorAt:indexOrName put:aSelector |
|
1385 |
"set an individual selector" |
|
1386 |
||
1387 |
|i| |
|
1388 |
||
1389 |
i := self indexOf:indexOrName. |
|
1390 |
i ~~ 0 ifTrue:[selectors at:i put:aSelector] |
|
1391 |
! |
|
1392 |
||
1393 |
selectors |
|
1394 |
"return the selector array" |
|
1395 |
||
1396 |
^ selectors |
|
1397 |
! |
|
1398 |
||
1399 |
selectors:anArray |
|
1400 |
"set the selector array" |
|
1401 |
||
604
04f04206a2fc
also copy selectors, args & shortKeys
Claus Gittinger <cg@exept.de>
parents:
603
diff
changeset
|
1402 |
selectors := anArray copy |
04f04206a2fc
also copy selectors, args & shortKeys
Claus Gittinger <cg@exept.de>
parents:
603
diff
changeset
|
1403 |
|
04f04206a2fc
also copy selectors, args & shortKeys
Claus Gittinger <cg@exept.de>
parents:
603
diff
changeset
|
1404 |
"Modified: 30.4.1996 / 15:54:07 / cg" |
202 | 1405 |
! |
1406 |
||
1407 |
someMenuItemLabeled:aLabel |
|
1408 |
"find a menu item. |
|
1409 |
Currently, in ST/X, instances of MenuItem are only created as dummy" |
|
1410 |
||
1411 |
|idx| |
|
1412 |
||
1413 |
idx := self indexOf:aLabel. |
|
1414 |
idx ~~ 0 ifTrue:[ |
|
1415 |
^ MenuItem new menu:self index:idx |
|
1416 |
]. |
|
1417 |
subMenus notNil ifTrue:[ |
|
1418 |
subMenus do:[:aMenu | |
|
1419 |
|item| |
|
1420 |
||
1421 |
aMenu notNil ifTrue:[ |
|
1422 |
(item := aMenu someMenuItemLabeled:aLabel) notNil ifTrue:[ |
|
1423 |
^ item |
|
1424 |
] |
|
1425 |
] |
|
1426 |
]. |
|
1427 |
]. |
|
1428 |
^ nil |
|
1429 |
! ! |
|
1430 |
||
1431 |
!MenuView methodsFor:'accessing-look'! |
|
1432 |
||
1433 |
font:aFont |
|
665 | 1434 |
"adjust size for new font. |
1435 |
CAVEAT: with the addition of Text objects, |
|
1989 | 1436 |
this method is going to be obsoleted by a textStyle |
1437 |
method, which allows specific control over |
|
1438 |
normalFont/boldFont/italicFont parameters." |
|
1439 |
||
4900 | 1440 |
super font:aFont. |
6496 | 1441 |
self flushCachedPreferredExtent. |
202 | 1442 |
shown ifTrue:[ |
1989 | 1443 |
self resize |
202 | 1444 |
] ifFalse:[ |
1989 | 1445 |
needResize := true |
202 | 1446 |
] |
665 | 1447 |
|
6496 | 1448 |
"Modified: / 22-05-1996 / 12:36:37 / cg" |
1449 |
"Modified: / 09-11-2018 / 20:17:00 / Claus Gittinger" |
|
202 | 1450 |
! ! |
1451 |
||
1452 |
!MenuView methodsFor:'accessing-misc'! |
|
1453 |
||
1454 |
masterView |
|
1455 |
"return the popup-masterview I am contained in." |
|
1456 |
||
1457 |
^ masterView |
|
1458 |
! |
|
1459 |
||
1460 |
masterView:aPopUpView |
|
1461 |
"set the popup-masterview I am contained in." |
|
1462 |
||
1463 |
masterView := aPopUpView |
|
1464 |
! |
|
1465 |
||
1466 |
selection:index |
|
4684 | 1467 |
"set the selection" |
1468 |
||
4195
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1469 |
super selection:(self validateSelection:index) |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1470 |
|
4198 | 1471 |
"Modified: / 29-11-2010 / 19:53:36 / cg" |
202 | 1472 |
! |
1473 |
||
683 | 1474 |
setSelection:index |
4195
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1475 |
super setSelection:(self validateSelection:index) |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1476 |
|
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1477 |
"Created: / 25-05-1996 / 12:27:33 / cg" |
4198 | 1478 |
"Modified: / 29-11-2010 / 19:53:31 / cg" |
683 | 1479 |
! |
1480 |
||
334 | 1481 |
sizeFixed:aBoolean |
1482 |
sizeFixed := aBoolean |
|
1483 |
||
1484 |
"Created: 9.2.1996 / 01:12:40 / cg" |
|
1485 |
! |
|
1486 |
||
202 | 1487 |
superMenu |
1488 |
"ret the menu I am contained in |
|
1489 |
- need this to hide main menus when a submenu performed its action" |
|
1490 |
||
1491 |
^ superMenu |
|
1492 |
! |
|
1493 |
||
1494 |
superMenu:aMenu |
|
1495 |
"set the menu I am contained in |
|
1496 |
- need this to hide main menus when a submenu performed its action" |
|
1497 |
||
1498 |
superMenu := aMenu |
|
4195
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1499 |
! |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1500 |
|
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1501 |
validateSelection:index |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1502 |
|sel line| |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1503 |
|
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1504 |
sel := index. |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1505 |
sel notNil ifTrue:[ |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1506 |
line := self listAt:index. |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1507 |
(self isGraphicItem:line) ifTrue:[ |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1508 |
" |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1509 |
not really selectable, but a separating line |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1510 |
" |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1511 |
sel := nil |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1512 |
] |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1513 |
]. |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1514 |
^ sel |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1515 |
|
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1516 |
"Created: / 29-11-2010 / 18:51:24 / cg" |
136 | 1517 |
! ! |
1518 |
||
1519 |
!MenuView methodsFor:'accessing-submenus'! |
|
1520 |
||
0 | 1521 |
subMenuAt:indexOrName |
1522 |
"return a submenu, or nil" |
|
1523 |
||
3 | 1524 |
|i| |
1525 |
||
0 | 1526 |
subMenus isNil ifTrue:[^ nil]. |
3 | 1527 |
i := self indexOf:indexOrName. |
1528 |
i == 0 ifTrue:[^ nil]. |
|
1529 |
^ subMenus at:i |
|
0 | 1530 |
! |
1531 |
||
1532 |
subMenuAt:indexOrName put:aPopUpMenu |
|
1533 |
"define a submenu" |
|
1534 |
||
59 | 1535 |
|i newSubMenus| |
3 | 1536 |
|
1537 |
i := self indexOf:indexOrName. |
|
2920 | 1538 |
i == 0 ifTrue:[ |
1539 |
'MenuView [warning]: no submenu with for index: ' infoPrint. indexOrName infoPrintCR. |
|
1540 |
^ nil |
|
1541 |
]. |
|
497 | 1542 |
|
59 | 1543 |
subMenus size < i ifTrue:[ |
2399
550e5ab64b82
care for nil arg in #subMenuAt:put:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
1544 |
newSubMenus := Array new:(list size max:i). |
550e5ab64b82
care for nil arg in #subMenuAt:put:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
1545 |
subMenus notNil ifTrue:[ |
550e5ab64b82
care for nil arg in #subMenuAt:put:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
1546 |
newSubMenus replaceFrom:1 with:subMenus. |
550e5ab64b82
care for nil arg in #subMenuAt:put:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
1547 |
]. |
550e5ab64b82
care for nil arg in #subMenuAt:put:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
1548 |
subMenus := newSubMenus. |
550e5ab64b82
care for nil arg in #subMenuAt:put:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
1549 |
shown ifTrue:[ |
550e5ab64b82
care for nil arg in #subMenuAt:put:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
1550 |
self resize |
550e5ab64b82
care for nil arg in #subMenuAt:put:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
1551 |
] ifFalse:[ |
550e5ab64b82
care for nil arg in #subMenuAt:put:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
1552 |
needResize := true |
550e5ab64b82
care for nil arg in #subMenuAt:put:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
1553 |
] |
0 | 1554 |
]. |
2683 | 1555 |
|
497 | 1556 |
subMenus at:i put:aPopUpMenu. |
5048 | 1557 |
(aPopUpMenu notNil and:[aPopUpMenu isBlock not]) ifTrue:[ |
5638 | 1558 |
aPopUpMenu device:device. |
5048 | 1559 |
(receiver notNil and:[aPopUpMenu receiver isNil]) ifTrue:[ |
1560 |
aPopUpMenu receiver:receiver |
|
1561 |
] |
|
497 | 1562 |
]. |
1563 |
||
956 | 1564 |
"Modified: 17.1.1997 / 01:03:55 / cg" |
202 | 1565 |
! |
1566 |
||
1567 |
subMenuShown |
|
1568 |
"return the currently visible submenu - or nil if there is none" |
|
1569 |
||
1570 |
^ subMenuShown |
|
1571 |
! ! |
|
1572 |
||
1573 |
!MenuView methodsFor:'disabled scrolling'! |
|
1574 |
||
1575 |
makeSelectionVisible |
|
1576 |
^ self |
|
1577 |
! ! |
|
1578 |
||
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1579 |
!MenuView methodsFor:'drawing'! |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1580 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1581 |
drawAccelerator:aSymbolicKey inVisibleLine:visLineNr with:fg and:bg |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1582 |
"draw the accelerator at the right." |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1583 |
|
462
d66445011d3e
if there are both a short-key AND a submenu, indent differently
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
1584 |
|s x l isSubMenuEntry| |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1585 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1586 |
"/ this is somewhat complicated: we have the symbolic key at hand, |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1587 |
"/ but want to show the untranslated (inverse keyBoardMapped) key & modifier |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1588 |
"/ |
5638 | 1589 |
s := device shortKeyStringFor:aSymbolicKey. |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1590 |
s isNil ifTrue:[^ self]. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1591 |
|
462
d66445011d3e
if there are both a short-key AND a submenu, indent differently
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
1592 |
l := self visibleLineToAbsoluteLine:visLineNr. |
2572
9b09dd9d9dae
dont forget to draw accelerator when disabled
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
1593 |
|
9b09dd9d9dae
dont forget to draw accelerator when disabled
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
1594 |
disabledEtchedFgColor notNil ifTrue:[ |
9b09dd9d9dae
dont forget to draw accelerator when disabled
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
1595 |
(self isInSelection:l) ifFalse:[ |
2575
a0381bf78464
oops - redraw bug with etched color fixed
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
1596 |
(self isEnabled:l) ifFalse:[ |
a0381bf78464
oops - redraw bug with etched color fixed
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
1597 |
s := s asText emphasisAllAdd:(#etchColor -> disabledEtchedFgColor) |
a0381bf78464
oops - redraw bug with etched color fixed
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
1598 |
] |
2572
9b09dd9d9dae
dont forget to draw accelerator when disabled
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
1599 |
] |
9b09dd9d9dae
dont forget to draw accelerator when disabled
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
1600 |
]. |
462
d66445011d3e
if there are both a short-key AND a submenu, indent differently
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
1601 |
isSubMenuEntry := (subMenus notNil and:[(subMenus at:l) notNil]). |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1602 |
|
462
d66445011d3e
if there are both a short-key AND a submenu, indent differently
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
1603 |
isSubMenuEntry ifFalse:[ |
2572
9b09dd9d9dae
dont forget to draw accelerator when disabled
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
1604 |
"/ this aligns them along their left |
9b09dd9d9dae
dont forget to draw accelerator when disabled
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
1605 |
x := width - textStartLeft - self shortKeyInset. |
462
d66445011d3e
if there are both a short-key AND a submenu, indent differently
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
1606 |
] ifTrue:[ |
2572
9b09dd9d9dae
dont forget to draw accelerator when disabled
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
1607 |
"/ this aligns them at the right |
4900 | 1608 |
x := width - leftMargin - (gc font widthOf:s). |
2572
9b09dd9d9dae
dont forget to draw accelerator when disabled
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
1609 |
x := x - 16 "/ should query for the arrow size here ... |
461
45282807f7fa
handle shortKey & submenu-arrow in one line; allow turning of of accelerator display
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
1610 |
]. |
45282807f7fa
handle shortKey & submenu-arrow in one line; allow turning of of accelerator display
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
1611 |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1612 |
hilightStyle == #openwin ifTrue:[ |
2572
9b09dd9d9dae
dont forget to draw accelerator when disabled
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
1613 |
x := x - 2 "/ inset of rounded rectangle |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1614 |
]. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1615 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1616 |
self drawLine:s fromX:x inVisible:visLineNr with:fg and:bg |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1617 |
|
3323
ce80842d41e0
shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents:
3294
diff
changeset
|
1618 |
"Created: / 28-02-1996 / 18:48:05 / cg" |
ce80842d41e0
shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents:
3294
diff
changeset
|
1619 |
"Modified: / 08-08-2006 / 15:47:11 / cg" |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1620 |
! |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1621 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1622 |
drawCheckLine:line inVisibleLine:visLineNr with:fg and:bg |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1623 |
"draw an on/off-mark (or the space for it). |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1624 |
Supported checkmark types: |
1532 | 1625 |
\c simple mark; space if off |
1626 |
\b box mark |
|
1627 |
\t thumbsUp/thumbsDown mark |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1628 |
" |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1629 |
|
1649
e0deb9ce1e08
fixed checkItem (\c) detection
Claus Gittinger <cg@exept.de>
parents:
1640
diff
changeset
|
1630 |
|w h y x l check xR yB form markIndex i2 markType found| |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1631 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1632 |
l := self visibleLineToListLine:visLineNr. |
1532 | 1633 |
onOffFlags isNil ifTrue:[^ false]. "/ not a check-item line |
1634 |
check := onOffFlags at:l ifAbsent:nil. |
|
1635 |
check isNil ifTrue:[^ false]. "/ not a check-item line |
|
1636 |
check := check value. |
|
1637 |
||
1638 |
markIndex := 1. |
|
1649
e0deb9ce1e08
fixed checkItem (\c) detection
Claus Gittinger <cg@exept.de>
parents:
1640
diff
changeset
|
1639 |
found := false. |
e0deb9ce1e08
fixed checkItem (\c) detection
Claus Gittinger <cg@exept.de>
parents:
1640
diff
changeset
|
1640 |
[markIndex ~~ 0 and:[found not]] whileTrue:[ |
1532 | 1641 |
markIndex := line indexOf:$\ startingAt:markIndex. |
1649
e0deb9ce1e08
fixed checkItem (\c) detection
Claus Gittinger <cg@exept.de>
parents:
1640
diff
changeset
|
1642 |
markIndex ~~ 0 ifTrue:[ |
e0deb9ce1e08
fixed checkItem (\c) detection
Claus Gittinger <cg@exept.de>
parents:
1640
diff
changeset
|
1643 |
i2 := markIndex + 1. |
e0deb9ce1e08
fixed checkItem (\c) detection
Claus Gittinger <cg@exept.de>
parents:
1640
diff
changeset
|
1644 |
found := 'cbt' includes:(line at:i2). |
e0deb9ce1e08
fixed checkItem (\c) detection
Claus Gittinger <cg@exept.de>
parents:
1640
diff
changeset
|
1645 |
found ifFalse:[ |
e0deb9ce1e08
fixed checkItem (\c) detection
Claus Gittinger <cg@exept.de>
parents:
1640
diff
changeset
|
1646 |
markIndex := i2 + 1. |
e0deb9ce1e08
fixed checkItem (\c) detection
Claus Gittinger <cg@exept.de>
parents:
1640
diff
changeset
|
1647 |
]. |
e0deb9ce1e08
fixed checkItem (\c) detection
Claus Gittinger <cg@exept.de>
parents:
1640
diff
changeset
|
1648 |
]. |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1649 |
]. |
1649
e0deb9ce1e08
fixed checkItem (\c) detection
Claus Gittinger <cg@exept.de>
parents:
1640
diff
changeset
|
1650 |
markIndex == 0ifTrue:[ |
e0deb9ce1e08
fixed checkItem (\c) detection
Claus Gittinger <cg@exept.de>
parents:
1640
diff
changeset
|
1651 |
^ super drawVisibleLine:visLineNr from:1 to:line size with:fg and:bg. |
e0deb9ce1e08
fixed checkItem (\c) detection
Claus Gittinger <cg@exept.de>
parents:
1640
diff
changeset
|
1652 |
]. |
e0deb9ce1e08
fixed checkItem (\c) detection
Claus Gittinger <cg@exept.de>
parents:
1640
diff
changeset
|
1653 |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1654 |
markType := line at:i2. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1655 |
|
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2399
diff
changeset
|
1656 |
x := (self xOfCol:markIndex inVisibleLine:visLineNr) - viewOrigin x. |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1657 |
y := (self yOfVisibleLine:visLineNr) - (lineSpacing//2). |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1658 |
|
6055 | 1659 |
gc paint:bg. |
1660 |
gc fillRectangleX:margin y:y width:(width-(margin*2)) height:fontHeight. |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1661 |
markIndex ~~ 1 ifTrue:[ |
1532 | 1662 |
super drawVisibleLine:visLineNr from:1 to:(markIndex-1) with:fg and:bg. |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1663 |
]. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1664 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1665 |
(markType == $c) ifTrue:[ |
4900 | 1666 |
w := gc font widthOf:'V'. |
1532 | 1667 |
check ifTrue:[ |
1668 |
form := checkOnImage. |
|
1669 |
] ifFalse:[ |
|
1670 |
form := checkOffImage. |
|
1671 |
] |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1672 |
] ifFalse:[ |
1532 | 1673 |
(markType == $b) ifTrue:[ |
4900 | 1674 |
w := gc font maxWidth. "/ font widthOf:' '. |
1532 | 1675 |
] ifFalse:[ |
1676 |
(markType == $t) ifTrue:[ |
|
1677 |
check ifTrue:[form := Cursor thumbsUp sourceForm] |
|
1678 |
ifFalse:[form := Cursor thumbsDown sourceForm] |
|
1679 |
] |
|
1680 |
] |
|
1681 |
]. |
|
1682 |
||
1683 |
form notNil ifTrue:[ |
|
1684 |
w := form width. |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1685 |
]. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1686 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1687 |
self drawLine:(line copyFrom:markIndex+2) fromX:x+w inVisible:visLineNr with:fg and:bg. |
6055 | 1688 |
gc paint:(check ifTrue:[checkColor == bg ifTrue:[fg] ifFalse:[checkColor]] ifFalse:[fg]). |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1689 |
|
4900 | 1690 |
h := gc font ascent. |
6055 | 1691 |
y := y + ((gc font height - h) // 2). |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1692 |
yB := y + h - 1. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1693 |
|
1532 | 1694 |
form notNil ifTrue:[ |
6055 | 1695 |
gc displayForm:form x:x y:y |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1696 |
] ifFalse:[ |
1532 | 1697 |
(markType == $c) ifTrue:[ |
1698 |
check ifTrue:[ |
|
1699 |
xR := x + (w // 3). |
|
6055 | 1700 |
gc displayLineFromX:x y:(y + (h // 2)) toX:xR y:yB. |
1701 |
gc displayLineFromX:xR y:yB toX:(x + w - 1) y:y |
|
1532 | 1702 |
] |
1703 |
] ifFalse:[ |
|
1704 |
(markType == $b) ifTrue:[ |
|
1705 |
check ifTrue:[ |
|
1706 |
xR := x + w - 2. |
|
6055 | 1707 |
gc displayLineFromX:x y:y toX:xR y:yB. |
1708 |
gc displayLineFromX:xR y:y toX:x y:yB. |
|
1532 | 1709 |
]. |
6055 | 1710 |
gc paint:fg. |
1711 |
gc displayRectangleX:x y:y width:h height:h. |
|
1532 | 1712 |
] |
1713 |
]. |
|
1714 |
]. |
|
1715 |
^ true |
|
1716 |
||
1717 |
"Modified: / 6.5.1997 / 18:04:38 / stefan" |
|
1649
e0deb9ce1e08
fixed checkItem (\c) detection
Claus Gittinger <cg@exept.de>
parents:
1640
diff
changeset
|
1718 |
"Modified: / 17.8.1998 / 10:25:01 / cg" |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1719 |
! |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1720 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1721 |
drawVisibleLine:visLineNr with:fg and:bg |
2113 | 1722 |
|lNr lineString xLatedLine isSpecial key| |
1723 |
||
1724 |
lNr := self visibleLineToListLine:visLineNr. |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1725 |
lineString := self visibleAt:visLineNr. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1726 |
|
2960 | 1727 |
isSpecial := lineString notNil and:[lineString asString string includes:$\]. |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1728 |
isSpecial ifFalse:[ |
1532 | 1729 |
" |
1730 |
a normal entry |
|
1731 |
" |
|
1732 |
super drawVisibleLine:visLineNr with:fg and:bg |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1733 |
] ifTrue:[ |
1532 | 1734 |
" |
1735 |
some speciality in this line; try checkMark |
|
1736 |
" |
|
1737 |
((self isCheckItem:lineString) |
|
1738 |
and:[self drawCheckLine:lineString inVisibleLine:visLineNr with:fg and:bg]) |
|
1739 |
ifFalse:[ |
|
6288 | 1740 |
xLatedLine := lineString copyReplaceString:'\\' withString:'\'. |
2113 | 1741 |
super drawLine:xLatedLine inVisible:visLineNr with:fg and:bg. |
1532 | 1742 |
]. |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1743 |
]. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1744 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1745 |
"/ |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1746 |
"/ is there a shortKey ? |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1747 |
"/ |
461
45282807f7fa
handle shortKey & submenu-arrow in one line; allow turning of of accelerator display
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
1748 |
((ShowAcceleratorKeys ~~ false) |
433
5e7847297ef8
allow turning off display of shortKeys (via style-sheet)
Claus Gittinger <cg@exept.de>
parents:
426
diff
changeset
|
1749 |
and:[shortKeys notNil |
2113 | 1750 |
and:[(key := shortKeys at:lNr ifAbsent:nil) notNil]]) ifTrue:[ |
1532 | 1751 |
self drawAccelerator:key inVisibleLine:visLineNr with:fg and:bg |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1752 |
] |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1753 |
|
6288 | 1754 |
"Modified: / 31-05-1999 / 12:35:48 / cg" |
1755 |
"Modified: / 27-02-2018 / 11:36:03 / stefan" |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1756 |
! |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1757 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1758 |
drawVisibleLineSelected:visLineNr with:fg and:bg |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1759 |
"redraw a single line as selected." |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1760 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1761 |
|listLine |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1762 |
y "{ Class: SmallInteger }" |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1763 |
y2 "{ Class: SmallInteger }" |
727 | 1764 |
r2 rI lI radius topLeftColor botRightColor | |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1765 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1766 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1767 |
hilightStyle ~~ #openwin ifTrue:[ |
6055 | 1768 |
^ super drawVisibleLineSelected:visLineNr with:fg and:bg. |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1769 |
]. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1770 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1771 |
" |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1772 |
openwin draws selections in a menu as (edged) rounded rectangles |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1773 |
" |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1774 |
listLine := self visibleLineToListLine:visLineNr. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1775 |
listLine notNil ifTrue:[ |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1776 |
|
6055 | 1777 |
self drawVisibleLine:visLineNr with:fg and:bg. |
1778 |
||
1779 |
y := (self yOfVisibleLine:visLineNr) - (lineSpacing//2). |
|
1780 |
y2 := y + fontHeight - 1. |
|
1781 |
r2 := fontHeight. |
|
1782 |
radius := r2 // 2. |
|
1783 |
rI := 0. "/ 2. |
|
1784 |
lI := 1. "/ 2. |
|
1785 |
||
1786 |
" |
|
1787 |
refill with normal bg, where arcs will be drawn below |
|
1788 |
" |
|
1789 |
gc paint:bgColor. |
|
1790 |
gc fillRectangleX:margin y:y width:radius height:fontHeight. |
|
1791 |
gc fillRectangleX:width-radius-margin y:y width:radius height:fontHeight. |
|
1792 |
" |
|
1793 |
fill the arcs |
|
1794 |
" |
|
1795 |
gc paint:hilightBgColor. |
|
1796 |
gc fillArcX:margin+lI y:y width:r2 height:r2+rI from:90 angle:180. |
|
1797 |
gc fillArcX:width-r2-rI-margin-1 y:y width:r2 height:r2+rI from:270 angle:180. |
|
1798 |
||
1799 |
" |
|
1800 |
a highlight-border around |
|
1801 |
" |
|
1802 |
hilightFrameColor notNil ifTrue:[ |
|
1803 |
gc paint:hilightFrameColor. |
|
1804 |
gc displayLineFromX:radius+2 y:y toX:width-radius-3 y:y. |
|
1805 |
gc displayLineFromX:radius+2 y:y2 toX:width-radius-3 y:y2. |
|
1806 |
||
1807 |
gc displayArcX:margin+lI y:y width:r2 height:r2+rI from:90 angle:180. |
|
1808 |
gc displayArcX:width-r2-rI-margin-1 y:y width:r2 height:r2+rI from:270 angle:180. |
|
1809 |
^ self |
|
1810 |
]. |
|
1811 |
||
1812 |
" |
|
1813 |
an edge around |
|
1814 |
" |
|
1815 |
(hilightLevel ~~ 0) ifTrue:[ |
|
1816 |
(hilightLevel < 0) ifTrue:[ |
|
1817 |
topLeftColor := shadowColor. |
|
1818 |
botRightColor := lightColor. |
|
1819 |
] ifFalse:[ |
|
1820 |
topLeftColor := lightColor. |
|
1821 |
botRightColor := shadowColor. |
|
1822 |
]. |
|
1823 |
||
1824 |
gc paint:topLeftColor. |
|
1825 |
gc displayLineFromX:radius+2 y:y toX:width-radius-3 y:y. |
|
1826 |
||
1827 |
gc displayArcX:margin+lI y:y width:r2 height:r2+rI-1 from:90 angle:125. |
|
1828 |
gc displayArcX:width-r2-rI-margin-1 y:y width:r2 height:r2+rI-1 from:270+125 angle:55. |
|
1829 |
||
1830 |
gc paint:botRightColor. |
|
1831 |
||
1832 |
gc displayLineFromX:radius+2 y:y2 toX:width-radius-3 y:y2. |
|
1833 |
gc displayArcX:margin+lI y:y width:r2 height:r2+rI-1 from:90+125 angle:55. |
|
1834 |
gc displayArcX:width-r2-rI-margin-1 y:y width:r2 height:r2+rI-1 from:270 angle:125. |
|
1835 |
]. |
|
1836 |
^ self |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1837 |
]. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1838 |
^ super drawVisibleLine:visLineNr with:fg and:bg |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1839 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1840 |
"Created: 28.2.1996 / 18:41:17 / cg" |
1346
98f855d33d66
fixed arc-edges for openWin style
Claus Gittinger <cg@exept.de>
parents:
1285
diff
changeset
|
1841 |
"Modified: 14.10.1997 / 00:05:43 / cg" |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1842 |
! ! |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1843 |
|
202 | 1844 |
!MenuView methodsFor:'event handling'! |
1845 |
||
1846 |
buttonMotion:state x:x y:y |
|
3911
2e2c5429a2f9
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3903
diff
changeset
|
1847 |
(self sensor hasButtonMotionEventFor:self) ifFalse:[ |
4195
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1848 |
self setSelectionForX:x y:y now:(UserPreferences current delayedMenuShowAndHide) not. |
202 | 1849 |
] |
4195
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1850 |
|
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1851 |
"Modified: / 29-11-2010 / 19:48:55 / cg" |
202 | 1852 |
! |
1853 |
||
1854 |
buttonPress:button x:x y:y |
|
4195
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1855 |
self setSelectionForX:x y:y now:true. |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1856 |
|
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1857 |
"Modified: / 29-11-2010 / 19:38:36 / cg" |
202 | 1858 |
! |
1859 |
||
1860 |
buttonRelease:button x:x y:y |
|
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
463
diff
changeset
|
1861 |
|hide| |
202 | 1862 |
|
4195
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1863 |
self cancelDelayedSubmenuHideOrShowAction. |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1864 |
|
202 | 1865 |
subMenuShown notNil ifTrue:[ |
1864 | 1866 |
^ self |
202 | 1867 |
]. |
1868 |
||
1864 | 1869 |
(x >= 0 |
1870 |
and:[x < width |
|
1871 |
and:[y >= 0 |
|
1872 |
and:[y < height]]]) ifTrue:[ |
|
1873 |
superMenu notNil ifTrue:[ |
|
1874 |
superMenu submenuTriggered. |
|
1875 |
||
2818 | 1876 |
shown ifFalse:[ |
1864 | 1877 |
superView notNil ifTrue:[ |
1878 |
superView shown ifTrue:[ |
|
3903 | 1879 |
superView isPopUpView ifTrue:[ |
1880 |
superView hide |
|
1881 |
]. |
|
1864 | 1882 |
] |
1883 |
] |
|
1884 |
] |
|
1885 |
]. |
|
1886 |
self performSelectedAction. |
|
202 | 1887 |
]. |
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
463
diff
changeset
|
1888 |
|
497 | 1889 |
"/ |
1890 |
"/ not within mySelf |
|
1891 |
"/ |
|
1892 |
||
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
463
diff
changeset
|
1893 |
superMenu notNil ifTrue:[ |
1864 | 1894 |
hide := hideOnRelease. |
1895 |
hide ifFalse:[ |
|
3153
499fc16c974a
refactored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
2975
diff
changeset
|
1896 |
superMenu shown ifFalse:[ |
1864 | 1897 |
superView notNil ifTrue:[ |
1898 |
superView shown ifTrue:[ |
|
1899 |
hide := true |
|
1900 |
] |
|
1901 |
] |
|
1902 |
]. |
|
1903 |
]. |
|
1904 |
hide ifTrue:[ |
|
1905 |
superView hide |
|
1906 |
]. |
|
202 | 1907 |
]. |
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
463
diff
changeset
|
1908 |
|
435 | 1909 |
"/ (superView notNil and:[superView isPopUpView]) ifTrue:[ |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1910 |
"/ 'refetch focus' printNL. |
435 | 1911 |
"/ superView regainControl. |
1912 |
"/ superView getKeyboardFocus. |
|
1913 |
"/ superView hide |
|
1914 |
"/ ] |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
1915 |
|
4195
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1916 |
"Modified: / 29-11-2010 / 19:39:42 / cg" |
202 | 1917 |
! |
1918 |
||
1919 |
keyPress:aKey x:x y:y |
|
491 | 1920 |
|
4491 | 1921 |
<resource: #keyboard (#Return #MenuSelect #Escape #CursorRight #CursorLeft)> |
491 | 1922 |
|
202 | 1923 |
|m| |
1924 |
||
4195
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1925 |
self cancelDelayedSubmenuHideOrShowAction. |
202 | 1926 |
subMenuShown notNil ifTrue:[ |
1860 | 1927 |
subMenuShown menuView keyPress:aKey x:0 y:0. |
1928 |
^ self |
|
202 | 1929 |
]. |
1930 |
||
1931 |
" |
|
1932 |
Return, space or the (virtual) MenuSelect |
|
1933 |
key trigger a selected entry. |
|
1934 |
" |
|
1935 |
(aKey == #Return |
|
1936 |
or:[aKey == #MenuSelect |
|
1937 |
or:[aKey == Character space]]) ifTrue:[ |
|
1860 | 1938 |
selection notNil ifTrue:[ |
1939 |
(subMenus notNil and:[(m := subMenus at:selection) notNil]) ifTrue:[ |
|
1940 |
self showSubmenu:selection. |
|
4546 | 1941 |
m isBlock ifFalse:[m hideOnLeave:false]. |
1860 | 1942 |
] ifFalse:[ |
1943 |
subMenuShown := nil. |
|
1944 |
self buttonRelease:2 x:0 y:0. |
|
1945 |
] |
|
1946 |
]. |
|
1947 |
^ self |
|
202 | 1948 |
]. |
317
f23de8b78f5e
Escape closes pullDownMenus & PopUpLists
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
1949 |
aKey == #Escape ifTrue:[ |
1860 | 1950 |
masterView notNil ifTrue:[ |
1951 |
masterView hideSubmenu. |
|
1952 |
masterView hide. |
|
3971 | 1953 |
^ self. |
1860 | 1954 |
]. |
1955 |
superView hide. |
|
1956 |
^ self |
|
317
f23de8b78f5e
Escape closes pullDownMenus & PopUpLists
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
1957 |
]. |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1958 |
aKey == #CursorRight ifTrue:[ |
1860 | 1959 |
selection notNil ifTrue:[ |
1960 |
(subMenus notNil and:[(m := subMenus at:selection) notNil]) ifTrue:[ |
|
1961 |
self showSubmenu:selection. |
|
4546 | 1962 |
m isBlock ifFalse:[m hideOnLeave:false]. |
1860 | 1963 |
^ self |
1964 |
] |
|
1965 |
]. |
|
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1966 |
]. |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1967 |
aKey == #CursorLeft ifTrue:[ |
1860 | 1968 |
masterView notNil ifTrue:[ |
1969 |
masterView hideSubmenu. |
|
1970 |
masterView regainControl. |
|
1971 |
]. |
|
1972 |
superView hide. |
|
1973 |
^ self |
|
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1974 |
]. |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1975 |
|
202 | 1976 |
super keyPress:aKey x:x y:y |
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
463
diff
changeset
|
1977 |
|
4195
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
1978 |
"Modified: / 29-11-2010 / 19:39:31 / cg" |
202 | 1979 |
! |
1980 |
||
1981 |
pointerLeave:state |
|
1982 |
subMenuShown notNil ifTrue:[ |
|
1860 | 1983 |
^ self |
202 | 1984 |
]. |
1985 |
"/ self setSelectionForX:-1 y:-1. "force deselect" |
|
1860 | 1986 |
self setSelection:nil |
202 | 1987 |
"/ superMenu notNil ifTrue:[ |
1988 |
"/ superMenu regainControl. |
|
1989 |
"/ ] |
|
683 | 1990 |
|
1991 |
"Modified: 25.5.1996 / 12:27:18 / cg" |
|
202 | 1992 |
! ! |
1993 |
||
2751 | 1994 |
!MenuView methodsFor:'initialization & release'! |
202 | 1995 |
|
1996 |
create |
|
1997 |
super create. |
|
1998 |
subMenuShown := nil. |
|
1999 |
self resizeIfChanged |
|
2000 |
! |
|
2001 |
||
2002 |
destroy |
|
2003 |
" |
|
2004 |
have to destroy the submenus manually here, |
|
2005 |
since they are no real subviews of myself |
|
2006 |
" |
|
2007 |
subMenus notNil ifTrue:[ |
|
2008 |
subMenus do:[:m | |
|
2009 |
m notNil ifTrue:[ |
|
2010 |
m destroy |
|
2011 |
] |
|
2012 |
]. |
|
2013 |
subMenus := nil |
|
2014 |
]. |
|
2015 |
super destroy. |
|
2016 |
! |
|
2017 |
||
939 | 2018 |
fetchDeviceResources |
2019 |
"fetch device colors, to avoid reallocation at redraw time" |
|
2020 |
||
2021 |
super fetchDeviceResources. |
|
2022 |
||
5638 | 2023 |
checkColor notNil ifTrue:[checkColor := checkColor onDevice:device]. |
2024 |
disabledFgColor notNil ifTrue:[disabledFgColor := disabledFgColor onDevice:device]. |
|
939 | 2025 |
|
3464 | 2026 |
hilightFgColorNoFocus := hilightFgColor. |
2027 |
hilightBgColorNoFocus := hilightBgColor. |
|
2028 |
||
939 | 2029 |
"Created: 14.1.1997 / 00:08:55 / cg" |
2030 |
! |
|
2031 |
||
202 | 2032 |
initEvents |
2033 |
super initEvents. |
|
2034 |
self enableLeaveEvents. |
|
3911
2e2c5429a2f9
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3903
diff
changeset
|
2035 |
self enableMotionEvents. |
495
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
2036 |
|
202 | 2037 |
windowGroup notNil ifTrue:[ |
3911
2e2c5429a2f9
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3903
diff
changeset
|
2038 |
windowGroup sensor compressMotionEvents:true |
202 | 2039 |
] |
495
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
2040 |
|
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
2041 |
"Modified: 7.3.1996 / 14:18:09 / cg" |
202 | 2042 |
! |
2043 |
||
2044 |
initStyle |
|
967 | 2045 |
"setup viewStyle specifics" |
2046 |
||
4900 | 2047 |
|style graphicsDevice| |
202 | 2048 |
|
2049 |
super initStyle. |
|
2050 |
||
5638 | 2051 |
graphicsDevice := device. |
202 | 2052 |
DefaultCheckColor notNil ifTrue:[ |
1989 | 2053 |
checkColor := DefaultCheckColor |
202 | 2054 |
] ifFalse:[ |
1989 | 2055 |
checkColor := fgColor. |
202 | 2056 |
]. |
939 | 2057 |
disabledFgColor := DefaultDisabledForegroundColor. |
2498 | 2058 |
disabledEtchedFgColor := DefaultDisabledEtchedForegroundColor. |
202 | 2059 |
|
2060 |
DefaultForegroundColor notNil ifTrue:[ |
|
4900 | 2061 |
fgColor := DefaultForegroundColor onDevice:graphicsDevice |
202 | 2062 |
]. |
2063 |
DefaultBackgroundColor notNil ifTrue:[ |
|
4900 | 2064 |
bgColor := DefaultBackgroundColor onDevice:graphicsDevice |
202 | 2065 |
]. |
2066 |
||
2067 |
DefaultShadowColor notNil ifTrue:[ |
|
4900 | 2068 |
shadowColor := DefaultShadowColor onDevice:graphicsDevice |
202 | 2069 |
]. |
2070 |
DefaultLightColor notNil ifTrue:[ |
|
4900 | 2071 |
lightColor := DefaultLightColor onDevice:graphicsDevice |
202 | 2072 |
]. |
2073 |
||
2074 |
DefaultHilightLevel notNil ifTrue:[ |
|
1989 | 2075 |
hilightLevel := DefaultHilightLevel |
202 | 2076 |
] ifFalse:[ |
1989 | 2077 |
hilightLevel := 0. |
202 | 2078 |
]. |
5197 | 2079 |
|
2080 |
"/ a temporary kludge to prevent drawing the white line below the selection. |
|
2081 |
hilightStyle == #macosx ifTrue:[ |
|
2082 |
hilightStyle := nil |
|
2083 |
]. |
|
512 | 2084 |
"/ hilightStyle := DefaultHilightStyle. |
202 | 2085 |
|
2086 |
hilightFrameColor := DefaultHilightFrameColor. |
|
2087 |
||
2088 |
styleSheet is3D ifTrue:[ |
|
1989 | 2089 |
"some 3D style menu - set hilight defaults to same" |
2090 |
||
2091 |
DefaultHilightForegroundColor notNil ifTrue:[ |
|
4900 | 2092 |
hilightFgColor := DefaultHilightForegroundColor onDevice:graphicsDevice |
1989 | 2093 |
] ifFalse:[ |
2094 |
hilightFgColor := fgColor. |
|
2095 |
]. |
|
2096 |
DefaultHilightBackgroundColor notNil ifTrue:[ |
|
4900 | 2097 |
hilightBgColor := DefaultHilightBackgroundColor onDevice:graphicsDevice |
1989 | 2098 |
] ifFalse:[ |
2099 |
hilightBgColor := bgColor. |
|
2100 |
]. |
|
2101 |
DefaultLineLevel notNil ifTrue:[ |
|
2102 |
lineLevel := DefaultLineLevel |
|
2103 |
] ifFalse:[ |
|
2104 |
lineLevel := -1. |
|
2105 |
] |
|
202 | 2106 |
] ifFalse:[ |
1989 | 2107 |
"some 2D style menu - set hilight defaults to inverse" |
2108 |
DefaultHilightForegroundColor notNil ifTrue:[ |
|
4900 | 2109 |
hilightFgColor := DefaultHilightForegroundColor onDevice:graphicsDevice |
1989 | 2110 |
] ifFalse:[ |
2111 |
hilightFgColor := bgColor. |
|
2112 |
]. |
|
2113 |
DefaultHilightBackgroundColor notNil ifTrue:[ |
|
4900 | 2114 |
hilightBgColor := DefaultHilightBackgroundColor onDevice:graphicsDevice |
1989 | 2115 |
] ifFalse:[ |
2116 |
hilightBgColor := fgColor. |
|
2117 |
]. |
|
2118 |
DefaultLineLevel notNil ifTrue:[ |
|
2119 |
lineLevel := DefaultLineLevel |
|
2120 |
] ifFalse:[ |
|
2121 |
lineLevel := 0. |
|
2122 |
] |
|
202 | 2123 |
]. |
2124 |
||
2125 |
DefaultLineInset notNil ifTrue:[ |
|
1989 | 2126 |
lineInset := DefaultLineInset |
202 | 2127 |
] ifFalse:[ |
4900 | 2128 |
lineInset := (graphicsDevice horizontalPixelPerMillimeter * 0.8) rounded. |
202 | 2129 |
]. |
2130 |
||
2131 |
" |
|
2132 |
the following has to be changed to |
|
2133 |
use the styleSheet too |
|
2134 |
" |
|
2135 |
style := styleSheet name. |
|
2136 |
||
2137 |
(style == #iris) ifTrue:[ |
|
4900 | 2138 |
graphicsDevice hasGrayscales ifTrue:[ |
1989 | 2139 |
lineSpacing := 3 |
2140 |
]. |
|
202 | 2141 |
]. |
2142 |
(style == #motif) ifTrue:[ |
|
1989 | 2143 |
lineSpacing := (2 * hilightLevel) |
202 | 2144 |
]. |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2145 |
"/ stupid - these are clobbered somewhere; see initialize and recreate |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2146 |
"/ hilightStyle == #openwin ifTrue:[ |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2147 |
"/ "add some space for rounded-hilight area" |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2148 |
"/ self leftMargin:(font height // 2 + 2 "inset of rounded rect") "10". |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2149 |
"/ ] ifFalse:[ |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2150 |
"/ (hilightLevel ~~ 0) ifTrue:[ |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2151 |
"/ self leftMargin:hilightLevel abs + self margin abs + 1. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2152 |
"/ lineSpacing := lineSpacing max:(hilightLevel abs * 2). |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2153 |
"/ ] |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2154 |
"/ ]. |
202 | 2155 |
(style == #st80) ifTrue:[ |
1989 | 2156 |
level := 0. |
202 | 2157 |
]. |
2158 |
DefaultViewBackground notNil ifTrue:[ |
|
4900 | 2159 |
viewBackground := DefaultViewBackground onDevice:graphicsDevice |
202 | 2160 |
]. |
2161 |
||
4323 | 2162 |
"Modified: / 22-01-1997 / 11:57:23 / cg" |
2163 |
"Modified (comment): / 05-10-2011 / 15:50:59 / az" |
|
202 | 2164 |
! |
2165 |
||
2166 |
initialize |
|
2167 |
|style| |
|
2168 |
||
2169 |
super initialize. |
|
2170 |
hideOnRelease := false. |
|
2171 |
autoScroll := false. |
|
334 | 2172 |
sizeFixed := false. |
202 | 2173 |
|
2174 |
(((style := styleSheet name) ~~ #normal) |
|
2175 |
and:[style ~~ #mswindows]) ifTrue:[ |
|
4027 | 2176 |
self borderWidth: 1. |
4024
7a30c88fc34d
no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents:
3980
diff
changeset
|
2177 |
(style ~~ #st80) ifTrue:[self level:1] |
202 | 2178 |
]. |
2179 |
||
2180 |
"stupid - have to redo this ..." |
|
2181 |
hilightStyle == #openwin ifTrue:[ |
|
4024
7a30c88fc34d
no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents:
3980
diff
changeset
|
2182 |
"add some space for rounded-hilight area" |
4900 | 2183 |
self leftMargin:(gc font height " // 2" + 2 "inset of rounded rect") "10". |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2184 |
] ifFalse:[ |
4024
7a30c88fc34d
no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents:
3980
diff
changeset
|
2185 |
(hilightLevel ~~ 0) ifTrue:[ |
7a30c88fc34d
no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents:
3980
diff
changeset
|
2186 |
self leftMargin:hilightLevel abs + margin abs + 1. |
7a30c88fc34d
no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents:
3980
diff
changeset
|
2187 |
lineSpacing := lineSpacing max:(hilightLevel abs * 2). |
4574 | 2188 |
]. |
2189 |
lineSpacing := lineSpacing max:2. |
|
202 | 2190 |
]. |
334 | 2191 |
|
751 | 2192 |
"Modified: 5.6.1996 / 14:36:56 / cg" |
202 | 2193 |
! |
2194 |
||
2195 |
recreate |
|
2258 | 2196 |
"when recreated after a snapin or a migration, resize myself, in case |
202 | 2197 |
font dimensions have changed on the display" |
2198 |
||
2199 |
super recreate. |
|
2200 |
hilightStyle == #openwin ifTrue:[ |
|
2258 | 2201 |
"add some space for rounded-hilight area" |
4900 | 2202 |
self leftMargin:(gc font height // 2 + 2 "inset of rounded rect") "10". |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2203 |
] ifFalse:[ |
2258 | 2204 |
(hilightLevel ~~ 0) ifTrue:[ |
2205 |
self leftMargin:hilightLevel abs + self margin abs + 1. |
|
2206 |
lineSpacing := lineSpacing max:(hilightLevel abs * 2). |
|
2207 |
] |
|
202 | 2208 |
]. |
2209 |
self resize |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2210 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2211 |
"Modified: 28.2.1996 / 19:39:37 / cg" |
202 | 2212 |
! |
2213 |
||
2214 |
reinitialize |
|
2215 |
"this is called right after snapIn; |
|
2216 |
a kind of kludge - reset cursor (in case the save was |
|
2217 |
done with myself being shown and active)" |
|
2218 |
||
2219 |
super reinitialize. |
|
2220 |
selection := nil. "self selection:nil." |
|
2221 |
self showPassive |
|
0 | 2222 |
! ! |
2223 |
||
2224 |
!MenuView methodsFor:'private'! |
|
2225 |
||
202 | 2226 |
isCheckItem:line |
1919
7752e8980de5
allow for \\ to allow the single \ to be displayed (DOS filenames)
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
2227 |
"return true if \c, \b or \t is contained in the line arg. |
7752e8980de5
allow for \\ to allow the single \ to be displayed (DOS filenames)
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
2228 |
Care for '\\'." |
7752e8980de5
allow for \\ to allow the single \ to be displayed (DOS filenames)
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
2229 |
|
7752e8980de5
allow for \\ to allow the single \ to be displayed (DOS filenames)
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
2230 |
|idx| |
7752e8980de5
allow for \\ to allow the single \ to be displayed (DOS filenames)
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
2231 |
|
3294
a3266e46b191
handle nonString items correctly
Stefan Vogel <sv@exept.de>
parents:
3153
diff
changeset
|
2232 |
line isString ifTrue:[ |
1919
7752e8980de5
allow for \\ to allow the single \ to be displayed (DOS filenames)
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
2233 |
idx := 1. |
7752e8980de5
allow for \\ to allow the single \ to be displayed (DOS filenames)
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
2234 |
[idx ~~ 0] whileTrue:[ |
7752e8980de5
allow for \\ to allow the single \ to be displayed (DOS filenames)
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
2235 |
idx := line indexOf:$\ startingAt:idx. |
7752e8980de5
allow for \\ to allow the single \ to be displayed (DOS filenames)
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
2236 |
(idx ~~ 0) ifTrue:[ |
7752e8980de5
allow for \\ to allow the single \ to be displayed (DOS filenames)
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
2237 |
idx < line size ifTrue:[ |
7752e8980de5
allow for \\ to allow the single \ to be displayed (DOS filenames)
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
2238 |
('cbt' includes:(line at:(idx+1))) ifTrue:[ |
7752e8980de5
allow for \\ to allow the single \ to be displayed (DOS filenames)
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
2239 |
^ true |
7752e8980de5
allow for \\ to allow the single \ to be displayed (DOS filenames)
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
2240 |
]. |
7752e8980de5
allow for \\ to allow the single \ to be displayed (DOS filenames)
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
2241 |
]. |
7752e8980de5
allow for \\ to allow the single \ to be displayed (DOS filenames)
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
2242 |
idx := idx + 2. |
7752e8980de5
allow for \\ to allow the single \ to be displayed (DOS filenames)
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
2243 |
]. |
7752e8980de5
allow for \\ to allow the single \ to be displayed (DOS filenames)
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
2244 |
]. |
202 | 2245 |
]. |
2246 |
^ false. |
|
405
39b9b0f04ccc
allow checkmarks at any position
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
2247 |
|
1919
7752e8980de5
allow for \\ to allow the single \ to be displayed (DOS filenames)
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
2248 |
"Modified: / 31.5.1999 / 12:59:07 / cg" |
119 | 2249 |
! |
2250 |
||
202 | 2251 |
isGraphicItem:line |
5693 | 2252 |
"redefine in subclasses to return false, |
2253 |
if no graphicLines are wanted (codeCompletionView does this)" |
|
2254 |
||
202 | 2255 |
(line = '-') ifTrue:[^ true]. |
2256 |
(line = '=') ifTrue:[^ true]. |
|
2257 |
(line = '') ifTrue:[^ true]. |
|
2258 |
^ false. |
|
127 | 2259 |
! |
119 | 2260 |
|
2973 | 2261 |
labelWithoutDoubleAmpersands:label |
3294
a3266e46b191
handle nonString items correctly
Stefan Vogel <sv@exept.de>
parents:
3153
diff
changeset
|
2262 |
(label isString and:[label includesString:'&&']) ifTrue:[ |
a3266e46b191
handle nonString items correctly
Stefan Vogel <sv@exept.de>
parents:
3153
diff
changeset
|
2263 |
^ label copyReplaceString:'&&' withString:'&' |
a3266e46b191
handle nonString items correctly
Stefan Vogel <sv@exept.de>
parents:
3153
diff
changeset
|
2264 |
] ifFalse:[ |
a3266e46b191
handle nonString items correctly
Stefan Vogel <sv@exept.de>
parents:
3153
diff
changeset
|
2265 |
^ label |
a3266e46b191
handle nonString items correctly
Stefan Vogel <sv@exept.de>
parents:
3153
diff
changeset
|
2266 |
]. |
2973 | 2267 |
! |
2268 |
||
463 | 2269 |
performSelectedAction |
878 | 2270 |
|theSelector theAction isCheck checkOn val idx didItHere| |
463 | 2271 |
|
2069 | 2272 |
(superView notNil and:[superView isPopUpView]) ifTrue:[superView hideForAction]. |
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
463
diff
changeset
|
2273 |
superMenu notNil ifTrue:[superMenu submenuTriggered]. |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
463
diff
changeset
|
2274 |
|
517
fc4ed55dcd35
added action-blocks (per menu item)
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
2275 |
idx := selection. |
fc4ed55dcd35
added action-blocks (per menu item)
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
2276 |
idx notNil ifTrue:[ |
878 | 2277 |
|
2069 | 2278 |
(subMenus isNil or:[(subMenus at:idx) isNil]) ifTrue:[ |
2279 |
didItHere := false. |
|
2280 |
||
2281 |
self showActive. |
|
2282 |
[ |
|
2283 |
superMenu notNil ifTrue:[ |
|
2284 |
superMenu showActive |
|
2285 |
]. |
|
2286 |
||
2287 |
val := idx. |
|
2288 |
args notNil ifTrue:[ |
|
2289 |
val := args at:idx |
|
2290 |
]. |
|
2291 |
||
2292 |
isCheck := false. |
|
2293 |
onOffFlags notNil ifTrue:[ |
|
2294 |
onOffFlags size >= idx ifTrue:[ |
|
2295 |
checkOn := (onOffFlags at:idx). |
|
2296 |
isCheck := checkOn notNil. |
|
2297 |
isCheck ifTrue:[ |
|
2298 |
checkOn := val := checkOn not. |
|
2299 |
onOffFlags at:idx put:checkOn. |
|
2300 |
] |
|
2301 |
] |
|
2302 |
]. |
|
2303 |
||
2304 |
" |
|
2305 |
ST-80 style model notification |
|
2306 |
" |
|
2307 |
self sendChangeMessageWith:val. |
|
2308 |
||
2309 |
" |
|
2310 |
item actions or selectors-array |
|
2311 |
" |
|
5638 | 2312 |
device activePointerGrab == self ifTrue:[ |
2313 |
device ungrabPointer. |
|
2069 | 2314 |
]. |
2315 |
||
2316 |
actions notNil ifTrue:[ |
|
2317 |
theAction := actions at:idx ifAbsent:nil. |
|
2318 |
]. |
|
2319 |
||
2320 |
theAction isNil ifTrue: [ |
|
2321 |
selectors notNil ifTrue: [ |
|
2322 |
||
2323 |
"/ selectors may be: |
|
2324 |
"/ - a single selector used for all items |
|
2325 |
"/ - an array of selectors used per item |
|
2326 |
||
2327 |
selectors isSymbol ifTrue:[ |
|
2328 |
theSelector := selectors |
|
2329 |
] ifFalse:[ |
|
2330 |
(idx notNil |
|
2331 |
and:[idx <= selectors size]) ifTrue:[ |
|
2332 |
theSelector := selectors at:idx |
|
2333 |
] |
|
2334 |
]. |
|
2335 |
]. |
|
2336 |
]. |
|
2337 |
||
2338 |
(theSelector notNil |
|
2339 |
or:[theAction notNil]) ifTrue:[ |
|
4867
8bf409df4dc9
AbortSignal -> AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
4723
diff
changeset
|
2340 |
AbortOperationRequest handle:[:ex | |
2069 | 2341 |
ex return |
2342 |
] do:[ |
|
2343 |
|theReceiver| |
|
2344 |
||
2345 |
didItHere := true. |
|
2346 |
theAction notNil ifTrue:[ |
|
2502
8f5b721ac183
use new #perform:withOptionalArgument:
Claus Gittinger <cg@exept.de>
parents:
2498
diff
changeset
|
2347 |
theAction valueWithOptionalArgument:val |
2069 | 2348 |
] ifFalse:[ |
2349 |
"/ support for ST-80 style message splitting: |
|
2350 |
"/ if there is a menuPerformer it gets the |
|
2351 |
"/ message (if understood). |
|
2352 |
"/ Otherwise if there is a model, try that. |
|
2353 |
"/ Finally, if there is a receiver, |
|
2354 |
"/ its sent to that one. |
|
2355 |
||
2356 |
theReceiver := menuPerformer. |
|
2357 |
(theReceiver isNil |
|
2358 |
or:[(theReceiver respondsTo:theSelector) not]) |
|
2359 |
ifTrue:[ |
|
2360 |
theReceiver := model. |
|
2361 |
]. |
|
2362 |
(theReceiver isNil |
|
2363 |
or:[(theReceiver respondsTo:theSelector) not]) |
|
2364 |
ifTrue:[ |
|
2365 |
theReceiver := receiver. |
|
2366 |
]. |
|
2367 |
||
5835 | 2368 |
theSelector isBlock ifTrue:[ |
2369 |
theSelector value |
|
2370 |
] ifFalse:[ |
|
2371 |
theSelector isArray ifTrue:[ |
|
2372 |
theReceiver perform:(theSelector first) withArguments:(theSelector copyFrom:2) |
|
2683 | 2373 |
] ifFalse:[ |
5835 | 2374 |
theSelector numArgs == 0 ifTrue:[ |
2375 |
theReceiver perform:theSelector |
|
2376 |
] ifFalse:[ |
|
2377 |
isCheck ifTrue:[ |
|
2378 |
self redrawLine:idx. |
|
2379 |
val := checkOn. |
|
2380 |
]. |
|
2381 |
theReceiver perform:theSelector with:val |
|
2382 |
] |
|
2683 | 2383 |
] |
2069 | 2384 |
] |
2385 |
] |
|
2386 |
||
2387 |
] |
|
2388 |
]. |
|
2389 |
||
2390 |
" |
|
2391 |
any action-block ? |
|
2392 |
" |
|
2393 |
actionBlock notNil ifTrue:[ |
|
4867
8bf409df4dc9
AbortSignal -> AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
4723
diff
changeset
|
2394 |
AbortOperationRequest handle:[:ex | |
2069 | 2395 |
ex return |
2396 |
] do:[ |
|
2397 |
didItHere ifTrue:[ |
|
2398 |
val := nil |
|
2399 |
]. |
|
2400 |
actionBlock numArgs == 1 ifTrue:[ |
|
2401 |
actionBlock value:val |
|
2402 |
] ifFalse:[ |
|
2403 |
actionBlock value:self value:val |
|
2404 |
] |
|
2405 |
] |
|
2406 |
]. |
|
2407 |
||
2521
ca205c023cc1
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2502
diff
changeset
|
2408 |
] ensure:[ |
2069 | 2409 |
realized ifTrue:[ |
2410 |
self showPassive. |
|
2411 |
]. |
|
2412 |
superMenu notNil ifTrue:[ |
|
2413 |
superMenu showPassive |
|
2414 |
] |
|
2415 |
]. |
|
2416 |
]. |
|
463 | 2417 |
] |
2418 |
||
2419 |
"Created: 4.3.1996 / 11:19:22 / cg" |
|
963 | 2420 |
"Modified: 21.1.1997 / 15:42:52 / cg" |
463 | 2421 |
! |
2422 |
||
127 | 2423 |
recomputeSize |
2424 |
"resize myself to my preferred size |
|
2425 |
OBSOLETE - use resize" |
|
2426 |
||
2427 |
self resize. |
|
0 | 2428 |
! |
2429 |
||
202 | 2430 |
resize |
2431 |
"resize myself to my preferred size" |
|
77 | 2432 |
|
337 | 2433 |
sizeFixed == true ifFalse:[ |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2434 |
widthOfWidestLine := nil. "/ i.e. unknown |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2435 |
super resize. |
334 | 2436 |
] |
2437 |
||
337 | 2438 |
"Modified: 9.2.1996 / 02:42:32 / cg" |
202 | 2439 |
! |
77 | 2440 |
|
202 | 2441 |
resizeIfChanged |
2442 |
needResize == true ifTrue:[ |
|
2443 |
self resize. |
|
2444 |
needResize := false |
|
2445 |
] |
|
77 | 2446 |
! |
2447 |
||
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
463
diff
changeset
|
2448 |
selectionChangedFrom:oldSelection |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
463
diff
changeset
|
2449 |
|
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
463
diff
changeset
|
2450 |
"Created: 4.3.1996 / 22:10:54 / cg" |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
463
diff
changeset
|
2451 |
! |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
463
diff
changeset
|
2452 |
|
4195
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2453 |
setSelectionForX:x y:y now:now |
77 | 2454 |
"select whatever is under x/y coordinate - if there is |
2455 |
a subMenu, show it" |
|
2456 |
||
1627
38d58b70124e
style option: submenu pops up everywhere in item or
Claus Gittinger <cg@exept.de>
parents:
1532
diff
changeset
|
2457 |
<resource: #style (#'menu.subMenuPopInRightHalfOnly')> |
38d58b70124e
style option: submenu pops up everywhere in item or
Claus Gittinger <cg@exept.de>
parents:
1532
diff
changeset
|
2458 |
|
133 | 2459 |
|newSelection subMenu| |
0 | 2460 |
|
4195
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2461 |
lastMousePoint := x@y. |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2462 |
|
38 | 2463 |
(x < 0 |
2464 |
or:[x >= width |
|
2465 |
or:[y < 0 |
|
2466 |
or:[y >= height]]]) ifTrue:[ |
|
1627
38d58b70124e
style option: submenu pops up everywhere in item or
Claus Gittinger <cg@exept.de>
parents:
1532
diff
changeset
|
2467 |
" |
1860 | 2468 |
moved outside |
1627
38d58b70124e
style option: submenu pops up everywhere in item or
Claus Gittinger <cg@exept.de>
parents:
1532
diff
changeset
|
2469 |
" |
4195
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2470 |
self cancelDelayedSubmenuHideOrShowAction. |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2471 |
|
1627
38d58b70124e
style option: submenu pops up everywhere in item or
Claus Gittinger <cg@exept.de>
parents:
1532
diff
changeset
|
2472 |
subMenuShown notNil ifTrue:[ |
38d58b70124e
style option: submenu pops up everywhere in item or
Claus Gittinger <cg@exept.de>
parents:
1532
diff
changeset
|
2473 |
^ self |
38d58b70124e
style option: submenu pops up everywhere in item or
Claus Gittinger <cg@exept.de>
parents:
1532
diff
changeset
|
2474 |
]. |
1860 | 2475 |
|
1627
38d58b70124e
style option: submenu pops up everywhere in item or
Claus Gittinger <cg@exept.de>
parents:
1532
diff
changeset
|
2476 |
superMenu notNil ifTrue:[ |
38d58b70124e
style option: submenu pops up everywhere in item or
Claus Gittinger <cg@exept.de>
parents:
1532
diff
changeset
|
2477 |
superMenu regainControl |
38d58b70124e
style option: submenu pops up everywhere in item or
Claus Gittinger <cg@exept.de>
parents:
1532
diff
changeset
|
2478 |
]. |
38 | 2479 |
]. |
2480 |
||
0 | 2481 |
newSelection := self positionToSelectionX:x y:y. |
7 | 2482 |
newSelection ~= selection ifTrue:[ |
1627
38d58b70124e
style option: submenu pops up everywhere in item or
Claus Gittinger <cg@exept.de>
parents:
1532
diff
changeset
|
2483 |
newSelection notNil ifTrue:[ |
4692 | 2484 |
(self isEnabled:newSelection) ifFalse:[ |
1627
38d58b70124e
style option: submenu pops up everywhere in item or
Claus Gittinger <cg@exept.de>
parents:
1532
diff
changeset
|
2485 |
newSelection := nil |
38d58b70124e
style option: submenu pops up everywhere in item or
Claus Gittinger <cg@exept.de>
parents:
1532
diff
changeset
|
2486 |
] |
38d58b70124e
style option: submenu pops up everywhere in item or
Claus Gittinger <cg@exept.de>
parents:
1532
diff
changeset
|
2487 |
]. |
4195
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2488 |
]. |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2489 |
newSelection = selection ifTrue:[ |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2490 |
now ifFalse:[ |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2491 |
^ self |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2492 |
] |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2493 |
]. |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2494 |
|
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2495 |
superMenu notNil ifTrue:[ |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2496 |
superMenu cancelDelayedSubmenuHideOrShowAction. |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2497 |
]. |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2498 |
self cancelDelayedSubmenuHideOrShowAction. |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2499 |
(subMenuShown isNil or:[now]) ifTrue:[ |
1627
38d58b70124e
style option: submenu pops up everywhere in item or
Claus Gittinger <cg@exept.de>
parents:
1532
diff
changeset
|
2500 |
self setSelection:newSelection. |
133 | 2501 |
]. |
7 | 2502 |
|
4195
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2503 |
now ifTrue:[ |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2504 |
subMenu := nil. |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2505 |
newSelection notNil ifTrue:[ |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2506 |
subMenus notNil ifTrue:[ |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2507 |
((styleSheet at:#'menu.subMenuPopInRightHalfOnly' default:false) not |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2508 |
or:[x > (width // 2)]) ifTrue:[ |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2509 |
subMenu := (subMenus at:newSelection). |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2510 |
] |
1627
38d58b70124e
style option: submenu pops up everywhere in item or
Claus Gittinger <cg@exept.de>
parents:
1532
diff
changeset
|
2511 |
] |
4195
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2512 |
]. |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2513 |
|
4626 | 2514 |
subMenuShown notNil ifTrue:[ |
2515 |
self hideSubmenu. |
|
2516 |
subMenuShown := nil. |
|
2517 |
]. |
|
4195
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2518 |
subMenu notNil ifTrue:[ |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2519 |
self showSubmenu:newSelection. |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2520 |
]. |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2521 |
] ifFalse:[ |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2522 |
"/ new, delayed code |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2523 |
delayedSubmenuHideOrShowAction := |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2524 |
[ |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2525 |
self setSelectionForX:lastMousePoint x y:lastMousePoint y now:true. |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2526 |
]. |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2527 |
|
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2528 |
Processor |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2529 |
addTimedBlock:delayedSubmenuHideOrShowAction |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2530 |
afterMilliseconds:100. |
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2531 |
|
133 | 2532 |
]. |
4195
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2533 |
|
3a80e7b60d37
delayed submenu (one half; other half is in MenuPanel)
Claus Gittinger <cg@exept.de>
parents:
4134
diff
changeset
|
2534 |
"Created: / 29-11-2010 / 19:09:54 / cg" |
0 | 2535 |
! ! |
2536 |
||
202 | 2537 |
!MenuView methodsFor:'queries'! |
0 | 2538 |
|
6496 | 2539 |
computePreferredExtent |
969 | 2540 |
"compute & return my preferredExtent from labels width's" |
2541 |
||
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2542 |
|margin2 w h extra| |
202 | 2543 |
|
2544 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
119 | 2545 |
|
202 | 2546 |
margin2 := margin * 2. |
2547 |
w := self widthOfContents + leftMargin + leftMargin + margin2. |
|
2548 |
h := (self numberOfLines) * fontHeight - lineSpacing + (2 * topMargin) + margin2. |
|
228 | 2549 |
hilightLevel ~~ 0 ifTrue:[ |
3752
9c3b292df738
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3551
diff
changeset
|
2550 |
h := h + (hilightLevel abs) |
224 | 2551 |
]. |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2552 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2553 |
extra := 0. |
202 | 2554 |
"if there is a submenu, add some space for the right arrow" |
2555 |
subMenus notNil ifTrue:[ |
|
3752
9c3b292df738
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3551
diff
changeset
|
2556 |
extra := 16 |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2557 |
]. |
461
45282807f7fa
handle shortKey & submenu-arrow in one line; allow turning of of accelerator display
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
2558 |
((ShowAcceleratorKeys ~~ false) and:[shortKeys notNil]) ifTrue:[ |
3752
9c3b292df738
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3551
diff
changeset
|
2559 |
extra := extra max:(self shortKeyInset) + 10 "/ spacing |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2560 |
]. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2561 |
^ ((w+extra) @ h). |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2562 |
|
6496 | 2563 |
"Created: / 09-11-2018 / 19:57:01 / Claus Gittinger" |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2564 |
! |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2565 |
|
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2566 |
selectedItemHasSubmenu |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2567 |
selection isNil ifTrue:[^false]. |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2568 |
^ (subMenus notNil and:[(subMenus at:selection) notNil]). |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2569 |
|
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2570 |
"Modified: 20.11.1997 / 00:07:50 / cg" |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2571 |
! |
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2572 |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2573 |
shortKeyInset |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2574 |
"compute the width req'd for the shortKey" |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2575 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2576 |
maxShortKeyStringLen isNil ifTrue:[ |
3323
ce80842d41e0
shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents:
3294
diff
changeset
|
2577 |
shortKeys isNil ifTrue:[ |
ce80842d41e0
shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents:
3294
diff
changeset
|
2578 |
maxShortKeyStringLen := 0 |
ce80842d41e0
shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents:
3294
diff
changeset
|
2579 |
] ifFalse:[ |
ce80842d41e0
shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents:
3294
diff
changeset
|
2580 |
maxShortKeyStringLen := shortKeys |
ce80842d41e0
shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents:
3294
diff
changeset
|
2581 |
inject:0 |
ce80842d41e0
shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents:
3294
diff
changeset
|
2582 |
into:[:maxSoFar :thisKey | |short| |
ce80842d41e0
shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents:
3294
diff
changeset
|
2583 |
|
ce80842d41e0
shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents:
3294
diff
changeset
|
2584 |
thisKey isNil ifTrue:[ |
ce80842d41e0
shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents:
3294
diff
changeset
|
2585 |
maxSoFar |
ce80842d41e0
shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents:
3294
diff
changeset
|
2586 |
] ifFalse:[ |
5638 | 2587 |
short := device shortKeyStringFor:thisKey. |
3323
ce80842d41e0
shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents:
3294
diff
changeset
|
2588 |
short isNil ifTrue:[ |
ce80842d41e0
shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents:
3294
diff
changeset
|
2589 |
maxSoFar |
ce80842d41e0
shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents:
3294
diff
changeset
|
2590 |
] ifFalse:[ |
4900 | 2591 |
maxSoFar max:(gc font widthOf:short) |
3323
ce80842d41e0
shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents:
3294
diff
changeset
|
2592 |
] |
ce80842d41e0
shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents:
3294
diff
changeset
|
2593 |
] |
ce80842d41e0
shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents:
3294
diff
changeset
|
2594 |
] |
ce80842d41e0
shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents:
3294
diff
changeset
|
2595 |
]. |
202 | 2596 |
]. |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2597 |
^ maxShortKeyStringLen |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2598 |
|
3323
ce80842d41e0
shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents:
3294
diff
changeset
|
2599 |
"Created: / 28-02-1996 / 16:30:09 / cg" |
ce80842d41e0
shortKey handling moved to device (shared between menu and menuPanel)
Claus Gittinger <cg@exept.de>
parents:
3294
diff
changeset
|
2600 |
"Modified: / 08-08-2006 / 15:47:07 / cg" |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2601 |
! |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2602 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2603 |
shortKeyPrefixFor:aModifier |
4374
e0cdb94c4530
changed: #shortKeyPrefixFor:
Claus Gittinger <cg@exept.de>
parents:
4327
diff
changeset
|
2604 |
<resource: #obsolete> |
e0cdb94c4530
changed: #shortKeyPrefixFor:
Claus Gittinger <cg@exept.de>
parents:
4327
diff
changeset
|
2605 |
"obsolete?" |
e0cdb94c4530
changed: #shortKeyPrefixFor:
Claus Gittinger <cg@exept.de>
parents:
4327
diff
changeset
|
2606 |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2607 |
|m| |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2608 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2609 |
"/ aModifier = 'Alt' ifTrue:[ |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2610 |
"/ ^ '@-' |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2611 |
"/ ]. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2612 |
"/ aModifier = 'Cmd' ifTrue:[ |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2613 |
"/ ^ '@-' |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2614 |
"/ ]. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2615 |
"/ aModifier = 'Meta' ifTrue:[ |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2616 |
"/ ^ '$-' |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2617 |
"/ ]. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2618 |
"/ aModifier = 'Ctrl' ifTrue:[ |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2619 |
"/ ^ '^-' |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2620 |
"/ ]. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2621 |
"/ ^ aModifier. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2622 |
|
5638 | 2623 |
m := device modifierKeyTopFor:aModifier. |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2624 |
m notNil ifTrue:[ |
4374
e0cdb94c4530
changed: #shortKeyPrefixFor:
Claus Gittinger <cg@exept.de>
parents:
4327
diff
changeset
|
2625 |
^ m , '-' |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2626 |
]. |
508 | 2627 |
^ aModifier. |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2628 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2629 |
"Created: 28.2.1996 / 16:32:17 / cg" |
508 | 2630 |
"Modified: 20.3.1996 / 17:03:34 / cg" |
4723 | 2631 |
! |
2632 |
||
2633 |
wantsFocusWithButtonPress |
|
2634 |
^ false. |
|
77 | 2635 |
! ! |
2636 |
||
0 | 2637 |
!MenuView methodsFor:'redrawing'! |
2638 |
||
202 | 2639 |
redrawFromVisibleLine:start to:stop |
2640 |
"redraw a line range - redefined to care for special entries." |
|
2641 |
||
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2642 |
"/ the natural way to do it is: |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2643 |
"/ |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2644 |
"/ start to:stop do:[:visLine | |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2645 |
"/ self redrawVisibleLine:visLine |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2646 |
"/ ] |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2647 |
"/ |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2648 |
"/ but I want to draw the stuff in big chunks for slow machines ... |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2649 |
"/ Q: is it worth it ? |
191
5ccbde40bb6b
draw strings half a lineSpacing lower - highlight frames look better
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2650 |
|
202 | 2651 |
|first |
2652 |
index "{ Class: SmallInteger }" |
|
2653 |
current "{ Class: SmallInteger }" |
|
2654 |
line special index0| |
|
2655 |
||
2656 |
index0 := self visibleLineToListLine:start. |
|
2657 |
index0 notNil ifTrue:[ |
|
2959 | 2658 |
index := index0. |
2659 |
first := start. |
|
2660 |
current := start. |
|
2661 |
[current <= stop] whileTrue:[ |
|
2662 |
line := self visibleAt:current. |
|
2663 |
line notNil ifTrue:[ |
|
2664 |
line isText ifFalse:[ |
|
2960 | 2665 |
line := line asString string |
2959 | 2666 |
] |
2667 |
]. |
|
2668 |
||
2669 |
special := line notNil |
|
2670 |
and:[line isString |
|
2671 |
and:[(self isGraphicItem:line) |
|
2672 |
or:[line includes:$\ ]]]. |
|
2673 |
||
2674 |
(special |
|
2675 |
or:[shortKeys notNil |
|
4692 | 2676 |
or:[(self isEnabled:index) not]]) ifTrue:[ |
2959 | 2677 |
"a special case" |
2678 |
(first < current) ifTrue:[ |
|
2679 |
super redrawFromVisibleLine:first to:(current - 1) |
|
2680 |
]. |
|
2681 |
self redrawVisibleLine:current. |
|
2682 |
first := current + 1 |
|
2683 |
]. |
|
2684 |
current := current + 1. |
|
2685 |
index := index + 1 |
|
2686 |
]. |
|
2687 |
(first < current) ifTrue:[ |
|
2688 |
super redrawFromVisibleLine:first to:(current - 1) |
|
2689 |
]. |
|
2690 |
||
2691 |
"draw submenu marks" |
|
2692 |
subMenus notNil ifTrue:[ |
|
2693 |
index := index0. |
|
2694 |
start to:stop do:[:l | |
|
2695 |
index <= subMenus size ifTrue:[ |
|
2696 |
(subMenus at:index) notNil ifTrue:[ |
|
2697 |
self drawRightArrowInVisibleLine:l |
|
2698 |
]. |
|
2699 |
index := index + 1 |
|
2700 |
] |
|
2701 |
] |
|
2702 |
] |
|
202 | 2703 |
] |
405
39b9b0f04ccc
allow checkmarks at any position
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
2704 |
|
635
cb2ac261994b
handle non-string items better
Claus Gittinger <cg@exept.de>
parents:
624
diff
changeset
|
2705 |
"Modified: 12.5.1996 / 21:13:31 / cg" |
0 | 2706 |
! |
2707 |
||
2708 |
redrawVisibleLine:visLineNr |
|
63 | 2709 |
"redefined from normal list-line drawing, to handle special |
2710 |
lines. These are: |
|
2498 | 2711 |
lines consisting of '-' only: draw a horizontal separating line |
2712 |
lines consisting of '=' only: draw double separating line |
|
2713 |
empty line : leave blank |
|
63 | 2714 |
there may be more in the future. |
2715 |
" |
|
2716 |
||
2717 |
|line lineNr y isSpecial isSeparatingLine |
|
2572
9b09dd9d9dae
dont forget to draw accelerator when disabled
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
2718 |
isDoubleLine right clr1 clr2 text key| |
0 | 2719 |
|
2720 |
line := self visibleAt:visLineNr. |
|
2721 |
||
63 | 2722 |
isSpecial := isDoubleLine := isSeparatingLine := false. |
5693 | 2723 |
(self isGraphicItem:line) ifTrue:[ |
2724 |
(line = '-') ifTrue:[ |
|
2725 |
isSeparatingLine := isSpecial := true. |
|
2498 | 2726 |
] ifFalse:[ |
5693 | 2727 |
(line = '=') ifTrue:[ |
2728 |
isSeparatingLine := isSpecial := isDoubleLine := true. |
|
2729 |
] ifFalse:[ |
|
2730 |
(line = '') ifTrue:[ |
|
2731 |
isSpecial := true |
|
2732 |
] |
|
2498 | 2733 |
] |
5693 | 2734 |
]. |
0 | 2735 |
]. |
5693 | 2736 |
|
0 | 2737 |
isSpecial ifFalse:[ |
2498 | 2738 |
lineNr := self visibleLineToListLine:visLineNr. |
4692 | 2739 |
(self isEnabled:lineNr) ifFalse:[ |
2498 | 2740 |
text := self visibleAt:visLineNr. |
2741 |
disabledEtchedFgColor notNil ifTrue:[ |
|
2742 |
text := text asText emphasisAllAdd:(#etchColor -> disabledEtchedFgColor) |
|
2743 |
]. |
|
2744 |
self |
|
2745 |
drawLine:text |
|
2746 |
atX:(textStartLeft - viewOrigin x) |
|
2747 |
inVisible:visLineNr |
|
2748 |
with:disabledFgColor |
|
2749 |
and:bgColor. |
|
2572
9b09dd9d9dae
dont forget to draw accelerator when disabled
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
2750 |
|
9b09dd9d9dae
dont forget to draw accelerator when disabled
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
2751 |
"/ |
9b09dd9d9dae
dont forget to draw accelerator when disabled
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
2752 |
"/ is there a shortKey ? |
9b09dd9d9dae
dont forget to draw accelerator when disabled
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
2753 |
"/ |
9b09dd9d9dae
dont forget to draw accelerator when disabled
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
2754 |
((ShowAcceleratorKeys ~~ false) |
9b09dd9d9dae
dont forget to draw accelerator when disabled
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
2755 |
and:[shortKeys notNil |
9b09dd9d9dae
dont forget to draw accelerator when disabled
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
2756 |
and:[(key := shortKeys at:lineNr ifAbsent:nil) notNil]]) ifTrue:[ |
9b09dd9d9dae
dont forget to draw accelerator when disabled
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
2757 |
self drawAccelerator:key inVisibleLine:visLineNr with:disabledFgColor and:bgColor |
9b09dd9d9dae
dont forget to draw accelerator when disabled
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
2758 |
] |
2498 | 2759 |
"/ self drawVisibleLine:visLineNr with:disabledFgColor and:bgColor |
2760 |
] ifTrue:[ |
|
2761 |
super redrawVisibleLine:visLineNr |
|
2762 |
]. |
|
2763 |
||
2764 |
"/ |
|
2765 |
"/ is there a submenu ? |
|
2766 |
"/ |
|
2767 |
(subMenus notNil and:[(subMenus at:lineNr ifAbsent:nil) notNil]) ifTrue:[ |
|
2768 |
self drawRightArrowInVisibleLine:visLineNr |
|
2769 |
]. |
|
2770 |
^ self |
|
0 | 2771 |
]. |
2772 |
||
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2773 |
"/ |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2774 |
"/ handle separating lines |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2775 |
"/ |
0 | 2776 |
|
59 | 2777 |
y := self yOfVisibleLine:visLineNr. |
38 | 2778 |
|
6055 | 2779 |
gc paint:bgColor. |
2780 |
gc fillRectangleX:0 y:y width:width height:fontHeight. |
|
38 | 2781 |
|
0 | 2782 |
isSeparatingLine ifTrue:[ |
2498 | 2783 |
y := y + (fontHeight // 2). |
2784 |
isDoubleLine ifTrue:[ |
|
2785 |
y := y - (fontHeight // 8). |
|
2786 |
]. |
|
2787 |
||
2788 |
right := width - 1 - lineInset. |
|
2789 |
||
2790 |
lineLevel == 0 ifTrue:[ |
|
6055 | 2791 |
gc paint:fgColor. |
2792 |
gc displayLineFromX:lineInset y:y toX:right y:y. |
|
2498 | 2793 |
isDoubleLine ifTrue:[ |
2794 |
y := y + (fontHeight // 4). |
|
6055 | 2795 |
gc displayLineFromX:lineInset y:y toX:right y:y |
2498 | 2796 |
] |
2797 |
] ifFalse:[ |
|
2798 |
"the inset on each side" |
|
2799 |
||
2800 |
lineLevel < 0 ifTrue:[ |
|
2801 |
clr1 := shadowColor. |
|
2802 |
clr2 := lightColor. |
|
2803 |
] ifFalse:[ |
|
2804 |
clr1 := lightColor. |
|
2805 |
clr2 := shadowColor. |
|
2806 |
]. |
|
2807 |
||
6055 | 2808 |
gc paint:clr1. |
2809 |
gc displayLineFromX:lineInset y:y toX:right y:y. |
|
2810 |
gc paint:clr2. |
|
2498 | 2811 |
y := y + 1. |
6055 | 2812 |
gc displayLineFromX:lineInset y:y toX:right y:y. |
2498 | 2813 |
isDoubleLine ifTrue:[ |
2814 |
y := y + (fontHeight // 4). |
|
6055 | 2815 |
gc displayLineFromX:lineInset y:y toX:right y:y. |
2498 | 2816 |
y := y - 1. |
6055 | 2817 |
gc paint:clr1. |
2818 |
gc displayLineFromX:lineInset y:y toX:right y:y. |
|
2498 | 2819 |
] |
2820 |
] |
|
0 | 2821 |
] |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2822 |
|
461
45282807f7fa
handle shortKey & submenu-arrow in one line; allow turning of of accelerator display
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
2823 |
"Modified: 2.3.1996 / 14:48:08 / cg" |
0 | 2824 |
! |
2825 |
||
202 | 2826 |
redrawVisibleLine:visLine col:col |
2827 |
"redefined to always draw a full line - for openwin handling" |
|
0 | 2828 |
|
202 | 2829 |
self redrawVisibleLine:visLine |
2830 |
! |
|
97 | 2831 |
|
202 | 2832 |
redrawVisibleLine:visLine from:startCol |
2833 |
"redefined to always draw a full line - for openwin handling" |
|
21 | 2834 |
|
202 | 2835 |
self redrawVisibleLine:visLine |
2836 |
! |
|
2837 |
||
2838 |
redrawVisibleLine:visLine from:startCol to:endCol |
|
2839 |
"redefined to always draw a full line - for openwin handling" |
|
2840 |
||
2841 |
self redrawVisibleLine:visLine |
|
0 | 2842 |
! ! |
2843 |
||
202 | 2844 |
!MenuView methodsFor:'selections'! |
2845 |
||
2846 |
isValidSelection:aNumber |
|
2847 |
"return true, if aNumber is ok for a selection lineNo" |
|
2848 |
||
2849 |
|line| |
|
2850 |
||
2851 |
(super isValidSelection:aNumber) ifFalse:[^ false]. |
|
4692 | 2852 |
(self isEnabled:aNumber) ifFalse:[^ false]. |
202 | 2853 |
|
2854 |
line := self listAt:aNumber. |
|
2855 |
^ (self isGraphicItem:line) not |
|
1640
1ddc9c17b4bf
skip over disabled lines, when moving selection via cursor keys.
Claus Gittinger <cg@exept.de>
parents:
1627
diff
changeset
|
2856 |
|
1ddc9c17b4bf
skip over disabled lines, when moving selection via cursor keys.
Claus Gittinger <cg@exept.de>
parents:
1627
diff
changeset
|
2857 |
"Modified: / 8.8.1998 / 03:31:14 / cg" |
202 | 2858 |
! ! |
191
5ccbde40bb6b
draw strings half a lineSpacing lower - highlight frames look better
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2859 |
|
202 | 2860 |
!MenuView methodsFor:'showing'! |
2861 |
||
2862 |
realize |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2863 |
self resizeIfChanged. |
202 | 2864 |
super realize |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2865 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
408
diff
changeset
|
2866 |
"Modified: 28.2.1996 / 18:17:05 / cg" |
202 | 2867 |
! |
2868 |
||
2869 |
show |
|
3551
8cca2a43e849
use accessors for hiddenOnRealize and explicitExtents
Claus Gittinger <cg@exept.de>
parents:
3464
diff
changeset
|
2870 |
self hiddenOnRealize:false. |
509 | 2871 |
self showPassive. |
202 | 2872 |
self realize |
509 | 2873 |
|
2874 |
"Modified: 21.3.1996 / 17:21:46 / cg" |
|
1058
bf4c27091f6b
ignore motions if more are pending;
Claus Gittinger <cg@exept.de>
parents:
1048
diff
changeset
|
2875 |
! |
bf4c27091f6b
ignore motions if more are pending;
Claus Gittinger <cg@exept.de>
parents:
1048
diff
changeset
|
2876 |
|
bf4c27091f6b
ignore motions if more are pending;
Claus Gittinger <cg@exept.de>
parents:
1048
diff
changeset
|
2877 |
unmap |
1858 | 2878 |
"unmap the view - the view stays created (but invisible), and can be remapped again later." |
2879 |
||
1058
bf4c27091f6b
ignore motions if more are pending;
Claus Gittinger <cg@exept.de>
parents:
1048
diff
changeset
|
2880 |
self hideSubmenu. |
bf4c27091f6b
ignore motions if more are pending;
Claus Gittinger <cg@exept.de>
parents:
1048
diff
changeset
|
2881 |
super unmap. |
bf4c27091f6b
ignore motions if more are pending;
Claus Gittinger <cg@exept.de>
parents:
1048
diff
changeset
|
2882 |
|
bf4c27091f6b
ignore motions if more are pending;
Claus Gittinger <cg@exept.de>
parents:
1048
diff
changeset
|
2883 |
"Created: 25.2.1997 / 23:01:56 / cg" |
bf4c27091f6b
ignore motions if more are pending;
Claus Gittinger <cg@exept.de>
parents:
1048
diff
changeset
|
2884 |
"Modified: 25.2.1997 / 23:02:09 / cg" |
191
5ccbde40bb6b
draw strings half a lineSpacing lower - highlight frames look better
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2885 |
! ! |
5ccbde40bb6b
draw strings half a lineSpacing lower - highlight frames look better
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
2886 |
|
110 | 2887 |
!MenuView methodsFor:'submenu notifications'! |
7 | 2888 |
|
4197 | 2889 |
cancelDelayedSubmenuHideOrShowAction |
2890 |
delayedSubmenuHideOrShowAction notNil ifTrue:[ |
|
2891 |
Processor removeTimedBlock:delayedSubmenuHideOrShowAction. |
|
2892 |
delayedSubmenuHideOrShowAction := nil. |
|
2893 |
]. |
|
2894 |
||
2895 |
"Created: / 29-11-2010 / 19:21:36 / cg" |
|
2896 |
! |
|
2897 |
||
2898 |
hideSubmenu |
|
2899 |
"hide the currently shown subMenu (if any)" |
|
2900 |
||
2901 |
|m id| |
|
2902 |
||
2903 |
(m := subMenuShown) notNil ifTrue:[ |
|
2904 |
"/ race condition kludge ... |
|
2905 |
m realized ifFalse:[ |
|
6449 | 2906 |
(id := m drawableId) notNil ifTrue:[ |
5638 | 2907 |
device unmapWindow:id. |
4197 | 2908 |
] |
2909 |
] ifTrue:[ |
|
2910 |
m hide. |
|
2911 |
]. |
|
2912 |
||
2913 |
subMenuShown := nil. |
|
2914 |
"/ self setSelection:nil. |
|
2915 |
]. |
|
2916 |
||
2917 |
"Modified: / 29-11-2010 / 18:57:37 / cg" |
|
6449 | 2918 |
"Modified: / 01-10-2018 / 17:04:25 / Claus Gittinger" |
4197 | 2919 |
! |
2920 |
||
70 | 2921 |
regainControl |
7 | 2922 |
"take over pointer control from a submenu" |
2923 |
||
70 | 2924 |
masterView notNil ifTrue:[ |
1860 | 2925 |
masterView regainControl. |
2926 |
subMenuShown := nil. |
|
70 | 2927 |
]. |
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
463
diff
changeset
|
2928 |
|
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
463
diff
changeset
|
2929 |
"Modified: 4.3.1996 / 23:17:15 / cg" |
7 | 2930 |
! |
2931 |
||
2932 |
showActive |
|
110 | 2933 |
"submenu is about to perform a menu-action - show wait cursor here as well" |
7 | 2934 |
|
2935 |
self cursor:(Cursor wait) |
|
2936 |
! |
|
2937 |
||
2938 |
showPassive |
|
110 | 2939 |
"submenu has finished its menu-action - show normal cursor again" |
7 | 2940 |
|
2941 |
self cursor:(Cursor hand) |
|
0 | 2942 |
! |
2943 |
||
4197 | 2944 |
showSubmenu:index |
2945 |
"show subMenu at index" |
|
2946 |
||
2947 |
|org mx my menuOrBlock menu rightInset| |
|
2948 |
||
2949 |
rightInset := 5. |
|
2950 |
||
2951 |
menuOrBlock := subMenus at:index. |
|
2952 |
menuOrBlock isNil ifTrue:[^ self]. |
|
2953 |
menuOrBlock == subMenuShown ifTrue:[^ self]. |
|
2954 |
||
2955 |
menuOrBlock isBlock ifTrue:[ |
|
2956 |
menuOrBlock == blockOfSubMenuShown ifTrue:[^ self]. |
|
2957 |
menu := menuOrBlock value. |
|
2958 |
] ifFalse:[ |
|
2959 |
menu := menuOrBlock. |
|
2960 |
]. |
|
2961 |
||
2962 |
mx := width - rightInset. |
|
2963 |
my := self yOfVisibleLine:index. |
|
2964 |
" |
|
2965 |
need to know the physical screen coordinate, |
|
2966 |
to map the subview there |
|
2967 |
" |
|
5638 | 2968 |
org := device translatePoint:(mx @ my) fromView:self toView:nil. |
4197 | 2969 |
|
2970 |
" |
|
2971 |
before showing, process all of my expose events |
|
2972 |
" |
|
2973 |
"/ "/ mhmh - is this still needed ? |
|
2974 |
"/ windowGroup notNil ifTrue:[ |
|
2975 |
"/ windowGroup processExposeEvents |
|
2976 |
"/ ]. |
|
2977 |
||
5638 | 2978 |
menu topView device:device. "/ req'd for multiDisplay operation |
4197 | 2979 |
menu superMenu:self. |
2980 |
||
2981 |
actionBlock notNil ifTrue:[ |
|
2982 |
"/ mhmh - I am an ST-80 style menu |
|
2983 |
"/ which does not send any messages to the receiver, |
|
2984 |
"/ but returns the selector instead. |
|
2985 |
"/ let my submenu do so as well ... |
|
2986 |
||
2987 |
menu menuView action:actionBlock |
|
2988 |
]. |
|
2989 |
||
2990 |
" |
|
2991 |
realize the submenu in MY windowgroup |
|
2992 |
" |
|
2993 |
windowGroup notNil ifTrue:[ |
|
2994 |
menu windowGroup:windowGroup. |
|
2995 |
windowGroup addTopView:menu. |
|
2996 |
]. |
|
2997 |
menu fixSize. |
|
2998 |
menu origin:org. |
|
2999 |
menu makeFullyVisible. |
|
3000 |
||
3001 |
"/ cg: Jan-2010 |
|
3002 |
"/ if the submenu covers me, try to show it to the left instead of the right) |
|
3003 |
(menu screenBounds intersects:(self screenBounds insetBy:(rightInset*2))) ifTrue:[ |
|
3004 |
menu origin:(org - (width @ 0) - (menu width @ 0) + ((rightInset*2) @ 0)). |
|
3005 |
menu makeFullyVisible. |
|
3006 |
]. |
|
3007 |
||
3008 |
menu noShadow. |
|
3009 |
menu haveControl:true. "/ grap pointers during mapped |
|
3010 |
||
3011 |
"/ race condition kludge ... |
|
3012 |
menu realized ifFalse:[ |
|
3013 |
menu realize. |
|
3014 |
] ifTrue:[ |
|
5638 | 3015 |
device mapWindow:menu id. |
4197 | 3016 |
]. |
3017 |
"/ device flush. |
|
3018 |
menuOrBlock isBlock ifTrue:[ |
|
3019 |
blockOfSubMenuShown := menuOrBlock |
|
3020 |
] ifFalse:[ |
|
3021 |
blockOfSubMenuShown := nil |
|
3022 |
]. |
|
3023 |
subMenuShown := menu |
|
3024 |
||
3025 |
"Modified: / 10.10.2001 / 14:12:44 / cg" |
|
3026 |
! |
|
3027 |
||
202 | 3028 |
submenuTriggered |
3029 |
"submenu has performed some action - have to deselect here" |
|
77 | 3030 |
|
683 | 3031 |
self setSelection:nil. |
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
463
diff
changeset
|
3032 |
|
202 | 3033 |
"a bad kludge - 5 minutes before writing the alpha tapes ..." |
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
463
diff
changeset
|
3034 |
superView isPopUpView ifTrue:[ |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3035 |
superView hide |
136 | 3036 |
]. |
202 | 3037 |
superMenu notNil ifTrue:[ |
1403
ddc59498d1c3
toggle & cursor behavior as in mswindows
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3038 |
superMenu submenuTriggered |
202 | 3039 |
]. |
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
463
diff
changeset
|
3040 |
|
683 | 3041 |
"Modified: 25.5.1996 / 12:27:42 / cg" |
0 | 3042 |
! ! |
202 | 3043 |
|
878 | 3044 |
!MenuView class methodsFor:'documentation'! |
205 | 3045 |
|
3046 |
version |
|
5638 | 3047 |
^ '$Header$' |
3966 | 3048 |
! |
3049 |
||
3050 |
version_CVS |
|
5638 | 3051 |
^ '$Header$' |
205 | 3052 |
! ! |
4491 | 3053 |