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