author | Claus Gittinger <cg@exept.de> |
Wed, 29 May 1996 12:24:15 +0200 | |
changeset 714 | 5ff02d2d9fa7 |
parent 709 | a738bd76ace4 |
child 721 | 4a01084cf643 |
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 |
||
542 | 13 |
View subclass:#PullDownMenu |
283 | 14 |
instanceVariableNames:'receiver menus titles selectors activeMenuNumber |
250
77012e65ac84
draw strings as opaque strings - OS/2 server has a bug with non-image strings
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
15 |
showSeparatingLines topMargin fgColor bgColor activeFgColor |
77012e65ac84
draw strings as opaque strings - OS/2 server has a bug with non-image strings
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
16 |
activeBgColor onLevel offLevel edgeStyle keepMenu toggleKeep |
542 | 17 |
raiseTopWhenActivated actions' |
392
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
18 |
classVariableNames:'DefaultViewBackground DefaultForegroundColor |
250
77012e65ac84
draw strings as opaque strings - OS/2 server has a bug with non-image strings
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
19 |
DefaultBackgroundColor DefaultHilightForegroundColor |
77012e65ac84
draw strings as opaque strings - OS/2 server has a bug with non-image strings
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
20 |
DefaultHilightBackgroundColor DefaultLevel DefaultHilightLevel |
77012e65ac84
draw strings as opaque strings - OS/2 server has a bug with non-image strings
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
21 |
DefaultShadowColor DefaultLightColor DefaultEdgeStyle |
77012e65ac84
draw strings as opaque strings - OS/2 server has a bug with non-image strings
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
22 |
DefaultKeepMenu DefaultToggleKeep DefaultSeparatingLines' |
283 | 23 |
poolDictionaries:'' |
24 |
category:'Views-Menus' |
|
0 | 25 |
! |
26 |
||
3 | 27 |
!PullDownMenu class methodsFor:'documentation'! |
28 |
||
38 | 29 |
copyright |
30 |
" |
|
31 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
59 | 32 |
All Rights Reserved |
38 | 33 |
|
34 |
This software is furnished under a license and may be used |
|
35 |
only in accordance with the terms of that license and with the |
|
36 |
inclusion of the above copyright notice. This software may not |
|
37 |
be provided or otherwise made available to, or used by, any |
|
38 |
other person. No title to or ownership of the software is |
|
39 |
hereby transferred. |
|
40 |
" |
|
41 |
! |
|
42 |
||
3 | 43 |
documentation |
44 |
" |
|
38 | 45 |
PullDown menu provides the top (always visible) part of these menus. |
46 |
It controls display of its menus, which become visible when one of the |
|
47 |
PullDownMenus entries is pressed. |
|
0 | 48 |
|
128 | 49 |
A PullDownMenu itself consists of a single row of labels, which activate |
50 |
a pulled menu when clicked. Entries may be empty (i.e. have no menu) |
|
51 |
and empty entries may (optionally) also perform some action when clicked. |
|
52 |
An entries selector is used as the key to define and access submenus |
|
53 |
and (for empty entries:) the selector sent to the receiver of the menu. |
|
54 |
||
586 | 55 |
[Instance variables:] |
0 | 56 |
|
128 | 57 |
menus <Collection> the sub menus |
58 |
||
59 |
titles <Collection> the strings in the menu |
|
60 |
||
61 |
selectors <Collection> the selectors to send to the menu- |
|
586 | 62 |
receiver (for empty pull-menus) |
63 |
if nil (the default), title entries |
|
64 |
do not send anything. |
|
128 | 65 |
|
110 | 66 |
activeMenuNumber <Number> the index of the currently active menu |
128 | 67 |
|
110 | 68 |
showSeparatingLines <Boolean> show separating lines between my menu-strings |
128 | 69 |
|
110 | 70 |
topMargin <Number> number of pixels at top |
128 | 71 |
|
72 |
fgColor <Color> fg color to draw passive menu-titles |
|
73 |
bgColor <Color> bg color to draw passive menu-titles |
|
74 |
||
75 |
activeFgColor <Color> fg color to draw activated menu-titles |
|
76 |
activeBgColor <Color> bg color to draw activated menu-titles |
|
77 |
||
78 |
onLevel <Integer> 3D level of entry-buttons when pressed |
|
79 |
offLevel <Integer> 3D level of entry-buttons when released |
|
80 |
||
81 |
edgeStyle <Symbol> how to draw edges |
|
82 |
||
110 | 83 |
keepmenu <Boolean> if on, pulled menu stays on click, |
586 | 84 |
till clicked again (motif & windows behavior) |
77 | 85 |
|
128 | 86 |
toggleKeep <Boolean> if on and keepMenu is on, |
586 | 87 |
clicking again on label closes menu |
128 | 88 |
|
89 |
except menus, titles and selectors, instvars are usually defined from |
|
90 |
defaults in the styleSheet; you should not care for them. |
|
91 |
||
77 | 92 |
|
586 | 93 |
[StyleSheet values:] |
77 | 94 |
|
110 | 95 |
pullDownMenuViewBackground view background Color for the menu bar |
586 | 96 |
default: menuViewBackground |
110 | 97 |
|
98 |
pullDownMenuForegroundColor foreground drawing color for the menu bar |
|
586 | 99 |
default: menuForegroundColor |
110 | 100 |
|
101 |
pullDownMenuBackgroundColor background drawing color for the menu bar |
|
586 | 102 |
default: menuBackgroundColor |
110 | 103 |
|
104 |
pullDownMenuHilightForegroundColor active foreground drawing color for the menu bar |
|
586 | 105 |
default: menuHilightForegroundColor |
110 | 106 |
|
107 |
pullDownMenuHilightBackgroundColor active background drawing color for the menu bar |
|
586 | 108 |
default: menuHilightBackgroundColor |
110 | 109 |
|
110 |
pullDownMenuHilightLevel level (3D only) when active |
|
586 | 111 |
default: menuHilightLevel |
77 | 112 |
|
110 | 113 |
pullDownMenuEdgeStyle edge style (nil or #soft) |
114 |
||
115 |
pullDownMenuKeepMenu if true, pulled menu stays open until button |
|
586 | 116 |
is pressed again outside of the item-area (motif behavior) |
117 |
if false, menu closes on release (default) |
|
110 | 118 |
|
119 |
pullDownMenuToggleKeep if true, pulled menu closes when an entry is pressed |
|
586 | 120 |
again. Otherwise, only press outside of the items area |
121 |
hides it. default is false |
|
110 | 122 |
|
123 |
pullDownMenuLevel level (3D only) |
|
124 |
||
125 |
pullDownMenuFont font to use for the menu bar |
|
586 | 126 |
default: menuFont |
128 | 127 |
|
128 |
pullDownMenuShowSeparatingLines if true, lines are drawn between items. |
|
586 | 129 |
default: false |
133 | 130 |
|
131 |
pullDownMenuRaiseTop if true, topview is raised whenever an entry |
|
586 | 132 |
is activated. |
133 |
default: true |
|
134 |
||
135 |
[author:] |
|
136 |
Claus Gittinger |
|
110 | 137 |
" |
138 |
! |
|
77 | 139 |
|
110 | 140 |
examples |
141 |
" |
|
593 | 142 |
[exBegin] |
143 |
|top menu| |
|
128 | 144 |
|
593 | 145 |
top := StandardSystemView new. |
146 |
top extent:300@300. |
|
128 | 147 |
|
593 | 148 |
menu := PullDownMenu origin:0.0@0.0 corner:1.0@30 in:top. |
149 |
menu labels:#('foo' 'bar'). |
|
150 |
menu selectors:#(foo bar). |
|
151 |
menu at:#foo |
|
152 |
putLabels:#('foo1' 'foo2' 'foo3') |
|
153 |
selectors:#(foo1 foo2 foo3) |
|
154 |
receiver:nil. |
|
155 |
menu at:#bar |
|
156 |
putLabels:#('bar1' 'bar2' 'bar3') |
|
157 |
selectors:#(bar1 bar2 bar3) |
|
158 |
receiver:nil. |
|
159 |
top open |
|
128 | 160 |
|
161 |
||
110 | 162 |
|
128 | 163 |
empty entries are possible as selectable items (with non-nil seletor) ... |
593 | 164 |
[exEnd] |
165 |
|top menu| |
|
128 | 166 |
|
593 | 167 |
top := StandardSystemView new. |
168 |
top extent:300@300. |
|
128 | 169 |
|
593 | 170 |
menu := PullDownMenu origin:0.0@0.0 corner:1.0@30 in:top. |
171 |
menu labels:#('foo' 'bar' 'baz'). |
|
172 |
menu selectors:#(foo bar baz). |
|
173 |
menu at:#foo |
|
174 |
putLabels:#('foo1' 'foo2' 'foo3') |
|
175 |
selectors:#(foo1 foo2 foo3) |
|
176 |
receiver:nil. |
|
177 |
menu at:#baz |
|
178 |
putLabels:#('baz1' 'baz2' 'baz3') |
|
179 |
selectors:#(baz1 baz2 baz3) |
|
180 |
receiver:nil. |
|
181 |
top open |
|
110 | 182 |
|
183 |
||
77 | 184 |
|
128 | 185 |
... or as separators (with nil selector) |
593 | 186 |
[exBegin] |
187 |
|top menu| |
|
128 | 188 |
|
593 | 189 |
top := StandardSystemView new. |
190 |
top extent:500@200. |
|
110 | 191 |
|
593 | 192 |
menu := PullDownMenu origin:0.0@0.0 corner:1.0@30 in:top. |
193 |
menu labels:#('foo' ' ' 'bar' ' baz' ' ' 'moreFoo' 'moreBar' 'moreBaz'). |
|
194 |
menu selectors:#(foo nil bar baz nil moreFoo moreBar moreBaz). |
|
195 |
menu at:#foo |
|
196 |
putLabels:#('foo1' 'foo2' 'foo3') |
|
197 |
selectors:#(foo1 foo2 foo3) |
|
198 |
receiver:nil. |
|
199 |
menu at:#bar |
|
200 |
putLabels:#('bar1' 'bar2' 'bar3') |
|
201 |
selectors:#(bar1 bar2 bar3) |
|
202 |
receiver:nil. |
|
203 |
menu at:#baz |
|
204 |
putLabels:#('baz1' 'baz2' 'baz3') |
|
205 |
selectors:#(baz1 baz2 baz3) |
|
206 |
receiver:nil. |
|
207 |
top open |
|
110 | 208 |
|
209 |
||
210 |
||
128 | 211 |
|
212 |
use the menus default height |
|
593 | 213 |
[exEnd] |
214 |
|top menu| |
|
128 | 215 |
|
593 | 216 |
top := StandardSystemView new. |
217 |
top extent:300@300. |
|
77 | 218 |
|
593 | 219 |
menu := PullDownMenu in:top. |
220 |
menu origin:0.0@0.0 corner:1.0@(menu height). |
|
221 |
menu labels:#('foo' 'bar'). |
|
222 |
menu selectors:#(foo bar). |
|
223 |
menu at:#foo |
|
224 |
putLabels:#('foo1' 'foo2' 'foo3') |
|
225 |
selectors:#(foo1 foo2 foo3) |
|
226 |
receiver:nil. |
|
227 |
top open |
|
110 | 228 |
|
77 | 229 |
|
110 | 230 |
|
231 |
||
605
11b03282d684
copy selectors, args & shortKeys
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
232 |
although you can change the font, colors etc. (as shown below) |
128 | 233 |
you should NOT do it - since if you do so, the styleSheet settings |
605
11b03282d684
copy selectors, args & shortKeys
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
234 |
are ineffective (which users probably won't like) |
128 | 235 |
BTW: The styleSheet entries for below are pullDownMenuForegroundColor, |
593 | 236 |
pullDownMenuBackgroundColor and pullDownMenuFont |
237 |
[exBegin] |
|
238 |
|top menu| |
|
77 | 239 |
|
593 | 240 |
top := StandardSystemView new. |
241 |
menu := PullDownMenu in:top. |
|
242 |
menu font:(Font family:'courier' size:20). |
|
243 |
menu foregroundColor:Color red. |
|
244 |
menu backgroundColor:Color yellow. |
|
245 |
menu viewBackground:Color yellow. |
|
246 |
menu showSeparatingLines:true. |
|
110 | 247 |
|
593 | 248 |
menu origin:0.0@0.0 corner:1.0@(menu height). |
249 |
menu labels:#('foo' 'bar'). |
|
250 |
menu selectors:#(foo bar). |
|
251 |
menu at:#foo |
|
252 |
putLabels:#('foo1' 'foo2' 'foo3') |
|
253 |
selectors:#(foo1 foo2 foo3) |
|
254 |
receiver:nil. |
|
255 |
(menu menuAt:#foo) font:(Font family:'courier' size:36). |
|
256 |
top open |
|
110 | 257 |
|
258 |
||
77 | 259 |
|
128 | 260 |
you can use icons, too ... |
593 | 261 |
[exEnd] |
262 |
|labels top menu| |
|
128 | 263 |
|
593 | 264 |
top := StandardSystemView new. |
265 |
top extent:300@300. |
|
110 | 266 |
|
593 | 267 |
menu := PullDownMenu in:top. |
268 |
menu origin:0.0@0.0 corner:1.0@(menu height). |
|
269 |
labels := Array with:((Image fromFile:'SmalltalkX.xbm') magnifiedTo:16@16) |
|
270 |
with:'foo' |
|
271 |
with:'bar'. |
|
272 |
menu labels:labels. |
|
273 |
menu selectors:#(about foo bar). |
|
274 |
menu at:#about |
|
275 |
putLabels:#('about PullDownMenus') |
|
276 |
selectors:#(aboutMenus) |
|
277 |
receiver:nil. |
|
278 |
menu at:#foo |
|
279 |
putLabels:#('foo1' 'foo2' 'foo3') |
|
280 |
selectors:#(foo1 foo2 foo3) |
|
281 |
receiver:nil. |
|
282 |
top open |
|
110 | 283 |
|
284 |
||
285 |
||
128 | 286 |
a concrete example (combining things described above) |
287 |
(using a Plug, since we have no application class here): |
|
593 | 288 |
[exBegin] |
289 |
|labels top menu textView appModel| |
|
110 | 290 |
|
593 | 291 |
appModel := Plug new. |
292 |
appModel respondTo:#quit with:[top destroy]. |
|
293 |
appModel respondTo:#showAbout with:[self information:'some info here ...']. |
|
294 |
appModel respondTo:#help with:[self information:'some help here ...']. |
|
128 | 295 |
|
593 | 296 |
top := StandardSystemView new. |
297 |
top extent:300@300. |
|
128 | 298 |
|
593 | 299 |
menu := PullDownMenu in:top. |
300 |
menu receiver:appModel. |
|
301 |
menu origin:0.0@0.0 corner:1.0@(menu height). |
|
77 | 302 |
|
593 | 303 |
textView := ScrollableView forView:(EditTextView new). |
304 |
textView origin:0.0@menu height corner:1.0@1.0. |
|
305 |
top addSubView:textView. |
|
128 | 306 |
|
593 | 307 |
labels := Array with:((Image fromFile:'SmalltalkX.xbm') magnifiedTo:16@16) |
308 |
with:'file' |
|
309 |
with:'edit' |
|
310 |
with:'help'. |
|
311 |
menu labels:labels. |
|
312 |
menu selectors:#(about file edit help). |
|
313 |
menu at:#about |
|
314 |
putLabels:#('about PullDownMenus') |
|
315 |
selectors:#(showAbout) |
|
316 |
receiver:appModel. |
|
317 |
menu at:#file |
|
318 |
putLabels:#('quit') |
|
319 |
selectors:#(quit) |
|
320 |
receiver:appModel. |
|
321 |
menu at:#edit |
|
322 |
putLabels:#('copy' 'cut' 'paste') |
|
323 |
selectors:#(copySelection cut paste) |
|
324 |
receiver:textView. |
|
325 |
top open |
|
326 |
[exEnd] |
|
3 | 327 |
" |
202 | 328 |
! ! |
329 |
||
330 |
!PullDownMenu class methodsFor:'instance creation'! |
|
331 |
||
332 |
labels:titleArray |
|
333 |
"create and return a new PullDownMenu" |
|
334 |
||
335 |
^ self new labels:titleArray |
|
3 | 336 |
! ! |
0 | 337 |
|
59 | 338 |
!PullDownMenu class methodsFor:'defaults'! |
339 |
||
340 |
updateStyleCache |
|
110 | 341 |
"extract values from the styleSheet and cache them in class variables" |
342 |
||
456 | 343 |
<resource: #style (#pullDownMenuViewBackground #menuViewBackground |
344 |
#pullDownMenuForegroundColor #menuForegroundColor |
|
345 |
#pullDownMenuBackgroundColor #menuBackgroundColor |
|
346 |
#pullDownMenuHilightForegroundColor #menuHilightForegroundColor |
|
347 |
#pullDownMenuHilightBackgroundColor #menuHilightBackgroundColor |
|
348 |
#pullDownMenuHilightLevel #menuHilightLevel |
|
349 |
#pullDownMenuEdgeStyle #pullDownMenuKeepMenu |
|
350 |
#pullDownMenuToggleKeep #pullDownMenuLevel |
|
351 |
#pullDownMenuFont #menuFont |
|
352 |
#pullDownMenuSeparatingLines)> |
|
353 |
||
133 | 354 |
|styleSheet| |
355 |
||
356 |
styleSheet := StyleSheet. |
|
357 |
||
358 |
DefaultViewBackground := styleSheet colorAt:'pullDownMenuViewBackground'. |
|
60 | 359 |
DefaultViewBackground isNil ifTrue:[ |
456 | 360 |
DefaultViewBackground := styleSheet colorAt:'menuViewBackground'. |
59 | 361 |
]. |
133 | 362 |
DefaultForegroundColor := styleSheet colorAt:'pullDownMenuForegroundColor'. |
60 | 363 |
DefaultForegroundColor isNil ifTrue:[ |
456 | 364 |
DefaultForegroundColor := styleSheet colorAt:'menuForegroundColor'. |
60 | 365 |
]. |
133 | 366 |
DefaultBackgroundColor := styleSheet colorAt:'pullDownMenuBackgroundColor'. |
60 | 367 |
DefaultBackgroundColor isNil ifTrue:[ |
456 | 368 |
DefaultViewBackground notNil ifTrue:[ |
369 |
DefaultBackgroundColor := DefaultViewBackground |
|
370 |
] ifFalse:[ |
|
371 |
DefaultBackgroundColor := styleSheet colorAt:'menuBackgroundColor'. |
|
372 |
] |
|
59 | 373 |
]. |
133 | 374 |
DefaultHilightForegroundColor := styleSheet colorAt:'pullDownMenuHilightForegroundColor'. |
60 | 375 |
DefaultHilightForegroundColor isNil ifTrue:[ |
456 | 376 |
DefaultHilightForegroundColor := styleSheet colorAt:'menuHilightForegroundColor'. |
59 | 377 |
]. |
133 | 378 |
DefaultHilightBackgroundColor := styleSheet colorAt:'pullDownMenuHilightBackgroundColor'. |
60 | 379 |
DefaultHilightBackgroundColor isNil ifTrue:[ |
456 | 380 |
DefaultHilightBackgroundColor := styleSheet colorAt:'menuHilightBackgroundColor'. |
59 | 381 |
]. |
133 | 382 |
DefaultHilightLevel := styleSheet at:'pullDownMenuHilightLevel'. |
60 | 383 |
DefaultHilightLevel isNil ifTrue:[ |
456 | 384 |
DefaultHilightLevel := styleSheet at:'menuHilightLevel' default:0. |
59 | 385 |
]. |
133 | 386 |
DefaultEdgeStyle := styleSheet at:'pullDownMenuEdgeStyle'. |
387 |
DefaultKeepMenu := styleSheet at:'pullDownMenuKeepMenu' default:false. |
|
388 |
DefaultToggleKeep := styleSheet at:'pullDownMenuToggleKeep' default:false. |
|
389 |
DefaultLevel := styleSheet at:'pullDownMenuLevel' default:1. |
|
390 |
DefaultFont := styleSheet fontAt:'pullDownMenuFont'. |
|
392
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
391 |
DefaultFont isNil ifTrue:[DefaultFont := styleSheet fontAt:'menuFont']. |
133 | 392 |
DefaultSeparatingLines := styleSheet at:'pullDownMenuSeparatingLines' default:false. |
110 | 393 |
|
394 |
" |
|
395 |
PullDownMenu updateStyleCache |
|
396 |
" |
|
456 | 397 |
|
398 |
"Modified: 1.3.1996 / 13:45:19 / cg" |
|
59 | 399 |
! ! |
400 |
||
202 | 401 |
!PullDownMenu methodsFor:'accessing'! |
402 |
||
542 | 403 |
actionAt:stringOrNumber |
404 |
"return the actionBlock associated with stringOrNumber; |
|
405 |
nil if there is none (but there may be still a selector there)." |
|
406 |
||
407 |
|index| |
|
408 |
||
409 |
actions isNil ifTrue:[^ nil]. |
|
410 |
index := self indexOf:stringOrNumber. |
|
411 |
(index == 0) ifTrue:[^ nil]. |
|
412 |
^ actions at:index ifAbsent:nil |
|
413 |
||
414 |
"Modified: 24.3.1996 / 17:09:56 / cg" |
|
415 |
"Created: 17.4.1996 / 20:50:45 / cg" |
|
416 |
! |
|
417 |
||
418 |
actionAt:stringOrNumber put:aBlock |
|
419 |
"return the actionBlock associated with stringOrNumber; |
|
420 |
nil if there is none (but there may be still a selector there)." |
|
421 |
||
422 |
|index newActions| |
|
423 |
||
424 |
index := self indexOf:stringOrNumber. |
|
425 |
(index == 0) ifTrue:[^ nil]. |
|
426 |
actions size < index ifTrue:[ |
|
427 |
newActions := Array new:index. |
|
428 |
newActions replaceFrom:1 to:actions size with:actions. |
|
429 |
actions := newActions |
|
430 |
]. |
|
431 |
actions at:index put:aBlock |
|
432 |
||
433 |
"Modified: 24.3.1996 / 17:09:56 / cg" |
|
434 |
"Created: 17.4.1996 / 20:52:13 / cg" |
|
435 |
! |
|
436 |
||
283 | 437 |
add:label selector:selector |
309
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
438 |
"add a new title-item at the end. |
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
439 |
The corresponding label can later be set with #at:putMenu: |
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
440 |
or #at:putLabels:selectors:..." |
283 | 441 |
|
309
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
442 |
self add:label selector:selector after:nil |
283 | 443 |
! |
444 |
||
445 |
add:label selector:selector after:indexOrString |
|
532
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
446 |
"add a new title-item after an existing item, indexOrString, |
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
447 |
or at the end if the after-arg is nil. |
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
448 |
The corresponding label can later be set with #at:putMenu: |
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
449 |
or #at:putLabels:selectors:..." |
283 | 450 |
|
532
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
451 |
|idx| |
283 | 452 |
|
532
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
453 |
indexOrString isNil ifTrue:[ |
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
454 |
idx := titles size |
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
455 |
] ifFalse:[ |
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
456 |
idx := self indexOf:indexOrString. |
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
457 |
]. |
283 | 458 |
|
532
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
459 |
titles isNil ifTrue:[ |
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
460 |
menus := Array with:nil. |
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
461 |
titles := Array with:label. |
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
462 |
selectors := Array with:selector. |
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
463 |
] ifFalse:[ |
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
464 |
menus := (menus copyTo:idx) , #(nil) , (menus copyFrom:idx+1). |
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
465 |
titles := ((titles copyTo:idx) copyWith:label) , (titles copyFrom:idx+1). |
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
466 |
selectors := ((selectors copyTo:idx) copyWith:selector) , (selectors copyFrom:idx+1). |
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
467 |
]. |
283 | 468 |
|
532
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
469 |
" |
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
470 |
|top m| |
283 | 471 |
|
532
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
472 |
top := StandardSystemView new. |
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
473 |
m := PullDownMenu in:top. |
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
474 |
m labels:#('file' 'edit'). |
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
475 |
m selectors:#(file #edit). |
283 | 476 |
|
532
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
477 |
m add:'help' selector:#help after:#file. |
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
478 |
m at:#help putMenu:(MenuView labels:#('foo' 'bar') |
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
479 |
selectors:#(foo bar) |
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
480 |
receiver:nil). |
283 | 481 |
|
532
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
482 |
top open |
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
483 |
" |
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
484 |
|
689d1c622a14
oops - adding to an empty menu forgor selector
Claus Gittinger <cg@exept.de>
parents:
518
diff
changeset
|
485 |
"Modified: 12.4.1996 / 19:02:47 / cg" |
283 | 486 |
! |
487 |
||
202 | 488 |
at:aString putLabels:labels selector:selector args:args receiver:anObject |
489 |
"create and set the menu under the title, aString" |
|
490 |
||
491 |
|menuView| |
|
492 |
||
493 |
menuView := MenuView labels:labels |
|
494 |
selector:selector |
|
495 |
args:args |
|
496 |
receiver:anObject |
|
497 |
for:self. |
|
498 |
self at:aString putMenu:menuView |
|
499 |
! |
|
500 |
||
518
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
516
diff
changeset
|
501 |
at:aString putLabels:labels selectors:selectors |
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
516
diff
changeset
|
502 |
"create and set the menu under the title, aString" |
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
516
diff
changeset
|
503 |
|
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
516
diff
changeset
|
504 |
^ self at:aString putLabels:labels selectors:selectors receiver:nil |
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
516
diff
changeset
|
505 |
|
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
516
diff
changeset
|
506 |
"Created: 24.3.1996 / 17:06:45 / cg" |
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
516
diff
changeset
|
507 |
! |
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
516
diff
changeset
|
508 |
|
202 | 509 |
at:aString putLabels:labels selectors:selectors args:args receiver:anObject |
510 |
"create and set the menu under the title, aString" |
|
511 |
||
512 |
|menuView| |
|
513 |
||
514 |
menuView := MenuView labels:labels |
|
515 |
selectors:selectors |
|
516 |
args:args |
|
517 |
receiver:anObject |
|
518 |
for:self. |
|
519 |
self at:aString putMenu:menuView |
|
520 |
! |
|
521 |
||
522 |
at:aString putLabels:labels selectors:selectors receiver:anObject |
|
523 |
"create and set the menu under the title, aString" |
|
524 |
||
525 |
|menuView| |
|
526 |
||
527 |
menuView := MenuView labels:labels |
|
528 |
selectors:selectors |
|
529 |
receiver:anObject |
|
530 |
for:self. |
|
531 |
self at:aString putMenu:menuView |
|
532 |
! |
|
533 |
||
534 |
at:aString putMenu:aMenu |
|
535 |
"set the menu under the title, aString" |
|
536 |
||
537 |
|index| |
|
538 |
||
539 |
index := self indexOf:aString. |
|
540 |
(index == 0) ifTrue:[ |
|
620
f513bc136ab7
renamed #superView: to #container (migration towards ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
541 |
self error:'no such menu entry'. |
f513bc136ab7
renamed #superView: to #container (migration towards ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
542 |
^ nil |
202 | 543 |
]. |
544 |
||
545 |
"/ not needed: |
|
546 |
"/ aMenu origin:((left + (self titleLenUpTo:index)) |
|
547 |
"/ @ |
|
548 |
"/ (height + aMenu borderWidth)). |
|
620
f513bc136ab7
renamed #superView: to #container (migration towards ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
549 |
aMenu container:(self superView). |
291 | 550 |
aMenu beInvisible. |
202 | 551 |
menus at:index put:aMenu. |
552 |
aMenu masterView:self. |
|
620
f513bc136ab7
renamed #superView: to #container (migration towards ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
553 |
|
f513bc136ab7
renamed #superView: to #container (migration towards ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
554 |
"Modified: 9.5.1996 / 00:43:28 / cg" |
202 | 555 |
! |
556 |
||
557 |
labels |
|
558 |
"return the menu-titles (group-headers)" |
|
559 |
||
560 |
^ titles |
|
561 |
! |
|
0 | 562 |
|
563 |
labels:titleArray |
|
202 | 564 |
"define the menu-titles (group-headers)" |
565 |
||
566 |
|numberOfLabels| |
|
567 |
||
568 |
numberOfLabels := titleArray size. |
|
569 |
menus := Array new:numberOfLabels. |
|
570 |
titles := Array new:numberOfLabels. |
|
571 |
||
572 |
titleArray keysAndValuesDo:[:index :entry | |
|
573 |
|e| |
|
574 |
||
575 |
entry isImage ifTrue:[ |
|
576 |
e := entry on:device |
|
577 |
] ifFalse:[ |
|
578 |
e := entry printString |
|
579 |
]. |
|
580 |
titles at:index put:e |
|
581 |
]. |
|
582 |
shown ifTrue:[ |
|
583 |
self clear. |
|
584 |
self redraw |
|
585 |
] |
|
586 |
! |
|
587 |
||
588 |
labels:titleArray selectors:selectorArray |
|
589 |
"define the menu-titles (group-headers) and selectors. |
|
590 |
Selectors are mostly used as access keys to get to submenus later." |
|
591 |
||
592 |
self labels:titleArray. |
|
593 |
self selectors:selectorArray |
|
594 |
||
595 |
"Created: 20.10.1995 / 20:15:54 / cg" |
|
596 |
! |
|
597 |
||
598 |
menuAt:stringOrNumber |
|
518
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
516
diff
changeset
|
599 |
"return the menu with the title; nil if not found" |
202 | 600 |
|
518
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
516
diff
changeset
|
601 |
^ self subMenuAt:stringOrNumber |
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
516
diff
changeset
|
602 |
|
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
516
diff
changeset
|
603 |
"Modified: 24.3.1996 / 17:10:11 / cg" |
202 | 604 |
! |
605 |
||
606 |
numberOfTitles:n |
|
607 |
"setup blank title-space to be filled in later" |
|
608 |
||
609 |
menus := Array new:n. |
|
610 |
titles := Array new:n |
|
611 |
! |
|
612 |
||
613 |
receiver:anObject |
|
614 |
"set the menu-receiver. Thats the one who gets the |
|
615 |
messages (both from myself and from my submenus). |
|
616 |
This only sets the receiver for menus which are already |
|
617 |
created - menus added later should get their receiver in |
|
618 |
the creation send." |
|
619 |
||
620 |
receiver := anObject. |
|
621 |
menus notNil ifTrue:[ |
|
622 |
menus do:[:aMenu | |
|
623 |
aMenu notNil ifTrue:[ |
|
624 |
aMenu receiver:anObject |
|
625 |
] |
|
626 |
] |
|
627 |
] |
|
628 |
! |
|
629 |
||
283 | 630 |
selectors |
631 |
"return the menu-selectors" |
|
632 |
||
633 |
^ selectors |
|
634 |
! |
|
635 |
||
202 | 636 |
selectors:selectorArray |
637 |
"define the menu-selectors. These are used as accesskey only |
|
638 |
in menuAt: accesses. This makes PullDownMenu accesss |
|
639 |
somewhat more compatible to PopUpMenus." |
|
640 |
||
605
11b03282d684
copy selectors, args & shortKeys
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
641 |
selectors := selectorArray copy. |
283 | 642 |
|
605
11b03282d684
copy selectors, args & shortKeys
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
643 |
"Modified: 30.4.1996 / 15:57:04 / cg" |
518
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
516
diff
changeset
|
644 |
! |
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
516
diff
changeset
|
645 |
|
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
516
diff
changeset
|
646 |
subMenuAt:stringOrNumber |
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
516
diff
changeset
|
647 |
"return the menu with the title; nil if not found." |
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
516
diff
changeset
|
648 |
|
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
516
diff
changeset
|
649 |
|index| |
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
516
diff
changeset
|
650 |
|
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
516
diff
changeset
|
651 |
index := self indexOf:stringOrNumber. |
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
516
diff
changeset
|
652 |
(index == 0) ifTrue:[^ nil]. |
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
516
diff
changeset
|
653 |
^ menus at:index |
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
516
diff
changeset
|
654 |
|
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
516
diff
changeset
|
655 |
"Modified: 24.3.1996 / 17:09:56 / cg" |
202 | 656 |
! ! |
657 |
||
658 |
!PullDownMenu methodsFor:'accessing-look'! |
|
659 |
||
660 |
backgroundColor:aColor |
|
661 |
"set the background drawing color. |
|
662 |
You should not use this method; instead leave the value as |
|
663 |
defined in the styleSheet." |
|
664 |
||
665 |
bgColor := aColor on:device |
|
666 |
! |
|
667 |
||
668 |
font:aFont |
|
669 |
"set the menus font. |
|
670 |
adjusts menu-origins when font changes. |
|
671 |
You should not use this method; instead leave the value as |
|
665 | 672 |
defined in the styleSheet. |
673 |
CAVEAT: with the addition of Text objects, |
|
674 |
this method is going to be obsoleted by a textStyle |
|
675 |
method, which allows specific control over |
|
676 |
normalFont/boldFont/italicFont parameters." |
|
202 | 677 |
|
678 |
aFont ~~ font ifTrue:[ |
|
665 | 679 |
super font:(aFont on:device). |
680 |
self height:(font height + (font descent * 2)). |
|
681 |
shown ifTrue:[ |
|
682 |
self setMenuOrigins |
|
683 |
] |
|
202 | 684 |
] |
665 | 685 |
|
686 |
"Modified: 22.5.1996 / 12:37:04 / cg" |
|
202 | 687 |
! |
688 |
||
689 |
foregroundColor:aColor |
|
690 |
"set the foreground drawing color. |
|
691 |
You should not use this method; instead leave the value as |
|
692 |
defined in the styleSheet." |
|
693 |
||
694 |
fgColor := aColor on:device |
|
695 |
! |
|
696 |
||
697 |
showSeparatingLines:aBoolean |
|
698 |
"turn on/off drawing of separating lines. |
|
699 |
You should not use this method; instead leave the value as |
|
700 |
defined in the styleSheet." |
|
701 |
||
702 |
showSeparatingLines := aBoolean. |
|
703 |
shown ifTrue:[ |
|
704 |
self setMenuOrigins. |
|
705 |
self redraw |
|
706 |
] |
|
707 |
! ! |
|
708 |
||
709 |
!PullDownMenu methodsFor:'drawing '! |
|
710 |
||
711 |
drawActiveTitleSelected:selected |
|
712 |
|x| |
|
713 |
activeMenuNumber notNil ifTrue:[ |
|
714 |
x := self titleLenUpTo:activeMenuNumber. |
|
715 |
self drawTitle:(titles at:activeMenuNumber) x:x selected:selected |
|
716 |
] |
|
717 |
! |
|
718 |
||
719 |
drawTitle:stringOrImage x:x0 selected:selected |
|
720 |
|y w x wSpace fg bg map| |
|
721 |
||
722 |
selected ifTrue:[ |
|
723 |
fg := activeFgColor. |
|
724 |
bg := activeBgColor |
|
725 |
] ifFalse:[ |
|
726 |
fg := fgColor. |
|
727 |
bg := bgColor |
|
728 |
]. |
|
729 |
||
730 |
wSpace := font widthOf:' '. |
|
731 |
x := x0. |
|
732 |
stringOrImage isString ifTrue:[ |
|
733 |
y := ((height - (font height)) // 2) + (font ascent) "+ topMargin". |
|
734 |
w := font widthOf:stringOrImage. |
|
735 |
] ifFalse:[ |
|
736 |
y := ((height - stringOrImage height) // 2) max:0. |
|
737 |
w := stringOrImage width |
|
738 |
]. |
|
739 |
w := w + (wSpace * 2). |
|
740 |
||
741 |
self paint:bg. |
|
742 |
self fillRectangleX:x y:0 width:w height:height. |
|
743 |
||
744 |
self is3D ifTrue:[ |
|
745 |
self drawEdgesForX:x y:0 |
|
746 |
width:w |
|
747 |
height:height |
|
748 |
level:(selected ifTrue:[onLevel] ifFalse:[offLevel]) |
|
749 |
]. |
|
250
77012e65ac84
draw strings as opaque strings - OS/2 server has a bug with non-image strings
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
750 |
self paint:fg on:bg. |
202 | 751 |
x := x + wSpace. |
752 |
stringOrImage isString ifTrue:[ |
|
250
77012e65ac84
draw strings as opaque strings - OS/2 server has a bug with non-image strings
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
753 |
self displayOpaqueString:stringOrImage x:x y:y |
202 | 754 |
] ifFalse:[ |
755 |
stringOrImage isImageOrForm ifTrue:[ |
|
756 |
stringOrImage depth == 1 ifTrue:[ |
|
757 |
(map := stringOrImage colorMap) notNil ifTrue:[ |
|
758 |
self paint:(map at:2) on:(map at:1). |
|
759 |
self displayOpaqueForm:stringOrImage x:x y:y. |
|
760 |
^ self |
|
761 |
] |
|
762 |
]. |
|
763 |
self displayForm:stringOrImage x:x y:y |
|
764 |
] ifFalse:[ |
|
765 |
stringOrImage displayOn:self x:x y:y |
|
766 |
] |
|
767 |
] |
|
768 |
||
769 |
"Modified: 20.10.1995 / 22:03:27 / cg" |
|
770 |
! |
|
771 |
||
772 |
highlightActiveTitle |
|
773 |
self drawActiveTitleSelected:true |
|
774 |
! |
|
775 |
||
776 |
redraw |
|
777 |
|x "{ Class: SmallInteger }" |
|
778 |
y "{ Class: SmallInteger }" |
|
779 |
index "{ Class: SmallInteger }" |
|
780 |
wSpace clr| |
|
781 |
||
782 |
shown ifFalse: [ ^ self ]. |
|
783 |
titles isNil ifTrue:[^ self]. |
|
784 |
||
785 |
wSpace := (font widthOf:' '). |
|
786 |
x := 0. |
|
787 |
y := height "- 1". |
|
788 |
index := 1. |
|
789 |
titles do:[:title | |
|
790 |
self drawTitle:title x:x selected:(index == activeMenuNumber). |
|
791 |
||
792 |
title isString ifTrue:[ |
|
793 |
x := x + (font widthOf:title). |
|
794 |
] ifFalse:[ |
|
795 |
x := x + title width |
|
796 |
]. |
|
797 |
x := x + wSpace + wSpace. |
|
798 |
showSeparatingLines ifTrue:[ |
|
799 |
self is3D ifTrue:[ |
|
800 |
self paint:shadowColor. |
|
801 |
self displayLineFromX:x y:0 toX:x y:y. |
|
802 |
x := x + 1. |
|
803 |
clr := lightColor. |
|
804 |
] ifFalse:[ |
|
805 |
clr := fgColor. |
|
806 |
]. |
|
807 |
self paint:clr. |
|
808 |
self displayLineFromX:x y:0 toX:x y:y. |
|
809 |
x := x + 1 |
|
810 |
]. |
|
811 |
index := index + 1 |
|
812 |
] |
|
813 |
! |
|
814 |
||
815 |
unHighlightActiveTitle |
|
816 |
self drawActiveTitleSelected:false |
|
817 |
! ! |
|
818 |
||
819 |
!PullDownMenu methodsFor:'event handling'! |
|
820 |
||
821 |
buttonMotion:state x:x y:y |
|
822 |
|titleIndex activeMenu activeLeft activeTop| |
|
823 |
||
824 |
state == 0 ifTrue:[^ self]. |
|
825 |
||
826 |
activeMenuNumber notNil ifTrue:[ |
|
684 | 827 |
activeMenu := menus at:activeMenuNumber. |
202 | 828 |
]. |
0 | 829 |
|
202 | 830 |
(y < height) ifTrue:[ |
684 | 831 |
"moving around in title line" |
832 |
activeMenu notNil ifTrue:[ |
|
833 |
activeMenu setSelection:nil |
|
834 |
]. |
|
835 |
titleIndex := self titleIndexForX:x. |
|
836 |
titleIndex notNil ifTrue:[ |
|
837 |
(titleIndex ~~ activeMenuNumber) ifTrue:[ |
|
838 |
self pullMenu:titleIndex |
|
839 |
] |
|
840 |
] ifFalse:[ |
|
841 |
self hideActiveMenu |
|
842 |
] |
|
202 | 843 |
] ifFalse:[ |
684 | 844 |
"moving around below" |
845 |
activeMenu isNil ifTrue:[^self]. |
|
846 |
activeLeft := activeMenu left. |
|
847 |
(x between:activeLeft and:(activeMenu right)) ifTrue:[ |
|
848 |
activeTop := activeMenu top. |
|
849 |
(y between:activeTop and:(activeMenu bottom)) ifTrue:[ |
|
850 |
"moving around in menu" |
|
851 |
activeMenu buttonMotion:state |
|
852 |
x:(x - activeLeft) |
|
853 |
y:(y - activeTop). |
|
854 |
^ self |
|
855 |
] |
|
856 |
]. |
|
857 |
"moved outside menu" |
|
858 |
activeMenu setSelection:nil |
|
202 | 859 |
] |
684 | 860 |
|
861 |
"Modified: 25.5.1996 / 12:28:32 / cg" |
|
202 | 862 |
! |
863 |
||
864 |
buttonPress:button x:x y:y |
|
865 |
|titleIndex activeMenu activeLeft activeTop m| |
|
866 |
||
867 |
device ungrabPointer. |
|
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
868 |
device ungrabKeyboard. |
202 | 869 |
|
870 |
(y between:0 and:height) ifTrue:[ |
|
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
871 |
titleIndex := self titleIndexForX:x. |
202 | 872 |
]. |
873 |
||
874 |
" |
|
875 |
now, titleIndex is non-nil if pressed within myself |
|
876 |
" |
|
877 |
(titleIndex notNil and:[titleIndex ~~ activeMenuNumber]) ifTrue:[ |
|
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
878 |
m := self pullMenu:titleIndex. |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
879 |
(keepMenu and:[m notNil]) ifTrue:[ |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
880 |
device grabPointerInView:self. |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
881 |
device grabKeyboardInView:self. |
484 | 882 |
"/ self cursor:Cursor upRightArrow |
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
883 |
] |
202 | 884 |
] ifFalse:[ |
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
885 |
(keepMenu and:[toggleKeep not]) ifTrue:[ |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
886 |
titleIndex == activeMenuNumber ifTrue:[ |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
887 |
"same pressed again ... stay" |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
888 |
titleIndex notNil ifTrue:[ |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
889 |
device grabPointerInView:self. |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
890 |
device grabKeyboardInView:self. |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
891 |
]. |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
892 |
^ self |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
893 |
]. |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
894 |
"moving around below" |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
895 |
activeMenuNumber isNil ifTrue:[^self]. |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
896 |
activeMenu := menus at:activeMenuNumber. |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
897 |
activeLeft := activeMenu left. |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
898 |
(x between:activeLeft and:(activeMenu right)) ifTrue:[ |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
899 |
activeTop := activeMenu top. |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
900 |
(y between:activeTop and:(activeMenu bottom)) ifTrue:[ |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
901 |
"moving around in menu" |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
902 |
activeMenu buttonPress:button |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
903 |
x:(x - activeLeft) |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
904 |
y:(y - activeTop). |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
905 |
^ self |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
906 |
] |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
907 |
]. |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
908 |
]. |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
909 |
self hideActiveMenu |
202 | 910 |
] |
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
911 |
|
484 | 912 |
"Modified: 6.3.1996 / 17:14:16 / cg" |
202 | 913 |
! |
914 |
||
915 |
buttonRelease:button x:x y:y |
|
916 |
|activeMenu activeLeft activeTop hideMenu sel| |
|
917 |
||
918 |
activeMenuNumber isNil ifTrue:[^self]. |
|
919 |
activeMenu := menus at:activeMenuNumber. |
|
920 |
||
921 |
hideMenu := false. |
|
922 |
(y >= height) ifTrue:[ |
|
542 | 923 |
"release below title-line" |
924 |
activeLeft := activeMenu left. |
|
925 |
" |
|
926 |
released in a submenu ? |
|
927 |
" |
|
928 |
(x between:activeLeft and:(activeMenu right)) ifTrue:[ |
|
929 |
activeTop := activeMenu top. |
|
930 |
(y between:activeTop and:(activeMenu bottom)) ifTrue:[ |
|
931 |
"release in menu" |
|
932 |
self hideActiveMenu. |
|
933 |
activeMenu buttonRelease:button |
|
934 |
x:(x - activeLeft) |
|
935 |
y:(y - activeTop). |
|
936 |
^ self |
|
937 |
] |
|
938 |
]. |
|
939 |
hideMenu := true. |
|
202 | 940 |
] ifFalse:[ |
542 | 941 |
y < 0 ifTrue:[ |
942 |
hideMenu := true |
|
943 |
] ifFalse:[ |
|
944 |
activeMenu isNil ifTrue:[ |
|
945 |
self performSelectedAction. |
|
946 |
hideMenu := true. |
|
947 |
] ifFalse:[ |
|
948 |
keepMenu ifFalse:[ |
|
949 |
hideMenu := true |
|
950 |
] |
|
951 |
] |
|
952 |
] |
|
202 | 953 |
]. |
954 |
hideMenu ifTrue:[ |
|
955 |
self hideActiveMenu. |
|
956 |
] |
|
542 | 957 |
|
958 |
"Modified: 17.4.1996 / 20:56:08 / cg" |
|
202 | 959 |
! |
960 |
||
961 |
keyPress:key x:x y:y |
|
491 | 962 |
|
202 | 963 |
<resource: #keyboard (#CursorLeft #CursorRight #MenuSelect)> |
964 |
||
513
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
965 |
|index startIndex m sel| |
202 | 966 |
|
967 |
" |
|
968 |
handle CursorLeft/Right for non-mouse operation |
|
969 |
(for example, if it has the explicit focus) |
|
970 |
These will pull the previous/next menu |
|
971 |
" |
|
972 |
((key == #CursorRight) or:[key == #CursorLeft]) ifTrue:[ |
|
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
973 |
activeMenuNumber isNil ifTrue:[ |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
974 |
index := (key == #CursorRight) ifTrue:[1] ifFalse:[menus size]. |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
975 |
] ifFalse:[ |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
976 |
(key == #CursorRight) ifTrue:[ |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
977 |
index := activeMenuNumber+1 |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
978 |
] ifFalse:[ |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
979 |
index := activeMenuNumber-1 |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
980 |
]. |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
981 |
index == 0 ifTrue:[index := menus size] |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
982 |
ifFalse:[ |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
983 |
index > menus size ifTrue:[index := 1] |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
984 |
] |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
985 |
]. |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
986 |
self pullMenu:index. |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
987 |
^ self |
202 | 988 |
]. |
989 |
||
513
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
990 |
"/ activeMenuNumber isNil ifTrue:[ |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
991 |
"/ |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
992 |
"/ find an item starting with that alpha-key |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
993 |
"/ |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
994 |
key isCharacter ifTrue:[ |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
995 |
(key isLetter) ifTrue:[ |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
996 |
activeMenuNumber isNil ifTrue:[ |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
997 |
startIndex := 1. |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
998 |
] ifFalse:[ |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
999 |
startIndex := activeMenuNumber + 1 |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1000 |
]. |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1001 |
index := titles |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1002 |
findFirst:[:item | |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1003 |
item isString |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1004 |
and:[(item startsWith:key asUppercase) |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1005 |
or:[item startsWith:key asLowercase]]] |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1006 |
startingAt:startIndex. |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1007 |
|
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1008 |
(index == 0 and:[startIndex ~~ 1]) ifTrue:[ |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1009 |
index := titles |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1010 |
findFirst:[:item | |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1011 |
item isString |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1012 |
and:[(item startsWith:key asUppercase) |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1013 |
or:[item startsWith:key asLowercase]]] |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1014 |
startingAt:1. |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1015 |
]. |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1016 |
|
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1017 |
index ~~ 0 ifTrue:[ |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1018 |
self pullMenu:index. |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1019 |
]. |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1020 |
^ self |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1021 |
] |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1022 |
]. |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1023 |
"/ ]. |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1024 |
|
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1025 |
activeMenuNumber isNil ifTrue:[ |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1026 |
^ super keyPress:key x:x y:y |
97fe3c60042b
quick item select (press alpha key for item)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1027 |
]. |
202 | 1028 |
|
1029 |
" |
|
1030 |
Return, space or the (virtual) MenuSelect key trigger |
|
1031 |
a menu entry (for non-submenu entries). |
|
1032 |
Otherwise, if we have a submenu open, |
|
1033 |
pass the key on to it ... |
|
1034 |
" |
|
1035 |
m := menus at:activeMenuNumber. |
|
1036 |
m isNil ifTrue:[ |
|
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1037 |
(key == #Return |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1038 |
or:[key == #MenuSelect |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1039 |
or:[key == Character space]]) ifTrue:[ |
542 | 1040 |
self performSelectedAction. |
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1041 |
]. |
202 | 1042 |
] ifFalse:[ |
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1043 |
m keyPress:key x:0 y:0. |
202 | 1044 |
]. |
491 | 1045 |
|
542 | 1046 |
"Modified: 17.4.1996 / 20:56:20 / cg" |
202 | 1047 |
! |
1048 |
||
309
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
1049 |
showNoFocus:explicit |
202 | 1050 |
"when stepping focus, hide any active menu" |
1051 |
||
1052 |
self hideActiveMenu. |
|
309
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
1053 |
super showNoFocus:explicit |
202 | 1054 |
! ! |
1055 |
||
1056 |
!PullDownMenu methodsFor:'hiding/showing menus'! |
|
1057 |
||
317
f23de8b78f5e
Escape closes pullDownMenus & PopUpLists
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1058 |
hide |
f23de8b78f5e
Escape closes pullDownMenus & PopUpLists
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1059 |
"sent by an aborted menu" |
f23de8b78f5e
Escape closes pullDownMenus & PopUpLists
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1060 |
|
f23de8b78f5e
Escape closes pullDownMenus & PopUpLists
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1061 |
self hideActiveMenu. |
f23de8b78f5e
Escape closes pullDownMenus & PopUpLists
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1062 |
! |
f23de8b78f5e
Escape closes pullDownMenus & PopUpLists
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1063 |
|
202 | 1064 |
hideActiveMenu |
1065 |
"hide currently active menu - release grab if there is any grab (keepMenu)" |
|
1066 |
||
1067 |
^ self hideActiveMenuRelease:true |
|
1068 |
! |
|
1069 |
||
1070 |
hideActiveMenuRelease:aBoolean |
|
1071 |
"hide currently active menu - release grab if aBoolean is true |
|
1072 |
and a grab was set (keepMenu)" |
|
1073 |
||
1074 |
|m| |
|
1075 |
||
1076 |
activeMenuNumber notNil ifTrue:[ |
|
476
c101043c91f7
oops - must release the keyboard as well
Claus Gittinger <cg@exept.de>
parents:
465
diff
changeset
|
1077 |
(m := menus at:activeMenuNumber) notNil ifTrue:[ |
c101043c91f7
oops - must release the keyboard as well
Claus Gittinger <cg@exept.de>
parents:
465
diff
changeset
|
1078 |
m beInvisible. |
c101043c91f7
oops - must release the keyboard as well
Claus Gittinger <cg@exept.de>
parents:
465
diff
changeset
|
1079 |
]. |
c101043c91f7
oops - must release the keyboard as well
Claus Gittinger <cg@exept.de>
parents:
465
diff
changeset
|
1080 |
self unHighlightActiveTitle. |
c101043c91f7
oops - must release the keyboard as well
Claus Gittinger <cg@exept.de>
parents:
465
diff
changeset
|
1081 |
activeMenuNumber := nil |
202 | 1082 |
]. |
1083 |
aBoolean ifTrue:[ |
|
476
c101043c91f7
oops - must release the keyboard as well
Claus Gittinger <cg@exept.de>
parents:
465
diff
changeset
|
1084 |
device ungrabKeyboard. |
c101043c91f7
oops - must release the keyboard as well
Claus Gittinger <cg@exept.de>
parents:
465
diff
changeset
|
1085 |
device ungrabPointer. |
484 | 1086 |
"/ self cursor:Cursor normal |
202 | 1087 |
]. |
476
c101043c91f7
oops - must release the keyboard as well
Claus Gittinger <cg@exept.de>
parents:
465
diff
changeset
|
1088 |
|
484 | 1089 |
"Modified: 6.3.1996 / 17:14:21 / cg" |
202 | 1090 |
! |
1091 |
||
1092 |
pullMenu:aNumber |
|
1093 |
"activate a menu, return it or nil" |
|
1094 |
||
1095 |
|subMenu r posY| |
|
1096 |
||
1097 |
activeMenuNumber notNil ifTrue:[self hideActiveMenuRelease:false]. |
|
1098 |
activeMenuNumber := aNumber. |
|
1099 |
subMenu := menus at:aNumber. |
|
1100 |
||
1101 |
raiseTopWhenActivated ifTrue:[ |
|
631
3b50fb0a505e
support autoSelect of first item (motif style)
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
1102 |
self topView raise. |
202 | 1103 |
]. |
1104 |
||
1105 |
(activeMenuNumber notNil |
|
1106 |
and:[ |
|
631
3b50fb0a505e
support autoSelect of first item (motif style)
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
1107 |
subMenu notNil |
3b50fb0a505e
support autoSelect of first item (motif style)
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
1108 |
or:[selectors notNil and:[(selectors at:activeMenuNumber) notNil]]]) ifTrue:[ |
3b50fb0a505e
support autoSelect of first item (motif style)
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
1109 |
self highlightActiveTitle. |
3b50fb0a505e
support autoSelect of first item (motif style)
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
1110 |
]. |
202 | 1111 |
|
1112 |
subMenu notNil ifTrue:[ |
|
631
3b50fb0a505e
support autoSelect of first item (motif style)
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
1113 |
subMenu origin:((left + (self titleLenUpTo:aNumber)) |
3b50fb0a505e
support autoSelect of first item (motif style)
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
1114 |
@ |
3b50fb0a505e
support autoSelect of first item (motif style)
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
1115 |
(posY := height + subMenu borderWidth)). |
3b50fb0a505e
support autoSelect of first item (motif style)
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
1116 |
subMenu hiddenOnRealize:false. |
684 | 1117 |
subMenu setSelection:nil. |
631
3b50fb0a505e
support autoSelect of first item (motif style)
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
1118 |
subMenu create. |
3b50fb0a505e
support autoSelect of first item (motif style)
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
1119 |
subMenu saveUnder:true. |
3b50fb0a505e
support autoSelect of first item (motif style)
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
1120 |
subMenu superMenu:self. |
202 | 1121 |
|
631
3b50fb0a505e
support autoSelect of first item (motif style)
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
1122 |
subMenu right > (r := self right) ifTrue:[ |
3b50fb0a505e
support autoSelect of first item (motif style)
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
1123 |
subMenu origin:((r - subMenu width) @ posY). |
3b50fb0a505e
support autoSelect of first item (motif style)
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
1124 |
]. |
3b50fb0a505e
support autoSelect of first item (motif style)
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
1125 |
subMenu raise show. |
3b50fb0a505e
support autoSelect of first item (motif style)
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
1126 |
|
3b50fb0a505e
support autoSelect of first item (motif style)
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
1127 |
(styleSheet at:#pullDownMenuAutoselectFirst) == true ifTrue:[ |
684 | 1128 |
subMenu setSelection:1 |
631
3b50fb0a505e
support autoSelect of first item (motif style)
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
1129 |
] |
202 | 1130 |
]. |
1131 |
^ subMenu |
|
631
3b50fb0a505e
support autoSelect of first item (motif style)
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
1132 |
|
684 | 1133 |
"Modified: 25.5.1996 / 13:02:58 / cg" |
202 | 1134 |
! |
1135 |
||
1136 |
regainControl |
|
1137 |
keepMenu ifTrue:[ |
|
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1138 |
device grabPointerInView:self. |
476
c101043c91f7
oops - must release the keyboard as well
Claus Gittinger <cg@exept.de>
parents:
465
diff
changeset
|
1139 |
device grabKeyboardInView:self. |
484 | 1140 |
"/ self cursor:Cursor upRightArrow |
202 | 1141 |
] |
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1142 |
|
484 | 1143 |
"Modified: 6.3.1996 / 17:14:27 / cg" |
0 | 1144 |
! ! |
1145 |
||
77 | 1146 |
!PullDownMenu methodsFor:'initialize / release'! |
0 | 1147 |
|
620
f513bc136ab7
renamed #superView: to #container (migration towards ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
1148 |
container:aView |
f513bc136ab7
renamed #superView: to #container (migration towards ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
1149 |
"when my container changes, all of my menus must change as well" |
f513bc136ab7
renamed #superView: to #container (migration towards ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
1150 |
|
f513bc136ab7
renamed #superView: to #container (migration towards ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
1151 |
super container:aView. |
f513bc136ab7
renamed #superView: to #container (migration towards ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
1152 |
|
f513bc136ab7
renamed #superView: to #container (migration towards ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
1153 |
menus notNil ifTrue:[ |
f513bc136ab7
renamed #superView: to #container (migration towards ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
1154 |
menus do:[:aMenu | |
f513bc136ab7
renamed #superView: to #container (migration towards ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
1155 |
aMenu notNil ifTrue:[ |
f513bc136ab7
renamed #superView: to #container (migration towards ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
1156 |
aMenu container:aView |
f513bc136ab7
renamed #superView: to #container (migration towards ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
1157 |
] |
f513bc136ab7
renamed #superView: to #container (migration towards ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
1158 |
] |
f513bc136ab7
renamed #superView: to #container (migration towards ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
1159 |
] |
f513bc136ab7
renamed #superView: to #container (migration towards ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
1160 |
|
f513bc136ab7
renamed #superView: to #container (migration towards ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
1161 |
"Modified: 9.5.1996 / 00:43:13 / cg" |
f513bc136ab7
renamed #superView: to #container (migration towards ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
1162 |
"Created: 9.5.1996 / 00:43:38 / cg" |
f513bc136ab7
renamed #superView: to #container (migration towards ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
1163 |
! |
f513bc136ab7
renamed #superView: to #container (migration towards ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
1164 |
|
202 | 1165 |
create |
1166 |
super create. |
|
1167 |
self setMenuOrigins |
|
1168 |
! |
|
1169 |
||
1170 |
destroy |
|
1171 |
"have to destroy the menus manually here, |
|
1172 |
since they are no real subviews of myself" |
|
0 | 1173 |
|
202 | 1174 |
menus notNil ifTrue:[ |
1175 |
menus do:[:m | |
|
1176 |
m notNil ifTrue:[m destroy] |
|
1177 |
]. |
|
1178 |
menus := nil |
|
1179 |
]. |
|
1180 |
activeMenuNumber := nil. |
|
1181 |
super destroy. |
|
1182 |
! |
|
1183 |
||
1184 |
initCursor |
|
1185 |
"set up a hand cursor" |
|
1186 |
||
1187 |
cursor := Cursor hand |
|
0 | 1188 |
! |
1189 |
||
1190 |
initStyle |
|
130 | 1191 |
|style| |
1192 |
||
0 | 1193 |
super initStyle. |
1194 |
||
392
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1195 |
"/ DefaultFont notNil ifTrue:[font := DefaultFont on:device]. |
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1196 |
|
128 | 1197 |
showSeparatingLines := DefaultSeparatingLines. "/ false. |
59 | 1198 |
DefaultViewBackground notNil ifTrue:[ |
709 | 1199 |
viewBackground := DefaultViewBackground on:device |
59 | 1200 |
]. |
1201 |
||
1202 |
DefaultForegroundColor notNil ifTrue:[ |
|
709 | 1203 |
fgColor := DefaultForegroundColor |
59 | 1204 |
] ifFalse:[ |
709 | 1205 |
fgColor := Black. |
59 | 1206 |
]. |
1207 |
DefaultBackgroundColor notNil ifTrue:[ |
|
709 | 1208 |
bgColor := DefaultBackgroundColor |
59 | 1209 |
] ifFalse:[ |
709 | 1210 |
bgColor := viewBackground. |
59 | 1211 |
]. |
1212 |
onLevel := DefaultHilightLevel. |
|
1213 |
offLevel := DefaultLevel. |
|
21 | 1214 |
|
0 | 1215 |
self is3D ifTrue:[ |
709 | 1216 |
device hasColors ifTrue:[ |
1217 |
activeFgColor := Color name:'yellow' |
|
1218 |
] ifFalse:[ |
|
1219 |
activeFgColor := White |
|
1220 |
]. |
|
1221 |
device hasGrayscales ifTrue:[ |
|
1222 |
activeBgColor := bgColor. |
|
1223 |
] ifFalse:[ |
|
1224 |
activeBgColor := fgColor. |
|
1225 |
]. |
|
1226 |
topMargin := 2. |
|
21 | 1227 |
|
709 | 1228 |
style := styleSheet name. |
1229 |
((style == #iris) or:[style == #motif]) ifTrue:[ |
|
1230 |
self level:2. |
|
1231 |
onLevel := 2. |
|
1232 |
offLevel := 0. |
|
1233 |
activeFgColor := fgColor |
|
1234 |
] |
|
0 | 1235 |
] ifFalse:[ |
709 | 1236 |
activeFgColor := bgColor. |
1237 |
activeBgColor := fgColor. |
|
1238 |
topMargin := 0 |
|
59 | 1239 |
]. |
1240 |
||
63 | 1241 |
edgeStyle := DefaultEdgeStyle. |
1242 |
keepMenu := DefaultKeepMenu. |
|
110 | 1243 |
toggleKeep := DefaultToggleKeep. |
63 | 1244 |
|
59 | 1245 |
DefaultHilightForegroundColor notNil ifTrue:[ |
709 | 1246 |
activeFgColor := DefaultHilightForegroundColor |
59 | 1247 |
]. |
1248 |
DefaultHilightBackgroundColor notNil ifTrue:[ |
|
709 | 1249 |
activeBgColor := DefaultHilightBackgroundColor |
0 | 1250 |
]. |
59 | 1251 |
DefaultShadowColor notNil ifTrue:[ |
709 | 1252 |
shadowColor := DefaultShadowColor on:device |
59 | 1253 |
]. |
1254 |
DefaultLightColor notNil ifTrue:[ |
|
709 | 1255 |
lightColor := DefaultLightColor on:device |
59 | 1256 |
]. |
1257 |
||
1258 |
bgColor := bgColor on:device. |
|
1259 |
fgColor := fgColor on:device. |
|
1260 |
activeBgColor := activeBgColor on:device. |
|
1261 |
activeFgColor := activeFgColor on:device. |
|
133 | 1262 |
|
1263 |
raiseTopWhenActivated := styleSheet at:'pullDownMenuRaiseTop' default:true. |
|
709 | 1264 |
|
1265 |
"Modified: 28.5.1996 / 21:13:10 / cg" |
|
133 | 1266 |
! |
1267 |
||
202 | 1268 |
initialize |
1269 |
super initialize. |
|
133 | 1270 |
|
202 | 1271 |
font := font on:device. |
1272 |
self origin:(0.0 @ 0.0) |
|
1273 |
extent:(1.0 @ self preferredExtent y) |
|
1274 |
"/ extent:(1.0 @ (font height + (font descent * 2) + topMargin)). |
|
0 | 1275 |
! |
1276 |
||
1277 |
recreate |
|
128 | 1278 |
"if the image was saved with an active menu, hide it" |
1279 |
||
1280 |
|m| |
|
115 | 1281 |
|
1282 |
activeMenuNumber notNil ifTrue:[ |
|
613 | 1283 |
(m := menus at:activeMenuNumber) notNil ifTrue:[ |
1284 |
m unmap. |
|
1285 |
]. |
|
1286 |
activeMenuNumber := nil. |
|
115 | 1287 |
]. |
1288 |
super recreate. |
|
0 | 1289 |
self setMenuOrigins |
613 | 1290 |
|
1291 |
"Modified: 3.5.1996 / 23:48:55 / stefan" |
|
0 | 1292 |
! ! |
1293 |
||
1294 |
!PullDownMenu methodsFor:'private'! |
|
1295 |
||
1296 |
indexOf:stringOrNumber |
|
91 | 1297 |
"return the index of the menu with title; return 0 if not found. |
1298 |
stringOrNumber may be a number, a selector from the selectorArray |
|
593 | 1299 |
or a string from the title array. |
1300 |
If stringOrNumber is not a valid item, return 0." |
|
91 | 1301 |
|
1302 |
|idx| |
|
0 | 1303 |
|
91 | 1304 |
stringOrNumber isNumber ifTrue:[ |
593 | 1305 |
^ stringOrNumber |
0 | 1306 |
]. |
91 | 1307 |
selectors notNil ifTrue:[ |
593 | 1308 |
idx := selectors indexOf:stringOrNumber. |
1309 |
idx ~~ 0 ifTrue:[^ idx]. |
|
1310 |
]. |
|
1311 |
stringOrNumber isString ifTrue:[ |
|
1312 |
^ titles indexOf:stringOrNumber |
|
91 | 1313 |
]. |
593 | 1314 |
(stringOrNumber respondsTo:#string) ifTrue:[ |
1315 |
^ titles indexOf:stringOrNumber asString |
|
1316 |
]. |
|
1317 |
^ 0 |
|
1318 |
||
1319 |
"Modified: 27.4.1996 / 15:25:28 / cg" |
|
0 | 1320 |
! |
1321 |
||
542 | 1322 |
performEntry:itemIndex |
1323 |
|block sel model| |
|
1324 |
||
1325 |
actions notNil ifTrue:[ |
|
1326 |
block := actions at:itemIndex. |
|
1327 |
block notNil ifTrue:[ |
|
1328 |
block value. |
|
1329 |
^ self |
|
1330 |
]. |
|
1331 |
]. |
|
1332 |
selectors notNil ifTrue:[ |
|
1333 |
sel := selectors at:itemIndex. |
|
1334 |
sel notNil ifTrue:[ |
|
1335 |
model notNil ifTrue:[ |
|
1336 |
model perform:sel |
|
1337 |
] ifFalse:[ |
|
1338 |
receiver perform:sel |
|
1339 |
] |
|
1340 |
]. |
|
1341 |
]. |
|
1342 |
||
1343 |
"Modified: 17.4.1996 / 20:55:11 / cg" |
|
1344 |
! |
|
1345 |
||
1346 |
performSelectedAction |
|
1347 |
|block sel| |
|
1348 |
||
1349 |
actions notNil ifTrue:[ |
|
1350 |
block := actions at:activeMenuNumber. |
|
1351 |
block notNil ifTrue:[ |
|
1352 |
block value. |
|
1353 |
^ self |
|
1354 |
]. |
|
1355 |
]. |
|
1356 |
selectors notNil ifTrue:[ |
|
1357 |
sel := selectors at:activeMenuNumber. |
|
1358 |
sel notNil ifTrue:[ |
|
1359 |
model notNil ifTrue:[ |
|
1360 |
model perform:sel |
|
1361 |
] ifFalse:[ |
|
1362 |
receiver perform:sel |
|
1363 |
] |
|
1364 |
]. |
|
1365 |
]. |
|
1366 |
||
1367 |
"Modified: 17.4.1996 / 20:55:11 / cg" |
|
1368 |
"Created: 17.4.1996 / 20:55:53 / cg" |
|
1369 |
! |
|
1370 |
||
202 | 1371 |
setMenuOrigins |
1372 |
"adjust origins of menus when font changes" |
|
1373 |
||
1374 |
(font device == device) ifTrue:[ |
|
516 | 1375 |
menus notNil ifTrue:[ |
1376 |
menus keysAndValuesDo:[:index :aMenu | |
|
1377 |
aMenu notNil ifTrue:[ |
|
1378 |
aMenu origin:((left + (self titleLenUpTo:index)) |
|
1379 |
@ |
|
1380 |
(height + aMenu borderWidth)) |
|
1381 |
]. |
|
1382 |
] |
|
1383 |
] |
|
202 | 1384 |
] |
516 | 1385 |
|
1386 |
"Modified: 23.3.1996 / 17:18:36 / cg" |
|
202 | 1387 |
! |
1388 |
||
133 | 1389 |
someMenuItemLabeled:aLabel |
1390 |
"find a menu item. |
|
1391 |
Currently, in ST/X, instances of MenuItem are only created as dummy" |
|
1392 |
||
1393 |
|idx| |
|
1394 |
||
1395 |
idx := self indexOf:aLabel. |
|
1396 |
idx ~~ 0 ifTrue:[ |
|
1397 |
^ MenuItem new menu:self index:idx |
|
1398 |
]. |
|
1399 |
menus notNil ifTrue:[ |
|
1400 |
menus do:[:aMenu | |
|
1401 |
|item| |
|
1402 |
||
1403 |
aMenu notNil ifTrue:[ |
|
1404 |
(item := aMenu someMenuItemLabeled:aLabel) notNil ifTrue:[ |
|
1405 |
^ item |
|
1406 |
] |
|
1407 |
] |
|
1408 |
] |
|
1409 |
]. |
|
1410 |
^ nil |
|
1411 |
! |
|
1412 |
||
110 | 1413 |
titleIndexForX:x |
1414 |
"given a click x-position, return index in title or nil" |
|
1415 |
||
1416 |
|xstart "{ Class: SmallInteger }" |
|
1417 |
xend "{ Class: SmallInteger }" |
|
1418 |
wSpace wSep| |
|
1419 |
||
1420 |
wSpace := (font widthOf:' ') * 2. |
|
1421 |
showSeparatingLines ifTrue:[ |
|
1422 |
self is3D ifTrue:[ |
|
1423 |
wSep := 2 |
|
1424 |
] ifFalse:[ |
|
1425 |
wSep := 1 |
|
1426 |
] |
|
1427 |
] ifFalse:[ |
|
1428 |
wSep := 0 |
|
1429 |
]. |
|
1430 |
xstart := 0. |
|
1431 |
1 to:(titles size) do:[:index | |
|
1432 |
|entry thisLength| |
|
1433 |
||
1434 |
entry := titles at:index. |
|
1435 |
entry isString ifTrue:[ |
|
1436 |
thisLength := font widthOf:entry. |
|
1437 |
] ifFalse:[ |
|
1438 |
thisLength := entry width |
|
1439 |
]. |
|
1440 |
xend := xstart + thisLength + wSpace + wSep. |
|
1441 |
(x between:xstart and:xend) ifTrue:[^ index]. |
|
1442 |
xstart := xend |
|
1443 |
]. |
|
1444 |
^ nil |
|
1445 |
! |
|
1446 |
||
202 | 1447 |
titleLenUpTo:index |
1448 |
"answer len (in pixels) of all title-strings up-to |
|
1449 |
(but excluding) title-index. Used to compute x-position when drawing |
|
1450 |
individual entries." |
|
110 | 1451 |
|
202 | 1452 |
|len "{ Class: SmallInteger }" |
1453 |
wSpace wSep| |
|
110 | 1454 |
|
202 | 1455 |
(index <= 1) ifTrue:[^ 0]. |
1456 |
wSpace := (font widthOf:' '). |
|
1457 |
showSeparatingLines ifTrue:[ |
|
1458 |
self is3D ifTrue:[ |
|
1459 |
wSep := 2 |
|
1460 |
] ifFalse:[ |
|
1461 |
wSep := 1 |
|
1462 |
] |
|
1463 |
] ifFalse:[ |
|
1464 |
wSep := 0 |
|
133 | 1465 |
]. |
1466 |
||
202 | 1467 |
len := 0. |
1468 |
titles from:1 to:(index - 1) do:[:entry | |
|
1469 |
|thisLength| |
|
128 | 1470 |
|
202 | 1471 |
entry isString ifTrue:[ |
1472 |
thisLength := (font widthOf:entry). |
|
1473 |
] ifFalse:[ |
|
1474 |
thisLength := entry width |
|
131 | 1475 |
]. |
202 | 1476 |
len := len + thisLength + wSpace + wSep + wSpace. |
110 | 1477 |
]. |
202 | 1478 |
^ len |
110 | 1479 |
! ! |
1480 |
||
202 | 1481 |
!PullDownMenu methodsFor:'queries'! |
110 | 1482 |
|
202 | 1483 |
preferredExtent |
572 | 1484 |
"return my preferredExtent from the title-item widths & font height" |
1485 |
||
202 | 1486 |
|w| |
0 | 1487 |
|
714
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
709
diff
changeset
|
1488 |
preferredExtent notNil ifTrue:[ |
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
709
diff
changeset
|
1489 |
^ preferredExtent |
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
709
diff
changeset
|
1490 |
]. |
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
709
diff
changeset
|
1491 |
|
202 | 1492 |
w := self titleLenUpTo:(titles size + 1). |
1493 |
^ w @ (font height + (font descent * 2) "+ topMargin" + (margin*2)). |
|
572 | 1494 |
|
714
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
709
diff
changeset
|
1495 |
"Modified: 29.5.1996 / 12:11:11 / cg" |
110 | 1496 |
! ! |
0 | 1497 |
|
110 | 1498 |
!PullDownMenu methodsFor:'submenu notifications'! |
0 | 1499 |
|
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1500 |
hideSubmenu |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1501 |
"sent by en escaped menu - ignored here" |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1502 |
|
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1503 |
^ self |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1504 |
|
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1505 |
"Modified: 4.3.1996 / 22:58:22 / cg" |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1506 |
! |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
1507 |
|
110 | 1508 |
showActive |
128 | 1509 |
"sent by a menu to tell me that it starts to perform |
1510 |
its menu action." |
|
131 | 1511 |
|
1512 |
windowGroup notNil ifTrue:[windowGroup showCursor:Cursor wait] |
|
38 | 1513 |
! |
1514 |
||
110 | 1515 |
showPassive |
128 | 1516 |
"sent by a menu to tell me that it finished its menu-action. |
1517 |
Here, we hide the currently active menu." |
|
0 | 1518 |
|
131 | 1519 |
self hideActiveMenu. |
1520 |
windowGroup notNil ifTrue:[windowGroup restoreCursors] |
|
77 | 1521 |
! |
1522 |
||
110 | 1523 |
submenuTriggered |
1524 |
"sent by a sub-submenu to tell me that it finished its menu-action." |
|
1525 |
||
1526 |
self showPassive |
|
0 | 1527 |
! ! |
1528 |
||
205 | 1529 |
!PullDownMenu class methodsFor:'documentation'! |
1530 |
||
1531 |
version |
|
714
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
709
diff
changeset
|
1532 |
^ '$Header: /cvs/stx/stx/libwidg/PullDownMenu.st,v 1.57 1996-05-29 10:22:21 cg Exp $' |
205 | 1533 |
! ! |