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