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