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