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