author | Claus Gittinger <cg@exept.de> |
Thu, 09 Nov 2017 20:09:30 +0100 | |
changeset 6225 | 0122e4e6c587 |
parent 6178 | b21eb474fd9d |
child 6450 | 31226e8a8c7c |
permissions | -rw-r--r-- |
0 | 1 |
" |
4 | 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 |
" |
|
2253 | 12 |
"{ Package: 'stx:libwidg' }" |
13 |
||
5449 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
0 | 16 |
Label subclass:#Button |
264 | 17 |
instanceVariableNames:'activeLogo passiveLogo disabledLogo focusLogo onLevel offLevel |
2497
e3e1a719e31d
support etched color (win32 style)
Claus Gittinger <cg@exept.de>
parents:
2490
diff
changeset
|
18 |
disabledFgColor disabledEtchedFgColor activeFgColor activeBgColor |
e3e1a719e31d
support etched color (win32 style)
Claus Gittinger <cg@exept.de>
parents:
2490
diff
changeset
|
19 |
enteredFgColor enteredBgColor isReturnButton shadowForm lightForm |
e3e1a719e31d
support etched color (win32 style)
Claus Gittinger <cg@exept.de>
parents:
2490
diff
changeset
|
20 |
formColor formShadowColor formLightColor edgeStyle |
3052 | 21 |
halfShadowColor halfLightColor defaultable enterLevel leaveLevel |
22 |
enteredLogo' |
|
420 | 23 |
classVariableNames:'ReturnForm ReturnLightForm ReturnShadowForm DefaultActiveLevel |
24 |
DefaultPassiveLevel DefaultEdgeStyle DefaultBorderWidth |
|
25 |
DefaultForegroundColor DefaultBackgroundColor |
|
264 | 26 |
DefaultDisabledForegroundColor DefaultDisabledBackgroundColor |
2497
e3e1a719e31d
support etched color (win32 style)
Claus Gittinger <cg@exept.de>
parents:
2490
diff
changeset
|
27 |
DefaultDisabledEtchedForegroundColor |
264 | 28 |
DefaultEnteredForegroundColor DefaultEnteredBackgroundColor |
29 |
DefaultActiveForegroundColor DefaultActiveBackgroundColor |
|
30 |
DefaultReturnButtonHasImage DefaultReturnButtonHasBorder |
|
31 |
DefaultShadowColor DefaultLightColor DefaultHalfShadowColor |
|
2137
2642e627bb2a
eliminated styleSheet name = win95 queries
Claus Gittinger <cg@exept.de>
parents:
2078
diff
changeset
|
32 |
DefaultHalfLightColor DefaultFocusHighlightStyle' |
264 | 33 |
poolDictionaries:'' |
34 |
category:'Views-Interactors' |
|
0 | 35 |
! |
36 |
||
850 | 37 |
!Button class methodsFor:'documentation'! |
0 | 38 |
|
205 | 39 |
actionBlocksVersusModelChanges |
40 |
" |
|
41 |
You may ask yourself, why ST/X supports two different ways |
|
42 |
to trigger a buttons action (also true for sliders, selectionInListViews, |
|
43 |
toggles etc.) and when to use which mechanism. |
|
44 |
||
45 |
There are two reasons: |
|
46 |
1) history - historically, ST/X used only actionBlocks |
|
47 |
Basically, these provide the most general functionality |
|
48 |
(you can of course send change-messages from those blocks) |
|
49 |
||
50 |
Change-message notification was added later, to make porting |
|
51 |
of existing applications easier. |
|
52 |
||
53 |
2) for many (simple) applications, it is often easier, to simply |
|
54 |
define an action block. This is especially true, if the button |
|
55 |
triggers some action (such as ok-/abort-buttons) and does NOT |
|
56 |
change some models internal value. |
|
57 |
(other smalltalks provide extra adapter-models for this, |
|
58 |
in which you can set actionBlocks in much the same way). |
|
59 |
||
60 |
In general: |
|
61 |
use model-change-messages, iff multiple views are possibly open |
|
62 |
on the same domain model, and changes can occur from multiple |
|
63 |
places. Or if a change has to be forwarded to multiple other objects |
|
64 |
(possible not foreseen). |
|
65 |
||
66 |
For simplicity, better use actionBlocks for trigger-like actions |
|
67 |
(such as closing a view, ok/abort etc.) iff there is only a single |
|
258
ae4b8f1a6738
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
244
diff
changeset
|
68 |
entity which is interested in that button press. |
205 | 69 |
" |
70 |
! |
|
71 |
||
35 | 72 |
copyright |
73 |
" |
|
74 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
59 | 75 |
All Rights Reserved |
35 | 76 |
|
77 |
This software is furnished under a license and may be used |
|
78 |
only in accordance with the terms of that license and with the |
|
79 |
inclusion of the above copyright notice. This software may not |
|
80 |
be provided or otherwise made available to, or used by, any |
|
81 |
other person. No title to or ownership of the software is |
|
82 |
hereby transferred. |
|
83 |
" |
|
84 |
! |
|
85 |
||
0 | 86 |
documentation |
87 |
" |
|
88 |
Buttons are Labels which do something when pressed/released. |
|
113 | 89 |
Since they inherit from Label, read the documentation on Labels to |
90 |
see how color, layout, font, image or labelString are changed. |
|
91 |
||
133 | 92 |
Buttons (and also instances of subclasses, such as toggles, checkToggles |
93 |
and radioButtons) perform some action when pressed, and optionally when |
|
94 |
released. Due to historic reasons, ST/X buttons support two mechanisms: |
|
95 |
||
113 | 96 |
Actionblock operation: |
133 | 97 |
the button has an actionBlock (actually, it has two: a pressAction and |
98 |
a releaseAction) which is evaluated, when the button is pressed. |
|
99 |
The user of a button can set these action blocks via the #action:, |
|
100 |
#pressAction: or #releaseAction: messages. |
|
113 | 101 |
|
102 |
Model-View interaction: |
|
133 | 103 |
buttons with a model will send change-messages to the model and also react |
104 |
to changes in the model. |
|
105 |
You have to define the buttons labelMessage and an aspectSymbol. |
|
106 |
When changed, the model should send 'self changed:<aspect>' if it wants the |
|
107 |
label to change and return a string from the labelSymbol-message. |
|
118 | 108 |
By default, the labelMsg is nil, therefore no update of the label is done. |
109 |
(this behavior is inherited from label, see documentation there) |
|
110 |
||
133 | 111 |
When pressed, the button sends a changeMessage to the model. |
118 | 112 |
If the changeMsg is for a one-argument message, the current |
113 | 113 |
press-state is passed as argument (i.e. true if pressed, false if released). |
118 | 114 |
By default, the change-Message is #value: (for ST-80 compatibility). |
113 | 115 |
|
585 | 116 |
button model:aModel. |
117 |
button aspect:aspectSymbol. |
|
118 |
button change:changeSymbol. |
|
119 |
button labelMessage:labelSymbol. |
|
113 | 120 |
|
585 | 121 |
model sends #changed:aspectSymbol |
122 |
---> button will redraw its label from value returned by model>>labelSymbol |
|
113 | 123 |
|
585 | 124 |
button changes state: |
125 |
---> button sends changeSymbol / changeSymbol:state to the model |
|
113 | 126 |
|
118 | 127 |
By default (as inherited), the labelMsg is nil; therefore, buttons |
5778 | 128 |
do not try to acquire a new labelString from the model. |
118 | 129 |
If you want this behavior, you must set labelMsg and aspectMsg |
130 |
as appropriate. |
|
0 | 131 |
|
3925 | 132 |
labels |
133 |
Originally, labels only had a label- and disabledLabel attributes (both |
|
134 |
had to be explicitly set via setter methods). |
|
135 |
Later the model- and labelChannel interfaces were added; model interface |
|
136 |
for compatbility with other smalltalks, where a single multi-aspect model |
|
137 |
might be used, the channels were added to support visualWorks style of multiple |
|
138 |
single-aspect holders. This final version is also what the UIBuilder is working |
|
139 |
against. The other mechanisms are still present, but disabled if a newer mechanism |
|
140 |
is used (i.e. if a labelChannel has been given, the label and disabledLabel instvars |
|
141 |
are ignored). |
|
142 |
All of this is here to provide backward compatibility for existing customers |
|
143 |
and st/x programs (which is a good thing to have, b.t.w). |
|
144 |
||
145 |
||
133 | 146 |
See examples. |
147 |
||
148 |
||
585 | 149 |
[Instance variables:] |
0 | 150 |
|
59 | 151 |
activeLogo <StringOrImage> logo to show when active (pressed) |
152 |
passiveLogo <StringOrImage> logo to show when passive (released) |
|
585 | 153 |
default is nil for both, so the normal logo is used |
154 |
(see superclass: Label) |
|
35 | 155 |
onLevel <Integer> level when pressed (3D only) (default: depends on style) |
156 |
offLevel <Integer> level when released (3D only) (default: depends on style) |
|
157 |
disabledFgColor <Color> color used to draw logo when disabled (default: depends on style) |
|
158 |
activeFgColor <Color> color to draw logo when pressed (default: depends on style) |
|
159 |
activeBgColor <Color> bg color when pressed (default: depends on style) |
|
160 |
enteredFgColor <Color> fg color to draw logo when cursor entered (default: depends on style) |
|
161 |
enteredBgColor <Color> bg color when cursor entered (default: depends on style) |
|
0 | 162 |
|
35 | 163 |
isReturnButton <Boolean> true if this button is also activated by the |
585 | 164 |
return key - if true, it will draw a return-bitmap |
165 |
in addition to the logo (default: false) |
|
35 | 166 |
|
3925 | 167 |
defaultable <Boolean> true, if this button can become a returnButton. |
168 |
(computes its default extent differently) |
|
1051 | 169 |
|
59 | 170 |
shadowForm <Form> form to display in addition to buttons label (returnbutton only) |
171 |
lightForm <Form> light part of shadowForm (returnbutton only) |
|
172 |
||
173 |
formColor <Color> color to draw form with (returnbutton only) |
|
174 |
formShadowColor <Color> color for shadowing the form (3D only & return) |
|
35 | 175 |
formLightColor <Color> color for lighting the form (3D only) |
176 |
||
62 | 177 |
|
585 | 178 |
[styleSheet parameters:] |
62 | 179 |
|
180 |
buttonActiveLevel <Integer> level when on (ignored in 2D styles) |
|
181 |
buttonPassiveLevel <Integer> level when off (ignored in 2D styles) |
|
74 | 182 |
buttonBorderWidth <Integer> default borderwidth |
62 | 183 |
buttonEdgeStyle <Symbol> style of edges (currently #soft or nil) |
184 |
buttonFont <Font> font to use for textual labels |
|
185 |
buttonForegroundColor <Color> color to draw foreground pixels (i.e. the string) |
|
186 |
buttonBackgroundColor <Color> color to draw background pixels |
|
187 |
buttonDisabledForegroundColor <Color> same when disabled |
|
188 |
buttonDisabledBackgroundColor <Color> same when disabled |
|
189 |
buttonEnteredForegroundColor <Color> same when mouse pointer is in |
|
190 |
buttonEnteredBackgroundColor <Color> same when mouse pointer is in |
|
191 |
buttonActiveForegroundColor <Color> same when button is active |
|
192 |
buttonActiveBackgroundColor <Color> same when button is active |
|
193 |
buttonShadowColor <Color> shadow color for edgaes (ignored in 2D styles) |
|
194 |
buttonLightColor <Color> light color for edgaes (ignored in 2D styles) |
|
195 |
buttonHalfShadowColor <Color> half shadow color; for soft edges only |
|
196 |
buttonHalfLightColor <Color> half light color; for soft edges only |
|
197 |
||
198 |
buttonReturnButtonHasImage <Boolean> if true, return-buttons draw a return-key image |
|
199 |
buttonReturnButtonHasBorder <Boolean> if true, return-buttons show a border |
|
130 | 200 |
|
585 | 201 |
[author:] |
202 |
Claus Gittinger |
|
203 |
||
204 |
[see also:] |
|
205 |
Toggle CheckToggle CheckBox |
|
593 | 206 |
Dialog |
207 |
ValueHolder TriggerValue |
|
208 |
Block |
|
133 | 209 |
" |
210 |
! |
|
211 |
||
62 | 212 |
examples |
213 |
" |
|
5583 | 214 |
You don't have to normally care for all the internals |
420 | 215 |
(they allow many variations though). |
216 |
For buttons with a stringLabel, the typical use is: |
|
35 | 217 |
|
420 | 218 |
b := Button label:'some logo' in:aView. |
219 |
b action:[ .. things to do, when pressed ... ] |
|
35 | 220 |
|
420 | 221 |
and for bitmap/image buttons its: |
62 | 222 |
|
420 | 223 |
b := Button label:someImage in:aView. |
224 |
b action:[ .. things to do, when pressed ... ] |
|
62 | 225 |
|
420 | 226 |
|
62 | 227 |
|
133 | 228 |
Of course, you can also setup things the ST-80 way, in first |
229 |
creating the button and later add it to some superview: |
|
230 |
||
420 | 231 |
b := Button new. |
232 |
b label:someImage. |
|
233 |
b action:[ .. things to do, when pressed ... ] |
|
234 |
... |
|
235 |
aSuperView add:b in:<frameRectangle>. |
|
118 | 236 |
|
420 | 237 |
|
238 |
Although you can specify most of the look of a button, |
|
133 | 239 |
you should use the defaults in most applications. |
88 | 240 |
As you specify more things in your program, |
241 |
the styleSheet settings are more and more ignored. |
|
242 |
Also, even though it might look fancy, colorful |
|
243 |
button panels are usually not a good GUI design; |
|
244 |
they will attract the users attention - possibly to things |
|
245 |
which are not worth it. |
|
420 | 246 |
Finally, if you use fancy colors, always think of those poor users |
133 | 247 |
without color displays - the styleSheet allows those people to adjust things, |
130 | 248 |
while hard-coded colors cannot be fixed without changing the code. |
88 | 249 |
|
420 | 250 |
a simple button with default settings and no action: |
133 | 251 |
(you may want to try it with different viewStyle settings in effect): |
593 | 252 |
[exBegin] |
420 | 253 |
|top b| |
254 |
||
255 |
top := StandardSystemView new. |
|
256 |
top extent:100@100. |
|
88 | 257 |
|
420 | 258 |
b := Button in:top. |
259 |
b label:'hello'. |
|
260 |
||
261 |
top open. |
|
593 | 262 |
[exEnd] |
420 | 263 |
|
6178 | 264 |
[exBegin] |
265 |
|top b| |
|
266 |
||
267 |
top := StandardSystemView new. |
|
268 |
top extent:100@100. |
|
269 |
||
270 |
b := Button in:top. |
|
271 |
b label:'press\me' withCRs. |
|
272 |
||
273 |
top open. |
|
274 |
[exEnd] |
|
275 |
||
88 | 276 |
|
593 | 277 |
give it some action (watch the transcript): |
278 |
[exBegin] |
|
420 | 279 |
|top b| |
280 |
||
281 |
top := StandardSystemView new. |
|
282 |
top extent:100@100. |
|
283 |
||
284 |
b := Button in:top. |
|
285 |
b label:'hello'. |
|
286 |
b action:[Transcript flash]. |
|
287 |
||
288 |
top open. |
|
593 | 289 |
[exEnd] |
88 | 290 |
|
291 |
||
113 | 292 |
there is also a combined instance creation message: |
593 | 293 |
[exBegin] |
420 | 294 |
|top b| |
113 | 295 |
|
420 | 296 |
top := StandardSystemView new. |
297 |
top extent:100@100. |
|
113 | 298 |
|
420 | 299 |
b := Button label:'hello' action:[Transcript flash] in:top. |
300 |
||
301 |
top open. |
|
593 | 302 |
[exEnd] |
113 | 303 |
|
304 |
||
133 | 305 |
a return button |
306 |
(in dialogs, you should setup things to have the return-key perform |
|
307 |
the ok action, and mark the corresponding button as being a returnButton): |
|
593 | 308 |
[exBegin] |
420 | 309 |
|top b| |
310 |
||
311 |
top := StandardSystemView new. |
|
312 |
top extent:100@100. |
|
313 |
||
314 |
b := Button label:'hello' action:[Transcript flash] in:top. |
|
315 |
b beReturnButton. |
|
316 |
top open. |
|
593 | 317 |
[exEnd] |
420 | 318 |
|
319 |
||
320 |
||
321 |
multiple buttons in a panel: |
|
593 | 322 |
[exBegin] |
420 | 323 |
|top panel b1 b2 b3| |
324 |
||
325 |
top := StandardSystemView new. |
|
326 |
top extent:300@100. |
|
327 |
||
328 |
panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
133 | 329 |
|
420 | 330 |
b1 := Button label:'one' in:panel. |
331 |
b2 := Button label:'two' in:panel. |
|
332 |
b3 := Button label:'three' action:[Transcript flash] in:panel. |
|
333 |
||
334 |
top open. |
|
593 | 335 |
[exEnd] |
420 | 336 |
|
133 | 337 |
|
338 |
||
339 |
enabling/disabling buttons via explicit messages: |
|
593 | 340 |
[exBegin] |
420 | 341 |
|top panel b1 b2 b3| |
342 |
||
343 |
top := StandardSystemView new. |
|
344 |
top extent:300@100. |
|
345 |
panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
133 | 346 |
|
420 | 347 |
b1 := Button label:'enable' action:[b3 enable] in:panel. |
348 |
b2 := Button label:'disable' action:[b3 disable] in:panel. |
|
349 |
b3 := Button label:'flash' action:[Transcript flash] in:panel. |
|
350 |
top open. |
|
593 | 351 |
[exEnd] |
133 | 352 |
|
353 |
||
354 |
||
355 |
enabling/disabling buttons via implicit value change of a valueHolder: |
|
420 | 356 |
The two views are only indirectly coupled (via the valueHolder); |
357 |
not knowing about each other. |
|
593 | 358 |
[exBegin] |
420 | 359 |
|top panel ena t b1 b2 b3 check| |
133 | 360 |
|
420 | 361 |
top := StandardSystemView new. |
362 |
top extent:300@100. |
|
363 |
||
364 |
panel := HorizontalPanelView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top. |
|
133 | 365 |
|
420 | 366 |
ena := false asValue. |
133 | 367 |
|
420 | 368 |
t := Toggle label:'enable' in:panel. |
369 |
t model:ena. |
|
133 | 370 |
|
420 | 371 |
b1 := Button label:'button1' in:panel. |
372 |
b1 controller enableChannel:ena. |
|
133 | 373 |
|
420 | 374 |
b2 := Button label:'button2' in:panel. |
375 |
b2 controller enableChannel:ena. |
|
133 | 376 |
|
420 | 377 |
b3 := Button label:'button3' in:panel. |
378 |
b3 controller enableChannel:ena. |
|
133 | 379 |
|
420 | 380 |
top open. |
133 | 381 |
|
420 | 382 |
check := CheckBox model:ena. |
383 |
check label:'also enable'. |
|
384 |
check extent:(check preferredExtent + (5@5)). |
|
385 |
check open |
|
593 | 386 |
[exEnd] |
133 | 387 |
|
388 |
||
389 |
||
88 | 390 |
changing colors: |
593 | 391 |
[exBegin] |
420 | 392 |
|top b| |
88 | 393 |
|
420 | 394 |
top := StandardSystemView new. |
395 |
top extent:100@100. |
|
88 | 396 |
|
420 | 397 |
b := Button label:'hello' in:top. |
398 |
b action:[Transcript flash]. |
|
399 |
b activeForegroundColor:(Color white). |
|
400 |
b activeBackgroundColor:(Color red). |
|
401 |
||
402 |
top open. |
|
593 | 403 |
[exEnd] |
88 | 404 |
|
405 |
||
406 |
changing more colors: |
|
593 | 407 |
[exBegin] |
420 | 408 |
|top b| |
88 | 409 |
|
420 | 410 |
top := StandardSystemView new. |
411 |
top extent:100@100. |
|
88 | 412 |
|
420 | 413 |
b := Button label:'hello' in:top. |
414 |
b action:[Transcript flash]. |
|
415 |
b enteredForegroundColor:(Color red). |
|
416 |
b enteredBackgroundColor:(b backgroundColor). |
|
417 |
b activeForegroundColor:(Color white). |
|
418 |
b activeBackgroundColor:(Color red). |
|
419 |
||
420 |
top open. |
|
593 | 421 |
[exEnd] |
88 | 422 |
|
423 |
||
113 | 424 |
button with an image and different colors: |
593 | 425 |
[exBegin] |
420 | 426 |
|top b| |
88 | 427 |
|
420 | 428 |
top := StandardSystemView new. |
429 |
top extent:100@100. |
|
88 | 430 |
|
420 | 431 |
b := Button in:top. |
432 |
b label:(Image fromFile:'bitmaps/SBrowser.xbm'). |
|
433 |
b action:[Transcript flash]. |
|
434 |
b enteredForegroundColor:(Color green darkened). |
|
435 |
b enteredBackgroundColor:(b backgroundColor). |
|
436 |
b activeForegroundColor:(Color white). |
|
437 |
b activeBackgroundColor:(Color red). |
|
438 |
||
439 |
top open. |
|
593 | 440 |
[exEnd] |
88 | 441 |
|
442 |
||
118 | 443 |
changing the image when pressed: |
593 | 444 |
[exBegin] |
420 | 445 |
|top b| |
88 | 446 |
|
420 | 447 |
top := StandardSystemView new. |
448 |
top extent:100@100. |
|
62 | 449 |
|
420 | 450 |
b := Button in:top. |
451 |
b passiveLogo:(Image fromFile:'bitmaps/SBrowser.xbm'). |
|
452 |
b activeLogo:(Image fromFile:'bitmaps/CBrowser.xbm'). |
|
453 |
b action:[Transcript flash]. |
|
454 |
b enteredForegroundColor:(Color red). |
|
455 |
b enteredBackgroundColor:(b backgroundColor). |
|
456 |
b activeForegroundColor:(Color white). |
|
457 |
b activeBackgroundColor:(Color red). |
|
458 |
||
459 |
top open. |
|
593 | 460 |
[exEnd] |
88 | 461 |
|
462 |
||
113 | 463 |
well, even that is possible (but you should NEVER do it): |
593 | 464 |
[exBegin] |
420 | 465 |
|top b| |
88 | 466 |
|
420 | 467 |
top := StandardSystemView new. |
468 |
top extent:100@100. |
|
88 | 469 |
|
420 | 470 |
b := Button in:top. |
3052 | 471 |
b passiveLogo:(Image fromFile:'../../goodies/bitmaps/xpmBitmaps/misc_tools/email.xpm'). |
1153 | 472 |
b activeLogo:'start'. |
420 | 473 |
b action:[Transcript flash]. |
474 |
b enteredForegroundColor:(Color red). |
|
475 |
b enteredBackgroundColor:(b backgroundColor). |
|
476 |
b activeForegroundColor:(Color white). |
|
477 |
b activeBackgroundColor:(Color red). |
|
478 |
top open. |
|
593 | 479 |
[exEnd] |
88 | 480 |
|
481 |
||
482 |
more playing with colors: |
|
593 | 483 |
[exBegin] |
420 | 484 |
|top b| |
88 | 485 |
|
420 | 486 |
top := StandardSystemView new. |
487 |
top extent:100@100. |
|
88 | 488 |
|
420 | 489 |
b := Button in:top. |
3052 | 490 |
b logo:(Image fromFile:'../../goodies/bitmaps/xbmBitmaps/TicTacToe.xbm'). |
420 | 491 |
b action:[Transcript flash]. |
492 |
b foregroundColor:(Color red:0 green:80 blue:20) darkened. |
|
493 |
b backgroundColor:(Color grey:10). |
|
494 |
b enteredForegroundColor:(Color red). |
|
495 |
b activeForegroundColor:(Color red). |
|
3052 | 496 |
b activeBackgroundColor:(Color grey:50). |
420 | 497 |
top open. |
593 | 498 |
[exEnd] |
88 | 499 |
|
500 |
||
113 | 501 |
fire on press (buttons in scrollbars do this, while normal buttons |
133 | 502 |
fire on release). |
503 |
To give the user a chance to change her mind |
|
504 |
and leave the button without action, you should not change the default |
|
505 |
behavior and NOT use triggerOnDown-buttons in most applications: |
|
593 | 506 |
[exBegin] |
420 | 507 |
|top b| |
88 | 508 |
|
420 | 509 |
top := StandardSystemView new. |
510 |
top extent:100@100. |
|
88 | 511 |
|
420 | 512 |
b := Button label:'hello' in:top. |
513 |
b controller beTriggerOnDown. |
|
514 |
b action:[Transcript flash]. |
|
515 |
top open. |
|
593 | 516 |
[exEnd] |
62 | 517 |
|
518 |
||
519 |
To implement fun buttons (for games, show-demos etc.), you can |
|
520 |
access all internal parameters (and not take the viewStyle defaults) |
|
521 |
as in: |
|
593 | 522 |
[exBegin] |
420 | 523 |
|b granite light shadow| |
62 | 524 |
|
420 | 525 |
b := Button label:'a nice one ?'. |
526 |
granite := Image fromFile:'bitmaps/granite_small.tiff'. |
|
527 |
light := granite lightened. |
|
528 |
shadow := granite darkened darkened. |
|
529 |
b backgroundColor:granite. |
|
530 |
b foregroundColor:Color white. |
|
531 |
b shadowColor:shadow. |
|
532 |
b lightColor:light. |
|
533 |
b enteredBackgroundColor:light. |
|
534 |
b enteredForegroundColor:Color black. |
|
535 |
b activeLevel:-3; passiveLevel:5. |
|
536 |
b extent:(200 @ 50). |
|
537 |
b open |
|
593 | 538 |
[exEnd] |
62 | 539 |
|
540 |
However, in your application, you may want to read those bitmaps only once |
|
541 |
during startup and cache them for later reuse in some class variable |
|
542 |
(reading, lightning & darkening of images is a bit slow) |
|
88 | 543 |
|
113 | 544 |
|
118 | 545 |
ST/X Buttons allow simulation of the ST-80 MVC way of interacting. |
546 |
To do so, instead (or in addition) to defining actionBlocks, set the |
|
127 | 547 |
buttons model to have this be informed (in addition): |
118 | 548 |
|
549 |
Model-View interaction (ST-80 style): |
|
550 |
(have a look at the models values in the inspector, as the toggles change) |
|
593 | 551 |
[exBegin] |
420 | 552 |
|bool1 bool2 b1 b2 panel top| |
118 | 553 |
|
420 | 554 |
bool1 := ValueHolder newBoolean. |
555 |
bool2 := ValueHolder newBoolean value:true. |
|
118 | 556 |
|
420 | 557 |
top := StandardSystemView new. |
558 |
top extent:200@100. |
|
118 | 559 |
|
420 | 560 |
panel := HorizontalPanelView |
561 |
origin:0.0 @ 0.0 corner:1.0 @ 50 in:top. |
|
118 | 562 |
|
420 | 563 |
b1 := Toggle label:'eat me' in:panel. |
564 |
b1 model:bool1. |
|
118 | 565 |
|
420 | 566 |
b2 := Toggle label:'drink me' in:panel. |
567 |
b2 model:bool2. |
|
118 | 568 |
|
420 | 569 |
top open. |
570 |
bool1 inspect. |
|
571 |
bool2 inspect. |
|
593 | 572 |
[exEnd] |
118 | 573 |
|
133 | 574 |
|
118 | 575 |
Using a PluggableAdaptor (ST-80 style): |
576 |
(notice, that this is almost what ST/X buttons did originally, |
|
127 | 577 |
therefore, you may want use actionBlocks right away ...) |
593 | 578 |
[exBegin] |
420 | 579 |
|adaptor1 adaptor2 b1 b2 panel top| |
118 | 580 |
|
420 | 581 |
adaptor1 := PluggableAdaptor new |
582 |
getBlock:[:m | false] |
|
655 | 583 |
putBlock:[:m :v | Transcript showCR:'eat'] |
420 | 584 |
updateBlock:nil. |
585 |
adaptor2 := PluggableAdaptor new |
|
586 |
getBlock:[:m | false] |
|
655 | 587 |
putBlock:[:m :v | Transcript showCR:'drink'] |
420 | 588 |
updateBlock:nil. |
118 | 589 |
|
420 | 590 |
top := StandardSystemView new. |
591 |
top extent:200@100. |
|
118 | 592 |
|
420 | 593 |
panel := HorizontalPanelView |
594 |
origin:0.0 @ 0.0 corner:1.0 @ 50 in:top. |
|
118 | 595 |
|
420 | 596 |
b1 := Button label:'eat me' in:panel. |
597 |
b1 model:adaptor1. |
|
118 | 598 |
|
420 | 599 |
b2 := Button label:'drink me' in:panel. |
600 |
b2 model:adaptor2. |
|
118 | 601 |
|
420 | 602 |
top open. |
593 | 603 |
[exEnd] |
118 | 604 |
|
605 |
||
606 |
as a reminder, the corresponding ST/X setup is: |
|
593 | 607 |
[exBegin] |
420 | 608 |
|b1 b2 panel top| |
118 | 609 |
|
420 | 610 |
top := StandardSystemView new. |
611 |
top extent:200@100. |
|
118 | 612 |
|
420 | 613 |
panel := HorizontalPanelView |
614 |
origin:0.0 @ 0.0 corner:1.0 @ 50 in:top. |
|
118 | 615 |
|
420 | 616 |
b1 := Button label:'eat me' in:panel. |
655 | 617 |
b1 action:[Transcript showCR:'eat']. |
118 | 618 |
|
420 | 619 |
b2 := Button label:'drink me' in:panel. |
655 | 620 |
b2 action:[Transcript showCR:'drink']. |
118 | 621 |
|
420 | 622 |
top open. |
593 | 623 |
[exEnd] |
118 | 624 |
|
625 |
||
130 | 626 |
accessing multiple aspects of a complex model |
627 |
(using a plug here to simulate that model ...) |
|
133 | 628 |
(Notice, the next example shall demonstrate multiple aspects; |
629 |
for this kind of functionality, you'd better use actionBlocks in |
|
630 |
real applications) |
|
593 | 631 |
[exBegin] |
420 | 632 |
|myModel b1 b2 panel top| |
113 | 633 |
|
420 | 634 |
myModel := Plug new. |
635 |
myModel respondTo:#grow with:[top extent:200@300]. |
|
636 |
myModel respondTo:#shrink with:[top extent:200@100]. |
|
113 | 637 |
|
420 | 638 |
top := StandardSystemView new. |
639 |
top extent:200@100. |
|
113 | 640 |
|
420 | 641 |
panel := HorizontalPanelView |
642 |
origin:0.0 @ 0.0 |
|
643 |
corner:1.0 @ 50 |
|
644 |
in:top. |
|
113 | 645 |
|
420 | 646 |
b1 := Button label:'eat me' in:panel. |
647 |
b1 model:myModel; change:#grow. |
|
113 | 648 |
|
420 | 649 |
b2 := Button label:'drink me' in:panel. |
650 |
b2 model:myModel; change:#shrink. |
|
113 | 651 |
|
420 | 652 |
top open. |
593 | 653 |
[exEnd] |
118 | 654 |
|
113 | 655 |
|
5778 | 656 |
acquiring the label from the model |
130 | 657 |
(this functionality is inherited from Label) |
593 | 658 |
[exBegin] |
420 | 659 |
|myModel b1 b2 b3 panel top currentLabel| |
130 | 660 |
|
420 | 661 |
currentLabel := 'foo'. |
130 | 662 |
|
420 | 663 |
myModel := Plug new. |
664 |
myModel respondTo:#getLabel with:[currentLabel]. |
|
665 |
myModel respondTo:#b0Pressed with:[]. |
|
666 |
myModel respondTo:#b1Pressed with:[currentLabel := 'bar'. |
|
667 |
myModel changed:#labelAspect]. |
|
668 |
myModel respondTo:#b2Pressed with:[currentLabel := 'foo'. |
|
669 |
myModel changed:#labelAspect]. |
|
130 | 670 |
|
420 | 671 |
top := StandardSystemView new. |
672 |
top extent:300@100. |
|
130 | 673 |
|
420 | 674 |
panel := HorizontalPanelView |
675 |
origin:0.0 @ 0.0 |
|
676 |
corner:1.0 @ 50 |
|
677 |
in:top. |
|
130 | 678 |
|
420 | 679 |
b1 := Button label:'press me' in:panel. |
680 |
b1 model:myModel; change:#b0Pressed; |
|
681 |
labelMessage:#getLabel; aspect:#labelAspect. |
|
130 | 682 |
|
420 | 683 |
b2 := Button label:'press for bar' in:panel. |
684 |
b2 model:myModel; change:#b1Pressed. |
|
130 | 685 |
|
420 | 686 |
b3 := Button label:'press for foo' in:panel. |
687 |
b3 model:myModel; change:#b2Pressed. |
|
130 | 688 |
|
420 | 689 |
top open. |
593 | 690 |
[exEnd] |
130 | 691 |
|
133 | 692 |
|
693 |
the same, using actionBlocks: |
|
420 | 694 |
(notice, that we must disable changeMessages from the first button). |
593 | 695 |
[exBegin] |
420 | 696 |
|myModel b1 b2 b3 panel top currentLabel| |
697 |
||
698 |
currentLabel := 'foo'. |
|
133 | 699 |
|
420 | 700 |
myModel := Plug new. |
701 |
myModel respondTo:#getLabel with:[currentLabel]. |
|
702 |
||
703 |
top := StandardSystemView new. |
|
704 |
top extent:300@100. |
|
133 | 705 |
|
420 | 706 |
panel := HorizontalPanelView origin:0.0 @ 0.0 corner:1.0 @ 50 in:top. |
707 |
||
708 |
b1 := Button label:'press me' in:panel. |
|
655 | 709 |
b1 model:myModel; action:[Transcript showCR:'pressed']; |
420 | 710 |
labelMessage:#getLabel; aspect:#labelAspect; change:nil. |
133 | 711 |
|
420 | 712 |
b2 := Button label:'press for bar' in:panel. |
713 |
b2 action:[currentLabel := 'bar'. myModel changed:#labelAspect]. |
|
133 | 714 |
|
420 | 715 |
b3 := Button label:'press for foo' in:panel. |
716 |
b3 action:[currentLabel := 'foo'. myModel changed:#labelAspect]. |
|
133 | 717 |
|
420 | 718 |
top open. |
593 | 719 |
[exEnd] |
420 | 720 |
|
721 |
||
722 |
the same, using a labelChannel: |
|
593 | 723 |
[exBegin] |
420 | 724 |
|b1 b2 b3 panel top labelHolder| |
725 |
||
726 |
labelHolder := 'press me' asValue. |
|
727 |
||
728 |
top := StandardSystemView new. |
|
729 |
top extent:350@100. |
|
133 | 730 |
|
420 | 731 |
panel := HorizontalPanelView origin:0.0 @ 0.0 corner:1.0 @ 50 in:top. |
732 |
||
733 |
b1 := Button label:'none yet ' in:panel. |
|
734 |
b1 labelChannel:labelHolder. |
|
655 | 735 |
b1 action:[Transcript showCR:'pressed']. |
420 | 736 |
b1 sizeFixed:true. |
133 | 737 |
|
420 | 738 |
b2 := Button label:'press for bar' in:panel. |
739 |
b2 action:[ labelHolder value:'bar' ]. |
|
133 | 740 |
|
420 | 741 |
b3 := Button label:'press for foo' in:panel. |
742 |
b3 action:[ labelHolder value:'foo' ]. |
|
743 |
||
744 |
top open. |
|
593 | 745 |
[exEnd] |
133 | 746 |
|
4128 | 747 |
the same, using a labelChannel: |
748 |
[exBegin] |
|
749 |
|b| |
|
750 |
b := Button new. |
|
751 |
b label:'hello'. |
|
752 |
b renderer:(ButtonRenderer new). |
|
753 |
b open. |
|
754 |
[exEnd] |
|
755 |
||
756 |
||
88 | 757 |
see 'doc/coding-examples' and 'doc/misc/quick_view_intro.doc' |
758 |
for more variations on this theme. |
|
0 | 759 |
" |
760 |
! ! |
|
761 |
||
850 | 762 |
!Button class methodsFor:'instance creation'! |
205 | 763 |
|
764 |
abortButton |
|
765 |
"since abort-buttons are very common, here is a convenient |
|
766 |
method to create one ..." |
|
767 |
||
768 |
|aButton| |
|
0 | 769 |
|
6018 | 770 |
aButton := self label:(self classResources string:'Cancel'). |
3839 | 771 |
aButton name: 'abortButton'. |
205 | 772 |
aButton cursor:(Cursor thumbsDown). |
773 |
^ aButton |
|
366
27bf7d05650b
renamed abort-button to cancel
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
774 |
|
27bf7d05650b
renamed abort-button to cancel
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
775 |
"Modified: 20.2.1996 / 20:20:16 / cg" |
205 | 776 |
! |
777 |
||
778 |
abortButtonIn:aView |
|
779 |
"since abort-buttons are very common, here is a convenient |
|
780 |
method to create one ..." |
|
781 |
||
782 |
|b| |
|
60 | 783 |
|
205 | 784 |
aView addSubView:(b := self abortButton). |
785 |
^ b |
|
786 |
! |
|
787 |
||
788 |
form:aForm action:aBlock in:aView |
|
789 |
"create and return a new Button with icon-label, aForm |
|
790 |
and pressAction, aBlock. Button is placed into aView. |
|
791 |
OBSOLETE: this is for backward compatibility; |
|
792 |
you can now pass an image or form in the #label:action:in: message." |
|
793 |
||
2971 | 794 |
<resource:#obsolete> |
795 |
||
205 | 796 |
^ ((self in:aView) form:aForm) action:aBlock |
797 |
! |
|
798 |
||
799 |
label:aLabel action:aBlock |
|
800 |
"create and return a new Button with text-label, aString |
|
801 |
and pressAction, aBlock." |
|
802 |
||
803 |
^ (self label:aLabel) action:aBlock |
|
804 |
! |
|
805 |
||
806 |
label:aLabel action:aBlock in:aView |
|
807 |
"create and return a new Button with text-label, aString |
|
808 |
and pressAction, aBlock. Button is placed into aView." |
|
60 | 809 |
|
205 | 810 |
^ ((self in:aView) label:aLabel) action:aBlock |
811 |
! |
|
812 |
||
813 |
okButton |
|
814 |
"since ok-buttons are very common, here is a convenient |
|
815 |
method to create one ..." |
|
816 |
||
817 |
|aButton| |
|
818 |
||
6018 | 819 |
aButton := self label:(self classResources string:'OK'). |
3839 | 820 |
aButton name: 'okButton'. |
205 | 821 |
aButton cursor:(Cursor thumbsUp). |
219 | 822 |
aButton beReturnButton. |
205 | 823 |
^ aButton |
59 | 824 |
! |
825 |
||
205 | 826 |
okButtonIn:aView |
827 |
"since ok-buttons are very common, here is a convenient |
|
828 |
method to create one ..." |
|
829 |
||
830 |
|b| |
|
831 |
||
832 |
aView addSubView:(b := self okButton). |
|
833 |
^ b |
|
1196
42a10a56d284
added #switch & #trigger for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
834 |
! ! |
42a10a56d284
added #switch & #trigger for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
835 |
|
42a10a56d284
added #switch & #trigger for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
836 |
!Button class methodsFor:'ST-80 instance creation'! |
42a10a56d284
added #switch & #trigger for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
837 |
|
42a10a56d284
added #switch & #trigger for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
838 |
switch |
42a10a56d284
added #switch & #trigger for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
839 |
"ST-80 compatibility: create & return a new radioButton" |
42a10a56d284
added #switch & #trigger for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
840 |
|
42a10a56d284
added #switch & #trigger for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
841 |
^ RadioButton new. |
42a10a56d284
added #switch & #trigger for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
842 |
|
42a10a56d284
added #switch & #trigger for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
843 |
"Created: 18.4.1997 / 20:19:09 / cg" |
42a10a56d284
added #switch & #trigger for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
844 |
"Modified: 18.4.1997 / 20:28:10 / cg" |
205 | 845 |
! |
846 |
||
847 |
toggle |
|
848 |
"ST-80 compatibility: create & return a new toggle." |
|
849 |
||
850 |
^ Toggle new |
|
851 |
||
852 |
" |
|
853 |
Button toggle label:'press me'; |
|
854 |
model:((PluggableAdaptor on:(Point new)) |
|
855 |
getSelector:#x putSelector:#x:) |
|
856 |
" |
|
857 |
"this is the same as" |
|
858 |
" |
|
859 |
Toggle new label:'press me'; |
|
860 |
model:((PluggableAdaptor on:(Point new)) |
|
861 |
getSelector:#x putSelector:#x:) |
|
862 |
" |
|
1196
42a10a56d284
added #switch & #trigger for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
863 |
! |
42a10a56d284
added #switch & #trigger for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
864 |
|
42a10a56d284
added #switch & #trigger for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
865 |
trigger |
42a10a56d284
added #switch & #trigger for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
866 |
"ST-80 compatibility: create & return a new button, which |
42a10a56d284
added #switch & #trigger for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
867 |
triggers on press." |
42a10a56d284
added #switch & #trigger for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
868 |
|
42a10a56d284
added #switch & #trigger for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
869 |
|b| |
42a10a56d284
added #switch & #trigger for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
870 |
|
6018 | 871 |
b := self new. |
1196
42a10a56d284
added #switch & #trigger for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
872 |
b controller beTriggerOnDown. |
42a10a56d284
added #switch & #trigger for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
873 |
^ b |
42a10a56d284
added #switch & #trigger for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
874 |
|
42a10a56d284
added #switch & #trigger for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
875 |
"Created: 18.4.1997 / 19:55:57 / cg" |
42a10a56d284
added #switch & #trigger for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1170
diff
changeset
|
876 |
"Modified: 18.4.1997 / 19:56:52 / cg" |
205 | 877 |
! ! |
878 |
||
850 | 879 |
!Button class methodsFor:'defaults'! |
205 | 880 |
|
1595 | 881 |
defaultDisabledForegroundColor |
882 |
^ DefaultDisabledForegroundColor |
|
883 |
||
884 |
"Created: / 20.6.1998 / 15:18:28 / cg" |
|
885 |
! |
|
886 |
||
0 | 887 |
returnFormOn:aDevice |
888 |
"return the form used for the return arrow in non-3D; |
|
889 |
cache the one for Display for the next round." |
|
890 |
||
891 |
|f| |
|
892 |
||
5729 | 893 |
ReturnForm notNil ifTrue:[ |
894 |
^ ReturnForm onDevice:aDevice. |
|
2056
4b107f0ab7eb
try bitmaps in package directory
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
895 |
] ifFalse:[ |
1387 | 896 |
f := Form width:24 height:14 fromArray:#[2r00000000 2r00000000 2r00000000 |
781
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
897 |
2r00000000 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
898 |
2r00000000 2r00000011 2r11100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
899 |
2r00000001 2r10000011 2r11100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
900 |
2r00000011 2r10000011 2r11100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
901 |
2r00000111 2r11111111 2r11100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
902 |
2r00001111 2r11111111 2r11100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
903 |
2r00011111 2r11111111 2r11100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
904 |
2r00001111 2r11111111 2r11100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
905 |
2r00000111 2r11111111 2r11100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
906 |
2r00000011 2r10000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
907 |
2r00000001 2r10000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
908 |
2r00000000 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
909 |
2r00000000 2r00000000 2r00000000] |
5729 | 910 |
onDevice:aDevice. |
911 |
aDevice == Display ifTrue:[ |
|
912 |
ReturnForm := f. |
|
913 |
]. |
|
914 |
^ f. |
|
915 |
]. |
|
781
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
916 |
|
1387 | 917 |
"Modified: / 3.11.1997 / 09:12:37 / cg" |
0 | 918 |
! |
919 |
||
205 | 920 |
returnLightFormOn:aDevice |
921 |
"return the form used for the return arrow light pixels (3D only); |
|
922 |
cache the one for Display for the next round" |
|
923 |
||
5729 | 924 |
|
205 | 925 |
|f| |
926 |
||
5729 | 927 |
ReturnLightForm notNil ifTrue:[ |
928 |
^ ReturnLightForm onDevice:aDevice. |
|
2056
4b107f0ab7eb
try bitmaps in package directory
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
929 |
] ifFalse:[ |
1387 | 930 |
f := Form width:24 height:14 fromArray:#[2r00000000 2r00000000 2r00000000 |
781
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
931 |
2r00000000 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
932 |
2r00000000 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
933 |
2r00000000 2r00000000 2r00100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
934 |
2r00000000 2r00000000 2r00100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
935 |
2r00000000 2r00000000 2r00100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
936 |
2r00000000 2r00000000 2r00100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
937 |
2r00000000 2r00000000 2r00100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
938 |
2r00000000 2r00000000 2r00100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
939 |
2r00000000 2r11111111 2r11100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
940 |
2r00000000 2r10000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
941 |
2r00000000 2r10000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
942 |
2r00000000 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
943 |
2r00000000 2r00000000 2r00000000] |
5729 | 944 |
onDevice:aDevice. |
945 |
aDevice == Display ifTrue:[ |
|
946 |
ReturnLightForm := f. |
|
947 |
]. |
|
948 |
^ f. |
|
205 | 949 |
]. |
781
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
950 |
|
1387 | 951 |
"Modified: / 3.11.1997 / 09:12:23 / cg" |
205 | 952 |
! |
953 |
||
0 | 954 |
returnShadowFormOn:aDevice |
955 |
"return the form used for the return arrow shadow pixels (3D only); |
|
956 |
cache the one for Display for the next round." |
|
957 |
||
958 |
|f| |
|
959 |
||
5729 | 960 |
ReturnShadowForm notNil ifTrue:[ |
961 |
^ ReturnShadowForm onDevice:aDevice. |
|
2056
4b107f0ab7eb
try bitmaps in package directory
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
962 |
] ifFalse:[ |
1387 | 963 |
f := Form width:24 height:14 fromArray:#[2r00000000 2r00000000 2r00000000 |
781
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
964 |
2r00000000 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
965 |
2r00000000 2r00000011 2r11100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
966 |
2r00000001 2r10000010 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
967 |
2r00000010 2r10000010 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
968 |
2r00000100 2r11111110 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
969 |
2r00001000 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
970 |
2r00010000 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
971 |
2r00001000 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
972 |
2r00000100 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
973 |
2r00000010 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
974 |
2r00000001 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
975 |
2r00000000 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
976 |
2r00000000 2r00000000 2r00000000] |
5729 | 977 |
onDevice:aDevice. |
978 |
aDevice == Display ifTrue:[ |
|
979 |
ReturnShadowForm := f. |
|
980 |
]. |
|
981 |
^ f. |
|
0 | 982 |
]. |
5729 | 983 |
|
781
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
984 |
|
1387 | 985 |
"Modified: / 3.11.1997 / 09:12:11 / cg" |
0 | 986 |
! |
987 |
||
205 | 988 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
989 |
"extract values from the styleSheet and cache them in class variables" |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
990 |
|
1355 | 991 |
<resource: #style (#'button.edgeStyle' #'button.font' #'button.borderWidth' |
992 |
#'button.activeLevel' #'button.passiveLevel' |
|
993 |
#'button.backgroundColor' #'button.foregroundColor' |
|
994 |
#'button.activeBackgroundColor' #'button.activeForegroundColor' |
|
995 |
#'button.enteredBackgroundColor' #'button.enteredForegroundColor' |
|
996 |
#'button.disabledForegroundColor' #'button.disabledBackgroundColor' |
|
2497
e3e1a719e31d
support etched color (win32 style)
Claus Gittinger <cg@exept.de>
parents:
2490
diff
changeset
|
997 |
#'button.disabledEtchedForegroundColor' |
1355 | 998 |
#'button.returnButtonHasImage' |
999 |
#'button.returnButtonHasBorder' |
|
1000 |
#'button.shadowColor' #'button.lightColor' |
|
2137
2642e627bb2a
eliminated styleSheet name = win95 queries
Claus Gittinger <cg@exept.de>
parents:
2078
diff
changeset
|
1001 |
#'button.halfShadowColor' #'button.halfLightColor' |
2642e627bb2a
eliminated styleSheet name = win95 queries
Claus Gittinger <cg@exept.de>
parents:
2078
diff
changeset
|
1002 |
#'focusHighlightStyle')> |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
1003 |
|
205 | 1004 |
|defaultLevel| |
0 | 1005 |
|
205 | 1006 |
StyleSheet is3D ifTrue:[ |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
1007 |
defaultLevel := 1. |
205 | 1008 |
] ifFalse:[ |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
1009 |
defaultLevel := 0 |
0 | 1010 |
]. |
1866 | 1011 |
DefaultActiveLevel := StyleSheet at:#'button.activeLevel' default:(defaultLevel negated). |
1012 |
DefaultPassiveLevel := StyleSheet at:#'button.passiveLevel' default:defaultLevel. |
|
1013 |
||
1014 |
DefaultEdgeStyle := StyleSheet at:#'button.edgeStyle'. |
|
1015 |
DefaultFont := StyleSheet fontAt:#'button.font'. |
|
1016 |
DefaultBorderWidth := StyleSheet at:#'button.borderWidth'. |
|
1017 |
DefaultForegroundColor := StyleSheet colorAt:#'button.foregroundColor'. |
|
1018 |
DefaultBackgroundColor := StyleSheet colorAt:#'button.backgroundColor'. |
|
1019 |
DefaultDisabledForegroundColor := StyleSheet colorAt:#'button.disabledForegroundColor' default:Color gray. |
|
1020 |
DefaultDisabledBackgroundColor := StyleSheet colorAt:#'button.disabledBackgroundColor'. |
|
2497
e3e1a719e31d
support etched color (win32 style)
Claus Gittinger <cg@exept.de>
parents:
2490
diff
changeset
|
1021 |
DefaultDisabledEtchedForegroundColor := StyleSheet colorAt:#'button.disabledEtchedForegroundColor'. |
1866 | 1022 |
DefaultEnteredForegroundColor := StyleSheet colorAt:#'button.enteredForegroundColor'. |
1023 |
DefaultEnteredBackgroundColor := StyleSheet colorAt:#'button.enteredBackgroundColor'. |
|
1024 |
DefaultActiveForegroundColor := StyleSheet colorAt:#'button.activeForegroundColor'. |
|
1025 |
DefaultActiveBackgroundColor := StyleSheet colorAt:#'button.activeBackgroundColor'. |
|
1026 |
DefaultReturnButtonHasImage := StyleSheet at:#'button.returnButtonHasImage' default:true. |
|
1027 |
DefaultReturnButtonHasBorder := StyleSheet at:#'button.returnButtonHasBorder' default:false. |
|
1028 |
DefaultShadowColor := StyleSheet colorAt:#'button.shadowColor'. |
|
1029 |
DefaultLightColor := StyleSheet colorAt:#'button.lightColor'. |
|
1030 |
DefaultHalfShadowColor := StyleSheet colorAt:#'button.halfShadowColor'. |
|
1031 |
DefaultHalfLightColor := StyleSheet colorAt:#'button.halfLightColor'. |
|
2137
2642e627bb2a
eliminated styleSheet name = win95 queries
Claus Gittinger <cg@exept.de>
parents:
2078
diff
changeset
|
1032 |
DefaultFocusHighlightStyle := StyleSheet at:#'focusHighlightStyle'. |
1355 | 1033 |
|
1034 |
"Modified: 20.10.1997 / 13:49:41 / cg" |
|
0 | 1035 |
! ! |
1036 |
||
205 | 1037 |
!Button methodsFor:'accessing-behavior'! |
1038 |
||
1039 |
action:aBlock |
|
1040 |
"convenient method: depending on the setting of controllers triggerOnDown flag, |
|
1041 |
either set the press-action and clear any release-action or |
|
1042 |
vice versa, set the release-action and clear the press-action." |
|
1043 |
||
2864 | 1044 |
controller isNil ifTrue:[ |
1045 |
'Button [error]: no controller in #action' errorPrintCR. |
|
1046 |
] ifFalse:[ |
|
2515 | 1047 |
controller action:aBlock |
2864 | 1048 |
]. |
205 | 1049 |
! |
1050 |
||
1051 |
autoRepeat |
|
346 | 1052 |
"turn on autorepeat OBSOLETE; use #autoRepeat:" |
205 | 1053 |
|
2971 | 1054 |
<resource:#obsolete> |
1055 |
||
205 | 1056 |
controller autoRepeat |
346 | 1057 |
|
1058 |
"Modified: 9.2.1996 / 22:42:37 / cg" |
|
205 | 1059 |
! |
1060 |
||
1061 |
autoRepeat:aBoolean |
|
1062 |
"turn on/off autorepeat" |
|
1063 |
||
1064 |
controller autoRepeat:aBoolean |
|
1065 |
||
1066 |
"Modified: 5.9.1995 / 22:06:13 / claus" |
|
1067 |
! |
|
1068 |
||
5879 | 1069 |
doubleClickAction |
1070 |
"return the doubleClickAction; that's the block which gets evaluated |
|
1071 |
when the button is double-clicked (if non-nil). |
|
1072 |
Seldom used with buttons" |
|
1073 |
||
1074 |
^ controller doubleClickAction |
|
1075 |
! |
|
1076 |
||
1077 |
doubleClickAction:aBlock |
|
1078 |
"define the action to be performed on doubleClick |
|
1079 |
Seldom used with buttons." |
|
1080 |
||
1081 |
controller notNil ifTrue:[ |
|
1082 |
controller doubleClickAction:aBlock |
|
1083 |
] |
|
1084 |
! |
|
1085 |
||
264 | 1086 |
enabled |
1087 |
"return true if the button is enabled" |
|
1088 |
||
1812 | 1089 |
^ controller notNil and:[controller enabled] |
264 | 1090 |
|
1091 |
"Created: 17.12.1995 / 16:12:26 / cg" |
|
1092 |
! |
|
1093 |
||
1832 | 1094 |
enabled:aBoolean |
1095 |
"enable/disable the button" |
|
1096 |
||
2515 | 1097 |
controller notNil ifTrue:[ |
1098 |
controller enabled:aBoolean |
|
1099 |
] |
|
1832 | 1100 |
|
1101 |
"Created: / 30.3.1999 / 14:50:58 / stefan" |
|
1102 |
! |
|
1103 |
||
205 | 1104 |
pressAction |
5879 | 1105 |
"return the pressAction; that's the block which gets evaluated |
205 | 1106 |
when the button is pressed (if non-nil)" |
1107 |
||
1108 |
^ controller pressAction |
|
1109 |
! |
|
0 | 1110 |
|
205 | 1111 |
pressAction:aBlock |
1112 |
"define the action to be performed on press" |
|
1113 |
||
2515 | 1114 |
controller notNil ifTrue:[ |
1115 |
controller pressAction:aBlock |
|
1116 |
] |
|
205 | 1117 |
! |
1118 |
||
867 | 1119 |
releaseAction |
5879 | 1120 |
"return the releaseAction; that's the block which gets evaluated |
1121 |
when the button is released (if non-nil)" |
|
867 | 1122 |
|
1123 |
^ controller releaseAction |
|
1124 |
! |
|
1125 |
||
1126 |
releaseAction:aBlock |
|
1127 |
"define the action to be performed on release" |
|
1128 |
||
2515 | 1129 |
controller notNil ifTrue:[ |
1130 |
controller releaseAction:aBlock |
|
1131 |
] |
|
867 | 1132 |
! ! |
1133 |
||
1134 |
!Button methodsFor:'accessing-channels'! |
|
1135 |
||
1136 |
enableChannel |
|
1137 |
"return a valueHolder for enable/disable" |
|
1138 |
||
1644
c2b849ce4552
care for non-existing controller when accessing channels.
Claus Gittinger <cg@exept.de>
parents:
1630
diff
changeset
|
1139 |
controller isNil ifTrue:[^ nil]. |
867 | 1140 |
^ controller enableChannel |
1141 |
||
1644
c2b849ce4552
care for non-existing controller when accessing channels.
Claus Gittinger <cg@exept.de>
parents:
1630
diff
changeset
|
1142 |
"Modified: / 13.8.1998 / 12:04:46 / cg" |
867 | 1143 |
! |
1144 |
||
1145 |
enableChannel:aValueHolderForBoolean |
|
1146 |
"set the valueHolder used for enable/disable" |
|
1147 |
||
1148 |
controller enableChannel:aValueHolderForBoolean |
|
1149 |
! |
|
1150 |
||
205 | 1151 |
pressChannel |
1152 |
"return the pressChannel" |
|
1153 |
||
1644
c2b849ce4552
care for non-existing controller when accessing channels.
Claus Gittinger <cg@exept.de>
parents:
1630
diff
changeset
|
1154 |
controller isNil ifTrue:[^ nil]. |
205 | 1155 |
^ controller pressChannel |
1156 |
||
1644
c2b849ce4552
care for non-existing controller when accessing channels.
Claus Gittinger <cg@exept.de>
parents:
1630
diff
changeset
|
1157 |
"Modified: / 7.9.1995 / 18:16:20 / claus" |
c2b849ce4552
care for non-existing controller when accessing channels.
Claus Gittinger <cg@exept.de>
parents:
1630
diff
changeset
|
1158 |
"Modified: / 13.8.1998 / 12:04:51 / cg" |
205 | 1159 |
! |
1160 |
||
1161 |
pressChannel:aBlock |
|
1162 |
"set the pressChannel" |
|
1163 |
||
1164 |
controller pressChannel:aBlock |
|
1165 |
||
1166 |
"Modified: 7.9.1995 / 18:05:14 / claus" |
|
1167 |
! |
|
1168 |
||
1169 |
releaseChannel |
|
1170 |
"return the releaseChannel" |
|
1171 |
||
1644
c2b849ce4552
care for non-existing controller when accessing channels.
Claus Gittinger <cg@exept.de>
parents:
1630
diff
changeset
|
1172 |
controller isNil ifTrue:[^ nil]. |
205 | 1173 |
^ controller releaseChannel |
1174 |
||
1644
c2b849ce4552
care for non-existing controller when accessing channels.
Claus Gittinger <cg@exept.de>
parents:
1630
diff
changeset
|
1175 |
"Modified: / 7.9.1995 / 18:15:24 / claus" |
c2b849ce4552
care for non-existing controller when accessing channels.
Claus Gittinger <cg@exept.de>
parents:
1630
diff
changeset
|
1176 |
"Modified: / 13.8.1998 / 12:04:55 / cg" |
205 | 1177 |
! |
1178 |
||
1179 |
releaseChannel:aBlock |
|
1180 |
"set the releaseChannel" |
|
1181 |
||
1182 |
controller releaseChannel:aBlock |
|
1183 |
||
1184 |
"Modified: 7.9.1995 / 18:05:21 / claus" |
|
1185 |
! ! |
|
1186 |
||
1187 |
!Button methodsFor:'accessing-look'! |
|
1188 |
||
1189 |
activeBackgroundColor |
|
1190 |
"return the background color to be used when pressed" |
|
1191 |
||
1192 |
^ activeBgColor |
|
164 | 1193 |
! |
1194 |
||
205 | 1195 |
activeBackgroundColor:aColor |
1196 |
"set the background color to be used when pressed" |
|
1197 |
||
1198 |
activeBgColor := aColor. |
|
1199 |
self redrawIfPressed |
|
1200 |
! |
|
1201 |
||
1202 |
activeForegroundColor |
|
1203 |
"return the foreground color to be used when pressed" |
|
1204 |
||
1205 |
^ activeFgColor |
|
1206 |
! |
|
1207 |
||
1208 |
activeForegroundColor:aColor |
|
1209 |
"set the foreground color to be used when pressed" |
|
1210 |
||
1211 |
activeFgColor := aColor. |
|
1212 |
self redrawIfPressed |
|
1213 |
! |
|
1214 |
||
1215 |
activeForegroundColor:fgColor backgroundColor:bgColor |
|
1216 |
"set both fg and bg colors to be used when pressed" |
|
1217 |
||
1218 |
activeFgColor := fgColor. |
|
1219 |
activeBgColor := bgColor. |
|
1220 |
self redrawIfPressed |
|
1221 |
! |
|
0 | 1222 |
|
205 | 1223 |
activeLevel |
1224 |
"return the level of the button when pressed" |
|
1225 |
||
1226 |
^ onLevel |
|
1227 |
! |
|
1228 |
||
1229 |
activeLevel:aNumber |
|
1230 |
"set the level of the button when pressed (i.e. how deep)" |
|
1231 |
||
1630 | 1232 |
onLevel ~~ aNumber ifTrue:[ |
5456 | 1233 |
(styleSheet at:'button.ignoreLevel' default:false) ifFalse:[ |
1234 |
onLevel := aNumber. |
|
1235 |
(controller notNil |
|
1236 |
and:[controller pressed]) ifTrue:[ |
|
1237 |
self level:onLevel. |
|
1238 |
margin := onLevel abs max:offLevel abs. |
|
1239 |
self invalidate. |
|
1240 |
] |
|
992 | 1241 |
] |
1630 | 1242 |
]. |
1243 |
||
1244 |
"Modified: / 30.7.1998 / 22:29:01 / cg" |
|
205 | 1245 |
! |
1246 |
||
1247 |
activeLogo:anImageOrString |
|
1248 |
"define the logo to be displayed while active - |
|
1249 |
this is optional; the default is to display the same |
|
1250 |
(logo) in both pressed and released states." |
|
1251 |
||
1252 |
activeLogo := anImageOrString. |
|
1253 |
controller pressed ifTrue:[ |
|
3122
2b734c50d620
Do not use obsolete message #logo:
Stefan Vogel <sv@exept.de>
parents:
3052
diff
changeset
|
1254 |
self label:anImageOrString |
205 | 1255 |
] |
0 | 1256 |
! |
1257 |
||
3598 | 1258 |
allViewBackground:something if:condition |
1956
9467faaaf048
allViewBackground blocking moved from Label to here
Claus Gittinger <cg@exept.de>
parents:
1875
diff
changeset
|
1259 |
"ignore here" |
9467faaaf048
allViewBackground blocking moved from Label to here
Claus Gittinger <cg@exept.de>
parents:
1875
diff
changeset
|
1260 |
! |
9467faaaf048
allViewBackground blocking moved from Label to here
Claus Gittinger <cg@exept.de>
parents:
1875
diff
changeset
|
1261 |
|
205 | 1262 |
beImageButton |
1263 |
"make mySelf an image button - that is turn off all levelChanges |
|
1264 |
and logo spacing. This should be sent for buttons which use both |
|
1265 |
passive and active logos, and the 3D effect comes from the bitmaps |
|
1266 |
(i.e. windows buttons)." |
|
1267 |
||
1268 |
self |
|
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1269 |
extent:(labelWidth @ labelHeight); |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1270 |
sizeFixed:true; |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1271 |
borderWidth:0; |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1272 |
activeLevel:0; |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1273 |
passiveLevel:0; |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1274 |
horizontalSpace:0; |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1275 |
verticalSpace:0; |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1276 |
newLayout. |
205 | 1277 |
|
1278 |
"Created: 17.9.1995 / 20:41:47 / claus" |
|
1279 |
"Modified: 19.9.1995 / 16:34:08 / claus" |
|
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1280 |
"Modified: 28.5.1996 / 22:04:14 / cg" |
205 | 1281 |
! |
1282 |
||
244 | 1283 |
beReturnButton |
1051 | 1284 |
"show show a return-key image after the label. |
1285 |
Same as 'isReturnButton:true' for ST-80 compatibility." |
|
244 | 1286 |
|
1287 |
self isReturnButton:true |
|
1288 |
! |
|
1289 |
||
205 | 1290 |
beRoundRadioButton |
1291 |
"setup myself for a round radioButton look. |
|
1292 |
this is a private method; do not use it. It is going to move into the |
|
1293 |
RadioButton class." |
|
0 | 1294 |
|
205 | 1295 |
self activeLogo:(Icon constantNamed:'RadioOn'). |
1296 |
self passiveLogo:(Icon constantNamed:'RadioOff'). |
|
1297 |
self activeLevel:0; |
|
1298 |
passiveLevel:0; |
|
1299 |
activeBackgroundColor:bgColor; |
|
1300 |
activeForegroundColor:fgColor; |
|
1301 |
borderWidth:0; |
|
1302 |
enteredBackgroundColor:bgColor. |
|
1303 |
self computeLabelSize. |
|
1304 |
self beImageButton. |
|
1305 |
||
1306 |
"Created: 22.9.1995 / 15:48:05 / claus" |
|
1307 |
"Modified: 22.9.1995 / 17:07:46 / claus" |
|
1308 |
! |
|
1309 |
||
1093
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
1310 |
defaultable |
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
1311 |
"return true, if the receiver is defaultable" |
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
1312 |
|
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
1313 |
^ defaultable |
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
1314 |
! |
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
1315 |
|
1051 | 1316 |
defaultable:aBoolean |
1317 |
"set/clear the defaultable attribute. If defaultable, |
|
1318 |
the preferredExtent is computed to include any additional |
|
1319 |
space required when the receiver is a returnButton." |
|
1320 |
||
1321 |
defaultable ~~ aBoolean ifTrue:[ |
|
1322 |
defaultable := aBoolean. |
|
1323 |
self newLayout |
|
1324 |
] |
|
1325 |
! |
|
1326 |
||
205 | 1327 |
disabledForegroundColor |
1328 |
"return the foreground color used when the button is disabled" |
|
1329 |
||
1330 |
^ disabledFgColor |
|
1331 |
! |
|
1332 |
||
2436 | 1333 |
disabledForegroundColor:aColor |
1334 |
"set the foreground color used when the button is disabled" |
|
1335 |
||
1336 |
disabledFgColor := aColor |
|
1337 |
! |
|
1338 |
||
205 | 1339 |
disabledLogo:anImageOrString |
2892 | 1340 |
"define the logo to be displayed while disabled - |
205 | 1341 |
this is optional; the default is to display the same |
3925 | 1342 |
(logo) in both pressed and released states. |
1343 |
However, the disabled logo is ignored if a labelChannel has |
|
1344 |
been set - then that value has priority." |
|
205 | 1345 |
|
1346 |
disabledLogo := anImageOrString. |
|
3925 | 1347 |
labelChannel isNil ifTrue:[ |
1348 |
self enabled ifFalse:[ |
|
1349 |
self label:anImageOrString |
|
1350 |
] |
|
205 | 1351 |
] |
1352 |
||
1353 |
"Created: 17.9.1995 / 19:50:17 / claus" |
|
1354 |
"Modified: 17.9.1995 / 19:50:34 / claus" |
|
59 | 1355 |
! |
1356 |
||
205 | 1357 |
edgeStyle:aSymbol |
1358 |
"set the edgestyle - currently only #soft or nil" |
|
1359 |
||
1360 |
edgeStyle := aSymbol |
|
1361 |
! |
|
1362 |
||
1206
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1363 |
enterLevel |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1364 |
"return the level to be used when the mouse |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1365 |
pointer enters the button area" |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1366 |
|
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1367 |
^ enterLevel |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1368 |
|
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1369 |
"Created: 26.4.1997 / 20:48:53 / cg" |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1370 |
"Modified: 26.4.1997 / 20:49:29 / cg" |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1371 |
! |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1372 |
|
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1373 |
enterLevel:aNumber |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1374 |
"set the level to be used when the mouse |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1375 |
pointer enters the button area" |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1376 |
|
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1377 |
enterLevel := aNumber |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1378 |
|
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1379 |
"Created: 26.4.1997 / 20:49:10 / cg" |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1380 |
"Modified: 26.4.1997 / 20:49:35 / cg" |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1381 |
! |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1382 |
|
205 | 1383 |
enteredBackgroundColor |
1384 |
"return the background color to be used when the mouse |
|
1385 |
pointer enters the button area" |
|
1386 |
||
1387 |
^ enteredBgColor |
|
1388 |
! |
|
1389 |
||
1390 |
enteredBackgroundColor:aColor |
|
1391 |
"set the background color to be used when the mouse |
|
1392 |
pointer enters the button area" |
|
1393 |
||
1394 |
enteredBgColor := aColor |
|
1395 |
! |
|
1396 |
||
1397 |
enteredForegroundColor |
|
1398 |
"return the foreground color to be used when the mouse |
|
1399 |
pointer enters the button area" |
|
1400 |
||
1401 |
^ enteredFgColor |
|
1402 |
! |
|
1403 |
||
1404 |
enteredForegroundColor:aColor |
|
1405 |
"set the foreground color to be used when the mouse |
|
1406 |
pointer enters the button area" |
|
59 | 1407 |
|
205 | 1408 |
enteredFgColor := aColor |
1409 |
! |
|
1410 |
||
3052 | 1411 |
enteredLogo:anImageOrString |
1412 |
"define the logo to be displayed while the mousePointer is in the button - |
|
1413 |
this is optional; the default is to display the same |
|
3925 | 1414 |
(logo) in both entered and normal states. |
1415 |
However, the entered logo is ignored if a labelChannel has |
|
1416 |
been set - then that value has priority." |
|
3052 | 1417 |
|
1418 |
enteredLogo := anImageOrString. |
|
3925 | 1419 |
labelChannel isNil ifTrue:[ |
1420 |
controller entered ifTrue:[ |
|
1421 |
self label:anImageOrString |
|
1422 |
] |
|
3052 | 1423 |
] |
1424 |
! |
|
1425 |
||
205 | 1426 |
focusLogo:anImageOrString |
1427 |
"define the logo to be displayed while active - |
|
1428 |
this is optional; the default is to display the same |
|
3925 | 1429 |
(logo) in both pressed and released states. |
1430 |
However, the focus logo is ignored if a labelChannel has |
|
1431 |
been set - then that value has priority." |
|
205 | 1432 |
|
1433 |
focusLogo := anImageOrString. |
|
1434 |
||
1435 |
"Created: 17.9.1995 / 19:50:17 / claus" |
|
1436 |
"Modified: 17.9.1995 / 20:00:43 / claus" |
|
1437 |
! |
|
59 | 1438 |
|
205 | 1439 |
isReturnButton:aBoolean |
5583 | 1440 |
"show/don't show a return-key image after the label" |
205 | 1441 |
|
1442 |
isReturnButton ~~ aBoolean ifTrue:[ |
|
5583 | 1443 |
DefaultReturnButtonHasBorder ifTrue:[ |
1444 |
self borderWidth:(aBoolean ifTrue:[1] ifFalse:[0]) |
|
1445 |
]. |
|
1446 |
isReturnButton := aBoolean. |
|
1447 |
self newLayout |
|
205 | 1448 |
] |
1449 |
! |
|
1450 |
||
2309 | 1451 |
label:aStringOrImageOrForm |
1452 |
|xlatedLabel| |
|
1453 |
||
1454 |
xlatedLabel := self defineShortcutAndTranslateLabelStringFrom:aStringOrImageOrForm. |
|
2415 | 1455 |
super label:xlatedLabel. |
1456 |
! |
|
2309 | 1457 |
|
1206
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1458 |
leaveLevel |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1459 |
"return the level to be used when the mouse |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1460 |
pointer leaves the button area" |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1461 |
|
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1462 |
^ leaveLevel |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1463 |
|
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1464 |
"Created: 26.4.1997 / 20:48:26 / cg" |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1465 |
"Modified: 26.4.1997 / 20:49:47 / cg" |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1466 |
! |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1467 |
|
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1468 |
leaveLevel:aNumber |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1469 |
"set the level to be used when the mouse |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1470 |
pointer leaves the button area" |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1471 |
|
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1472 |
leaveLevel := aNumber |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1473 |
|
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1474 |
"Created: 26.4.1997 / 20:49:22 / cg" |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1475 |
"Modified: 26.4.1997 / 20:49:53 / cg" |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1476 |
! |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
1477 |
|
1094 | 1478 |
loseDefault |
1479 |
"ST-80 compatibility - clear isReturnButton attribute" |
|
1480 |
||
1481 |
self isReturnButton:false |
|
1482 |
||
1483 |
"Created: 3.3.1997 / 16:20:47 / cg" |
|
1484 |
"Modified: 3.3.1997 / 18:12:06 / cg" |
|
1485 |
! |
|
1486 |
||
205 | 1487 |
offLevel |
3556 | 1488 |
<resource: #obsolete> |
205 | 1489 |
"return the level of the button when released. |
1490 |
Historic leftover; use #passiveLevel." |
|
1491 |
||
1492 |
^ offLevel |
|
59 | 1493 |
! |
1494 |
||
205 | 1495 |
offLevel:aNumber |
3556 | 1496 |
<resource: #obsolete> |
205 | 1497 |
"set the level of the button when released (i.e. how deep). |
1498 |
Historic leftover; use #passiveLevel:." |
|
1499 |
||
1500 |
^ self passiveLevel:aNumber |
|
1501 |
! |
|
1502 |
||
1503 |
onLevel |
|
3556 | 1504 |
<resource: #obsolete> |
205 | 1505 |
"return the level of the button when pressed. |
1506 |
Historic leftover; use #activeLevel." |
|
1507 |
||
1508 |
^ onLevel |
|
1509 |
! |
|
1510 |
||
1511 |
onLevel:aNumber |
|
3556 | 1512 |
<resource: #obsolete> |
205 | 1513 |
"set the level of the button when pressed (i.e. how deep). |
1514 |
Historic leftover; use #activeLevel:." |
|
1515 |
||
1516 |
^ self activeLevel:aNumber |
|
1517 |
! |
|
1518 |
||
1519 |
passiveLevel |
|
1520 |
"return the level of the button when released" |
|
1521 |
||
1522 |
^ offLevel |
|
1523 |
! |
|
1524 |
||
1525 |
passiveLevel:aNumber |
|
1526 |
"set the level of the button when not pressed (i.e. how high)" |
|
118 | 1527 |
|
1630 | 1528 |
offLevel ~~ aNumber ifTrue:[ |
5456 | 1529 |
(styleSheet at:'button.ignoreLevel' default:false) ifFalse:[ |
1530 |
offLevel := aNumber. |
|
1531 |
(controller notNil |
|
1532 |
and:[controller pressed not]) ifTrue:[ |
|
1533 |
self level:offLevel. |
|
1534 |
margin := onLevel abs max:offLevel abs. |
|
1535 |
self invalidate. |
|
1536 |
] |
|
992 | 1537 |
] |
205 | 1538 |
] |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1539 |
|
1630 | 1540 |
"Modified: / 30.7.1998 / 22:29:17 / cg" |
205 | 1541 |
! |
1542 |
||
1543 |
passiveLogo:anImageOrString |
|
1544 |
"define the logo to be displayed while inactive - |
|
1545 |
this is optional; the default is to display the same |
|
3925 | 1546 |
(logo) in both pressed and released states. |
1547 |
However, the inactive logo is ignored if a labelChannel has |
|
1548 |
been set - then that value has priority." |
|
118 | 1549 |
|
205 | 1550 |
passiveLogo := anImageOrString. |
3925 | 1551 |
labelChannel isNil ifTrue:[ |
1552 |
controller pressed ifFalse:[ |
|
1553 |
self label:anImageOrString |
|
1554 |
] |
|
205 | 1555 |
] |
1094 | 1556 |
! |
1557 |
||
1558 |
takeDefault |
|
1559 |
"ST-80 compatibility - set isReturnButton attribute" |
|
1560 |
||
1561 |
self isReturnButton:true |
|
1562 |
||
1563 |
"Created: 3.3.1997 / 16:20:52 / cg" |
|
1564 |
"Modified: 3.3.1997 / 18:11:58 / cg" |
|
1223
840e31e3f140
care for halfLight & halfShadow, when the viewBackground changes.
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1565 |
! |
840e31e3f140
care for halfLight & halfShadow, when the viewBackground changes.
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1566 |
|
6093 | 1567 |
viewBackground:aColorOrForm |
1568 |
super viewBackground:aColorOrForm. |
|
1569 |
aColorOrForm isColor ifTrue:[ |
|
5635 | 1570 |
device hasGrayscales ifTrue:[ |
1223
840e31e3f140
care for halfLight & halfShadow, when the viewBackground changes.
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1571 |
halfLightColor notNil ifTrue:[ |
6093 | 1572 |
halfLightColor := (aColorOrForm averageColorIn:(0@0 corner:7@7)) lightened "on:device". |
1223
840e31e3f140
care for halfLight & halfShadow, when the viewBackground changes.
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1573 |
]. |
840e31e3f140
care for halfLight & halfShadow, when the viewBackground changes.
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1574 |
halfShadowColor notNil ifTrue:[ |
6093 | 1575 |
halfShadowColor := (aColorOrForm averageColorIn:(0@0 corner:7@7)) darkened "on:device". |
1223
840e31e3f140
care for halfLight & halfShadow, when the viewBackground changes.
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1576 |
] |
840e31e3f140
care for halfLight & halfShadow, when the viewBackground changes.
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1577 |
] |
840e31e3f140
care for halfLight & halfShadow, when the viewBackground changes.
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1578 |
]. |
840e31e3f140
care for halfLight & halfShadow, when the viewBackground changes.
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1579 |
|
6093 | 1580 |
"Modified: / 03-05-1997 / 10:37:24 / cg" |
1581 |
"Modified (format): / 12-02-2017 / 12:58:10 / cg" |
|
205 | 1582 |
! ! |
1583 |
||
1584 |
!Button methodsFor:'changing state'! |
|
1585 |
||
1586 |
toggle |
|
1587 |
"toggle and perform the action" |
|
1588 |
||
1589 |
controller toggle |
|
1590 |
! |
|
1591 |
||
1592 |
toggleNoAction |
|
1593 |
"toggle, but do NOT perform any action - can be used to change a toggle |
|
1594 |
under program control (i.e. turn one toggle off from another one)" |
|
1595 |
||
1596 |
controller toggleNoAction |
|
118 | 1597 |
! |
1598 |
||
205 | 1599 |
turnOff |
1600 |
"turn the button off (if not already off) do NOT perform actions/change notifications" |
|
1601 |
||
328
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1602 |
(controller notNil and:[controller pressed]) ifTrue:[ |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1603 |
offLevel ~~ level ifTrue:[ |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1604 |
self level:offLevel. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1605 |
]. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1606 |
(passiveLogo notNil and:[passiveLogo ~~ logo]) ifTrue:[ |
3122
2b734c50d620
Do not use obsolete message #logo:
Stefan Vogel <sv@exept.de>
parents:
3052
diff
changeset
|
1607 |
self label:passiveLogo |
328
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1608 |
]. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1609 |
controller setPressed:false. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1610 |
controller active:false. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1611 |
level := offLevel. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1612 |
margin := level abs. |
2913
bdf4fb09cfc0
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2892
diff
changeset
|
1613 |
self invalidate |
205 | 1614 |
] |
328
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1615 |
|
992 | 1616 |
"Modified: 8.2.1997 / 15:21:44 / cg" |
205 | 1617 |
! |
1618 |
||
1619 |
turnOffWithAction |
|
1620 |
"turn the button off (if not already off) and perform any action/change notification" |
|
118 | 1621 |
|
328
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1622 |
(controller notNil and:[controller pressed]) ifTrue:[ |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1623 |
offLevel ~~ level ifTrue:[ |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1624 |
self level:offLevel. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1625 |
]. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1626 |
(passiveLogo notNil and:[passiveLogo ~~ logo]) ifTrue:[ |
3122
2b734c50d620
Do not use obsolete message #logo:
Stefan Vogel <sv@exept.de>
parents:
3052
diff
changeset
|
1627 |
self label:passiveLogo |
328
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1628 |
]. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1629 |
self turnOffWithoutRedraw. |
2913
bdf4fb09cfc0
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2892
diff
changeset
|
1630 |
self invalidate |
205 | 1631 |
] |
118 | 1632 |
|
205 | 1633 |
"Created: 15.11.1995 / 16:55:37 / cg" |
992 | 1634 |
"Modified: 8.2.1997 / 15:21:53 / cg" |
205 | 1635 |
! |
1636 |
||
1637 |
turnOffWithoutRedraw |
|
1638 |
"turn the button off - no redraw but perform any action/change notification" |
|
1639 |
||
328
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1640 |
controller notNil ifTrue:[ |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1641 |
controller pressed:false. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1642 |
controller active:false. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1643 |
]. |
205 | 1644 |
|
1645 |
"do not use super level:offLevel |
|
1646 |
- because that one does redraw the edges. |
|
1647 |
Sure, this is no good coding style" |
|
1648 |
||
1649 |
level := offLevel. |
|
1650 |
margin := level abs |
|
328
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1651 |
|
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1652 |
"Modified: 8.2.1996 / 15:28:53 / cg" |
118 | 1653 |
! |
1654 |
||
205 | 1655 |
turnOn |
1656 |
"turn the button on (if not already on) - do NOT perform any action/notification" |
|
1657 |
||
328
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1658 |
(controller notNil and:[controller pressed not]) ifTrue:[ |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1659 |
onLevel ~~ level ifTrue:[ |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1660 |
self level:onLevel. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1661 |
]. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1662 |
(activeLogo notNil and:[activeLogo ~~ logo]) ifTrue:[ |
3122
2b734c50d620
Do not use obsolete message #logo:
Stefan Vogel <sv@exept.de>
parents:
3052
diff
changeset
|
1663 |
self label:activeLogo |
328
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1664 |
]. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1665 |
controller setPressed:true. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1666 |
level := onLevel. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1667 |
margin := level abs. |
205 | 1668 |
|
2913
bdf4fb09cfc0
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2892
diff
changeset
|
1669 |
self invalidate |
205 | 1670 |
] |
59 | 1671 |
|
205 | 1672 |
"Created: 14.11.1995 / 22:00:45 / cg" |
992 | 1673 |
"Modified: 8.2.1997 / 15:22:01 / cg" |
205 | 1674 |
! |
1675 |
||
1676 |
turnOnWithAction |
|
1677 |
"turn the button on (if not already on) and perform any change actions/notifications" |
|
118 | 1678 |
|
328
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1679 |
(controller notNil and:[controller pressed not]) ifTrue:[ |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1680 |
onLevel ~~ level ifTrue:[ |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1681 |
self level:onLevel. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1682 |
]. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1683 |
(activeLogo notNil and:[activeLogo ~~ logo]) ifTrue:[ |
3122
2b734c50d620
Do not use obsolete message #logo:
Stefan Vogel <sv@exept.de>
parents:
3052
diff
changeset
|
1684 |
self label:activeLogo |
328
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1685 |
]. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1686 |
self turnOnWithoutRedraw. |
2913
bdf4fb09cfc0
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2892
diff
changeset
|
1687 |
self invalidate |
205 | 1688 |
] |
1689 |
||
1690 |
"Created: 15.11.1995 / 16:55:56 / cg" |
|
992 | 1691 |
"Modified: 8.2.1997 / 15:22:09 / cg" |
118 | 1692 |
! |
1693 |
||
205 | 1694 |
turnOnWithoutRedraw |
1695 |
"turn the button on - no redraw but perform any change actions/notifications" |
|
1696 |
||
328
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1697 |
controller notNil ifTrue:[ |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1698 |
controller pressed:true. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1699 |
]. |
118 | 1700 |
|
205 | 1701 |
"do not use super level:offLevel |
1702 |
- because that one does redraw the edges. |
|
1703 |
Sure, this is no good coding style" |
|
1704 |
||
1705 |
level := onLevel. |
|
1706 |
margin := level abs |
|
328
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1707 |
|
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1708 |
"Modified: 8.2.1996 / 15:29:23 / cg" |
205 | 1709 |
! ! |
1710 |
||
1805 | 1711 |
!Button methodsFor:'focus handling'! |
59 | 1712 |
|
309
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
1713 |
showFocus:explicit |
1805 | 1714 |
"the button got the keyboard focus |
1806 | 1715 |
(either explicit, via tabbing; or implicit, by pointer movement) |
1716 |
- change any display attributes as req'd." |
|
1805 | 1717 |
|
205 | 1718 |
focusLogo notNil ifTrue:[ |
2671 | 1719 |
self enabled ifTrue:[ |
1170 | 1720 |
logo := focusLogo. |
2913
bdf4fb09cfc0
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2892
diff
changeset
|
1721 |
self invalidate. |
bdf4fb09cfc0
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2892
diff
changeset
|
1722 |
^ self. |
1170 | 1723 |
] |
205 | 1724 |
]. |
1681 | 1725 |
(styleSheet at:#'focus.showBorder' default:true) ifFalse:[ |
2913
bdf4fb09cfc0
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2892
diff
changeset
|
1726 |
self invalidate. |
bdf4fb09cfc0
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2892
diff
changeset
|
1727 |
^ self. |
1681 | 1728 |
]. |
309
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
1729 |
super showFocus:explicit |
205 | 1730 |
|
1681 | 1731 |
"Created: / 17.9.1995 / 19:58:50 / claus" |
1721 | 1732 |
"Modified: / 19.11.1998 / 13:02:48 / cg" |
205 | 1733 |
! |
1734 |
||
309
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
1735 |
showNoFocus:explicit |
1805 | 1736 |
"the button lost the keyboard focus |
1806 | 1737 |
(either explicit, via tabbing; or implicit, by pointer movement) |
1738 |
- change any display attributes as req'd." |
|
1805 | 1739 |
|
205 | 1740 |
focusLogo notNil ifTrue:[ |
1170 | 1741 |
disabledLogo notNil ifTrue:[ |
2671 | 1742 |
self enabled ifTrue:[ |
1170 | 1743 |
logo := passiveLogo. |
1744 |
] ifFalse:[ |
|
1745 |
logo := disabledLogo. |
|
1746 |
]. |
|
1747 |
] ifFalse:[ |
|
1748 |
logo := passiveLogo |
|
1749 |
]. |
|
2913
bdf4fb09cfc0
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2892
diff
changeset
|
1750 |
self invalidate. |
bdf4fb09cfc0
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2892
diff
changeset
|
1751 |
^ self |
205 | 1752 |
]. |
1681 | 1753 |
(styleSheet at:#'focus.showBorder' default:true) ifFalse:[ |
2913
bdf4fb09cfc0
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2892
diff
changeset
|
1754 |
self invalidate. |
bdf4fb09cfc0
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2892
diff
changeset
|
1755 |
^ self |
1681 | 1756 |
]. |
309
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
1757 |
super showNoFocus:explicit |
205 | 1758 |
|
1681 | 1759 |
"Created: / 17.9.1995 / 20:00:06 / claus" |
1760 |
"Modified: / 17.9.1995 / 20:26:32 / claus" |
|
1721 | 1761 |
"Modified: / 19.11.1998 / 13:02:44 / cg" |
4413
1c3519b08bcf
added: #wantsFocusWithButtonPress
Claus Gittinger <cg@exept.de>
parents:
4319
diff
changeset
|
1762 |
! |
1c3519b08bcf
added: #wantsFocusWithButtonPress
Claus Gittinger <cg@exept.de>
parents:
4319
diff
changeset
|
1763 |
|
1c3519b08bcf
added: #wantsFocusWithButtonPress
Claus Gittinger <cg@exept.de>
parents:
4319
diff
changeset
|
1764 |
wantsFocusWithButtonPress |
1c3519b08bcf
added: #wantsFocusWithButtonPress
Claus Gittinger <cg@exept.de>
parents:
4319
diff
changeset
|
1765 |
"no, do not catch the keyboard focus on button click" |
1c3519b08bcf
added: #wantsFocusWithButtonPress
Claus Gittinger <cg@exept.de>
parents:
4319
diff
changeset
|
1766 |
|
1c3519b08bcf
added: #wantsFocusWithButtonPress
Claus Gittinger <cg@exept.de>
parents:
4319
diff
changeset
|
1767 |
^ false |
1c3519b08bcf
added: #wantsFocusWithButtonPress
Claus Gittinger <cg@exept.de>
parents:
4319
diff
changeset
|
1768 |
|
1c3519b08bcf
added: #wantsFocusWithButtonPress
Claus Gittinger <cg@exept.de>
parents:
4319
diff
changeset
|
1769 |
"Created: / 28-03-2012 / 09:45:59 / cg" |
0 | 1770 |
! ! |
1771 |
||
1772 |
!Button methodsFor:'initialization'! |
|
1773 |
||
205 | 1774 |
defaultControllerClass |
1775 |
^ ButtonController |
|
1776 |
! |
|
1777 |
||
931 | 1778 |
fetchDeviceResources |
1779 |
"fetch device colors, to avoid reallocation at redraw time" |
|
1780 |
||
4894 | 1781 |
|graphicsDevice| |
1782 |
||
931 | 1783 |
super fetchDeviceResources. |
5635 | 1784 |
graphicsDevice := device. |
4894 | 1785 |
|
1786 |
disabledFgColor notNil ifTrue:[disabledFgColor := disabledFgColor onDevice:graphicsDevice]. |
|
1787 |
disabledEtchedFgColor notNil ifTrue:[disabledEtchedFgColor := disabledEtchedFgColor onDevice:graphicsDevice]. |
|
1788 |
activeFgColor notNil ifTrue:[activeFgColor := activeFgColor onDevice:graphicsDevice]. |
|
1789 |
activeBgColor notNil ifTrue:[activeBgColor := activeBgColor onDevice:graphicsDevice]. |
|
1790 |
enteredFgColor notNil ifTrue:[enteredFgColor := enteredFgColor onDevice:graphicsDevice]. |
|
1791 |
enteredBgColor notNil ifTrue:[enteredBgColor := enteredBgColor onDevice:graphicsDevice]. |
|
1792 |
||
1793 |
formColor notNil ifTrue:[formColor := formColor onDevice:graphicsDevice]. |
|
1794 |
formLightColor notNil ifTrue:[formLightColor := formLightColor onDevice:graphicsDevice]. |
|
1795 |
formShadowColor notNil ifTrue:[formShadowColor := formShadowColor onDevice:graphicsDevice]. |
|
1796 |
halfShadowColor notNil ifTrue:[halfShadowColor := halfShadowColor onDevice:graphicsDevice]. |
|
1797 |
halfLightColor notNil ifTrue:[halfLightColor := halfLightColor onDevice:graphicsDevice]. |
|
931 | 1798 |
|
945 | 1799 |
"Modified: 15.2.1997 / 17:14:16 / cg" |
931 | 1800 |
! |
1801 |
||
5206 | 1802 |
initBorderStyle |
1803 |
DefaultBorderWidth notNil ifTrue:[ self borderWidth: DefaultBorderWidth]. |
|
1804 |
! |
|
1805 |
||
205 | 1806 |
initCursor |
1807 |
"set up a hand cursor" |
|
0 | 1808 |
|
205 | 1809 |
cursor := Cursor hand |
1810 |
! |
|
1811 |
||
1812 |
initEvents |
|
1813 |
super initEvents. |
|
1814 |
self enableEnterLeaveEvents |
|
0 | 1815 |
! |
1816 |
||
1817 |
initStyle |
|
959 | 1818 |
"setup viewStyle specifics" |
1819 |
||
5449 | 1820 |
<resource: #style (#name #'button.style')> |
1821 |
||
1822 |
|hasGreyscales nm graphicsDevice buttonStyle borderStyle| |
|
59 | 1823 |
|
1824 |
super initStyle. |
|
5635 | 1825 |
graphicsDevice := device. |
59 | 1826 |
|
5206 | 1827 |
DefaultBorderWidth notNil ifTrue:[ self borderWidth: DefaultBorderWidth]. |
934 | 1828 |
DefaultForegroundColor notNil ifTrue:[fgColor := DefaultForegroundColor]. |
1829 |
DefaultBackgroundColor notNil ifTrue:[bgColor := DefaultBackgroundColor]. |
|
59 | 1830 |
|
62 | 1831 |
edgeStyle := DefaultEdgeStyle. |
59 | 1832 |
onLevel := DefaultActiveLevel. |
1833 |
offLevel := DefaultPassiveLevel. |
|
1834 |
||
1835 |
DefaultDisabledForegroundColor notNil ifTrue:[ |
|
934 | 1836 |
disabledFgColor := DefaultDisabledForegroundColor |
59 | 1837 |
] ifFalse:[ |
705 | 1838 |
disabledFgColor := fgColor |
59 | 1839 |
]. |
2497
e3e1a719e31d
support etched color (win32 style)
Claus Gittinger <cg@exept.de>
parents:
2490
diff
changeset
|
1840 |
disabledEtchedFgColor := DefaultDisabledEtchedForegroundColor. |
59 | 1841 |
|
934 | 1842 |
DefaultEnteredForegroundColor notNil ifTrue:[enteredFgColor := DefaultEnteredForegroundColor]. |
1843 |
DefaultEnteredBackgroundColor notNil ifTrue:[enteredBgColor := DefaultEnteredBackgroundColor]. |
|
1844 |
DefaultActiveForegroundColor notNil ifTrue:[activeFgColor := DefaultActiveForegroundColor]. |
|
1845 |
DefaultActiveBackgroundColor notNil ifTrue:[activeBgColor := DefaultActiveBackgroundColor]. |
|
59 | 1846 |
|
934 | 1847 |
DefaultShadowColor notNil ifTrue:[shadowColor := DefaultShadowColor]. |
1848 |
DefaultLightColor notNil ifTrue:[lightColor := DefaultLightColor]. |
|
59 | 1849 |
|
62 | 1850 |
shadowColor isNil ifTrue:[ |
4909 | 1851 |
shadowColor := self blackColor. |
62 | 1852 |
]. |
1853 |
lightColor isNil ifTrue:[ |
|
4909 | 1854 |
lightColor := self whiteColor. |
62 | 1855 |
]. |
59 | 1856 |
|
4894 | 1857 |
hasGreyscales := graphicsDevice hasGrayscales. |
1651 | 1858 |
(edgeStyle == #soft or:[edgeStyle == #softWin95]) ifTrue:[ |
934 | 1859 |
DefaultHalfShadowColor notNil ifTrue:[halfShadowColor := DefaultHalfShadowColor]. |
1860 |
DefaultHalfLightColor notNil ifTrue:[halfLightColor := DefaultHalfLightColor]. |
|
62 | 1861 |
|
705 | 1862 |
halfShadowColor isNil ifTrue:[ |
62 | 1863 |
"/ hasGreyscales ifTrue:[ |
1864 |
"/ halfShadowColor := Color darkGrey |
|
1865 |
"/ ] ifFalse:[ |
|
1866 |
"/ halfShadowColor := shadowColor |
|
1867 |
"/ ] |
|
705 | 1868 |
halfShadowColor := shadowColor lightened |
1869 |
] |
|
59 | 1870 |
]. |
1871 |
||
62 | 1872 |
" |
1873 |
actually, the stuf below should not be needed |
|
1874 |
- the styleSheet should provide values for nonGreyscale displays too |
|
1875 |
" |
|
130 | 1876 |
nm := styleSheet name. |
62 | 1877 |
(nm == #iris) ifTrue:[ |
705 | 1878 |
hasGreyscales ifTrue:[ |
1879 |
DefaultEnteredBackgroundColor isNil ifTrue:[ |
|
1880 |
enteredBgColor := bgColor lightened "Color lightGray". |
|
1881 |
]. |
|
1882 |
DefaultActiveBackgroundColor isNil ifTrue:[ |
|
1883 |
activeBgColor := enteredBgColor. |
|
1884 |
]. |
|
1885 |
DefaultActiveForegroundColor isNil ifTrue:[ |
|
1886 |
activeFgColor := enteredFgColor. |
|
1887 |
]. |
|
1888 |
] ifFalse:[ |
|
1889 |
DefaultEnteredBackgroundColor isNil ifTrue:[ |
|
1890 |
enteredBgColor := Color veryLightGray. |
|
1891 |
]. |
|
1892 |
DefaultActiveBackgroundColor isNil ifTrue:[ |
|
4909 | 1893 |
activeBgColor := self blackColor. |
705 | 1894 |
]. |
1895 |
DefaultActiveForegroundColor isNil ifTrue:[ |
|
4909 | 1896 |
activeFgColor := self whiteColor. |
705 | 1897 |
]. |
1898 |
]. |
|
62 | 1899 |
] ifFalse:[ |
705 | 1900 |
nm == #motif ifTrue:[ |
1901 |
lightColor isNil ifTrue:[ |
|
1902 |
lightColor := bgColor lightened |
|
1903 |
]. |
|
62 | 1904 |
"/ hasGreyscales ifTrue:[ |
1905 |
"/ lightColor := Color lightGrey |
|
1906 |
"/ ] |
|
705 | 1907 |
] ifFalse:[ |
1908 |
nm == #st80 ifTrue:[ |
|
1909 |
hasGreyscales ifTrue:[ |
|
1910 |
DefaultActiveForegroundColor isNil ifTrue:[ |
|
1911 |
activeFgColor := fgColor. |
|
1912 |
]. |
|
1913 |
DefaultActiveBackgroundColor isNil ifTrue:[ |
|
1914 |
activeBgColor := bgColor darkened. |
|
1915 |
]. |
|
1916 |
] ifFalse:[ |
|
1917 |
DefaultActiveForegroundColor isNil ifTrue:[ |
|
4909 | 1918 |
activeFgColor := self whiteColor. |
705 | 1919 |
]. |
1920 |
DefaultActiveBackgroundColor isNil ifTrue:[ |
|
4909 | 1921 |
activeBgColor := self blackColor |
705 | 1922 |
] |
1923 |
] |
|
1924 |
] |
|
1925 |
] |
|
59 | 1926 |
]. |
1927 |
||
1928 |
offLevel ~~ level ifTrue:[ |
|
705 | 1929 |
self level:offLevel. |
1930 |
margin := (onLevel abs) max:(offLevel abs). |
|
59 | 1931 |
]. |
1932 |
||
1933 |
DefaultReturnButtonHasImage ifTrue:[ |
|
4620 | 1934 |
(hasGreyscales and:[styleSheet is3D]) ifTrue:[ |
4894 | 1935 |
shadowForm := self class returnShadowFormOn:graphicsDevice. |
1936 |
lightForm := self class returnLightFormOn:graphicsDevice. |
|
705 | 1937 |
formColor := viewBackground. |
1938 |
formShadowColor := shadowColor. |
|
1939 |
formLightColor := lightColor |
|
1940 |
] ifFalse:[ |
|
4894 | 1941 |
shadowForm := self class returnFormOn:graphicsDevice. |
4909 | 1942 |
formColor := self blackColor |
705 | 1943 |
]. |
59 | 1944 |
]. |
705 | 1945 |
|
5449 | 1946 |
buttonStyle := styleSheet at:'button.style' default:nil. |
1947 |
((self class == Button) and:[ buttonStyle == #MacOSX ]) ifTrue:[ |
|
1948 |
borderStyle := styleSheet at:'button.borderStyle'. |
|
5796 | 1949 |
self border:( (Smalltalk at:borderStyle asSymbol) color:self blackColor). |
5449 | 1950 |
self viewBackground:(View defaultViewBackgroundColor). |
1951 |
]. |
|
1952 |
||
4047
d6bc6e6fdc00
comment/format in: #initStyle
Claus Gittinger <cg@exept.de>
parents:
4018
diff
changeset
|
1953 |
"/ unfinished... |
d6bc6e6fdc00
comment/format in: #initStyle
Claus Gittinger <cg@exept.de>
parents:
4018
diff
changeset
|
1954 |
"/ nm = #winVista ifTrue:[ |
d6bc6e6fdc00
comment/format in: #initStyle
Claus Gittinger <cg@exept.de>
parents:
4018
diff
changeset
|
1955 |
"/ self border:(RoundButtonBorder width:2 color:Color grey). |
d6bc6e6fdc00
comment/format in: #initStyle
Claus Gittinger <cg@exept.de>
parents:
4018
diff
changeset
|
1956 |
"/ ]. |
d6bc6e6fdc00
comment/format in: #initStyle
Claus Gittinger <cg@exept.de>
parents:
4018
diff
changeset
|
1957 |
|
4319 | 1958 |
"Modified: / 20-08-1998 / 12:07:37 / cg" |
1959 |
"Modified (comment): / 05-10-2011 / 15:51:19 / az" |
|
59 | 1960 |
! |
1961 |
||
205 | 1962 |
initialize |
6075 | 1963 |
<modifier: #super> "must be called if redefined" |
1964 |
||
205 | 1965 |
super initialize. |
0 | 1966 |
|
1051 | 1967 |
isReturnButton := defaultable := false. |
6075 | 1968 |
|
1969 |
"Modified: / 08-02-2017 / 00:32:44 / cg" |
|
0 | 1970 |
! |
1971 |
||
1972 |
reinitialize |
|
1973 |
super reinitialize. |
|
77 | 1974 |
controller notNil ifTrue:[ |
1739 | 1975 |
controller reinitialize. |
77 | 1976 |
] |
205 | 1977 |
! ! |
1978 |
||
3035 | 1979 |
!Button methodsFor:'native widget support'! |
1980 |
||
1981 |
nativeWindowType |
|
1982 |
"return a symbol describing my native window type |
|
5539 | 1983 |
(may be used internally by the device as a native window creation hint, |
1984 |
if the device supports native windows)" |
|
3035 | 1985 |
|
5124 | 1986 |
self class == Button ifTrue:[ |
1987 |
^ #Button |
|
1988 |
]. |
|
3035 | 1989 |
^ nil |
1990 |
! |
|
1991 |
||
1992 |
win32nativeWMCommand:commandID |
|
1993 |
self controller performAction |
|
1994 |
! ! |
|
1995 |
||
205 | 1996 |
!Button methodsFor:'private'! |
1997 |
||
1998 |
computeLabelOrigin |
|
1999 |
"compute the origin of the text - if I am a returnButton, |
|
2000 |
shift it somwehat to the right (we have already allocated the |
|
2001 |
real estate, since computeLabelSize returned some extra space |
|
2002 |
before)." |
|
2003 |
||
2004 |
super computeLabelOrigin. |
|
1093
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
2005 |
shadowForm notNil ifTrue:[ |
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
2006 |
isReturnButton ifTrue:[ |
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
2007 |
labelOriginX := labelOriginX + hSpace + hSpace. |
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
2008 |
]. |
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
2009 |
|
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
2010 |
defaultable ifTrue:[ |
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
2011 |
labelOriginX < margin ifTrue:[ |
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
2012 |
labelOriginX := margin |
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
2013 |
] |
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
2014 |
] |
1663
c6cc4fe918ea
nicer 3D effect (shift label down-right) when pressed.
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
2015 |
]. |
1669 | 2016 |
"/ self class == Button ifTrue:[ |
2017 |
"/ labelOriginY := labelOriginY + 1. |
|
2018 |
"/ labelOriginX := labelOriginX + 1. |
|
2019 |
"/ ] |
|
2020 |
||
2021 |
"Modified: / 9.9.1998 / 20:22:01 / cg" |
|
205 | 2022 |
! |
2023 |
||
3925 | 2024 |
getLabelFromLabelChannel |
2025 |
passiveLogo := labelChannel value. |
|
2026 |
super getLabelFromLabelChannel. |
|
2027 |
! |
|
2028 |
||
4000
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2029 |
rawLabelSizeOf:aLogo |
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2030 |
"compute the extent needed to hold the label (plus the return form)" |
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2031 |
|
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2032 |
|ext| |
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2033 |
|
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2034 |
ext := super rawLabelSizeOf:aLogo. |
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2035 |
|
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2036 |
(activeLogo notNil and:[activeLogo ~~ logo]) ifTrue:[ |
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2037 |
ext := ext max:(super rawLabelSizeOf:activeLogo). |
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2038 |
]. |
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2039 |
(passiveLogo notNil and:[passiveLogo ~~ logo]) ifTrue:[ |
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2040 |
ext := ext max:(super rawLabelSizeOf:passiveLogo). |
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2041 |
]. |
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2042 |
|
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2043 |
((isReturnButton or:[defaultable]) and:[shadowForm notNil]) ifTrue:[ |
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2044 |
^ (ext x + (hSpace * 2) + shadowForm width) |
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2045 |
@ |
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2046 |
(ext y max: (shadowForm height "+ vSpace")) |
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2047 |
]. |
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2048 |
^ ext |
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2049 |
|
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2050 |
"Modified: / 3.11.1997 / 09:15:52 / cg" |
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2051 |
! |
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2052 |
|
2586 | 2053 |
shiftLabelWhenPressed |
2054 |
^ self class == Button |
|
0 | 2055 |
! ! |
2056 |
||
62 | 2057 |
!Button methodsFor:'queries'! |
0 | 2058 |
|
5449 | 2059 |
extraMarginForBorder |
2060 |
(self class == Button |
|
2061 |
and:[ (styleSheet at:'button.style' default:nil) == #'MacOSX' ]) ifTrue:[ |
|
2062 |
^ 4 |
|
2063 |
]. |
|
2064 |
^ 0 |
|
2065 |
! |
|
2066 |
||
0 | 2067 |
is3D |
850 | 2068 |
"return true, if the receiver is a 3D style view" |
761 | 2069 |
|
850 | 2070 |
<resource: #style (#name)> |
0 | 2071 |
|
130 | 2072 |
styleSheet name == #mswindows ifTrue:[^ true]. |
4506 | 2073 |
styleSheet name == #win8 ifTrue:[^ false]. |
0 | 2074 |
^ super is3D |
761 | 2075 |
|
850 | 2076 |
"Modified: 22.10.1996 / 18:26:41 / cg" |
0 | 2077 |
! |
2078 |
||
1782 | 2079 |
isDefault |
2080 |
"return true, if this is a default OK button" |
|
2081 |
||
2082 |
^ isReturnButton |
|
2083 |
! |
|
2084 |
||
127 | 2085 |
isOn |
2086 |
"return true, if this button is currently pressed" |
|
2087 |
||
5601 | 2088 |
^ controller notNil and:[controller pressed] |
155 | 2089 |
! |
2090 |
||
205 | 2091 |
isReturnButton |
2092 |
"return true, if this is a return button" |
|
0 | 2093 |
|
205 | 2094 |
^ isReturnButton |
156 | 2095 |
! |
2096 |
||
1370 | 2097 |
isTriggerOnDown |
2098 |
"return true, if I fire on press (instead of fire-on-release)" |
|
5601 | 2099 |
|
2100 |
^ controller notNil and:[controller isTriggerOnDown] |
|
1370 | 2101 |
|
2102 |
"Created: / 31.10.1997 / 19:33:56 / cg" |
|
2103 |
"Modified: / 31.10.1997 / 19:34:34 / cg" |
|
2104 |
! |
|
2105 |
||
205 | 2106 |
specClass |
1370 | 2107 |
"redefined, since the name of my specClass is nonStandard (i.e. not ButtonSpec)" |
2108 |
||
205 | 2109 |
self class == Button ifTrue:[^ ActionButtonSpec]. |
1050 | 2110 |
^ super specClass |
2111 |
||
1370 | 2112 |
"Modified: / 31.10.1997 / 19:49:07 / cg" |
162 | 2113 |
! ! |
2114 |
||
0 | 2115 |
!Button methodsFor:'redrawing'! |
2116 |
||
205 | 2117 |
drawBottomEdge |
2118 |
"draw bottom 3D edge into window frame" |
|
2119 |
||
2120 |
self drawBottomEdgeLevel:level |
|
2121 |
shadow:shadowColor |
|
2122 |
light:lightColor |
|
2123 |
halfShadow:halfShadowColor |
|
2124 |
halfLight:halfLightColor |
|
2125 |
style:edgeStyle. |
|
133 | 2126 |
! |
2127 |
||
62 | 2128 |
drawEdges |
2129 |
"draw all of my 3D edges" |
|
2130 |
||
2131 |
self drawEdgesForX:0 y:0 width:width height:height level:level |
|
2132 |
shadow:shadowColor |
|
2133 |
light:lightColor |
|
2134 |
halfShadow:halfShadowColor |
|
2135 |
halfLight:halfLightColor |
|
2136 |
style:edgeStyle |
|
2137 |
! |
|
2138 |
||
2139 |
drawLeftEdge |
|
2140 |
"draw left 3D edge into window frame" |
|
2141 |
||
2142 |
self drawLeftEdgeLevel:level |
|
2143 |
shadow:shadowColor |
|
2144 |
light:lightColor |
|
2145 |
halfShadow:halfShadowColor |
|
2146 |
halfLight:halfLightColor |
|
2147 |
style:edgeStyle. |
|
2148 |
! |
|
2149 |
||
2150 |
drawRightEdge |
|
2151 |
"draw right 3D edge into window frame" |
|
2152 |
||
2153 |
self drawRightEdgeLevel:level |
|
2154 |
shadow:shadowColor |
|
2155 |
light:lightColor |
|
2156 |
halfShadow:halfShadowColor |
|
2157 |
halfLight:halfLightColor |
|
2158 |
style:edgeStyle. |
|
2159 |
! |
|
2160 |
||
2161 |
drawTopEdge |
|
2162 |
"draw top 3D edge into window frame" |
|
2163 |
||
2164 |
self drawTopEdgeLevel:level |
|
2165 |
shadow:shadowColor |
|
2166 |
light:lightColor |
|
2167 |
halfShadow:halfShadowColor |
|
2168 |
halfLight:halfLightColor |
|
2169 |
style:edgeStyle. |
|
2170 |
! |
|
2171 |
||
0 | 2172 |
drawWith:fg and:bg |
2173 |
"redraw myself with fg/bg. Use super to draw the label, add |
|
2174 |
the return-arrow here." |
|
2175 |
||
5456 | 2176 |
|x y sColor lColor etchFg shownLogo isEnabled isActive isEntered clearInside showBorder| |
0 | 2177 |
|
59 | 2178 |
shown ifFalse:[^ self]. |
2497
e3e1a719e31d
support etched color (win32 style)
Claus Gittinger <cg@exept.de>
parents:
2490
diff
changeset
|
2179 |
|
2671 | 2180 |
isEnabled := self enabled. |
5449 | 2181 |
isActive := (controller active or:[controller pressed]). |
2182 |
isEntered := (controller entered or:[controller pressed]). |
|
2183 |
||
2671 | 2184 |
isEnabled ifFalse:[ |
2497
e3e1a719e31d
support etched color (win32 style)
Claus Gittinger <cg@exept.de>
parents:
2490
diff
changeset
|
2185 |
etchFg := disabledEtchedFgColor. |
e3e1a719e31d
support etched color (win32 style)
Claus Gittinger <cg@exept.de>
parents:
2490
diff
changeset
|
2186 |
]. |
e3e1a719e31d
support etched color (win32 style)
Claus Gittinger <cg@exept.de>
parents:
2490
diff
changeset
|
2187 |
|
5449 | 2188 |
isActive ifTrue:[ |
4179 | 2189 |
shownLogo := activeLogo ? enteredLogo ? passiveLogo ? logo. |
2190 |
] ifFalse:[ |
|
2191 |
shownLogo := passiveLogo ? logo. |
|
2192 |
(enteredLogo notNil and:[controller entered]) ifTrue:[ |
|
2193 |
shownLogo := enteredLogo. |
|
2609 | 2194 |
]. |
4179 | 2195 |
]. |
2196 |
(disabledLogo notNil and:[isEnabled not]) ifTrue:[ |
|
2197 |
shownLogo := disabledLogo. |
|
2198 |
]. |
|
2199 |
shownLogo ~= logo ifTrue:[ |
|
2200 |
self label:shownLogo redraw:false. |
|
2201 |
logo := shownLogo. |
|
3052 | 2202 |
]. |
2609 | 2203 |
|
5449 | 2204 |
clearInside := true. |
5456 | 2205 |
showBorder := false. |
2206 |
||
5449 | 2207 |
(self class == Button |
2208 |
and:[ ((styleSheet at:'button.style' default:nil) == #'MacOSX') ]) ifTrue:[ |
|
2209 |
|c1 c2 c3 bc| |
|
2210 |
isActive ifTrue:[ |
|
2211 |
c1 := (styleSheet colorAt:'button.activeBackgroundColor1' default:nil). |
|
2212 |
c2 := (styleSheet colorAt:'button.activeBackgroundColor2' default:nil). |
|
2213 |
c3 := (styleSheet colorAt:'button.activeBackgroundColor3' default:nil). |
|
2214 |
bc := (styleSheet colorAt:'button.activeBorderColor' default:(Color grey:72)). |
|
2215 |
] ifFalse:[ |
|
2216 |
isEntered ifTrue:[ |
|
2217 |
c1 := (styleSheet colorAt:'button.enteredBackgroundColor1' default:nil). |
|
2218 |
c2 := (styleSheet colorAt:'button.enteredBackgroundColor2' default:nil). |
|
2219 |
c3 := (styleSheet colorAt:'button.enteredBackgroundColor3' default:nil). |
|
2220 |
bc := (styleSheet colorAt:'button.enteredBorderColor' default:(Color grey:72)). |
|
2221 |
] ifFalse:[ |
|
2222 |
c1 := (styleSheet colorAt:'button.passiveBackgroundColor1' default:nil). |
|
2223 |
c2 := (styleSheet colorAt:'button.passiveBackgroundColor2' default:nil). |
|
2224 |
c3 := (styleSheet colorAt:'button.passiveBackgroundColor3' default:nil). |
|
2225 |
bc := (styleSheet colorAt:'button.passiveBorderColor' default:(Color grey:72)). |
|
2226 |
]. |
|
2227 |
]. |
|
2228 |
(border class == MacFlatButtonBorder) ifTrue:[ |
|
2229 |
(c1 notNil and:[c2 notNil]) ifTrue:[ |
|
2230 |
border backgroundColor1:c1. |
|
2231 |
border backgroundColor2:c2. |
|
2232 |
border color:bc. |
|
2233 |
(GradientBackground new |
|
2234 |
direction:#northSouth; |
|
2235 |
colors:{c1 . c2}; |
|
2236 |
usedLength:height) |
|
2237 |
fillRectangleX:0 y:0 width:width height:height in:self. |
|
2238 |
||
2239 |
clearInside := false. |
|
2240 |
] ifFalse:[ |
|
2241 |
c1 := c2 := bg. |
|
2242 |
border backgroundColor1:c1. |
|
2243 |
border backgroundColor2:c2. |
|
2244 |
border color:bc. |
|
2245 |
]. |
|
5456 | 2246 |
showBorder := true. |
5449 | 2247 |
]. |
2248 |
(border class == MacButtonBorder) ifTrue:[ |
|
2249 |
(c1 notNil and:[c2 notNil and:[c3 notNil]]) ifTrue:[ |
|
2250 |
border backgroundColor1:c1. |
|
2251 |
border backgroundColor2:c2. |
|
2252 |
border color:bc. |
|
2253 |
(GradientBackground new |
|
2254 |
direction:#northSouth; |
|
2255 |
colors:{ c1 . c2 . c3}; |
|
2256 |
usedLength:height) |
|
2257 |
fillRectangleX:0 y:0 width:width height:height in:self. |
|
2258 |
||
2259 |
clearInside := false. |
|
2260 |
] ifFalse:[ |
|
2261 |
c1 := c2 := bg. |
|
2262 |
border backgroundColor1:c1. |
|
2263 |
border backgroundColor2:c2. |
|
2264 |
border color:bc. |
|
2265 |
]. |
|
5456 | 2266 |
showBorder := true. |
5449 | 2267 |
]. |
2268 |
]. |
|
2269 |
self drawWith:fg and:bg clearInside:clearInside etchedFg:etchFg. "this draws the text/image" |
|
2270 |
||
5456 | 2271 |
showBorder ifTrue:[ |
2272 |
border displayOn:self forDisplayBox:(0@0 corner:width@height). |
|
2273 |
]. |
|
2274 |
||
59 | 2275 |
(isReturnButton and:[shadowForm notNil]) ifTrue:[ |
932
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
2276 |
y := (height - shadowForm height) // 2. |
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
2277 |
x := width - shadowForm width - (hSpace // 2). |
59 | 2278 |
|
2586 | 2279 |
(self shiftLabelWhenPressed and:[level < 0]) ifTrue:[ |
1665 | 2280 |
x := x + 1. |
2281 |
y := y + 1 |
|
1663
c6cc4fe918ea
nicer 3D effect (shift label down-right) when pressed.
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
2282 |
]. |
c6cc4fe918ea
nicer 3D effect (shift label down-right) when pressed.
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
2283 |
|
932
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
2284 |
formShadowColor isNil ifTrue:[ |
6066 | 2285 |
gc paint:fg on:bg. |
2286 |
gc displayOpaqueForm:shadowForm x:x y:y. |
|
932
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
2287 |
^ self |
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
2288 |
]. |
0 | 2289 |
|
932
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
2290 |
" |
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
2291 |
drawing form in 3d-style (i.e. with shadow and light) |
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
2292 |
" |
955 | 2293 |
(formShadowColor isColor and:[formShadowColor isDithered not |
2294 |
and:[formLightColor isColor and:[formLightColor isDithered not |
|
2295 |
and:[formColor isColor and:[formColor isDithered not]]]]]) |
|
932
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
2296 |
ifTrue:[ |
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
2297 |
sColor := formShadowColor. |
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
2298 |
lColor := formLightColor. |
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
2299 |
] ifFalse:[ |
5635 | 2300 |
sColor := device blackColor. |
2301 |
lColor := device whiteColor. |
|
932
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
2302 |
]. |
6066 | 2303 |
gc foreground:sColor. |
2304 |
gc displayForm:shadowForm x:x y:y. |
|
35 | 2305 |
|
932
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
2306 |
lightForm notNil ifTrue:[ |
6066 | 2307 |
gc foreground:lColor. |
2308 |
gc displayForm:lightForm x:x y:y. |
|
932
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
2309 |
]. |
6066 | 2310 |
gc paint:fg. |
1681 | 2311 |
]. |
2312 |
||
5456 | 2313 |
self hasFocus ifTrue:[ |
2314 |
self drawFocusFrame |
|
2315 |
]. |
|
932
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
2316 |
|
4179 | 2317 |
"Modified: / 22-10-2010 / 15:55:03 / cg" |
0 | 2318 |
! |
2319 |
||
1170 | 2320 |
redraw |
82 | 2321 |
"redraw the button. |
5203 | 2322 |
That's like redrawing a label, but uses different colors when pressed |
82 | 2323 |
or entered." |
0 | 2324 |
|
5449 | 2325 |
|fg bg entered hasFrame lvl isEnabled| |
0 | 2326 |
|
62 | 2327 |
shown ifFalse:[^ self]. |
2671 | 2328 |
isEnabled := self enabled. |
35 | 2329 |
|
5453 | 2330 |
"/ Transcript showCR:border. |
5449 | 2331 |
|
2609 | 2332 |
"/ disabledLogo notNil ifTrue:[ |
2333 |
"/ isEnabled ifFalse:[ |
|
2334 |
"/ logo := disabledLogo. |
|
2335 |
"/ ] ifTrue:[ |
|
2336 |
"/ controller active ifTrue:[ |
|
2337 |
"/ logo := activeLogo |
|
2338 |
"/ ] ifFalse:[ |
|
2339 |
"/ logo := passiveLogo |
|
2340 |
"/ ]. |
|
2341 |
"/ ]. |
|
2342 |
"/ ]. |
|
1092 | 2343 |
|
5449 | 2344 |
hasFrame := false. |
62 | 2345 |
fg := fgColor. |
2346 |
bg := bgColor. |
|
1778 | 2347 |
isEnabled ifFalse:[ |
2497
e3e1a719e31d
support etched color (win32 style)
Claus Gittinger <cg@exept.de>
parents:
2490
diff
changeset
|
2348 |
fg := disabledFgColor. |
62 | 2349 |
] ifTrue:[ |
1092 | 2350 |
entered := controller entered. |
2351 |
entered ifTrue:[ |
|
2352 |
enteredFgColor notNil ifTrue:[fg := enteredFgColor]. |
|
1206
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
2353 |
enteredBgColor notNil ifTrue:[bg := enteredBgColor]. |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
2354 |
lvl := enterLevel. |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
2355 |
] ifFalse:[ |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
2356 |
lvl := leaveLevel |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
2357 |
]. |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
2358 |
(enterLevel notNil and:[leaveLevel notNil]) ifTrue:[ |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
2359 |
offLevel ~~ lvl ifTrue:[ |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
2360 |
offLevel := lvl. |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
2361 |
offLevel ~~ level ifTrue:[ |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
2362 |
self level:offLevel |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
2363 |
] |
003498bf0349
added enter- and leaveLevels.
Claus Gittinger <cg@exept.de>
parents:
1196
diff
changeset
|
2364 |
] |
1092 | 2365 |
]. |
2366 |
(controller pressed and:[entered or:[controller isTriggerOnDown]]) ifTrue:[ |
|
5449 | 2367 |
hasFrame := self is3D not. |
1092 | 2368 |
activeFgColor isNil ifTrue:[ |
2369 |
onLevel == offLevel ifTrue:[ |
|
2370 |
fg := bgColor |
|
2371 |
] |
|
2372 |
] ifFalse:[ |
|
2373 |
fg := activeFgColor. |
|
2374 |
]. |
|
2375 |
activeBgColor isNil ifTrue:[ |
|
2376 |
onLevel == offLevel ifTrue:[ |
|
2377 |
bg := fgColor |
|
2378 |
] |
|
2379 |
] ifFalse:[ |
|
2380 |
bg := activeBgColor |
|
2381 |
]. |
|
232 | 2382 |
|
1092 | 2383 |
self is3D ifFalse:[ |
5449 | 2384 |
hasFrame := ((fgColor = fg) and:[bgColor = bg]) not. |
1092 | 2385 |
]. |
2386 |
]. |
|
62 | 2387 |
]. |
2497
e3e1a719e31d
support etched color (win32 style)
Claus Gittinger <cg@exept.de>
parents:
2490
diff
changeset
|
2388 |
|
265 | 2389 |
self drawWith:fg and:bg. |
5449 | 2390 |
hasFrame ifTrue:[ |
1092 | 2391 |
" |
2392 |
draw a rectangle around (2D styles only) |
|
2393 |
" |
|
6066 | 2394 |
gc paint:fg. |
2395 |
gc displayRectangleX:0 y:0 width:width height:height. |
|
1092 | 2396 |
^ self |
265 | 2397 |
]. |
2398 |
||
1387 | 2399 |
"Modified: / 3.11.1997 / 11:56:02 / cg" |
205 | 2400 |
! |
2401 |
||
2402 |
redrawIfPressed |
|
2403 |
"redraw the button, but only if visible and currently being pressed" |
|
2404 |
||
2405 |
shown ifTrue:[ |
|
1170 | 2406 |
controller pressed ifTrue:[ |
2407 |
self redraw |
|
2408 |
] |
|
205 | 2409 |
] |
1170 | 2410 |
|
2411 |
"Modified: 1.4.1997 / 13:26:27 / cg" |
|
205 | 2412 |
! |
2413 |
||
2414 |
redrawX:x y:y width:w height:h |
|
4128 | 2415 |
self renderOrRedraw. |
1170 | 2416 |
|
2417 |
"Modified: 1.4.1997 / 13:26:31 / cg" |
|
205 | 2418 |
! |
2419 |
||
2420 |
showActive |
|
2421 |
"redraw myself as active (i.e. busy)" |
|
162 | 2422 |
|
205 | 2423 |
onLevel ~~ level ifTrue:[ |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
2424 |
self level:onLevel. |
205 | 2425 |
]. |
3052 | 2426 |
"/ (activeLogo notNil and:[activeLogo ~~ logo]) ifTrue:[ |
2427 |
"/ self logo:activeLogo |
|
2428 |
"/ ]. |
|
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
2429 |
self invalidate |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
2430 |
|
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
2431 |
"Modified: 26.5.1996 / 18:08:52 / cg" |
205 | 2432 |
! |
2433 |
||
2434 |
showPassive |
|
2435 |
"redraw myself as passive" |
|
162 | 2436 |
|
205 | 2437 |
offLevel ~~ level ifTrue:[ |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
2438 |
self level:offLevel. |
205 | 2439 |
]. |
2440 |
(passiveLogo notNil and:[passiveLogo ~~ logo]) ifTrue:[ |
|
3122
2b734c50d620
Do not use obsolete message #logo:
Stefan Vogel <sv@exept.de>
parents:
3052
diff
changeset
|
2441 |
self label:passiveLogo |
205 | 2442 |
]. |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
2443 |
self invalidate. |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
2444 |
|
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
2445 |
"Modified: 26.5.1996 / 18:08:56 / cg" |
0 | 2446 |
! ! |
205 | 2447 |
|
850 | 2448 |
!Button class methodsFor:'documentation'! |
205 | 2449 |
|
2450 |
version |
|
5449 | 2451 |
^ '$Header$' |
4000
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2452 |
! |
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2453 |
|
aa7dd2f07400
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
2454 |
version_CVS |
5449 | 2455 |
^ '$Header$' |
205 | 2456 |
! ! |
4506 | 2457 |