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