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