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