author | Claus Gittinger <cg@exept.de> |
Sat, 22 Mar 1997 16:36:50 +0100 | |
changeset 1153 | 3d8eb61fad06 |
parent 1094 | 472652d88011 |
child 1170 | 5864abd318f6 |
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 |
" |
|
12 |
||
13 |
Label subclass:#Button |
|
264 | 14 |
instanceVariableNames:'activeLogo passiveLogo disabledLogo focusLogo onLevel offLevel |
15 |
disabledFgColor activeFgColor activeBgColor enteredFgColor |
|
16 |
enteredBgColor isReturnButton shadowForm lightForm formColor |
|
17 |
formShadowColor formLightColor edgeStyle halfShadowColor |
|
1051 | 18 |
halfLightColor defaultable' |
420 | 19 |
classVariableNames:'ReturnForm ReturnLightForm ReturnShadowForm DefaultActiveLevel |
20 |
DefaultPassiveLevel DefaultEdgeStyle DefaultBorderWidth |
|
21 |
DefaultForegroundColor DefaultBackgroundColor |
|
264 | 22 |
DefaultDisabledForegroundColor DefaultDisabledBackgroundColor |
23 |
DefaultEnteredForegroundColor DefaultEnteredBackgroundColor |
|
24 |
DefaultActiveForegroundColor DefaultActiveBackgroundColor |
|
25 |
DefaultReturnButtonHasImage DefaultReturnButtonHasBorder |
|
26 |
DefaultShadowColor DefaultLightColor DefaultHalfShadowColor |
|
27 |
DefaultHalfLightColor' |
|
28 |
poolDictionaries:'' |
|
29 |
category:'Views-Interactors' |
|
0 | 30 |
! |
31 |
||
850 | 32 |
!Button class methodsFor:'documentation'! |
0 | 33 |
|
205 | 34 |
actionBlocksVersusModelChanges |
35 |
" |
|
36 |
You may ask yourself, why ST/X supports two different ways |
|
37 |
to trigger a buttons action (also true for sliders, selectionInListViews, |
|
38 |
toggles etc.) and when to use which mechanism. |
|
39 |
||
40 |
There are two reasons: |
|
41 |
1) history - historically, ST/X used only actionBlocks |
|
42 |
Basically, these provide the most general functionality |
|
43 |
(you can of course send change-messages from those blocks) |
|
44 |
||
45 |
Change-message notification was added later, to make porting |
|
46 |
of existing applications easier. |
|
47 |
||
48 |
2) for many (simple) applications, it is often easier, to simply |
|
49 |
define an action block. This is especially true, if the button |
|
50 |
triggers some action (such as ok-/abort-buttons) and does NOT |
|
51 |
change some models internal value. |
|
52 |
(other smalltalks provide extra adapter-models for this, |
|
53 |
in which you can set actionBlocks in much the same way). |
|
54 |
||
55 |
In general: |
|
56 |
use model-change-messages, iff multiple views are possibly open |
|
57 |
on the same domain model, and changes can occur from multiple |
|
58 |
places. Or if a change has to be forwarded to multiple other objects |
|
59 |
(possible not foreseen). |
|
60 |
||
61 |
For simplicity, better use actionBlocks for trigger-like actions |
|
62 |
(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
|
63 |
entity which is interested in that button press. |
205 | 64 |
" |
65 |
! |
|
66 |
||
35 | 67 |
copyright |
68 |
" |
|
69 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
59 | 70 |
All Rights Reserved |
35 | 71 |
|
72 |
This software is furnished under a license and may be used |
|
73 |
only in accordance with the terms of that license and with the |
|
74 |
inclusion of the above copyright notice. This software may not |
|
75 |
be provided or otherwise made available to, or used by, any |
|
76 |
other person. No title to or ownership of the software is |
|
77 |
hereby transferred. |
|
78 |
" |
|
79 |
! |
|
80 |
||
0 | 81 |
documentation |
82 |
" |
|
83 |
Buttons are Labels which do something when pressed/released. |
|
113 | 84 |
Since they inherit from Label, read the documentation on Labels to |
85 |
see how color, layout, font, image or labelString are changed. |
|
86 |
||
133 | 87 |
Buttons (and also instances of subclasses, such as toggles, checkToggles |
88 |
and radioButtons) perform some action when pressed, and optionally when |
|
89 |
released. Due to historic reasons, ST/X buttons support two mechanisms: |
|
90 |
||
113 | 91 |
Actionblock operation: |
133 | 92 |
the button has an actionBlock (actually, it has two: a pressAction and |
93 |
a releaseAction) which is evaluated, when the button is pressed. |
|
94 |
The user of a button can set these action blocks via the #action:, |
|
95 |
#pressAction: or #releaseAction: messages. |
|
113 | 96 |
|
97 |
Model-View interaction: |
|
133 | 98 |
buttons with a model will send change-messages to the model and also react |
99 |
to changes in the model. |
|
100 |
You have to define the buttons labelMessage and an aspectSymbol. |
|
101 |
When changed, the model should send 'self changed:<aspect>' if it wants the |
|
102 |
label to change and return a string from the labelSymbol-message. |
|
118 | 103 |
By default, the labelMsg is nil, therefore no update of the label is done. |
104 |
(this behavior is inherited from label, see documentation there) |
|
105 |
||
133 | 106 |
When pressed, the button sends a changeMessage to the model. |
118 | 107 |
If the changeMsg is for a one-argument message, the current |
113 | 108 |
press-state is passed as argument (i.e. true if pressed, false if released). |
118 | 109 |
By default, the change-Message is #value: (for ST-80 compatibility). |
113 | 110 |
|
585 | 111 |
button model:aModel. |
112 |
button aspect:aspectSymbol. |
|
113 |
button change:changeSymbol. |
|
114 |
button labelMessage:labelSymbol. |
|
113 | 115 |
|
585 | 116 |
model sends #changed:aspectSymbol |
117 |
---> button will redraw its label from value returned by model>>labelSymbol |
|
113 | 118 |
|
585 | 119 |
button changes state: |
120 |
---> button sends changeSymbol / changeSymbol:state to the model |
|
113 | 121 |
|
118 | 122 |
By default (as inherited), the labelMsg is nil; therefore, buttons |
123 |
do not try to aquire a new labelString from the model. |
|
124 |
If you want this behavior, you must set labelMsg and aspectMsg |
|
125 |
as appropriate. |
|
0 | 126 |
|
133 | 127 |
See examples. |
128 |
||
129 |
||
585 | 130 |
[Instance variables:] |
0 | 131 |
|
59 | 132 |
activeLogo <StringOrImage> logo to show when active (pressed) |
133 |
passiveLogo <StringOrImage> logo to show when passive (released) |
|
585 | 134 |
default is nil for both, so the normal logo is used |
135 |
(see superclass: Label) |
|
35 | 136 |
onLevel <Integer> level when pressed (3D only) (default: depends on style) |
137 |
offLevel <Integer> level when released (3D only) (default: depends on style) |
|
138 |
disabledFgColor <Color> color used to draw logo when disabled (default: depends on style) |
|
139 |
activeFgColor <Color> color to draw logo when pressed (default: depends on style) |
|
140 |
activeBgColor <Color> bg color when pressed (default: depends on style) |
|
141 |
enteredFgColor <Color> fg color to draw logo when cursor entered (default: depends on style) |
|
142 |
enteredBgColor <Color> bg color when cursor entered (default: depends on style) |
|
0 | 143 |
|
35 | 144 |
isReturnButton <Boolean> true if this button is also activated by the |
585 | 145 |
return key - if true, it will draw a return-bitmap |
146 |
in addition to the logo (default: false) |
|
35 | 147 |
|
1051 | 148 |
defaultable <Boolean> true, if this button can become a returnButton. |
149 |
(computes its default extent differently) |
|
150 |
||
59 | 151 |
shadowForm <Form> form to display in addition to buttons label (returnbutton only) |
152 |
lightForm <Form> light part of shadowForm (returnbutton only) |
|
153 |
||
154 |
formColor <Color> color to draw form with (returnbutton only) |
|
155 |
formShadowColor <Color> color for shadowing the form (3D only & return) |
|
35 | 156 |
formLightColor <Color> color for lighting the form (3D only) |
157 |
||
62 | 158 |
|
585 | 159 |
[styleSheet parameters:] |
62 | 160 |
|
161 |
buttonActiveLevel <Integer> level when on (ignored in 2D styles) |
|
162 |
buttonPassiveLevel <Integer> level when off (ignored in 2D styles) |
|
74 | 163 |
buttonBorderWidth <Integer> default borderwidth |
62 | 164 |
buttonEdgeStyle <Symbol> style of edges (currently #soft or nil) |
165 |
buttonFont <Font> font to use for textual labels |
|
166 |
buttonForegroundColor <Color> color to draw foreground pixels (i.e. the string) |
|
167 |
buttonBackgroundColor <Color> color to draw background pixels |
|
168 |
buttonDisabledForegroundColor <Color> same when disabled |
|
169 |
buttonDisabledBackgroundColor <Color> same when disabled |
|
170 |
buttonEnteredForegroundColor <Color> same when mouse pointer is in |
|
171 |
buttonEnteredBackgroundColor <Color> same when mouse pointer is in |
|
172 |
buttonActiveForegroundColor <Color> same when button is active |
|
173 |
buttonActiveBackgroundColor <Color> same when button is active |
|
174 |
buttonShadowColor <Color> shadow color for edgaes (ignored in 2D styles) |
|
175 |
buttonLightColor <Color> light color for edgaes (ignored in 2D styles) |
|
176 |
buttonHalfShadowColor <Color> half shadow color; for soft edges only |
|
177 |
buttonHalfLightColor <Color> half light color; for soft edges only |
|
178 |
||
179 |
buttonReturnButtonHasImage <Boolean> if true, return-buttons draw a return-key image |
|
180 |
buttonReturnButtonHasBorder <Boolean> if true, return-buttons show a border |
|
130 | 181 |
|
585 | 182 |
[author:] |
183 |
Claus Gittinger |
|
184 |
||
185 |
[see also:] |
|
186 |
Toggle CheckToggle CheckBox |
|
593 | 187 |
Dialog |
188 |
ValueHolder TriggerValue |
|
189 |
Block |
|
133 | 190 |
" |
191 |
! |
|
192 |
||
62 | 193 |
examples |
194 |
" |
|
195 |
You dont have to normally care for all the internals |
|
420 | 196 |
(they allow many variations though). |
197 |
For buttons with a stringLabel, the typical use is: |
|
35 | 198 |
|
420 | 199 |
b := Button label:'some logo' in:aView. |
200 |
b action:[ .. things to do, when pressed ... ] |
|
35 | 201 |
|
420 | 202 |
and for bitmap/image buttons its: |
62 | 203 |
|
420 | 204 |
b := Button label:someImage in:aView. |
205 |
b action:[ .. things to do, when pressed ... ] |
|
62 | 206 |
|
420 | 207 |
|
62 | 208 |
|
133 | 209 |
Of course, you can also setup things the ST-80 way, in first |
210 |
creating the button and later add it to some superview: |
|
211 |
||
420 | 212 |
b := Button new. |
213 |
b label:someImage. |
|
214 |
b action:[ .. things to do, when pressed ... ] |
|
215 |
... |
|
216 |
aSuperView add:b in:<frameRectangle>. |
|
118 | 217 |
|
420 | 218 |
|
219 |
Although you can specify most of the look of a button, |
|
133 | 220 |
you should use the defaults in most applications. |
88 | 221 |
As you specify more things in your program, |
222 |
the styleSheet settings are more and more ignored. |
|
223 |
Also, even though it might look fancy, colorful |
|
224 |
button panels are usually not a good GUI design; |
|
225 |
they will attract the users attention - possibly to things |
|
226 |
which are not worth it. |
|
420 | 227 |
Finally, if you use fancy colors, always think of those poor users |
133 | 228 |
without color displays - the styleSheet allows those people to adjust things, |
130 | 229 |
while hard-coded colors cannot be fixed without changing the code. |
88 | 230 |
|
420 | 231 |
a simple button with default settings and no action: |
133 | 232 |
(you may want to try it with different viewStyle settings in effect): |
593 | 233 |
[exBegin] |
420 | 234 |
|top b| |
235 |
||
236 |
top := StandardSystemView new. |
|
237 |
top extent:100@100. |
|
88 | 238 |
|
420 | 239 |
b := Button in:top. |
240 |
b label:'hello'. |
|
241 |
||
242 |
top open. |
|
593 | 243 |
[exEnd] |
420 | 244 |
|
88 | 245 |
|
593 | 246 |
give it some action (watch the transcript): |
247 |
[exBegin] |
|
420 | 248 |
|top b| |
249 |
||
250 |
top := StandardSystemView new. |
|
251 |
top extent:100@100. |
|
252 |
||
253 |
b := Button in:top. |
|
254 |
b label:'hello'. |
|
255 |
b action:[Transcript flash]. |
|
256 |
||
257 |
top open. |
|
593 | 258 |
[exEnd] |
88 | 259 |
|
260 |
||
113 | 261 |
there is also a combined instance creation message: |
593 | 262 |
[exBegin] |
420 | 263 |
|top b| |
113 | 264 |
|
420 | 265 |
top := StandardSystemView new. |
266 |
top extent:100@100. |
|
113 | 267 |
|
420 | 268 |
b := Button label:'hello' action:[Transcript flash] in:top. |
269 |
||
270 |
top open. |
|
593 | 271 |
[exEnd] |
113 | 272 |
|
273 |
||
133 | 274 |
a return button |
275 |
(in dialogs, you should setup things to have the return-key perform |
|
276 |
the ok action, and mark the corresponding button as being a returnButton): |
|
593 | 277 |
[exBegin] |
420 | 278 |
|top b| |
279 |
||
280 |
top := StandardSystemView new. |
|
281 |
top extent:100@100. |
|
282 |
||
283 |
b := Button label:'hello' action:[Transcript flash] in:top. |
|
284 |
b beReturnButton. |
|
285 |
top open. |
|
593 | 286 |
[exEnd] |
420 | 287 |
|
288 |
||
289 |
||
290 |
multiple buttons in a panel: |
|
593 | 291 |
[exBegin] |
420 | 292 |
|top panel b1 b2 b3| |
293 |
||
294 |
top := StandardSystemView new. |
|
295 |
top extent:300@100. |
|
296 |
||
297 |
panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
133 | 298 |
|
420 | 299 |
b1 := Button label:'one' in:panel. |
300 |
b2 := Button label:'two' in:panel. |
|
301 |
b3 := Button label:'three' action:[Transcript flash] in:panel. |
|
302 |
||
303 |
top open. |
|
593 | 304 |
[exEnd] |
420 | 305 |
|
133 | 306 |
|
307 |
||
308 |
enabling/disabling buttons via explicit messages: |
|
593 | 309 |
[exBegin] |
420 | 310 |
|top panel b1 b2 b3| |
311 |
||
312 |
top := StandardSystemView new. |
|
313 |
top extent:300@100. |
|
314 |
panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
133 | 315 |
|
420 | 316 |
b1 := Button label:'enable' action:[b3 enable] in:panel. |
317 |
b2 := Button label:'disable' action:[b3 disable] in:panel. |
|
318 |
b3 := Button label:'flash' action:[Transcript flash] in:panel. |
|
319 |
top open. |
|
593 | 320 |
[exEnd] |
133 | 321 |
|
322 |
||
323 |
||
324 |
enabling/disabling buttons via implicit value change of a valueHolder: |
|
420 | 325 |
The two views are only indirectly coupled (via the valueHolder); |
326 |
not knowing about each other. |
|
593 | 327 |
[exBegin] |
420 | 328 |
|top panel ena t b1 b2 b3 check| |
133 | 329 |
|
420 | 330 |
top := StandardSystemView new. |
331 |
top extent:300@100. |
|
332 |
||
333 |
panel := HorizontalPanelView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top. |
|
133 | 334 |
|
420 | 335 |
ena := false asValue. |
133 | 336 |
|
420 | 337 |
t := Toggle label:'enable' in:panel. |
338 |
t model:ena. |
|
133 | 339 |
|
420 | 340 |
b1 := Button label:'button1' in:panel. |
341 |
b1 controller enableChannel:ena. |
|
133 | 342 |
|
420 | 343 |
b2 := Button label:'button2' in:panel. |
344 |
b2 controller enableChannel:ena. |
|
133 | 345 |
|
420 | 346 |
b3 := Button label:'button3' in:panel. |
347 |
b3 controller enableChannel:ena. |
|
133 | 348 |
|
420 | 349 |
top open. |
133 | 350 |
|
420 | 351 |
check := CheckBox model:ena. |
352 |
check label:'also enable'. |
|
353 |
check extent:(check preferredExtent + (5@5)). |
|
354 |
check open |
|
593 | 355 |
[exEnd] |
133 | 356 |
|
357 |
||
358 |
||
88 | 359 |
changing colors: |
593 | 360 |
[exBegin] |
420 | 361 |
|top b| |
88 | 362 |
|
420 | 363 |
top := StandardSystemView new. |
364 |
top extent:100@100. |
|
88 | 365 |
|
420 | 366 |
b := Button label:'hello' in:top. |
367 |
b action:[Transcript flash]. |
|
368 |
b activeForegroundColor:(Color white). |
|
369 |
b activeBackgroundColor:(Color red). |
|
370 |
||
371 |
top open. |
|
593 | 372 |
[exEnd] |
88 | 373 |
|
374 |
||
375 |
changing more colors: |
|
593 | 376 |
[exBegin] |
420 | 377 |
|top b| |
88 | 378 |
|
420 | 379 |
top := StandardSystemView new. |
380 |
top extent:100@100. |
|
88 | 381 |
|
420 | 382 |
b := Button label:'hello' in:top. |
383 |
b action:[Transcript flash]. |
|
384 |
b enteredForegroundColor:(Color red). |
|
385 |
b enteredBackgroundColor:(b backgroundColor). |
|
386 |
b activeForegroundColor:(Color white). |
|
387 |
b activeBackgroundColor:(Color red). |
|
388 |
||
389 |
top open. |
|
593 | 390 |
[exEnd] |
88 | 391 |
|
392 |
||
113 | 393 |
button with an image and different colors: |
593 | 394 |
[exBegin] |
420 | 395 |
|top b| |
88 | 396 |
|
420 | 397 |
top := StandardSystemView new. |
398 |
top extent:100@100. |
|
88 | 399 |
|
420 | 400 |
b := Button in:top. |
401 |
b label:(Image fromFile:'bitmaps/SBrowser.xbm'). |
|
402 |
b action:[Transcript flash]. |
|
403 |
b enteredForegroundColor:(Color green darkened). |
|
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 |
||
118 | 412 |
changing the image when pressed: |
593 | 413 |
[exBegin] |
420 | 414 |
|top b| |
88 | 415 |
|
420 | 416 |
top := StandardSystemView new. |
417 |
top extent:100@100. |
|
62 | 418 |
|
420 | 419 |
b := Button in:top. |
420 |
b passiveLogo:(Image fromFile:'bitmaps/SBrowser.xbm'). |
|
421 |
b activeLogo:(Image fromFile:'bitmaps/CBrowser.xbm'). |
|
422 |
b action:[Transcript flash]. |
|
423 |
b enteredForegroundColor:(Color red). |
|
424 |
b enteredBackgroundColor:(b backgroundColor). |
|
425 |
b activeForegroundColor:(Color white). |
|
426 |
b activeBackgroundColor:(Color red). |
|
427 |
||
428 |
top open. |
|
593 | 429 |
[exEnd] |
88 | 430 |
|
431 |
||
113 | 432 |
well, even that is possible (but you should NEVER do it): |
593 | 433 |
[exBegin] |
420 | 434 |
|top b| |
88 | 435 |
|
420 | 436 |
top := StandardSystemView new. |
437 |
top extent:100@100. |
|
88 | 438 |
|
420 | 439 |
b := Button in:top. |
440 |
b passiveLogo:(Image fromFile:'bitmaps/SmalltalkX.xbm'). |
|
1153 | 441 |
b activeLogo:'start'. |
420 | 442 |
b action:[Transcript flash]. |
443 |
b enteredForegroundColor:(Color red). |
|
444 |
b enteredBackgroundColor:(b backgroundColor). |
|
445 |
b activeForegroundColor:(Color white). |
|
446 |
b activeBackgroundColor:(Color red). |
|
447 |
top open. |
|
593 | 448 |
[exEnd] |
88 | 449 |
|
450 |
||
451 |
more playing with colors: |
|
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. |
459 |
b logo:(Image fromFile:'bitmaps/SmalltalkX.xbm'). |
|
460 |
b action:[Transcript flash]. |
|
461 |
b foregroundColor:(Color red:0 green:80 blue:20) darkened. |
|
462 |
b backgroundColor:(Color grey:10). |
|
463 |
b enteredForegroundColor:(Color red). |
|
464 |
b activeForegroundColor:(Color red). |
|
465 |
b activeBackgroundColor:(Color grey:10). |
|
466 |
top open. |
|
593 | 467 |
[exEnd] |
130 | 468 |
|
469 |
||
470 |
more playing with colors: |
|
593 | 471 |
[exBegin] |
420 | 472 |
|top b| |
130 | 473 |
|
420 | 474 |
top := StandardSystemView new. |
475 |
top extent:100@100. |
|
130 | 476 |
|
420 | 477 |
b := Button in:top. |
478 |
b logo:(Image fromFile:'bitmaps/SmalltalkX.xbm'). |
|
479 |
b action:[Transcript flash]. |
|
480 |
b foregroundColor:(Color red:0 green:80 blue:20) darkened. |
|
481 |
b backgroundColor:(Color grey:10). |
|
482 |
b enteredBackgroundColor:(Color grey:20). |
|
483 |
b activeForegroundColor:(Color red). |
|
484 |
b activeBackgroundColor:(Color grey:20). |
|
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 |
|
88 | 735 |
see 'doc/coding-examples' and 'doc/misc/quick_view_intro.doc' |
736 |
for more variations on this theme. |
|
0 | 737 |
" |
738 |
! ! |
|
739 |
||
850 | 740 |
!Button class methodsFor:'instance creation'! |
205 | 741 |
|
742 |
abortButton |
|
743 |
"since abort-buttons are very common, here is a convenient |
|
744 |
method to create one ..." |
|
745 |
||
746 |
|aButton| |
|
0 | 747 |
|
366
27bf7d05650b
renamed abort-button to cancel
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
748 |
aButton := Button label:(self classResources at:'cancel'). |
205 | 749 |
aButton cursor:(Cursor thumbsDown). |
750 |
^ aButton |
|
366
27bf7d05650b
renamed abort-button to cancel
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
751 |
|
27bf7d05650b
renamed abort-button to cancel
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
752 |
"Modified: 20.2.1996 / 20:20:16 / cg" |
205 | 753 |
! |
754 |
||
755 |
abortButtonIn:aView |
|
756 |
"since abort-buttons are very common, here is a convenient |
|
757 |
method to create one ..." |
|
758 |
||
759 |
|b| |
|
60 | 760 |
|
205 | 761 |
aView addSubView:(b := self abortButton). |
762 |
^ b |
|
763 |
! |
|
764 |
||
765 |
form:aForm action:aBlock in:aView |
|
766 |
"create and return a new Button with icon-label, aForm |
|
767 |
and pressAction, aBlock. Button is placed into aView. |
|
768 |
OBSOLETE: this is for backward compatibility; |
|
769 |
you can now pass an image or form in the #label:action:in: message." |
|
770 |
||
771 |
^ ((self in:aView) form:aForm) action:aBlock |
|
772 |
! |
|
773 |
||
774 |
label:aLabel action:aBlock |
|
775 |
"create and return a new Button with text-label, aString |
|
776 |
and pressAction, aBlock." |
|
777 |
||
778 |
^ (self label:aLabel) action:aBlock |
|
779 |
! |
|
780 |
||
781 |
label:aLabel action:aBlock in:aView |
|
782 |
"create and return a new Button with text-label, aString |
|
783 |
and pressAction, aBlock. Button is placed into aView." |
|
60 | 784 |
|
205 | 785 |
^ ((self in:aView) label:aLabel) action:aBlock |
786 |
! |
|
787 |
||
788 |
okButton |
|
789 |
"since ok-buttons are very common, here is a convenient |
|
790 |
method to create one ..." |
|
791 |
||
792 |
|aButton| |
|
793 |
||
794 |
aButton := Button label:(self classResources at:'ok'). |
|
795 |
aButton cursor:(Cursor thumbsUp). |
|
219 | 796 |
aButton beReturnButton. |
205 | 797 |
^ aButton |
59 | 798 |
! |
799 |
||
205 | 800 |
okButtonIn:aView |
801 |
"since ok-buttons are very common, here is a convenient |
|
802 |
method to create one ..." |
|
803 |
||
804 |
|b| |
|
805 |
||
806 |
aView addSubView:(b := self okButton). |
|
807 |
^ b |
|
808 |
! |
|
809 |
||
810 |
toggle |
|
811 |
"ST-80 compatibility: create & return a new toggle." |
|
812 |
||
813 |
^ Toggle new |
|
814 |
||
815 |
" |
|
816 |
Button toggle label:'press me'; |
|
817 |
model:((PluggableAdaptor on:(Point new)) |
|
818 |
getSelector:#x putSelector:#x:) |
|
819 |
" |
|
820 |
"this is the same as" |
|
821 |
" |
|
822 |
Toggle new label:'press me'; |
|
823 |
model:((PluggableAdaptor on:(Point new)) |
|
824 |
getSelector:#x putSelector:#x:) |
|
825 |
" |
|
826 |
! ! |
|
827 |
||
850 | 828 |
!Button class methodsFor:'defaults'! |
205 | 829 |
|
0 | 830 |
returnFormOn:aDevice |
831 |
"return the form used for the return arrow in non-3D; |
|
832 |
cache the one for Display for the next round." |
|
833 |
||
834 |
|f| |
|
835 |
||
781
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
836 |
(ReturnForm notNil and:[aDevice == ReturnForm graphicsDevice]) ifTrue:[ |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
837 |
^ ReturnForm |
0 | 838 |
]. |
899 | 839 |
f := Image fromFile:'bitmaps/Return.xbm' resolution:100 on:aDevice. |
0 | 840 |
f isNil ifTrue:[ |
781
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
841 |
f := Form width:24 height:16 fromArray:#[2r00000000 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
842 |
2r00000000 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
843 |
2r00000000 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
844 |
2r00000000 2r00000011 2r11100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
845 |
2r00000001 2r10000011 2r11100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
846 |
2r00000011 2r10000011 2r11100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
847 |
2r00000111 2r11111111 2r11100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
848 |
2r00001111 2r11111111 2r11100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
849 |
2r00011111 2r11111111 2r11100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
850 |
2r00001111 2r11111111 2r11100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
851 |
2r00000111 2r11111111 2r11100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
852 |
2r00000011 2r10000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
853 |
2r00000001 2r10000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
854 |
2r00000000 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
855 |
2r00000000 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
856 |
2r00000000 2r00000000 2r00000000] |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
857 |
on:aDevice |
0 | 858 |
]. |
35 | 859 |
ReturnForm := f. |
0 | 860 |
^ f |
781
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
861 |
|
899 | 862 |
"Modified: 19.12.1996 / 19:18:03 / cg" |
0 | 863 |
! |
864 |
||
205 | 865 |
returnLightFormOn:aDevice |
866 |
"return the form used for the return arrow light pixels (3D only); |
|
867 |
cache the one for Display for the next round" |
|
868 |
||
869 |
|f| |
|
870 |
||
781
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
871 |
(ReturnLightForm notNil and:[aDevice == ReturnLightForm graphicsDevice]) ifTrue:[ |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
872 |
^ ReturnLightForm |
205 | 873 |
]. |
899 | 874 |
f := Image fromFile:'bitmaps/ReturnLight.xbm' resolution:100 on:aDevice. |
205 | 875 |
f isNil ifTrue:[ |
781
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
876 |
f := Form width:24 height:16 fromArray:#[2r00000000 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
877 |
2r00000000 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
878 |
2r00000000 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
879 |
2r00000000 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
880 |
2r00000000 2r00000000 2r00100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
881 |
2r00000000 2r00000000 2r00100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
882 |
2r00000000 2r00000000 2r00100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
883 |
2r00000000 2r00000000 2r00100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
884 |
2r00000000 2r00000000 2r00100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
885 |
2r00000000 2r00000000 2r00100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
886 |
2r00000000 2r11111111 2r11100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
887 |
2r00000000 2r10000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
888 |
2r00000000 2r10000000 2r00000000 |
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 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
891 |
2r00000000 2r00000000 2r00000000] |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
892 |
on:aDevice |
205 | 893 |
]. |
894 |
ReturnLightForm := f. |
|
895 |
^ f |
|
781
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
896 |
|
899 | 897 |
"Modified: 19.12.1996 / 01:00:00 / cg" |
205 | 898 |
! |
899 |
||
0 | 900 |
returnShadowFormOn:aDevice |
901 |
"return the form used for the return arrow shadow pixels (3D only); |
|
902 |
cache the one for Display for the next round." |
|
903 |
||
904 |
|f| |
|
905 |
||
781
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
906 |
(ReturnShadowForm notNil and:[aDevice == ReturnShadowForm graphicsDevice]) ifTrue:[ |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
907 |
^ ReturnShadowForm |
0 | 908 |
]. |
899 | 909 |
f := Image fromFile:'bitmaps/ReturnShadow.xbm' resolution:100 on:aDevice. |
0 | 910 |
f isNil ifTrue:[ |
781
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
911 |
f := Form width:24 height:16 fromArray:#[2r00000000 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
912 |
2r00000000 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
913 |
2r00000000 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
914 |
2r00000000 2r00000011 2r11100000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
915 |
2r00000001 2r10000010 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
916 |
2r00000010 2r10000010 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
917 |
2r00000100 2r11111110 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
918 |
2r00001000 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
919 |
2r00010000 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
920 |
2r00001000 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
921 |
2r00000100 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
922 |
2r00000010 2r00000000 2r00000000 |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
923 |
2r00000001 2r00000000 2r00000000 |
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 2r00000000] |
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
927 |
on:aDevice |
0 | 928 |
]. |
35 | 929 |
ReturnShadowForm := f. |
0 | 930 |
^ f |
781
51741bd620ab
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
931 |
|
899 | 932 |
"Modified: 1.1.1970 / 01:00:00 / cg" |
0 | 933 |
! |
934 |
||
205 | 935 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
936 |
"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
|
937 |
|
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
938 |
<resource: #style (#buttonEdgeStyle #buttonFont #buttonBorderWidth |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
939 |
#buttonActiveLevel #buttonPassiveLevel |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
940 |
#buttonBackgroundColor #buttonForegroundColor |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
941 |
#buttonActiveBackgroundColor #buttonActiveForegroundColor |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
942 |
#buttonEnteredBackgroundColor #buttonEnteredForegroundColor |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
943 |
#buttonDisabledForegroundColor #buttonDisabledBackgroundColor |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
944 |
#buttonReturnButtonHasImage |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
945 |
#buttonReturnButtonHasBorder |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
946 |
#buttonShadowColor #buttonLightColor |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
947 |
#buttonHalfShadowColor #buttonHalfLightColor)> |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
948 |
|
205 | 949 |
|defaultLevel| |
0 | 950 |
|
205 | 951 |
StyleSheet is3D ifTrue:[ |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
952 |
defaultLevel := 1. |
205 | 953 |
] ifFalse:[ |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
954 |
defaultLevel := 0 |
0 | 955 |
]. |
205 | 956 |
DefaultActiveLevel := StyleSheet at:'buttonActiveLevel' default:(defaultLevel negated). |
957 |
DefaultPassiveLevel := StyleSheet at:'buttonPassiveLevel' default:defaultLevel. |
|
958 |
||
959 |
DefaultEdgeStyle := StyleSheet at:'buttonEdgeStyle'. |
|
960 |
DefaultFont := StyleSheet fontAt:'buttonFont'. |
|
961 |
DefaultBorderWidth := StyleSheet at:'buttonBorderWidth'. |
|
962 |
DefaultForegroundColor := StyleSheet colorAt:'buttonForegroundColor'. |
|
963 |
DefaultBackgroundColor := StyleSheet colorAt:'buttonBackgroundColor'. |
|
610 | 964 |
DefaultDisabledForegroundColor := StyleSheet colorAt:'buttonDisabledForegroundColor' default:Color gray. |
205 | 965 |
DefaultDisabledBackgroundColor := StyleSheet colorAt:'buttonDisabledBackgroundColor'. |
966 |
DefaultEnteredForegroundColor := StyleSheet colorAt:'buttonEnteredForegroundColor'. |
|
967 |
DefaultEnteredBackgroundColor := StyleSheet colorAt:'buttonEnteredBackgroundColor'. |
|
968 |
DefaultActiveForegroundColor := StyleSheet colorAt:'buttonActiveForegroundColor'. |
|
969 |
DefaultActiveBackgroundColor := StyleSheet colorAt:'buttonActiveBackgroundColor'. |
|
970 |
DefaultReturnButtonHasImage := StyleSheet at:'buttonReturnButtonHasImage' default:true. |
|
971 |
DefaultReturnButtonHasBorder := StyleSheet at:'buttonReturnButtonHasBorder' default:false. |
|
972 |
DefaultShadowColor := StyleSheet colorAt:'buttonShadowColor'. |
|
973 |
DefaultLightColor := StyleSheet colorAt:'buttonLightColor'. |
|
974 |
DefaultHalfShadowColor := StyleSheet colorAt:'buttonHalfShadowColor'. |
|
975 |
DefaultHalfLightColor := StyleSheet colorAt:'buttonHalfLightColor'. |
|
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
976 |
|
610 | 977 |
"Modified: 2.5.1996 / 11:37:43 / cg" |
0 | 978 |
! ! |
979 |
||
205 | 980 |
!Button methodsFor:'accessing-behavior'! |
981 |
||
982 |
action:aBlock |
|
983 |
"convenient method: depending on the setting of controllers triggerOnDown flag, |
|
984 |
either set the press-action and clear any release-action or |
|
985 |
vice versa, set the release-action and clear the press-action." |
|
986 |
||
315
dbfd0ae75b57
check for nil-controller (dont die if fBrowser is closed while command is being executed)
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
987 |
controller notNil ifTrue:[controller action:aBlock] |
205 | 988 |
! |
989 |
||
990 |
autoRepeat |
|
346 | 991 |
"turn on autorepeat OBSOLETE; use #autoRepeat:" |
205 | 992 |
|
993 |
controller autoRepeat |
|
346 | 994 |
|
995 |
"Modified: 9.2.1996 / 22:42:37 / cg" |
|
205 | 996 |
! |
997 |
||
998 |
autoRepeat:aBoolean |
|
999 |
"turn on/off autorepeat" |
|
1000 |
||
1001 |
controller autoRepeat:aBoolean |
|
1002 |
||
1003 |
"Modified: 5.9.1995 / 22:06:13 / claus" |
|
1004 |
! |
|
1005 |
||
1006 |
disable |
|
1007 |
"disable the button" |
|
1008 |
||
1009 |
controller disable. |
|
1010 |
! |
|
1011 |
||
1012 |
enable |
|
1013 |
"enable the button" |
|
1014 |
||
1015 |
controller enable |
|
1016 |
! |
|
1017 |
||
264 | 1018 |
enabled |
1019 |
"return true if the button is enabled" |
|
1020 |
||
1021 |
^ controller enabled |
|
1022 |
||
1023 |
"Created: 17.12.1995 / 16:12:26 / cg" |
|
1024 |
! |
|
1025 |
||
205 | 1026 |
pressAction |
1027 |
"return the pressAction; thats the block which gets evaluated |
|
1028 |
when the button is pressed (if non-nil)" |
|
1029 |
||
1030 |
^ controller pressAction |
|
1031 |
! |
|
0 | 1032 |
|
205 | 1033 |
pressAction:aBlock |
1034 |
"define the action to be performed on press" |
|
1035 |
||
1036 |
controller pressAction:aBlock |
|
1037 |
! |
|
1038 |
||
867 | 1039 |
releaseAction |
1040 |
"return the releaseAction; thats the block which gets evaluated |
|
1041 |
when the button is relreased (if non-nil)" |
|
1042 |
||
1043 |
^ controller releaseAction |
|
1044 |
! |
|
1045 |
||
1046 |
releaseAction:aBlock |
|
1047 |
"define the action to be performed on release" |
|
1048 |
||
1049 |
controller releaseAction:aBlock |
|
1050 |
! ! |
|
1051 |
||
1052 |
!Button methodsFor:'accessing-channels'! |
|
1053 |
||
1054 |
enableChannel |
|
1055 |
"return a valueHolder for enable/disable" |
|
1056 |
||
1057 |
^ controller enableChannel |
|
1058 |
||
1059 |
"Modified: 30.4.1996 / 15:09:42 / cg" |
|
1060 |
! |
|
1061 |
||
1062 |
enableChannel:aValueHolderForBoolean |
|
1063 |
"set the valueHolder used for enable/disable" |
|
1064 |
||
1065 |
controller enableChannel:aValueHolderForBoolean |
|
1066 |
! |
|
1067 |
||
205 | 1068 |
pressChannel |
1069 |
"return the pressChannel" |
|
1070 |
||
1071 |
^ controller pressChannel |
|
1072 |
||
1073 |
"Modified: 7.9.1995 / 18:16:20 / claus" |
|
1074 |
! |
|
1075 |
||
1076 |
pressChannel:aBlock |
|
1077 |
"set the pressChannel" |
|
1078 |
||
1079 |
controller pressChannel:aBlock |
|
1080 |
||
1081 |
"Modified: 7.9.1995 / 18:05:14 / claus" |
|
1082 |
! |
|
1083 |
||
1084 |
releaseChannel |
|
1085 |
"return the releaseChannel" |
|
1086 |
||
1087 |
^ controller releaseChannel |
|
1088 |
||
1089 |
"Modified: 7.9.1995 / 18:15:24 / claus" |
|
1090 |
! |
|
1091 |
||
1092 |
releaseChannel:aBlock |
|
1093 |
"set the releaseChannel" |
|
1094 |
||
1095 |
controller releaseChannel:aBlock |
|
1096 |
||
1097 |
"Modified: 7.9.1995 / 18:05:21 / claus" |
|
1098 |
! ! |
|
1099 |
||
1100 |
!Button methodsFor:'accessing-look'! |
|
1101 |
||
1102 |
activeBackgroundColor |
|
1103 |
"return the background color to be used when pressed" |
|
1104 |
||
1105 |
^ activeBgColor |
|
164 | 1106 |
! |
1107 |
||
205 | 1108 |
activeBackgroundColor:aColor |
1109 |
"set the background color to be used when pressed" |
|
1110 |
||
1111 |
activeBgColor := aColor. |
|
1112 |
self redrawIfPressed |
|
1113 |
! |
|
1114 |
||
1115 |
activeForegroundColor |
|
1116 |
"return the foreground color to be used when pressed" |
|
1117 |
||
1118 |
^ activeFgColor |
|
1119 |
! |
|
1120 |
||
1121 |
activeForegroundColor:aColor |
|
1122 |
"set the foreground color to be used when pressed" |
|
1123 |
||
1124 |
activeFgColor := aColor. |
|
1125 |
self redrawIfPressed |
|
1126 |
! |
|
1127 |
||
1128 |
activeForegroundColor:fgColor backgroundColor:bgColor |
|
1129 |
"set both fg and bg colors to be used when pressed" |
|
1130 |
||
1131 |
activeFgColor := fgColor. |
|
1132 |
activeBgColor := bgColor. |
|
1133 |
self redrawIfPressed |
|
1134 |
! |
|
0 | 1135 |
|
205 | 1136 |
activeLevel |
1137 |
"return the level of the button when pressed" |
|
1138 |
||
1139 |
^ onLevel |
|
1140 |
! |
|
1141 |
||
1142 |
activeLevel:aNumber |
|
1143 |
"set the level of the button when pressed (i.e. how deep)" |
|
1144 |
||
1145 |
onLevel := aNumber. |
|
1146 |
(controller notNil |
|
1147 |
and:[controller pressed]) ifTrue:[ |
|
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1148 |
self level:onLevel. |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1149 |
margin := onLevel abs max:offLevel abs. |
992 | 1150 |
shown ifTrue:[ |
1151 |
self invalidate. "/ redraw |
|
1152 |
] |
|
205 | 1153 |
] |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1154 |
|
992 | 1155 |
"Modified: 8.2.1997 / 15:21:25 / cg" |
205 | 1156 |
! |
1157 |
||
1158 |
activeLogo:anImageOrString |
|
1159 |
"define the logo to be displayed while active - |
|
1160 |
this is optional; the default is to display the same |
|
1161 |
(logo) in both pressed and released states." |
|
1162 |
||
1163 |
activeLogo := anImageOrString. |
|
1164 |
controller pressed ifTrue:[ |
|
1165 |
self logo:anImageOrString |
|
1166 |
] |
|
0 | 1167 |
! |
1168 |
||
205 | 1169 |
beImageButton |
1170 |
"make mySelf an image button - that is turn off all levelChanges |
|
1171 |
and logo spacing. This should be sent for buttons which use both |
|
1172 |
passive and active logos, and the 3D effect comes from the bitmaps |
|
1173 |
(i.e. windows buttons)." |
|
1174 |
||
1175 |
self |
|
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1176 |
extent:(labelWidth @ labelHeight); |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1177 |
sizeFixed:true; |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1178 |
borderWidth:0; |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1179 |
activeLevel:0; |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1180 |
passiveLevel:0; |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1181 |
horizontalSpace:0; |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1182 |
verticalSpace:0; |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1183 |
newLayout. |
205 | 1184 |
|
1185 |
"Created: 17.9.1995 / 20:41:47 / claus" |
|
1186 |
"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
|
1187 |
"Modified: 28.5.1996 / 22:04:14 / cg" |
205 | 1188 |
! |
1189 |
||
244 | 1190 |
beReturnButton |
1051 | 1191 |
"show show a return-key image after the label. |
1192 |
Same as 'isReturnButton:true' for ST-80 compatibility." |
|
244 | 1193 |
|
1194 |
self isReturnButton:true |
|
1195 |
! |
|
1196 |
||
205 | 1197 |
beRoundRadioButton |
1198 |
"setup myself for a round radioButton look. |
|
1199 |
this is a private method; do not use it. It is going to move into the |
|
1200 |
RadioButton class." |
|
0 | 1201 |
|
205 | 1202 |
self activeLogo:(Icon constantNamed:'RadioOn'). |
1203 |
self passiveLogo:(Icon constantNamed:'RadioOff'). |
|
1204 |
self activeLevel:0; |
|
1205 |
passiveLevel:0; |
|
1206 |
activeBackgroundColor:bgColor; |
|
1207 |
activeForegroundColor:fgColor; |
|
1208 |
borderWidth:0; |
|
1209 |
enteredBackgroundColor:bgColor. |
|
1210 |
self computeLabelSize. |
|
1211 |
self beImageButton. |
|
1212 |
||
1213 |
"Created: 22.9.1995 / 15:48:05 / claus" |
|
1214 |
"Modified: 22.9.1995 / 17:07:46 / claus" |
|
1215 |
! |
|
1216 |
||
1093
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
1217 |
defaultable |
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
1218 |
"return true, if the receiver is defaultable" |
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
1219 |
|
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
1220 |
^ defaultable |
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
1221 |
! |
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
1222 |
|
1051 | 1223 |
defaultable:aBoolean |
1224 |
"set/clear the defaultable attribute. If defaultable, |
|
1225 |
the preferredExtent is computed to include any additional |
|
1226 |
space required when the receiver is a returnButton." |
|
1227 |
||
1228 |
defaultable ~~ aBoolean ifTrue:[ |
|
1229 |
defaultable := aBoolean. |
|
1230 |
self newLayout |
|
1231 |
] |
|
1232 |
! |
|
1233 |
||
205 | 1234 |
disabledForegroundColor |
1235 |
"return the foreground color used when the button is disabled" |
|
1236 |
||
1237 |
^ disabledFgColor |
|
1238 |
! |
|
1239 |
||
1240 |
disabledLogo:anImageOrString |
|
1241 |
"define the logo to be displayed while active - |
|
1242 |
this is optional; the default is to display the same |
|
1243 |
(logo) in both pressed and released states." |
|
1244 |
||
1245 |
disabledLogo := anImageOrString. |
|
1246 |
controller enabled ifFalse:[ |
|
1247 |
self logo:anImageOrString |
|
1248 |
] |
|
1249 |
||
1250 |
"Created: 17.9.1995 / 19:50:17 / claus" |
|
1251 |
"Modified: 17.9.1995 / 19:50:34 / claus" |
|
59 | 1252 |
! |
1253 |
||
205 | 1254 |
edgeStyle:aSymbol |
1255 |
"set the edgestyle - currently only #soft or nil" |
|
1256 |
||
1257 |
edgeStyle := aSymbol |
|
1258 |
! |
|
1259 |
||
1260 |
enteredBackgroundColor |
|
1261 |
"return the background color to be used when the mouse |
|
1262 |
pointer enters the button area" |
|
1263 |
||
1264 |
^ enteredBgColor |
|
1265 |
! |
|
1266 |
||
1267 |
enteredBackgroundColor:aColor |
|
1268 |
"set the background color to be used when the mouse |
|
1269 |
pointer enters the button area" |
|
1270 |
||
1271 |
enteredBgColor := aColor |
|
1272 |
! |
|
1273 |
||
1274 |
enteredForegroundColor |
|
1275 |
"return the foreground color to be used when the mouse |
|
1276 |
pointer enters the button area" |
|
1277 |
||
1278 |
^ enteredFgColor |
|
1279 |
! |
|
1280 |
||
1281 |
enteredForegroundColor:aColor |
|
1282 |
"set the foreground color to be used when the mouse |
|
1283 |
pointer enters the button area" |
|
59 | 1284 |
|
205 | 1285 |
enteredFgColor := aColor |
1286 |
! |
|
1287 |
||
1288 |
focusLogo:anImageOrString |
|
1289 |
"define the logo to be displayed while active - |
|
1290 |
this is optional; the default is to display the same |
|
1291 |
(logo) in both pressed and released states." |
|
1292 |
||
1293 |
focusLogo := anImageOrString. |
|
1294 |
||
1295 |
"Created: 17.9.1995 / 19:50:17 / claus" |
|
1296 |
"Modified: 17.9.1995 / 20:00:43 / claus" |
|
1297 |
! |
|
59 | 1298 |
|
205 | 1299 |
isReturnButton:aBoolean |
1300 |
"show/dont show a return-key image after the label" |
|
1301 |
||
1302 |
isReturnButton ~~ aBoolean ifTrue:[ |
|
1303 |
DefaultReturnButtonHasBorder ifTrue:[ |
|
1304 |
self borderWidth:(aBoolean ifTrue:[1] ifFalse:[0]) |
|
1305 |
]. |
|
1306 |
isReturnButton := aBoolean. |
|
1307 |
self newLayout |
|
1308 |
] |
|
1309 |
! |
|
1310 |
||
1094 | 1311 |
loseDefault |
1312 |
"ST-80 compatibility - clear isReturnButton attribute" |
|
1313 |
||
1314 |
self isReturnButton:false |
|
1315 |
||
1316 |
"Created: 3.3.1997 / 16:20:47 / cg" |
|
1317 |
"Modified: 3.3.1997 / 18:12:06 / cg" |
|
1318 |
! |
|
1319 |
||
205 | 1320 |
offLevel |
1321 |
"return the level of the button when released. |
|
1322 |
Historic leftover; use #passiveLevel." |
|
1323 |
||
1324 |
^ offLevel |
|
59 | 1325 |
! |
1326 |
||
205 | 1327 |
offLevel:aNumber |
1328 |
"set the level of the button when released (i.e. how deep). |
|
1329 |
Historic leftover; use #passiveLevel:." |
|
1330 |
||
1331 |
^ self passiveLevel:aNumber |
|
1332 |
! |
|
1333 |
||
1334 |
onLevel |
|
1335 |
"return the level of the button when pressed. |
|
1336 |
Historic leftover; use #activeLevel." |
|
1337 |
||
1338 |
^ onLevel |
|
1339 |
! |
|
1340 |
||
1341 |
onLevel:aNumber |
|
1342 |
"set the level of the button when pressed (i.e. how deep). |
|
1343 |
Historic leftover; use #activeLevel:." |
|
1344 |
||
1345 |
^ self activeLevel:aNumber |
|
1346 |
! |
|
1347 |
||
1348 |
passiveLevel |
|
1349 |
"return the level of the button when released" |
|
1350 |
||
1351 |
^ offLevel |
|
1352 |
! |
|
1353 |
||
1354 |
passiveLevel:aNumber |
|
1355 |
"set the level of the button when not pressed (i.e. how high)" |
|
118 | 1356 |
|
205 | 1357 |
offLevel := aNumber. |
1358 |
(controller notNil |
|
1359 |
and:[controller pressed not]) ifTrue:[ |
|
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1360 |
self level:offLevel. |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1361 |
margin := onLevel abs max:offLevel abs. |
992 | 1362 |
shown ifTrue:[ |
1363 |
self invalidate. |
|
1364 |
] |
|
205 | 1365 |
] |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1366 |
|
992 | 1367 |
"Modified: 8.2.1997 / 15:21:33 / cg" |
205 | 1368 |
! |
1369 |
||
1370 |
passiveLogo:anImageOrString |
|
1371 |
"define the logo to be displayed while inactive - |
|
1372 |
this is optional; the default is to display the same |
|
1373 |
(logo) in both pressed and released states." |
|
118 | 1374 |
|
205 | 1375 |
passiveLogo := anImageOrString. |
1376 |
controller pressed ifFalse:[ |
|
1377 |
self logo:anImageOrString |
|
1378 |
] |
|
1094 | 1379 |
! |
1380 |
||
1381 |
takeDefault |
|
1382 |
"ST-80 compatibility - set isReturnButton attribute" |
|
1383 |
||
1384 |
self isReturnButton:true |
|
1385 |
||
1386 |
"Created: 3.3.1997 / 16:20:52 / cg" |
|
1387 |
"Modified: 3.3.1997 / 18:11:58 / cg" |
|
205 | 1388 |
! ! |
1389 |
||
1390 |
!Button methodsFor:'changing state'! |
|
1391 |
||
1392 |
toggle |
|
1393 |
"toggle and perform the action" |
|
1394 |
||
1395 |
controller toggle |
|
1396 |
! |
|
1397 |
||
1398 |
toggleNoAction |
|
1399 |
"toggle, but do NOT perform any action - can be used to change a toggle |
|
1400 |
under program control (i.e. turn one toggle off from another one)" |
|
1401 |
||
1402 |
controller toggleNoAction |
|
118 | 1403 |
! |
1404 |
||
205 | 1405 |
turnOff |
1406 |
"turn the button off (if not already off) do NOT perform actions/change notifications" |
|
1407 |
||
328
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1408 |
(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
|
1409 |
offLevel ~~ level ifTrue:[ |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1410 |
self level:offLevel. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1411 |
]. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1412 |
(passiveLogo notNil and:[passiveLogo ~~ logo]) ifTrue:[ |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1413 |
self logo:passiveLogo |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1414 |
]. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1415 |
controller setPressed:false. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1416 |
controller active:false. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1417 |
level := offLevel. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1418 |
margin := level abs. |
992 | 1419 |
shown ifTrue:[ |
1420 |
self invalidate |
|
1421 |
] |
|
205 | 1422 |
] |
328
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1423 |
|
992 | 1424 |
"Modified: 8.2.1997 / 15:21:44 / cg" |
205 | 1425 |
! |
1426 |
||
1427 |
turnOffWithAction |
|
1428 |
"turn the button off (if not already off) and perform any action/change notification" |
|
118 | 1429 |
|
328
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1430 |
(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
|
1431 |
offLevel ~~ level ifTrue:[ |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1432 |
self level:offLevel. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1433 |
]. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1434 |
(passiveLogo notNil and:[passiveLogo ~~ logo]) ifTrue:[ |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1435 |
self logo:passiveLogo |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1436 |
]. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1437 |
self turnOffWithoutRedraw. |
992 | 1438 |
shown ifTrue:[ |
1439 |
self invalidate |
|
1440 |
] |
|
205 | 1441 |
] |
118 | 1442 |
|
205 | 1443 |
"Created: 15.11.1995 / 16:55:37 / cg" |
992 | 1444 |
"Modified: 8.2.1997 / 15:21:53 / cg" |
205 | 1445 |
! |
1446 |
||
1447 |
turnOffWithoutRedraw |
|
1448 |
"turn the button off - no redraw but perform any action/change notification" |
|
1449 |
||
328
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1450 |
controller notNil ifTrue:[ |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1451 |
controller pressed:false. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1452 |
controller active:false. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1453 |
]. |
205 | 1454 |
|
1455 |
"do not use super level:offLevel |
|
1456 |
- because that one does redraw the edges. |
|
1457 |
Sure, this is no good coding style" |
|
1458 |
||
1459 |
level := offLevel. |
|
1460 |
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
|
1461 |
|
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1462 |
"Modified: 8.2.1996 / 15:28:53 / cg" |
118 | 1463 |
! |
1464 |
||
205 | 1465 |
turnOn |
1466 |
"turn the button on (if not already on) - do NOT perform any action/notification" |
|
1467 |
||
328
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1468 |
(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
|
1469 |
onLevel ~~ level ifTrue:[ |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1470 |
self level:onLevel. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1471 |
]. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1472 |
(activeLogo notNil and:[activeLogo ~~ logo]) ifTrue:[ |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1473 |
self logo:activeLogo |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1474 |
]. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1475 |
controller setPressed:true. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1476 |
level := onLevel. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1477 |
margin := level abs. |
205 | 1478 |
|
992 | 1479 |
shown ifTrue:[ |
1480 |
self invalidate |
|
1481 |
] |
|
205 | 1482 |
] |
59 | 1483 |
|
205 | 1484 |
"Created: 14.11.1995 / 22:00:45 / cg" |
992 | 1485 |
"Modified: 8.2.1997 / 15:22:01 / cg" |
205 | 1486 |
! |
1487 |
||
1488 |
turnOnWithAction |
|
1489 |
"turn the button on (if not already on) and perform any change actions/notifications" |
|
118 | 1490 |
|
328
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1491 |
(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
|
1492 |
onLevel ~~ level ifTrue:[ |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1493 |
self level:onLevel. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1494 |
]. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1495 |
(activeLogo notNil and:[activeLogo ~~ logo]) ifTrue:[ |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1496 |
self logo:activeLogo |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1497 |
]. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1498 |
self turnOnWithoutRedraw. |
992 | 1499 |
shown ifTrue:[ |
1500 |
self invalidate |
|
1501 |
] |
|
205 | 1502 |
] |
1503 |
||
1504 |
"Created: 15.11.1995 / 16:55:56 / cg" |
|
992 | 1505 |
"Modified: 8.2.1997 / 15:22:09 / cg" |
118 | 1506 |
! |
1507 |
||
205 | 1508 |
turnOnWithoutRedraw |
1509 |
"turn the button on - no redraw but perform any change actions/notifications" |
|
1510 |
||
328
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1511 |
controller notNil ifTrue:[ |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1512 |
controller pressed:true. |
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1513 |
]. |
118 | 1514 |
|
205 | 1515 |
"do not use super level:offLevel |
1516 |
- because that one does redraw the edges. |
|
1517 |
Sure, this is no good coding style" |
|
1518 |
||
1519 |
level := onLevel. |
|
1520 |
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
|
1521 |
|
6c4daccc6fb5
check for nil controller (turnOn/Off might be called after destroy)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
1522 |
"Modified: 8.2.1996 / 15:29:23 / cg" |
205 | 1523 |
! ! |
1524 |
||
1525 |
!Button methodsFor:'focus change'! |
|
59 | 1526 |
|
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
|
1527 |
showFocus:explicit |
205 | 1528 |
focusLogo notNil ifTrue:[ |
1529 |
controller enabled ifTrue:[ |
|
1530 |
logo := focusLogo. |
|
1531 |
^ self redisplay |
|
1532 |
] |
|
1533 |
]. |
|
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
|
1534 |
super showFocus:explicit |
205 | 1535 |
|
1536 |
"Created: 17.9.1995 / 19:58:50 / claus" |
|
1537 |
! |
|
1538 |
||
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
|
1539 |
showNoFocus:explicit |
205 | 1540 |
focusLogo notNil ifTrue:[ |
1541 |
disabledLogo notNil ifTrue:[ |
|
1542 |
controller enabled ifTrue:[ |
|
1543 |
logo := passiveLogo. |
|
1544 |
] ifFalse:[ |
|
1545 |
logo := disabledLogo. |
|
1546 |
]. |
|
1547 |
] ifFalse:[ |
|
1548 |
logo := passiveLogo |
|
1549 |
]. |
|
1550 |
^ self redisplay |
|
1551 |
]. |
|
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
|
1552 |
super showNoFocus:explicit |
205 | 1553 |
|
1554 |
"Created: 17.9.1995 / 20:00:06 / claus" |
|
1555 |
"Modified: 17.9.1995 / 20:26:32 / claus" |
|
0 | 1556 |
! ! |
1557 |
||
1558 |
!Button methodsFor:'initialization'! |
|
1559 |
||
205 | 1560 |
defaultControllerClass |
1561 |
^ ButtonController |
|
1562 |
! |
|
1563 |
||
931 | 1564 |
fetchDeviceResources |
1565 |
"fetch device colors, to avoid reallocation at redraw time" |
|
1566 |
||
1567 |
super fetchDeviceResources. |
|
1568 |
||
1569 |
disabledFgColor notNil ifTrue:[disabledFgColor := disabledFgColor on:device]. |
|
1570 |
activeFgColor notNil ifTrue:[activeFgColor := activeFgColor on:device]. |
|
1571 |
activeBgColor notNil ifTrue:[activeBgColor := activeBgColor on:device]. |
|
1572 |
enteredFgColor notNil ifTrue:[enteredFgColor := enteredFgColor on:device]. |
|
1573 |
enteredBgColor notNil ifTrue:[enteredBgColor := enteredBgColor on:device]. |
|
1574 |
||
1575 |
formColor notNil ifTrue:[formColor := formColor on:device]. |
|
1576 |
formLightColor notNil ifTrue:[formLightColor := formLightColor on:device]. |
|
945 | 1577 |
formShadowColor notNil ifTrue:[formShadowColor := formShadowColor on:device]. |
931 | 1578 |
halfShadowColor notNil ifTrue:[halfShadowColor := halfShadowColor on:device]. |
1579 |
halfLightColor notNil ifTrue:[halfLightColor := halfLightColor on:device]. |
|
1580 |
||
945 | 1581 |
"Modified: 15.2.1997 / 17:14:16 / cg" |
931 | 1582 |
! |
1583 |
||
205 | 1584 |
initCursor |
1585 |
"set up a hand cursor" |
|
0 | 1586 |
|
205 | 1587 |
cursor := Cursor hand |
1588 |
! |
|
1589 |
||
1590 |
initEvents |
|
1591 |
super initEvents. |
|
1592 |
self enableEnterLeaveEvents |
|
0 | 1593 |
! |
1594 |
||
1595 |
initStyle |
|
959 | 1596 |
"setup viewStyle specifics" |
1597 |
||
761 | 1598 |
<resource: #style (#name)> |
1599 |
||
59 | 1600 |
|hasGreyscales nm| |
1601 |
||
1602 |
super initStyle. |
|
1603 |
||
392
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
1604 |
"/ DefaultFont notNil ifTrue:[font := DefaultFont on:device]. |
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
1605 |
|
74 | 1606 |
DefaultBorderWidth notNil ifTrue:[borderWidth := DefaultBorderWidth]. |
934 | 1607 |
DefaultForegroundColor notNil ifTrue:[fgColor := DefaultForegroundColor]. |
1608 |
DefaultBackgroundColor notNil ifTrue:[bgColor := DefaultBackgroundColor]. |
|
59 | 1609 |
|
62 | 1610 |
edgeStyle := DefaultEdgeStyle. |
59 | 1611 |
onLevel := DefaultActiveLevel. |
1612 |
offLevel := DefaultPassiveLevel. |
|
1613 |
||
1614 |
DefaultDisabledForegroundColor notNil ifTrue:[ |
|
934 | 1615 |
disabledFgColor := DefaultDisabledForegroundColor |
59 | 1616 |
] ifFalse:[ |
705 | 1617 |
disabledFgColor := fgColor |
59 | 1618 |
]. |
1619 |
||
934 | 1620 |
DefaultEnteredForegroundColor notNil ifTrue:[enteredFgColor := DefaultEnteredForegroundColor]. |
1621 |
DefaultEnteredBackgroundColor notNil ifTrue:[enteredBgColor := DefaultEnteredBackgroundColor]. |
|
1622 |
DefaultActiveForegroundColor notNil ifTrue:[activeFgColor := DefaultActiveForegroundColor]. |
|
1623 |
DefaultActiveBackgroundColor notNil ifTrue:[activeBgColor := DefaultActiveBackgroundColor]. |
|
59 | 1624 |
|
934 | 1625 |
DefaultShadowColor notNil ifTrue:[shadowColor := DefaultShadowColor]. |
1626 |
DefaultLightColor notNil ifTrue:[lightColor := DefaultLightColor]. |
|
59 | 1627 |
|
62 | 1628 |
shadowColor isNil ifTrue:[ |
705 | 1629 |
shadowColor := Black. |
62 | 1630 |
]. |
1631 |
lightColor isNil ifTrue:[ |
|
705 | 1632 |
lightColor := White. |
62 | 1633 |
]. |
59 | 1634 |
|
707 | 1635 |
hasGreyscales := device hasGrayscales. |
62 | 1636 |
(edgeStyle == #soft) ifTrue:[ |
934 | 1637 |
DefaultHalfShadowColor notNil ifTrue:[halfShadowColor := DefaultHalfShadowColor]. |
1638 |
DefaultHalfLightColor notNil ifTrue:[halfLightColor := DefaultHalfLightColor]. |
|
62 | 1639 |
|
705 | 1640 |
halfShadowColor isNil ifTrue:[ |
62 | 1641 |
"/ hasGreyscales ifTrue:[ |
1642 |
"/ halfShadowColor := Color darkGrey |
|
1643 |
"/ ] ifFalse:[ |
|
1644 |
"/ halfShadowColor := shadowColor |
|
1645 |
"/ ] |
|
705 | 1646 |
halfShadowColor := shadowColor lightened |
1647 |
] |
|
59 | 1648 |
]. |
1649 |
||
62 | 1650 |
" |
1651 |
actually, the stuf below should not be needed |
|
1652 |
- the styleSheet should provide values for nonGreyscale displays too |
|
1653 |
" |
|
130 | 1654 |
nm := styleSheet name. |
62 | 1655 |
(nm == #iris) ifTrue:[ |
705 | 1656 |
hasGreyscales ifTrue:[ |
1657 |
DefaultEnteredBackgroundColor isNil ifTrue:[ |
|
1658 |
enteredBgColor := bgColor lightened "Color lightGray". |
|
1659 |
]. |
|
1660 |
DefaultActiveBackgroundColor isNil ifTrue:[ |
|
1661 |
activeBgColor := enteredBgColor. |
|
1662 |
]. |
|
1663 |
DefaultActiveForegroundColor isNil ifTrue:[ |
|
1664 |
activeFgColor := enteredFgColor. |
|
1665 |
]. |
|
1666 |
] ifFalse:[ |
|
1667 |
DefaultEnteredBackgroundColor isNil ifTrue:[ |
|
1668 |
enteredBgColor := Color veryLightGray. |
|
1669 |
]. |
|
1670 |
DefaultActiveBackgroundColor isNil ifTrue:[ |
|
1671 |
activeBgColor := Black. |
|
1672 |
]. |
|
1673 |
DefaultActiveForegroundColor isNil ifTrue:[ |
|
1674 |
activeFgColor := White. |
|
1675 |
]. |
|
1676 |
]. |
|
62 | 1677 |
] ifFalse:[ |
705 | 1678 |
nm == #motif ifTrue:[ |
1679 |
lightColor isNil ifTrue:[ |
|
1680 |
lightColor := bgColor lightened |
|
1681 |
]. |
|
62 | 1682 |
"/ hasGreyscales ifTrue:[ |
1683 |
"/ lightColor := Color lightGrey |
|
1684 |
"/ ] |
|
705 | 1685 |
] ifFalse:[ |
1686 |
nm == #st80 ifTrue:[ |
|
1687 |
hasGreyscales ifTrue:[ |
|
1688 |
DefaultActiveForegroundColor isNil ifTrue:[ |
|
1689 |
activeFgColor := fgColor. |
|
1690 |
]. |
|
1691 |
DefaultActiveBackgroundColor isNil ifTrue:[ |
|
1692 |
activeBgColor := bgColor darkened. |
|
1693 |
]. |
|
1694 |
] ifFalse:[ |
|
1695 |
DefaultActiveForegroundColor isNil ifTrue:[ |
|
1696 |
activeFgColor := White. |
|
1697 |
]. |
|
1698 |
DefaultActiveBackgroundColor isNil ifTrue:[ |
|
1699 |
activeBgColor := Black |
|
1700 |
] |
|
1701 |
] |
|
1702 |
] |
|
1703 |
] |
|
59 | 1704 |
]. |
1705 |
||
1706 |
offLevel ~~ level ifTrue:[ |
|
705 | 1707 |
self level:offLevel. |
1708 |
margin := (onLevel abs) max:(offLevel abs). |
|
59 | 1709 |
]. |
1710 |
||
1711 |
DefaultReturnButtonHasImage ifTrue:[ |
|
705 | 1712 |
(styleSheet is3D and:[hasGreyscales]) ifTrue:[ |
1713 |
shadowForm := self class returnShadowFormOn:device. |
|
1714 |
lightForm := self class returnLightFormOn:device. |
|
1715 |
formColor := viewBackground. |
|
1716 |
formShadowColor := shadowColor. |
|
1717 |
formLightColor := lightColor |
|
1718 |
] ifFalse:[ |
|
1719 |
shadowForm := self class returnFormOn:device. |
|
1720 |
formColor := Black |
|
1721 |
]. |
|
59 | 1722 |
]. |
705 | 1723 |
|
959 | 1724 |
"Modified: 17.1.1997 / 23:15:57 / cg" |
59 | 1725 |
! |
1726 |
||
205 | 1727 |
initialize |
1728 |
super initialize. |
|
0 | 1729 |
|
1051 | 1730 |
isReturnButton := defaultable := false. |
0 | 1731 |
! |
1732 |
||
1733 |
realize |
|
1734 |
super realize. |
|
118 | 1735 |
|
77 | 1736 |
controller active:false. |
1737 |
controller entered:false. |
|
0 | 1738 |
|
931 | 1739 |
"Modified: 13.1.1997 / 21:56:58 / cg" |
0 | 1740 |
! |
1741 |
||
1742 |
reinitialize |
|
1743 |
super reinitialize. |
|
77 | 1744 |
controller notNil ifTrue:[ |
1745 |
controller active:false. |
|
1746 |
controller entered:false. |
|
1747 |
] |
|
205 | 1748 |
! ! |
1749 |
||
1750 |
!Button methodsFor:'private'! |
|
1751 |
||
1752 |
computeLabelOrigin |
|
1753 |
"compute the origin of the text - if I am a returnButton, |
|
1754 |
shift it somwehat to the right (we have already allocated the |
|
1755 |
real estate, since computeLabelSize returned some extra space |
|
1756 |
before)." |
|
1757 |
||
1758 |
super computeLabelOrigin. |
|
1093
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
1759 |
shadowForm notNil ifTrue:[ |
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
1760 |
isReturnButton ifTrue:[ |
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
1761 |
labelOriginX := labelOriginX + hSpace + hSpace. |
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
1762 |
]. |
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
1763 |
|
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
1764 |
defaultable ifTrue:[ |
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
1765 |
labelOriginX < margin ifTrue:[ |
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
1766 |
labelOriginX := margin |
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
1767 |
] |
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
1768 |
] |
205 | 1769 |
] |
1093
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
1770 |
|
cb7b2c99f5cc
care for defaultable labels which fit while
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
1771 |
"Modified: 3.3.1997 / 15:56:05 / cg" |
205 | 1772 |
! |
1773 |
||
1774 |
computeLabelSize |
|
1051 | 1775 |
"compute the extent needed to hold the label (plus the return form)" |
205 | 1776 |
|
1777 |
super computeLabelSize. |
|
1051 | 1778 |
((isReturnButton or:[defaultable]) and:[shadowForm notNil]) ifTrue:[ |
205 | 1779 |
labelWidth := labelWidth + (hSpace * 2) + shadowForm width. |
1780 |
labelHeight := labelHeight max: (shadowForm height + vSpace) |
|
1781 |
] |
|
0 | 1782 |
! ! |
1783 |
||
62 | 1784 |
!Button methodsFor:'queries'! |
0 | 1785 |
|
1786 |
is3D |
|
850 | 1787 |
"return true, if the receiver is a 3D style view" |
761 | 1788 |
|
850 | 1789 |
<resource: #style (#name)> |
0 | 1790 |
|
130 | 1791 |
styleSheet name == #mswindows ifTrue:[^ true]. |
0 | 1792 |
^ super is3D |
761 | 1793 |
|
850 | 1794 |
"Modified: 22.10.1996 / 18:26:41 / cg" |
0 | 1795 |
! |
1796 |
||
127 | 1797 |
isOn |
1798 |
"return true, if this button is currently pressed" |
|
1799 |
||
1800 |
^ controller pressed |
|
155 | 1801 |
! |
1802 |
||
205 | 1803 |
isReturnButton |
1804 |
"return true, if this is a return button" |
|
0 | 1805 |
|
205 | 1806 |
^ isReturnButton |
156 | 1807 |
! |
1808 |
||
130 | 1809 |
preferredExtent |
1810 |
"return my preferred extent - this is the minimum size I would like to have" |
|
35 | 1811 |
|
1021
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1812 |
|extraH extraV oldLogo wActive hActive wPassive hPassive |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1813 |
wMax hMax anyLogo| |
35 | 1814 |
|
800 | 1815 |
"/ If I have an explicit preferredExtent .. |
1816 |
||
713
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
1817 |
preferredExtent notNil ifTrue:[ |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
1818 |
^ preferredExtent |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
1819 |
]. |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
1820 |
|
1021
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1821 |
"/ compute the max-extent of both passive- and activeLogos |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1822 |
"/ (if any) |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1823 |
|
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1824 |
wActive := wPassive := labelWidth. |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1825 |
hActive := hPassive := labelHeight. |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1826 |
oldLogo := logo. |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1827 |
anyLogo := false. |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1828 |
|
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1829 |
(activeLogo notNil and:[activeLogo ~~ logo]) ifTrue:[ |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1830 |
logo := activeLogo. |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1831 |
self computeLabelSize. |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1832 |
wActive := labelWidth. |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1833 |
hActive := labelHeight. |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1834 |
anyLogo := true. |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1835 |
]. |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1836 |
(passiveLogo notNil and:[passiveLogo ~~ logo]) ifTrue:[ |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1837 |
logo := passiveLogo. |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1838 |
self computeLabelSize. |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1839 |
wPassive := labelWidth. |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1840 |
hPassive := labelHeight. |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1841 |
anyLogo := true. |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1842 |
]. |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1843 |
oldLogo ~~ logo ifTrue:[ |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1844 |
logo := oldLogo. |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1845 |
self computeLabelSize. |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1846 |
]. |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1847 |
|
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1848 |
wMax := wActive max:wPassive. |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1849 |
hMax := hActive max:hPassive. |
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1850 |
|
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1851 |
anyLogo ifTrue:[ |
131 | 1852 |
" |
713
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
1853 |
extraH := extraV := (onLevel abs max:offLevel abs) + ViewSpacing * 2. |
131 | 1854 |
" |
713
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
1855 |
extraH := extraV := (onLevel abs max:offLevel abs). |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
1856 |
extraH := (extraH + hSpace * 2). |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
1857 |
extraV := (extraV + vSpace * 2). |
131 | 1858 |
|
713
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
1859 |
self is3D ifFalse:[ |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
1860 |
"add space for a frame around" |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
1861 |
extraH := extraH + 2. extraV := extraV + 2. |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
1862 |
]. |
1021
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1863 |
|
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1864 |
^ (wMax + extraH) @ (hMax + extraV) |
35 | 1865 |
]. |
1866 |
||
130 | 1867 |
^ super preferredExtent |
713
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
1868 |
|
1021
73ec8663c4cb
care for BOTH active- and passive logos,
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
1869 |
"Modified: 18.2.1997 / 13:22:52 / cg" |
0 | 1870 |
! |
1871 |
||
205 | 1872 |
specClass |
1873 |
self class == Button ifTrue:[^ ActionButtonSpec]. |
|
1050 | 1874 |
^ super specClass |
1875 |
||
1876 |
"Modified: 25.2.1997 / 14:58:07 / cg" |
|
162 | 1877 |
! ! |
1878 |
||
0 | 1879 |
!Button methodsFor:'redrawing'! |
1880 |
||
205 | 1881 |
drawBottomEdge |
1882 |
"draw bottom 3D edge into window frame" |
|
1883 |
||
1884 |
self drawBottomEdgeLevel:level |
|
1885 |
shadow:shadowColor |
|
1886 |
light:lightColor |
|
1887 |
halfShadow:halfShadowColor |
|
1888 |
halfLight:halfLightColor |
|
1889 |
style:edgeStyle. |
|
133 | 1890 |
! |
1891 |
||
62 | 1892 |
drawEdges |
1893 |
"draw all of my 3D edges" |
|
1894 |
||
1895 |
self drawEdgesForX:0 y:0 width:width height:height level:level |
|
1896 |
shadow:shadowColor |
|
1897 |
light:lightColor |
|
1898 |
halfShadow:halfShadowColor |
|
1899 |
halfLight:halfLightColor |
|
1900 |
style:edgeStyle |
|
1901 |
! |
|
1902 |
||
1903 |
drawLeftEdge |
|
1904 |
"draw left 3D edge into window frame" |
|
1905 |
||
1906 |
self drawLeftEdgeLevel:level |
|
1907 |
shadow:shadowColor |
|
1908 |
light:lightColor |
|
1909 |
halfShadow:halfShadowColor |
|
1910 |
halfLight:halfLightColor |
|
1911 |
style:edgeStyle. |
|
1912 |
! |
|
1913 |
||
1914 |
drawRightEdge |
|
1915 |
"draw right 3D edge into window frame" |
|
1916 |
||
1917 |
self drawRightEdgeLevel:level |
|
1918 |
shadow:shadowColor |
|
1919 |
light:lightColor |
|
1920 |
halfShadow:halfShadowColor |
|
1921 |
halfLight:halfLightColor |
|
1922 |
style:edgeStyle. |
|
1923 |
! |
|
1924 |
||
1925 |
drawTopEdge |
|
1926 |
"draw top 3D edge into window frame" |
|
1927 |
||
1928 |
self drawTopEdgeLevel:level |
|
1929 |
shadow:shadowColor |
|
1930 |
light:lightColor |
|
1931 |
halfShadow:halfShadowColor |
|
1932 |
halfLight:halfLightColor |
|
1933 |
style:edgeStyle. |
|
1934 |
! |
|
1935 |
||
0 | 1936 |
drawWith:fg and:bg |
1937 |
"redraw myself with fg/bg. Use super to draw the label, add |
|
1938 |
the return-arrow here." |
|
1939 |
||
18 | 1940 |
|x y sColor lColor| |
0 | 1941 |
|
59 | 1942 |
shown ifFalse:[^ self]. |
0 | 1943 |
super drawWith:fg and:bg. "this draws the text" |
1944 |
||
59 | 1945 |
(isReturnButton and:[shadowForm notNil]) ifTrue:[ |
932
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1946 |
y := (height - shadowForm height) // 2. |
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1947 |
x := width - shadowForm width - (hSpace // 2). |
59 | 1948 |
|
932
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1949 |
formShadowColor isNil ifTrue:[ |
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1950 |
self paint:fg on:bg. |
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1951 |
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
|
1952 |
^ self |
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1953 |
]. |
0 | 1954 |
|
932
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1955 |
" |
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1956 |
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
|
1957 |
" |
955 | 1958 |
(formShadowColor isColor and:[formShadowColor isDithered not |
1959 |
and:[formLightColor isColor and:[formLightColor isDithered not |
|
1960 |
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
|
1961 |
ifTrue:[ |
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1962 |
sColor := formShadowColor. |
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1963 |
lColor := formLightColor. |
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1964 |
] ifFalse:[ |
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1965 |
sColor := device blackColor. |
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1966 |
lColor := device whiteColor. |
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1967 |
]. |
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1968 |
self foreground:sColor. |
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1969 |
self displayForm:shadowForm x:x y:y. |
35 | 1970 |
|
932
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1971 |
lightForm notNil ifTrue:[ |
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1972 |
self foreground:lColor. |
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1973 |
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
|
1974 |
]. |
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1975 |
self paint:fg. |
0 | 1976 |
] |
932
43879de4e75d
use devices black/whiteColor instead of Black/White
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1977 |
|
955 | 1978 |
"Modified: 16.1.1997 / 23:57:42 / cg" |
0 | 1979 |
! |
1980 |
||
133 | 1981 |
redisplay |
82 | 1982 |
"redraw the button. |
1983 |
Thats like redrawing a label, but use different colors when pressed |
|
1984 |
or entered." |
|
0 | 1985 |
|
229 | 1986 |
|fg bg entered noFrame| |
0 | 1987 |
|
62 | 1988 |
shown ifFalse:[^ self]. |
35 | 1989 |
|
1092 | 1990 |
disabledLogo notNil ifTrue:[ |
1991 |
controller enabled ifFalse:[ |
|
1992 |
logo := disabledLogo. |
|
1993 |
] ifTrue:[ |
|
1994 |
controller active ifTrue:[ |
|
1995 |
logo := activeLogo |
|
1996 |
] ifFalse:[ |
|
1997 |
logo := passiveLogo |
|
1998 |
]. |
|
1999 |
]. |
|
2000 |
]. |
|
2001 |
||
265 | 2002 |
noFrame := true. |
62 | 2003 |
fg := fgColor. |
2004 |
bg := bgColor. |
|
77 | 2005 |
controller enabled ifFalse:[ |
1092 | 2006 |
fg := disabledFgColor |
62 | 2007 |
] ifTrue:[ |
1092 | 2008 |
entered := controller entered. |
2009 |
entered ifTrue:[ |
|
2010 |
enteredFgColor notNil ifTrue:[fg := enteredFgColor]. |
|
2011 |
enteredBgColor notNil ifTrue:[bg := enteredBgColor] |
|
2012 |
]. |
|
2013 |
(controller pressed and:[entered or:[controller isTriggerOnDown]]) ifTrue:[ |
|
2014 |
noFrame := false. |
|
2015 |
activeFgColor isNil ifTrue:[ |
|
2016 |
onLevel == offLevel ifTrue:[ |
|
2017 |
fg := bgColor |
|
2018 |
] |
|
2019 |
] ifFalse:[ |
|
2020 |
fg := activeFgColor. |
|
2021 |
]. |
|
2022 |
activeBgColor isNil ifTrue:[ |
|
2023 |
onLevel == offLevel ifTrue:[ |
|
2024 |
bg := fgColor |
|
2025 |
] |
|
2026 |
] ifFalse:[ |
|
2027 |
bg := activeBgColor |
|
2028 |
]. |
|
232 | 2029 |
|
1092 | 2030 |
self is3D ifFalse:[ |
2031 |
noFrame := (fgColor = fg) and:[bgColor = bg]. |
|
2032 |
]. |
|
2033 |
]. |
|
62 | 2034 |
]. |
265 | 2035 |
self drawWith:fg and:bg. |
2036 |
noFrame ifFalse:[ |
|
1092 | 2037 |
" |
2038 |
draw a rectangle around (2D styles only) |
|
2039 |
" |
|
2040 |
self paint:fg. |
|
2041 |
self displayRectangleX:0 y:0 width:width height:height. |
|
2042 |
^ self |
|
265 | 2043 |
]. |
2044 |
||
1092 | 2045 |
"Modified: 3.3.1997 / 11:01:21 / cg" |
162 | 2046 |
! |
2047 |
||
205 | 2048 |
redraw |
2049 |
"redraw the button. but not if currently active" |
|
2050 |
||
2051 |
shown ifFalse:[^ self]. |
|
2052 |
"/ controller active ifTrue:[^ self]. - disabled; otherwise, we do not redreaw if changed from within action procedure |
|
2053 |
self redisplay. |
|
2054 |
! |
|
2055 |
||
2056 |
redrawIfPressed |
|
2057 |
"redraw the button, but only if visible and currently being pressed" |
|
2058 |
||
2059 |
shown ifTrue:[ |
|
2060 |
controller pressed ifTrue:[ |
|
2061 |
self redisplay |
|
2062 |
] |
|
2063 |
] |
|
2064 |
! |
|
2065 |
||
2066 |
redrawX:x y:y width:w height:h |
|
2067 |
self redisplay. |
|
2068 |
! |
|
2069 |
||
2070 |
showActive |
|
2071 |
"redraw myself as active (i.e. busy)" |
|
162 | 2072 |
|
205 | 2073 |
onLevel ~~ level ifTrue:[ |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
2074 |
self level:onLevel. |
205 | 2075 |
]. |
2076 |
(activeLogo notNil and:[activeLogo ~~ logo]) ifTrue:[ |
|
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
2077 |
self logo:activeLogo |
162 | 2078 |
]. |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
2079 |
self invalidate |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
2080 |
|
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
2081 |
"Modified: 26.5.1996 / 18:08:52 / cg" |
205 | 2082 |
! |
2083 |
||
2084 |
showPassive |
|
2085 |
"redraw myself as passive" |
|
162 | 2086 |
|
205 | 2087 |
offLevel ~~ level ifTrue:[ |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
2088 |
self level:offLevel. |
205 | 2089 |
]. |
2090 |
(passiveLogo notNil and:[passiveLogo ~~ logo]) ifTrue:[ |
|
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
2091 |
self logo:passiveLogo |
205 | 2092 |
]. |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
2093 |
self invalidate. |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
2094 |
|
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
2095 |
"Modified: 26.5.1996 / 18:08:56 / cg" |
0 | 2096 |
! ! |
205 | 2097 |
|
850 | 2098 |
!Button class methodsFor:'documentation'! |
205 | 2099 |
|
2100 |
version |
|
1153 | 2101 |
^ '$Header: /cvs/stx/stx/libwidg/Button.st,v 1.82 1997-03-22 15:36:50 cg Exp $' |
205 | 2102 |
! ! |