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