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