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