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