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