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