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