author | ca |
Tue, 17 Dec 2019 16:40:54 +0100 | |
branch | jv |
changeset 6787 | 51fbee1169fc |
parent 6085 | 4ecbe3a93aec |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
59 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
2192
e9068416fd41
foreground-, backgroundChannel moved to superclass (#destroy)
Stefan Vogel <sv@exept.de>
parents:
2098
diff
changeset
|
12 |
"{ Package: 'stx:libwidg' }" |
e9068416fd41
foreground-, backgroundChannel moved to superclass (#destroy)
Stefan Vogel <sv@exept.de>
parents:
2098
diff
changeset
|
13 |
|
5445 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
0 | 16 |
View subclass:#Label |
254
aa15cac0670f
oops - foregroundColor was overwritten by backgroundColor (if defined in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
250
diff
changeset
|
17 |
instanceVariableNames:'logo labelWidth labelHeight labelOriginX labelOriginY adjust |
2496 | 18 |
hSpace vSpace bgColor fgColor etchedFgColor fixSize labelMsg |
19 |
converter labelChannel' |
|
392
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
20 |
classVariableNames:'DefaultForegroundColor DefaultBackgroundColor' |
254
aa15cac0670f
oops - foregroundColor was overwritten by backgroundColor (if defined in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
250
diff
changeset
|
21 |
poolDictionaries:'' |
aa15cac0670f
oops - foregroundColor was overwritten by backgroundColor (if defined in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
250
diff
changeset
|
22 |
category:'Views-Layout' |
0 | 23 |
! |
24 |
||
5751 | 25 |
Object subclass:#AnimatorState |
5755 | 26 |
instanceVariableNames:'timedBlock nextOffset logoShown moveDirection pointerEntered' |
5751 | 27 |
classVariableNames:'' |
28 |
poolDictionaries:'' |
|
29 |
privateIn:Label |
|
30 |
! |
|
31 |
||
935 | 32 |
!Label class methodsFor:'documentation'! |
3 | 33 |
|
38 | 34 |
copyright |
35 |
" |
|
36 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
59 | 37 |
All Rights Reserved |
38 | 38 |
|
39 |
This software is furnished under a license and may be used |
|
40 |
only in accordance with the terms of that license and with the |
|
41 |
inclusion of the above copyright notice. This software may not |
|
42 |
be provided or otherwise made available to, or used by, any |
|
43 |
other person. No title to or ownership of the software is |
|
44 |
hereby transferred. |
|
45 |
" |
|
46 |
! |
|
47 |
||
3 | 48 |
documentation |
49 |
" |
|
38 | 50 |
This class implements labels, which are views to display a string or image. |
51 |
The Label will try to do its best to make its contents fit into the |
|
52 |
view. The contents can be a String, a collection of Strings (i.e. |
|
118 | 53 |
a StringCollection) or a Form/Image. |
63 | 54 |
|
55 |
The contents is drawn in fgColor/bgColor, which can be changed using: |
|
56 |
||
585 | 57 |
aLabel foregroundColor:aColor |
58 |
aLabel backgroundColor:aColor |
|
3 | 59 |
|
38 | 60 |
When a label is assigned a contents, it will resize itself to fit |
61 |
the required size. This resizing can be suppressed by setting the |
|
62 |
fixsize attribute to true using: |
|
63 | 63 |
|
585 | 64 |
aLabel sizeFixed:true |
3 | 65 |
|
38 | 66 |
This can be used, if resizing of the label is not wanted. |
63 | 67 |
However, in this case you have to make certain that the size is big enough |
118 | 68 |
to hold any changed logos later. (usually, you create the label first with |
69 |
the longest string first to have it compute its size, then set the fixSize |
|
70 |
attribute to avoid resizing later). |
|
125 | 71 |
Be careful when placing self-resizing labels into panels - by default, |
72 |
panels do not react on the size change - leading to ugly looking geometry. |
|
73 |
(but you can tell the panel to watch for changes with #elementsCHangeSize:) |
|
38 | 74 |
|
75 |
The placement of the contents within the label is controlled by |
|
63 | 76 |
the adjust attribute, it can be set with: |
77 |
||
585 | 78 |
aLabel adjust:how |
3 | 79 |
|
1946 | 80 |
where how is one of the symbols left, #right, #center, #centerEach, |
81 |
#centerLeft, #centerRight, #leftRight or #rightLeft |
|
82 |
(see the comment in Label>>adjust:). The default is #center. |
|
3 | 83 |
|
145 | 84 |
model-less operation (ok for static labels): |
118 | 85 |
if no model is set, the labels contents is set with: |
86 |
||
585 | 87 |
aLabel label:aStringOrImage |
118 | 88 |
|
89 |
and stays constant unless changed by new calls to #label:. |
|
90 |
||
91 |
||
145 | 92 |
model operation (ST-80 style): |
118 | 93 |
labels with a model, aspectMsg and labelMsg react to |
94 |
changes of the aspect, and send a labelMsg-message |
|
5782 | 95 |
to the model in order to acquire a new labelString or image. |
118 | 96 |
The model should send 'self changed:aspectMsg' if it thinks the label |
97 |
should change and return a string or image from the labelMsg-message. |
|
98 |
||
585 | 99 |
label model:aModel. |
100 |
label aspect:aspectSymbol. |
|
101 |
label labelMessage:labelSymbol. |
|
118 | 102 |
|
585 | 103 |
model sends #changed:aspectSymbol |
104 |
---> label will redraw its label from value of model perform:labelSymbol |
|
118 | 105 |
|
106 |
Having a labelSymbol different from the aspectSymbol allows for two labels |
|
107 |
to react on the same aspect-change, but use different messages when asking |
|
108 |
the model for a new label contents. By default, the labelMsg is nil, |
|
109 |
so the label does NOT update its shown contents. |
|
110 |
The aspectMsg defaults to #value. |
|
111 |
||
125 | 112 |
|
145 | 113 |
|
114 |
channel operation (new ST/X style): |
|
115 |
||
116 |
the label will react on changes of the token found in the |
|
117 |
channels: foregroundChannel, backgroundChannel and labelChannel. |
|
118 |
These are valueHolders and can be shared between labels. |
|
119 |
||
120 |
||
121 |
||
585 | 122 |
[Instance variables:] |
3 | 123 |
|
585 | 124 |
logo <Object> the logo, can be a Form, String or Text |
125 |
labelWidth <Integer> the width of the logo in device units |
|
126 |
labelHeight <Integer> the height of the logo in device units |
|
127 |
labelOriginX <Integer> the x-position of the logo withing the Label |
|
128 |
labelOriginY <Integer> the y-position of the logo withing the Label |
|
129 |
adjust <Symbol> controls how the logo is positioned within the |
|
130 |
label. Can be one of:#left,#right,#center, |
|
131 |
#centerLeft or #centerRight (see comment in adjust:) |
|
132 |
hSpace <Integer> number of horizontal pixels around logo |
|
133 |
vSpace <Integer> number of vertical pixels around logo |
|
3 | 134 |
|
585 | 135 |
bgColor <Color> background color |
136 |
fgColor <Color> foreground color |
|
38 | 137 |
|
585 | 138 |
fixSize <Boolean> if true, a change of the logo change will not |
139 |
resize the label; otherwise, its size is adjusted. |
|
140 |
default:false. |
|
50 | 141 |
|
585 | 142 |
labelMsg <Symbol> if non-nil, this is sent to the model to |
5782 | 143 |
acquire the labelString or labelImage. |
585 | 144 |
If nil, the label stays as is |
113 | 145 |
|
585 | 146 |
[styleSheet parameters:] |
50 | 147 |
|
118 | 148 |
labelForegroundColor <Color> color to draw foreground pixels (i.e. the string) |
149 |
labelBackgroundColor <Color> color to draw background pixels |
|
150 |
labelFont <Font> font to use for textual labels |
|
585 | 151 |
|
152 |
[author:] |
|
153 |
Claus Gittinger |
|
593 | 154 |
|
155 |
[see also:] |
|
156 |
Panel HorizontalPanel VerticalPanel |
|
157 |
TextView EditTextView |
|
158 |
Button |
|
159 |
InfoBox WarningBox |
|
3 | 160 |
" |
63 | 161 |
! |
162 |
||
163 |
examples |
|
164 |
" |
|
165 |
Notice, that Buttons and others inherit from Label; |
|
166 |
therefore, the following geometry examples apply to all subclasses too. |
|
167 |
||
168 |
||
113 | 169 |
simple (default position is 0@0): |
593 | 170 |
[exBegin] |
171 |
|top l| |
|
63 | 172 |
|
593 | 173 |
top := StandardSystemView new. |
174 |
top extent:(200 @ 200). |
|
63 | 175 |
|
593 | 176 |
l := Label in:top. |
177 |
l label:'hello world'. |
|
63 | 178 |
|
593 | 179 |
top open |
180 |
[exEnd] |
|
63 | 181 |
|
113 | 182 |
|
626 | 183 |
simple with emphasis: |
184 |
[exBegin] |
|
185 |
|top l| |
|
186 |
||
187 |
top := StandardSystemView new. |
|
188 |
top extent:(300 @ 100). |
|
189 |
||
190 |
l := Label in:top. |
|
191 |
l level:-1. |
|
192 |
l label:('hello world - this is text in a label ' asText |
|
193 |
emphasizeFrom:7 to:11 with:#italic; |
|
194 |
emphasizeFrom:23 to:26 with:#bold). |
|
195 |
top open |
|
196 |
[exEnd] |
|
197 |
||
198 |
||
113 | 199 |
there is also a creation message which sets the label: |
593 | 200 |
[exBegin] |
201 |
|top l| |
|
113 | 202 |
|
593 | 203 |
top := StandardSystemView new. |
204 |
top extent:(200 @ 200). |
|
113 | 205 |
|
593 | 206 |
l := Label label:'hello world' in:top. |
113 | 207 |
|
593 | 208 |
top open |
209 |
[exEnd] |
|
113 | 210 |
|
211 |
||
63 | 212 |
placement: |
593 | 213 |
[exBegin] |
214 |
|top l| |
|
63 | 215 |
|
593 | 216 |
top := StandardSystemView new. |
217 |
top extent:(200 @ 200). |
|
63 | 218 |
|
593 | 219 |
l := Label in:top. |
220 |
l label:'hello world'. |
|
221 |
l origin:50@100. |
|
63 | 222 |
|
593 | 223 |
top open |
224 |
[exEnd] |
|
63 | 225 |
|
113 | 226 |
|
63 | 227 |
level: |
593 | 228 |
[exBegin] |
229 |
|top l| |
|
63 | 230 |
|
593 | 231 |
top := StandardSystemView new. |
232 |
top extent:(200 @ 200). |
|
63 | 233 |
|
593 | 234 |
l := Label in:top. |
235 |
l level:5. |
|
236 |
l label:'hello world'. |
|
237 |
l origin:50@100. |
|
63 | 238 |
|
593 | 239 |
top open |
240 |
[exEnd] |
|
63 | 241 |
|
113 | 242 |
|
63 | 243 |
another level: |
593 | 244 |
[exBegin] |
245 |
|top l| |
|
63 | 246 |
|
593 | 247 |
top := StandardSystemView new. |
248 |
top extent:(200 @ 200). |
|
63 | 249 |
|
593 | 250 |
l := Label in:top. |
251 |
l level:-1. |
|
252 |
l label:'hello world'. |
|
253 |
l origin:50@100. |
|
63 | 254 |
|
593 | 255 |
top open |
256 |
[exEnd] |
|
63 | 257 |
|
113 | 258 |
|
118 | 259 |
colors & font: |
593 | 260 |
[exBegin] |
261 |
|top l| |
|
118 | 262 |
|
593 | 263 |
top := StandardSystemView new. |
264 |
top extent:(200 @ 200). |
|
118 | 265 |
|
593 | 266 |
l := Label in:top. |
267 |
l level:-1. |
|
268 |
l font:(Font family:'Times' size:18). |
|
269 |
l foregroundColor:Color yellow. |
|
270 |
l backgroundColor:Color red. |
|
271 |
l label:'hello world'. |
|
272 |
l origin:50@100. |
|
118 | 273 |
|
593 | 274 |
top open |
275 |
[exEnd] |
|
118 | 276 |
|
277 |
||
63 | 278 |
border & colors: |
593 | 279 |
[exBegin] |
280 |
|top l| |
|
63 | 281 |
|
593 | 282 |
top := StandardSystemView new. |
283 |
top extent:(200 @ 200). |
|
63 | 284 |
|
593 | 285 |
l := Label in:top. |
286 |
l level:0. |
|
287 |
l borderWidth:1. |
|
288 |
l borderColor:Color red. |
|
289 |
l foregroundColor:Color green darkened. |
|
290 |
l backgroundColor:Color green lightened. |
|
291 |
l label:'hello world'. |
|
292 |
l origin:50@100. |
|
63 | 293 |
|
593 | 294 |
top open |
295 |
[exEnd] |
|
63 | 296 |
|
113 | 297 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
298 |
different adjusts (resize to see): |
593 | 299 |
[exBegin] |
300 |
|top l| |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
301 |
|
593 | 302 |
top := StandardSystemView new. |
303 |
top extent:(300 @ 250). |
|
304 |
top label:'make me smaller'. |
|
305 |
||
306 |
l := Label in:top. |
|
307 |
l borderWidth:1. |
|
308 |
l label:'default - #centered'. |
|
309 |
l origin:0.1@40. |
|
310 |
l width:0.8. |
|
63 | 311 |
|
593 | 312 |
l := Label in:top. |
313 |
l borderWidth:1. |
|
314 |
l adjust:#left. |
|
315 |
l label:'#left adjust'. |
|
316 |
l origin:0.1@70. |
|
317 |
l width:0.8. |
|
63 | 318 |
|
593 | 319 |
l := Label in:top. |
320 |
l borderWidth:1. |
|
321 |
l adjust:#right. |
|
322 |
l label:'#right adjust'. |
|
323 |
l origin:0.1@100. |
|
324 |
l width:0.8. |
|
118 | 325 |
|
593 | 326 |
l := Label in:top. |
327 |
l borderWidth:1. |
|
328 |
l adjust:#centerLeft. |
|
329 |
l label:'#centerLeft adjust with a long text'. |
|
330 |
l origin:0.1@130. |
|
331 |
l width:0.8. |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
332 |
|
593 | 333 |
l := Label in:top. |
334 |
l borderWidth:1. |
|
335 |
l adjust:#centerRight. |
|
336 |
l label:'#centerRight adjust with a long text'. |
|
337 |
l origin:0.1@160. |
|
338 |
l width:0.8. |
|
63 | 339 |
|
593 | 340 |
l := Label in:top. |
341 |
l borderWidth:1. |
|
342 |
l adjust:#leftRight. |
|
343 |
l label:'#leftRight adjust with a long text'. |
|
344 |
l origin:0.1@190. |
|
345 |
l width:0.8. |
|
63 | 346 |
|
593 | 347 |
l := Label in:top. |
348 |
l borderWidth:1. |
|
349 |
l adjust:#rightLeft. |
|
350 |
l label:'#rightLeft adjust with a long text'. |
|
351 |
l origin:0.1@220. |
|
352 |
l width:0.8. |
|
118 | 353 |
|
593 | 354 |
top open |
355 |
[exEnd] |
|
63 | 356 |
|
113 | 357 |
|
1945 | 358 |
center vs. centerEach adjust (only with multiline labels): |
359 |
[exBegin] |
|
360 |
|top l| |
|
361 |
||
362 |
top := StandardSystemView new. |
|
363 |
top extent:(300 @ 250). |
|
364 |
top label:'resize me'. |
|
365 |
||
366 |
l := Label in:top. |
|
367 |
l borderWidth:1. |
|
368 |
l label:'this labels logo |
|
1946 | 369 |
consists of multiple lines |
370 |
with #center adjust'. |
|
1945 | 371 |
l origin:0.1@0.1. |
372 |
l corner:0.9@0.9. |
|
373 |
l adjust:#center. |
|
374 |
||
375 |
top open. |
|
376 |
||
377 |
top := StandardSystemView new. |
|
378 |
top extent:(300 @ 250). |
|
379 |
top label:'resize me'. |
|
380 |
||
381 |
l := Label in:top. |
|
382 |
l borderWidth:1. |
|
383 |
l label:'this labels logo |
|
1946 | 384 |
consists of multiple lines |
385 |
with #centerEach adjust'. |
|
1945 | 386 |
l origin:0.1@0.1. |
387 |
l corner:0.9@0.9. |
|
388 |
l adjust:#centerEach. |
|
389 |
||
390 |
top open |
|
391 |
||
392 |
[exEnd] |
|
393 |
||
131 | 394 |
fitting-adjust (resize to see): |
395 |
Warning: #fit is experimental and should not be used. |
|
593 | 396 |
[exBegin] |
397 |
|top l| |
|
131 | 398 |
|
593 | 399 |
top := StandardSystemView new. |
400 |
top extent:(200 @ 200). |
|
131 | 401 |
|
593 | 402 |
l := Label origin:0.25 @ 0.25 corner:0.75@0.75 in:top. |
403 |
l label:'stretch'. |
|
404 |
l level:-1. |
|
405 |
l adjust:#fit. |
|
131 | 406 |
|
593 | 407 |
top open |
408 |
[exEnd] |
|
131 | 409 |
|
410 |
or: |
|
411 |
Warning: #fit is experimental and should not be used. |
|
593 | 412 |
[exBegin] |
413 |
|top l| |
|
131 | 414 |
|
593 | 415 |
top := StandardSystemView new. |
416 |
top extent:(200 @ 200). |
|
131 | 417 |
|
593 | 418 |
l := Label origin:0.25 @ 0.25 corner:0.75@0.75 in:top. |
419 |
l label:(Image fromFile:'bitmaps/SBrowser.xbm'). |
|
420 |
l level:-1. |
|
421 |
l adjust:#fit. |
|
131 | 422 |
|
593 | 423 |
top open |
424 |
[exEnd] |
|
131 | 425 |
|
426 |
||
63 | 427 |
just a reminder, that instead of doing placement manually |
113 | 428 |
as in ...: |
593 | 429 |
[exBegin] |
430 |
|top l| |
|
63 | 431 |
|
593 | 432 |
top := StandardSystemView new. |
433 |
top extent:(200 @ 200). |
|
63 | 434 |
|
593 | 435 |
l := Label in:top. |
436 |
l borderWidth:1. |
|
437 |
l label:'default - centered'. |
|
438 |
l origin:0.1@70. |
|
439 |
l width:0.8. |
|
63 | 440 |
|
593 | 441 |
l := Label in:top. |
442 |
l borderWidth:1. |
|
443 |
l adjust:#left. |
|
444 |
l label:'left adjust'. |
|
445 |
l origin:0.1@100. |
|
446 |
l width:0.8. |
|
63 | 447 |
|
593 | 448 |
l := Label in:top. |
449 |
l borderWidth:1. |
|
450 |
l adjust:#right. |
|
451 |
l label:'right adjust'. |
|
452 |
l origin:0.1@130. |
|
453 |
l width:0.8. |
|
63 | 454 |
|
593 | 455 |
top open |
456 |
[exEnd] |
|
63 | 457 |
|
113 | 458 |
|
459 |
... it is much easier, to use a geometry handler, such as |
|
63 | 460 |
a VerticalPanel. Try: |
593 | 461 |
[exBegin] |
462 |
|top panel l| |
|
63 | 463 |
|
593 | 464 |
top := StandardSystemView new. |
465 |
top extent:(200 @ 200). |
|
63 | 466 |
|
593 | 467 |
panel := VerticalPanelView |
468 |
origin:0.1 @ 0.0 |
|
469 |
corner:0.9 @ 1.0 |
|
470 |
in:top. |
|
63 | 471 |
|
593 | 472 |
panel horizontalLayout:#fit. |
473 |
panel verticalLayout:#center. |
|
63 | 474 |
|
593 | 475 |
l := Label in:panel. |
476 |
l borderWidth:1. |
|
477 |
l label:'default - centered'. |
|
63 | 478 |
|
593 | 479 |
l := Label in:panel. |
480 |
l borderWidth:1. |
|
481 |
l adjust:#left. |
|
482 |
l label:'left adjust'. |
|
63 | 483 |
|
593 | 484 |
l := Label in:panel. |
485 |
l borderWidth:1. |
|
486 |
l adjust:#right. |
|
487 |
l label:'right adjust'. |
|
63 | 488 |
|
593 | 489 |
top open |
490 |
[exEnd] |
|
63 | 491 |
|
113 | 492 |
|
63 | 493 |
labels with bitmaps or images: |
593 | 494 |
[exBegin] |
495 |
|top l| |
|
63 | 496 |
|
593 | 497 |
top := StandardSystemView new. |
498 |
top extent:(200 @ 200). |
|
63 | 499 |
|
593 | 500 |
l := Label in:top. |
501 |
l level:-1. |
|
5855 | 502 |
l label:((Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif') magnifiedBy:0.2 @ 0.2). |
593 | 503 |
l origin:50@100. |
63 | 504 |
|
593 | 505 |
top open |
506 |
[exEnd] |
|
113 | 507 |
|
508 |
||
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
509 |
that even works with #fit: |
593 | 510 |
[exBegin] |
511 |
|top l| |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
512 |
|
593 | 513 |
top := StandardSystemView new. |
514 |
top extent:(200 @ 200). |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
515 |
|
593 | 516 |
l := Label in:top. |
517 |
l adjust:#fit. |
|
518 |
l level:-1. |
|
5855 | 519 |
l label:(Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif'). |
593 | 520 |
l origin:0.2@0.2 corner:0.8@0.8. |
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
521 |
|
593 | 522 |
top open |
523 |
[exEnd] |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
524 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
525 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
526 |
notice, that Buttons inherit from Label; thus: |
593 | 527 |
[exBegin] |
528 |
|top b| |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
529 |
|
593 | 530 |
top := StandardSystemView new. |
531 |
top extent:(200 @ 200). |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
532 |
|
593 | 533 |
b := Button in:top. |
534 |
b adjust:#fit. |
|
5855 | 535 |
b label:(Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif'). |
593 | 536 |
b origin:0.2@0.2 corner:0.8@0.8. |
655 | 537 |
b action:[Transcript showCR:'wow']. |
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
538 |
|
593 | 539 |
top open |
540 |
[exEnd] |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
541 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
542 |
|
1374 | 543 |
Channel operation (controlling fg, bg and labelText via ValueHolders) |
145 | 544 |
----------------- |
593 | 545 |
[exBegin] |
546 |
|top panel logoChannel fgChannel bgChannel l b| |
|
145 | 547 |
|
593 | 548 |
top := StandardSystemView new. |
549 |
top extent:(450 @ 200). |
|
145 | 550 |
|
593 | 551 |
panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
145 | 552 |
|
593 | 553 |
l := Label in:panel. |
554 |
l level:-1. |
|
555 |
l label:'change my colors'. |
|
556 |
l origin:50@100. |
|
557 |
l sizeFixed:true. |
|
145 | 558 |
|
593 | 559 |
fgChannel := Color blue asValue. |
560 |
bgChannel := Color grey asValue. |
|
561 |
logoChannel := 'change me' asValue. |
|
145 | 562 |
|
593 | 563 |
b := Toggle label:'change fg' in:panel. b showLamp:false; onLevel:-2. |
564 |
b pressAction:[fgChannel value:Color red]. |
|
565 |
b releaseAction:[fgChannel value:Color blue]. |
|
145 | 566 |
|
593 | 567 |
b := Toggle label:'change bg' in:panel. |
568 |
b pressAction:[bgChannel value:Color yellow]. |
|
569 |
b releaseAction:[bgChannel value:Color grey]. |
|
145 | 570 |
|
593 | 571 |
b := Toggle label:'change text' in:panel. |
572 |
b pressAction:[logoChannel value:'wow']. |
|
573 |
b releaseAction:[logoChannel value:'not bad' ]. |
|
145 | 574 |
|
593 | 575 |
l labelChannel:logoChannel. |
576 |
l foregroundChannel:fgChannel. |
|
577 |
l backgroundChannel:bgChannel. |
|
145 | 578 |
|
593 | 579 |
top open |
580 |
[exEnd] |
|
145 | 581 |
|
582 |
||
146 | 583 |
multiple labels on one channel: |
593 | 584 |
[exBegin] |
585 |
|l1 l2 b conv| |
|
146 | 586 |
|
593 | 587 |
l1 := Label label:'label1'. |
146 | 588 |
|
593 | 589 |
l2 := Label label:'label2'. |
146 | 590 |
|
593 | 591 |
b := Button label:'change'. |
592 |
conv := (ConvertedValue new |
|
593 |
conversion:[:input | |
|
594 |
input ifTrue:[ |
|
595 |
Color red |
|
596 |
] ifFalse:[ |
|
597 |
Color blue |
|
598 |
]]). |
|
599 |
conv value:false. |
|
146 | 600 |
|
593 | 601 |
b controller pressChannel:conv. |
602 |
l1 foregroundChannel:conv. |
|
603 |
l2 foregroundColor:Color white; backgroundChannel:conv. |
|
146 | 604 |
|
593 | 605 |
b open. |
606 |
l1 open. |
|
607 |
l2 open. |
|
608 |
[exEnd] |
|
146 | 609 |
|
610 |
||
125 | 611 |
MVC operation |
145 | 612 |
------------- |
613 |
||
125 | 614 |
model provides the label): |
615 |
(have to use a plug to simulate a model which responds to |
|
593 | 616 |
the #someAspect message): |
617 |
|top l model| |
|
113 | 618 |
|
593 | 619 |
model := Plug new. |
620 |
model respondTo:#someAspect with:['models labelString']. |
|
113 | 621 |
|
593 | 622 |
top := StandardSystemView new. |
623 |
top extent:(200 @ 200). |
|
113 | 624 |
|
593 | 625 |
l := Label in:top. |
626 |
l model:model; labelMessage:#someAspect. |
|
113 | 627 |
|
593 | 628 |
top open |
629 |
... |
|
118 | 630 |
|
593 | 631 |
model changed:#someAspect |
632 |
... |
|
113 | 633 |
|
634 |
||
118 | 635 |
concrete example (track a counters value): |
125 | 636 |
(here, the default aspect #value is used both to notify the label about |
5782 | 637 |
changes and to acquire a new value from the model). |
593 | 638 |
[exBegin] |
639 |
|top l model| |
|
113 | 640 |
|
593 | 641 |
model := ValueHolder new. |
642 |
model value:'0'. |
|
643 |
[ |
|
644 |
1 to:20 do:[:i | |
|
645 |
(Delay forSeconds:1) wait. |
|
646 |
model value:i printString |
|
647 |
]. |
|
648 |
top destroy |
|
649 |
] fork. |
|
113 | 650 |
|
593 | 651 |
top := StandardSystemView new. |
652 |
top extent:(200 @ 200). |
|
113 | 653 |
|
593 | 654 |
l := Label in:top. |
655 |
l level:-1. |
|
656 |
l model:model; labelMessage:#value. |
|
118 | 657 |
|
593 | 658 |
top open |
659 |
[exEnd] |
|
118 | 660 |
|
661 |
||
133 | 662 |
with a printConverter: |
593 | 663 |
[exBegin] |
664 |
|top l model| |
|
133 | 665 |
|
593 | 666 |
model := Date today asValue. |
667 |
[ |
|
668 |
1 to:50 do:[:i | |
|
669 |
(Delay forSeconds:1) wait. |
|
670 |
model value:(model value addDays:1) |
|
671 |
]. |
|
672 |
top destroy |
|
673 |
] fork. |
|
133 | 674 |
|
593 | 675 |
top := StandardSystemView new. |
676 |
top extent:(200 @ 200). |
|
133 | 677 |
|
593 | 678 |
l := Label in:top. |
679 |
l level:-1. |
|
680 |
l converter:(PrintConverter new initForDate). |
|
681 |
l model:model; labelMessage:#value. |
|
133 | 682 |
|
593 | 683 |
top open |
684 |
[exEnd] |
|
133 | 685 |
|
686 |
||
125 | 687 |
model changes aspect after a while; two labels on the same model: |
593 | 688 |
[exBegin] |
689 |
|top l model| |
|
118 | 690 |
|
593 | 691 |
model := Plug new. |
692 |
model respondTo:#labelValue1 with:['models labelString1']. |
|
693 |
model respondTo:#labelValue2 with:['models labelString2']. |
|
118 | 694 |
|
593 | 695 |
top := StandardSystemView new. |
696 |
top extent:(200 @ 200). |
|
118 | 697 |
|
593 | 698 |
l := Label origin:0.0@0.0 corner:1.0@0.5 in:top. |
699 |
l model:model; aspect:#someAspect; labelMessage:#labelValue1. |
|
700 |
l := Label origin:0.0@0.5 corner:1.0@1.0 in:top. |
|
701 |
l model:model; aspect:#someAspect; labelMessage:#labelValue2. |
|
702 |
||
703 |
top open. |
|
113 | 704 |
|
593 | 705 |
(Delay forSeconds:5) wait. |
706 |
model respondTo:#labelValue1 with:['new string1']. |
|
707 |
model respondTo:#labelValue2 with:['new string2']. |
|
118 | 708 |
|
593 | 709 |
model changed:#someAspect |
710 |
[exEnd] |
|
118 | 711 |
|
712 |
||
125 | 713 |
plugged MVC operation (getBlock returns the label): |
593 | 714 |
[exBegin] |
715 |
|top l model| |
|
118 | 716 |
|
593 | 717 |
model := PluggableAdaptor new |
718 |
getBlock:[:m | 'hello'] |
|
719 |
putBlock:nil |
|
720 |
updateBlock:nil. |
|
118 | 721 |
|
593 | 722 |
top := StandardSystemView new. |
723 |
top extent:(200 @ 200). |
|
118 | 724 |
|
593 | 725 |
l := Label origin:0.0@0.0 corner:1.0@0.5 in:top. |
726 |
l model:model; labelMessage:#value. |
|
118 | 727 |
|
593 | 728 |
top open. |
729 |
[exEnd] |
|
125 | 730 |
|
731 |
||
732 |
use different label-selectors to access fields of a complex model: |
|
593 | 733 |
[exBegin] |
734 |
|top panel model| |
|
125 | 735 |
|
593 | 736 |
model := Plug new. |
737 |
model respondTo:#field1 with:['value1']. |
|
738 |
model respondTo:#field2 with:['value2']. |
|
739 |
model respondTo:#field3 with:['value3']. |
|
740 |
model respondTo:#field4 with:['value4']. |
|
125 | 741 |
|
593 | 742 |
top := StandardSystemView new. |
743 |
||
744 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
745 |
panel elementsChangeSize:true. |
|
125 | 746 |
|
593 | 747 |
panel addSubView:((Label on:model) labelMessage:#field1). |
748 |
panel addSubView:((Label on:model) labelMessage:#field2). |
|
749 |
panel addSubView:((Label on:model) labelMessage:#field3). |
|
750 |
panel addSubView:((Label on:model) labelMessage:#field4). |
|
125 | 751 |
|
593 | 752 |
top extent:(200 @ 200). |
753 |
top open. |
|
125 | 754 |
|
593 | 755 |
(Delay forSeconds:5) wait. |
125 | 756 |
|
593 | 757 |
model respondTo:#field2 with:['new value2']. |
758 |
model changed:#value |
|
759 |
[exEnd] |
|
125 | 760 |
|
761 |
||
762 |
same as above, using default aspects in the label, and an adaptor |
|
763 |
to translate aspects: |
|
593 | 764 |
[exBegin] |
765 |
|top panel model v1| |
|
125 | 766 |
|
593 | 767 |
model := Plug new. |
768 |
model respondTo:#field1 with:[v1]. |
|
769 |
model respondTo:#field1: with:[:arg | v1 := arg. model changed:#field1]. |
|
770 |
model respondTo:#field2 with:['value2']. |
|
771 |
model respondTo:#field2: with:[:arg |]. |
|
772 |
model respondTo:#field3 with:['value3']. |
|
773 |
model respondTo:#field3: with:[:arg |]. |
|
774 |
model respondTo:#field4 with:['value4']. |
|
775 |
model respondTo:#field4: with:[:arg |]. |
|
125 | 776 |
|
593 | 777 |
top := StandardSystemView new. |
125 | 778 |
|
593 | 779 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
780 |
panel elementsChangeSize:true. |
|
781 |
||
782 |
panel addSubView:((Label on:((AspectAdaptor subject:model) forAspect:#field1)) labelMessage:#value). |
|
783 |
panel addSubView:((Label on:((AspectAdaptor subject:model) forAspect:#field2)) labelMessage:#value). |
|
784 |
panel addSubView:((Label on:((AspectAdaptor subject:model) forAspect:#field3)) labelMessage:#value). |
|
785 |
panel addSubView:((Label on:((AspectAdaptor subject:model) forAspect:#field4)) labelMessage:#value). |
|
125 | 786 |
|
593 | 787 |
top extent:(200 @ 200). |
788 |
top open. |
|
125 | 789 |
|
593 | 790 |
(Delay forSeconds:5) wait. |
125 | 791 |
|
593 | 792 |
model field1:'new value1'. |
793 |
[exEnd] |
|
125 | 794 |
|
795 |
||
796 |
use an adapter to access fields of a complex model: |
|
593 | 797 |
[exBegin] |
798 |
|top l panel model| |
|
125 | 799 |
|
593 | 800 |
model := #('one' 'two' 'three') asValue. |
125 | 801 |
|
593 | 802 |
top := StandardSystemView new. |
125 | 803 |
|
593 | 804 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
805 |
panel elementsChangeSize:true. |
|
125 | 806 |
|
593 | 807 |
panel addSubView:((Label on:(ProtocolAdaptor |
808 |
subjectChannel:model |
|
809 |
accessPath:#(1))) labelMessage:#value). |
|
810 |
panel addSubView:((Label on:(ProtocolAdaptor |
|
811 |
subjectChannel:model |
|
812 |
accessPath:#(2))) labelMessage:#value). |
|
813 |
panel addSubView:((Label on:(ProtocolAdaptor |
|
814 |
subjectChannel:model |
|
815 |
accessPath:#(3))) labelMessage:#value). |
|
125 | 816 |
|
593 | 817 |
top extent:(200 @ 200). |
818 |
top open. |
|
125 | 819 |
|
593 | 820 |
(Delay forSeconds:5) wait. |
125 | 821 |
|
593 | 822 |
model value:#('oneone' 'twotwo' 'threethree'). |
823 |
[exEnd] |
|
63 | 824 |
" |
3 | 825 |
! ! |
826 |
||
935 | 827 |
!Label class methodsFor:'instance creation'! |
105 | 828 |
|
829 |
form:aForm |
|
118 | 830 |
"return a new Label showing a form. |
831 |
OBSOLETE: you should now use #label: for both text and bitmap labels." |
|
105 | 832 |
|
2366 | 833 |
<resource:#obsolete> |
834 |
||
1246
9033af51413c
obsolete: #form: / #form:in:
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
835 |
self obsoleteMethodWarning:'use #label:'. |
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2968
diff
changeset
|
836 |
^ (self onDevice:Screen current) label:aForm |
1246
9033af51413c
obsolete: #form: / #form:in:
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
837 |
|
9033af51413c
obsolete: #form: / #form:in:
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
838 |
"Modified: 16.6.1997 / 11:47:38 / cg" |
105 | 839 |
! |
840 |
||
841 |
form:aForm in:aView |
|
118 | 842 |
"return a new Label showing a form. |
843 |
OBSOLETE: you should now use #label:in: for both text and bitmap labels." |
|
105 | 844 |
|
2366 | 845 |
<resource:#obsolete> |
846 |
||
1246
9033af51413c
obsolete: #form: / #form:in:
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
847 |
self obsoleteMethodWarning:'use #label:in:'. |
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2968
diff
changeset
|
848 |
^ (self in:aView) label:aForm |
1246
9033af51413c
obsolete: #form: / #form:in:
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
849 |
|
9033af51413c
obsolete: #form: / #form:in:
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
850 |
"Modified: 16.6.1997 / 11:47:57 / cg" |
105 | 851 |
! ! |
852 |
||
935 | 853 |
!Label class methodsFor:'defaults'! |
0 | 854 |
|
855 |
defaultExtent |
|
571 | 856 |
"return the default extent of my instances. |
857 |
The value returned here is usually ignored, and |
|
858 |
the value from preferredExtent taken instead." |
|
0 | 859 |
|
860 |
^ 16 @ 16 |
|
571 | 861 |
|
862 |
"Modified: 22.4.1996 / 23:36:11 / cg" |
|
59 | 863 |
! |
864 |
||
2098
22fcc05794eb
accessor for defaultForegroundColor
Claus Gittinger <cg@exept.de>
parents:
1991
diff
changeset
|
865 |
defaultForegroundColor |
22fcc05794eb
accessor for defaultForegroundColor
Claus Gittinger <cg@exept.de>
parents:
1991
diff
changeset
|
866 |
"return the default foregroundColor of my instances." |
22fcc05794eb
accessor for defaultForegroundColor
Claus Gittinger <cg@exept.de>
parents:
1991
diff
changeset
|
867 |
|
22fcc05794eb
accessor for defaultForegroundColor
Claus Gittinger <cg@exept.de>
parents:
1991
diff
changeset
|
868 |
^ DefaultForegroundColor |
22fcc05794eb
accessor for defaultForegroundColor
Claus Gittinger <cg@exept.de>
parents:
1991
diff
changeset
|
869 |
|
22fcc05794eb
accessor for defaultForegroundColor
Claus Gittinger <cg@exept.de>
parents:
1991
diff
changeset
|
870 |
! |
22fcc05794eb
accessor for defaultForegroundColor
Claus Gittinger <cg@exept.de>
parents:
1991
diff
changeset
|
871 |
|
59 | 872 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
416
diff
changeset
|
873 |
"extract values from the styleSheet and cache them in class variables" |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
416
diff
changeset
|
874 |
|
1356 | 875 |
<resource: #style (#'label.foregroundColor' #'label.backgroundColor' |
442 | 876 |
#foregroundColor #backgroundColor |
1356 | 877 |
#'label.font')> |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
416
diff
changeset
|
878 |
|
1872 | 879 |
DefaultForegroundColor := StyleSheet colorAt:#'label.foregroundColor'. |
77 | 880 |
DefaultForegroundColor isNil ifTrue:[ |
1374 | 881 |
"/ fallBack: comon value |
4915 | 882 |
DefaultForegroundColor := StyleSheet colorAt:#'foregroundColor' default:Color black. |
77 | 883 |
]. |
1872 | 884 |
DefaultBackgroundColor := StyleSheet colorAt:#'label.backgroundColor'. |
77 | 885 |
DefaultBackgroundColor isNil ifTrue:[ |
1374 | 886 |
"/ fallBack: comon value |
1872 | 887 |
DefaultBackgroundColor := StyleSheet colorAt:#'backgroundColor'. |
77 | 888 |
]. |
1872 | 889 |
DefaultFont := StyleSheet fontAt:#'label.font'. |
60 | 890 |
|
891 |
" |
|
892 |
self updateStyleCache |
|
893 |
" |
|
254
aa15cac0670f
oops - foregroundColor was overwritten by backgroundColor (if defined in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
250
diff
changeset
|
894 |
|
1374 | 895 |
"Modified: / 31.10.1997 / 14:53:48 / cg" |
0 | 896 |
! ! |
897 |
||
4670 | 898 |
!Label class methodsFor:'menu specs'! |
899 |
||
900 |
middleButtonMenu |
|
901 |
"This resource specification was automatically generated |
|
902 |
by the MenuEditor of ST/X." |
|
903 |
||
904 |
"Do not manually edit this!! If it is corrupted, |
|
905 |
the MenuEditor may not be able to read the specification." |
|
906 |
||
907 |
||
908 |
" |
|
909 |
MenuEditor new openOnClass:Label andSelector:#middleButtonMenu |
|
910 |
(Menu new fromLiteralArrayEncoding:(Label middleButtonMenu)) startUp |
|
911 |
" |
|
912 |
||
913 |
<resource: #menu> |
|
914 |
||
915 |
^ |
|
916 |
#(Menu |
|
917 |
( |
|
918 |
(MenuItem |
|
919 |
label: 'Copy Label Text' |
|
920 |
itemValue: copyLabelText |
|
921 |
enabled: isTextLabel |
|
922 |
) |
|
923 |
) |
|
924 |
nil |
|
925 |
nil |
|
926 |
) |
|
927 |
! ! |
|
928 |
||
202 | 929 |
!Label methodsFor:'accessing-channels'! |
105 | 930 |
|
260 | 931 |
labelChannel |
1374 | 932 |
"return the labelChannel - or nil" |
933 |
||
260 | 934 |
^ labelChannel. |
935 |
||
1374 | 936 |
"Created: / 16.12.1995 / 15:50:18 / cg" |
937 |
"Modified: / 31.10.1997 / 14:43:14 / cg" |
|
260 | 938 |
! |
939 |
||
145 | 940 |
labelChannel:aValueHolder |
1374 | 941 |
"set the labelChannel - a valueHolder holding a string or image |
942 |
which is shown as my logo" |
|
943 |
||
146 | 944 |
|prev| |
945 |
||
946 |
prev := labelChannel. |
|
145 | 947 |
labelChannel := aValueHolder. |
3927 | 948 |
self setupChannel:aValueHolder for:nil withOld:prev. |
949 |
self getLabelFromLabelChannel. |
|
1374 | 950 |
|
951 |
"Modified: / 31.10.1997 / 14:37:02 / cg" |
|
145 | 952 |
! ! |
953 |
||
202 | 954 |
!Label methodsFor:'accessing-colors'! |
125 | 955 |
|
202 | 956 |
backgroundColor |
957 |
"return the background color" |
|
125 | 958 |
|
202 | 959 |
^ bgColor |
125 | 960 |
! |
961 |
||
202 | 962 |
backgroundColor:aColor |
963 |
"set the background color" |
|
125 | 964 |
|
263 | 965 |
aColor ~~ bgColor ifTrue:[ |
3582 | 966 |
bgColor := aColor. |
967 |
bgColor notNil ifTrue:[ |
|
5633 | 968 |
bgColor := bgColor onDevice:device. |
3597 | 969 |
self class == Label ifTrue:[ |
970 |
super viewBackground:bgColor |
|
971 |
]. |
|
1218 | 972 |
]. |
2913
bdf4fb09cfc0
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2751
diff
changeset
|
973 |
self invalidateRepairNow:true |
263 | 974 |
] |
975 |
||
1414
b86d8f36f3a9
Use Color>>onDevice: instead of obsolete Color>>on:
Stefan Vogel <sv@exept.de>
parents:
1398
diff
changeset
|
976 |
"Modified: / 15.1.1998 / 00:14:10 / stefan" |
1554
b05a50854c76
redrawNow for visible changes.
Claus Gittinger <cg@exept.de>
parents:
1509
diff
changeset
|
977 |
"Modified: / 6.6.1998 / 20:01:56 / cg" |
105 | 978 |
! |
979 |
||
2496 | 980 |
etchedForegroundColor |
981 |
"return the etched foreground color (or nil)" |
|
982 |
||
983 |
^ etchedFgColor |
|
984 |
! |
|
985 |
||
986 |
etchedForegroundColor:aColor |
|
987 |
"set the etched foreground color" |
|
988 |
||
989 |
aColor ~~ etchedFgColor ifTrue:[ |
|
990 |
etchedFgColor := aColor. |
|
991 |
etchedFgColor notNil ifTrue:[ |
|
5633 | 992 |
etchedFgColor := etchedFgColor onDevice:device. |
2496 | 993 |
]. |
2913
bdf4fb09cfc0
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2751
diff
changeset
|
994 |
self invalidateRepairNow:true |
2496 | 995 |
]. |
996 |
! |
|
997 |
||
105 | 998 |
foregroundColor |
999 |
"return the foreground color" |
|
1000 |
||
1001 |
^ fgColor |
|
1002 |
! |
|
1003 |
||
202 | 1004 |
foregroundColor:aColor |
1005 |
"set the foreground color" |
|
105 | 1006 |
|
263 | 1007 |
aColor ~~ fgColor ifTrue:[ |
5633 | 1008 |
fgColor := aColor onDevice:device. |
2913
bdf4fb09cfc0
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2751
diff
changeset
|
1009 |
self invalidateRepairNow:true |
263 | 1010 |
]. |
1011 |
||
1414
b86d8f36f3a9
Use Color>>onDevice: instead of obsolete Color>>on:
Stefan Vogel <sv@exept.de>
parents:
1398
diff
changeset
|
1012 |
"Modified: / 15.1.1998 / 00:14:22 / stefan" |
1554
b05a50854c76
redrawNow for visible changes.
Claus Gittinger <cg@exept.de>
parents:
1509
diff
changeset
|
1013 |
"Modified: / 6.6.1998 / 20:02:02 / cg" |
105 | 1014 |
! |
1015 |
||
1016 |
foregroundColor:fg backgroundColor:bg |
|
1017 |
"set the colors to be used for drawing" |
|
1018 |
||
993 | 1019 |
(fgColor ~~ fg or:[bgColor ~~ bg]) ifTrue:[ |
5633 | 1020 |
fgColor := fg onDevice:device. |
1021 |
bgColor := bg onDevice:device. |
|
1218 | 1022 |
self class == Label ifTrue:[ |
1414
b86d8f36f3a9
Use Color>>onDevice: instead of obsolete Color>>on:
Stefan Vogel <sv@exept.de>
parents:
1398
diff
changeset
|
1023 |
super viewBackground:bgColor |
1218 | 1024 |
]. |
2913
bdf4fb09cfc0
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2751
diff
changeset
|
1025 |
self invalidateRepairNow:true |
993 | 1026 |
]. |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
1027 |
|
1414
b86d8f36f3a9
Use Color>>onDevice: instead of obsolete Color>>on:
Stefan Vogel <sv@exept.de>
parents:
1398
diff
changeset
|
1028 |
"Modified: / 15.1.1998 / 00:14:36 / stefan" |
1554
b05a50854c76
redrawNow for visible changes.
Claus Gittinger <cg@exept.de>
parents:
1509
diff
changeset
|
1029 |
"Modified: / 6.6.1998 / 20:02:07 / cg" |
1218 | 1030 |
! |
1031 |
||
1032 |
viewBackground:aColor |
|
1033 |
"for labels, the viewBackground is forced to be the same as |
|
1034 |
the backgroundColor" |
|
1035 |
||
1554
b05a50854c76
redrawNow for visible changes.
Claus Gittinger <cg@exept.de>
parents:
1509
diff
changeset
|
1036 |
super viewBackground:aColor. |
1218 | 1037 |
self class == Label ifTrue:[ |
1554
b05a50854c76
redrawNow for visible changes.
Claus Gittinger <cg@exept.de>
parents:
1509
diff
changeset
|
1038 |
self backgroundColor:aColor |
1218 | 1039 |
]. |
1554
b05a50854c76
redrawNow for visible changes.
Claus Gittinger <cg@exept.de>
parents:
1509
diff
changeset
|
1040 |
|
b05a50854c76
redrawNow for visible changes.
Claus Gittinger <cg@exept.de>
parents:
1509
diff
changeset
|
1041 |
"Modified: / 6.6.1998 / 20:02:22 / cg" |
133 | 1042 |
! ! |
1043 |
||
1044 |
!Label methodsFor:'accessing-contents'! |
|
0 | 1045 |
|
202 | 1046 |
form:aForm |
1047 |
"set the labels form; adjust extent if not already realized. |
|
1048 |
OBSOLETE: you should now use #label: for both strings and images" |
|
118 | 1049 |
|
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2968
diff
changeset
|
1050 |
<resource:#obsolete> |
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2968
diff
changeset
|
1051 |
|
202 | 1052 |
self label:aForm |
1053 |
! |
|
1054 |
||
1055 |
label |
|
1056 |
"return the labels string or image" |
|
1057 |
||
1058 |
^ logo |
|
118 | 1059 |
! |
105 | 1060 |
|
118 | 1061 |
label:aStringOrFormOrImage |
4174 | 1062 |
"set the labelString or image; |
1063 |
adjust extent if not already realized and not fixedSize; |
|
1064 |
also redraw" |
|
1065 |
||
1066 |
self label:aStringOrFormOrImage redraw:true |
|
1067 |
||
1068 |
"Modified: / 13-10-2010 / 12:17:36 / cg" |
|
1069 |
! |
|
1070 |
||
1071 |
label:aStringOrFormOrImage redraw:doRedraw |
|
118 | 1072 |
"set the labelString or image; adjust extent if not already realized and |
1073 |
not fixedSize" |
|
1074 |
||
3999
f605cc13731e
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
1075 |
|newLogo numberOfLines| |
2639 | 1076 |
|
1077 |
newLogo := aStringOrFormOrImage. |
|
3999
f605cc13731e
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
1078 |
newLogo isString ifTrue:[ |
f605cc13731e
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
1079 |
numberOfLines := 1 + (newLogo occurrencesOf:(Character cr)). |
f605cc13731e
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
1080 |
(numberOfLines ~~ 1) ifTrue:[ |
f605cc13731e
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
1081 |
newLogo := newLogo asStringCollection |
f605cc13731e
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
1082 |
] |
f605cc13731e
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
1083 |
] ifFalse:[ |
f605cc13731e
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
1084 |
newLogo isStringCollection ifTrue:[ |
f605cc13731e
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
1085 |
numberOfLines := newLogo size. |
f605cc13731e
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
1086 |
(numberOfLines <= 1) ifTrue:[ |
f605cc13731e
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
1087 |
newLogo := newLogo asString |
f605cc13731e
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
1088 |
] |
f605cc13731e
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
1089 |
] |
f605cc13731e
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
1090 |
]. |
f605cc13731e
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
1091 |
|
118 | 1092 |
(aStringOrFormOrImage ~~ logo) ifTrue:[ |
616
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
1093 |
"/ |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
1094 |
"/ avoid recompute of size, if its an image with |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
1095 |
"/ the same size |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
1096 |
"/ |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
1097 |
aStringOrFormOrImage isImageOrForm ifTrue:[ |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
1098 |
logo notNil ifTrue:[ |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
1099 |
logo isImageOrForm ifTrue:[ |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
1100 |
logo extent = aStringOrFormOrImage extent ifTrue:[ |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
1101 |
logo := aStringOrFormOrImage. |
4174 | 1102 |
doRedraw ifTrue:[ self invalidateRepairNow:true ]. |
616
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
1103 |
^ self |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
1104 |
] |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
1105 |
] |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
1106 |
] |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
1107 |
] ifFalse:[ |
806
a641ed42df70
dont ignore new label setting, if the emphasis changed
Claus Gittinger <cg@exept.de>
parents:
799
diff
changeset
|
1108 |
"/ any change ? |
4443
a5a69820a9b5
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
4341
diff
changeset
|
1109 |
(logo isString |
a5a69820a9b5
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
4341
diff
changeset
|
1110 |
and:[ newLogo isString |
a5a69820a9b5
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
4341
diff
changeset
|
1111 |
and:[ newLogo = logo |
a5a69820a9b5
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
4341
diff
changeset
|
1112 |
and:[ logo emphasis = newLogo emphasis]]]) ifTrue:[ |
3649 | 1113 |
^ self |
616
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
1114 |
] |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
1115 |
]. |
3557
e57daeff04be
changed #label: - fix typo in comment
Stefan Vogel <sv@exept.de>
parents:
3531
diff
changeset
|
1116 |
"/ do not check using #isString here; |
3531 | 1117 |
"/ we allow for non-strings to be used as logo as well (it must understand displayOn:). |
1118 |
newLogo isNumber ifTrue:[ |
|
1119 |
logo := newLogo asString |
|
1120 |
] ifFalse:[ |
|
1121 |
logo := newLogo. |
|
1122 |
]. |
|
4174 | 1123 |
doRedraw ifTrue:[ |
1124 |
self newLayout. |
|
1125 |
self repairDamage |
|
1126 |
]. |
|
105 | 1127 |
] |
616
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
1128 |
|
4174 | 1129 |
"Created: / 13-10-2010 / 12:16:34 / cg" |
105 | 1130 |
! |
0 | 1131 |
|
1367 | 1132 |
label:newLabel suppressResize:suppress |
1133 |
"change the label and optionally suppress a resize operation" |
|
1134 |
||
1135 |
|wasFix| |
|
1136 |
||
1137 |
wasFix := fixSize. |
|
1138 |
suppress ifTrue:[ |
|
1139 |
fixSize := true. |
|
1140 |
]. |
|
1141 |
here label:newLabel. |
|
1142 |
fixSize := wasFix |
|
1143 |
||
1144 |
"Modified: / 29.10.1997 / 15:50:01 / cg" |
|
1145 |
! |
|
1146 |
||
202 | 1147 |
labelString:aString |
1148 |
"for ST-80 compatibility: same as #label: |
|
1149 |
set the label-string; adjust extent if not already realized and not fixedSize" |
|
118 | 1150 |
|
202 | 1151 |
self label:aString |
1152 |
! |
|
1153 |
||
1154 |
labelWidth |
|
1155 |
"return the logos width in pixels" |
|
1156 |
||
1157 |
^ labelWidth |
|
118 | 1158 |
! |
1159 |
||
1160 |
logo:something |
|
1161 |
"set the labels form or string. |
|
1162 |
OBSOLETE: the old version used #form: for images and #label: for strings. |
|
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2968
diff
changeset
|
1163 |
you should now use #label: for any." |
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2968
diff
changeset
|
1164 |
|
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2968
diff
changeset
|
1165 |
<resource:#obsolete> |
118 | 1166 |
|
1167 |
self label:something |
|
133 | 1168 |
! ! |
1169 |
||
1170 |
!Label methodsFor:'accessing-layout'! |
|
1171 |
||
202 | 1172 |
adjust |
1921 | 1173 |
"return the adjust symbol. See #adjust: for an explanation." |
0 | 1174 |
|
202 | 1175 |
^ adjust |
125 | 1176 |
! |
1177 |
||
105 | 1178 |
adjust:how |
1179 |
"set the adjust, how which must be one of |
|
0 | 1180 |
|
105 | 1181 |
#left -> left adjust logo |
1182 |
#right -> right adjust logo |
|
1183 |
#center -> center logo |
|
1945 | 1184 |
#centerEach -> like #center, but if its a multiline logo, |
1185 |
center each line individually. |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1186 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1187 |
#centerRight -> center logo if it fits; |
533 | 1188 |
BUT, if it does not fit, right adjust the logo |
1189 |
(use with filenames, where the interesting part is |
|
1190 |
at the right if the label is too small) |
|
1191 |
||
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1192 |
#centerLeft -> center logo if it fits; |
533 | 1193 |
BUT, if it does not fit, left adjust the logo |
1194 |
(use with strings where the interesting part is at the |
|
1195 |
left if the label is too small) |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1196 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1197 |
#leftRight -> left adjust logo if it fits |
533 | 1198 |
BUT, if it does not fit, right adjust the logo |
1199 |
(use with filenames, where the interesting part is |
|
1200 |
at the right if the label is too small) |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1201 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1202 |
#rightLeft -> right adjust logo if it fits |
533 | 1203 |
BUT, if it does not fit, left adjust the logo |
1204 |
(use with strings where the interesting part is at the |
|
1205 |
left if the label is too small) |
|
1206 |
||
1207 |
See examples in the documentation category. |
|
105 | 1208 |
" |
118 | 1209 |
|
105 | 1210 |
(adjust ~~ how) ifTrue:[ |
533 | 1211 |
adjust := how. |
1212 |
self newLayout |
|
105 | 1213 |
] |
533 | 1214 |
|
1215 |
"Modified: 13.4.1996 / 11:17:58 / cg" |
|
105 | 1216 |
! |
1217 |
||
5445 | 1218 |
extraMarginForBorder |
1219 |
"some (round) borders may need more space" |
|
1220 |
||
1221 |
^ 0 |
|
1222 |
! |
|
1223 |
||
202 | 1224 |
font:aFont |
665 | 1225 |
"set the font - if I'm not realized and not fixedSize, adjust my size. |
1226 |
CAVEAT: with the addition of Text objects, |
|
1227 |
this method is going to be obsoleted by a textStyle |
|
1228 |
method, which allows specific control over |
|
1229 |
normalFont/boldFont/italicFont parameters." |
|
125 | 1230 |
|
4891 | 1231 |
(aFont notNil and:[aFont ~~ gc font]) ifTrue:[ |
1232 |
super font:aFont. |
|
416 | 1233 |
self newLayout |
202 | 1234 |
] |
416 | 1235 |
|
665 | 1236 |
"Modified: 22.5.1996 / 12:36:29 / cg" |
133 | 1237 |
! |
1238 |
||
1239 |
horizontalSpace:aNumber |
|
1240 |
"set the number of pixels by which the logo |
|
1241 |
is horizontally inset from the border" |
|
1242 |
||
162 | 1243 |
hSpace := aNumber. |
1244 |
self newLayout |
|
133 | 1245 |
! |
1246 |
||
202 | 1247 |
layout:something |
1248 |
"OBSOLETE compatibility interface. Will vanish. |
|
1249 |
for protocol compatibility: alias for #adjust:. |
|
1250 |
Please use #adjust:, since #layout: conflicts with a method |
|
1251 |
in VW (which has a completely different meaning). |
|
1252 |
In future versions of ST/X, #layout: will behave the VW way. |
|
1253 |
In the meantime, try to figure out what is meant ... a kludge" |
|
1254 |
||
2366 | 1255 |
<resource:#obsolete> |
1256 |
||
3215 | 1257 |
something isSymbol ifFalse:[^ super layout:something]. |
202 | 1258 |
|
1259 |
self obsoleteMethodWarning:'use #adjust:'. |
|
1260 |
self adjust:something |
|
1261 |
||
1262 |
"Modified: 31.8.1995 / 23:08:13 / claus" |
|
1263 |
! |
|
1264 |
||
1265 |
sizeFixed |
|
1266 |
"return the fix-size attribute" |
|
1267 |
||
1268 |
^ fixSize |
|
1269 |
! |
|
1270 |
||
1271 |
sizeFixed:aBoolean |
|
1272 |
"set/clear the fix-size attribute. |
|
5708 | 1273 |
If true, the label will not change its size when the labelString/logo |
1274 |
changes. |
|
1275 |
If false (the default), it will resize itself to make the logo fit." |
|
202 | 1276 |
|
1277 |
fixSize := aBoolean |
|
1278 |
! |
|
1279 |
||
1280 |
verticalSpace:aNumber |
|
1281 |
"set the number of pixels by which the logo |
|
1282 |
is vertically inset from the border" |
|
1283 |
||
1284 |
vSpace := aNumber. |
|
1285 |
self newLayout |
|
1286 |
! ! |
|
1287 |
||
1288 |
!Label methodsFor:'accessing-mvc'! |
|
1289 |
||
1290 |
addModelInterfaceTo:aDictionary |
|
1291 |
"see comment in View>>modelInterface" |
|
1292 |
||
1293 |
super addModelInterfaceTo:aDictionary. |
|
1294 |
aDictionary at:#labelMessage put:labelMsg |
|
1295 |
! |
|
1296 |
||
1297 |
converter:aConverter |
|
1298 |
"set the printConverter; |
|
1299 |
that one is asked to convert the models value to a printed |
|
1300 |
representation (if non-nil). If nil, the model is supposed to |
|
1301 |
return a string or bitmap image." |
|
1302 |
||
1303 |
converter := aConverter |
|
1304 |
! |
|
105 | 1305 |
|
202 | 1306 |
labelMessage |
5782 | 1307 |
"return the symbol used to acquire the labelString/image from the model |
202 | 1308 |
when the aspect changes. |
1309 |
The default is nil, which means: leave the label unchanged." |
|
1310 |
||
1311 |
^ labelMsg |
|
1312 |
! |
|
1313 |
||
1314 |
labelMessage:aSymbol |
|
5782 | 1315 |
"set the symbol used to acquire the labelString/image from the model. |
202 | 1316 |
The default is nil, which means: leave the label unchanged." |
1317 |
||
1318 |
labelMsg ~~ aSymbol ifTrue:[ |
|
5782 | 1319 |
labelMsg := aSymbol. |
1320 |
self getLabelFromModel |
|
202 | 1321 |
] |
1322 |
! |
|
1323 |
||
1324 |
model:aModel |
|
1325 |
super model:aModel. |
|
1039 | 1326 |
labelMsg notNil ifTrue:[ |
1327 |
self getLabelFromModel. |
|
1328 |
] |
|
202 | 1329 |
! ! |
1330 |
||
1331 |
!Label methodsFor:'change & update'! |
|
1332 |
||
3924 | 1333 |
getLabelFromLabelChannel |
1334 |
self label:(labelChannel value). |
|
1335 |
! |
|
1336 |
||
202 | 1337 |
update:something with:aParameter from:changedObject |
1338 |
"the MVC way of changing the label ..." |
|
1339 |
||
1374 | 1340 |
changedObject notNil ifTrue:[ |
1341 |
changedObject == labelChannel ifTrue:[ |
|
3924 | 1342 |
self getLabelFromLabelChannel. |
1374 | 1343 |
^ self |
1344 |
]. |
|
1345 |
||
1346 |
changedObject == model ifTrue:[ |
|
1347 |
something == aspectMsg ifTrue:[ |
|
1348 |
self getLabelFromModel. |
|
1349 |
^ self. |
|
1350 |
] |
|
1351 |
]. |
|
202 | 1352 |
]. |
1353 |
^ super update:something with:aParameter from:changedObject |
|
1374 | 1354 |
|
1355 |
"Modified: / 31.10.1997 / 14:32:02 / cg" |
|
1828 | 1356 |
"Modified: / 30.3.1999 / 13:57:26 / stefan" |
202 | 1357 |
! ! |
1358 |
||
1359 |
!Label methodsFor:'event handling'! |
|
1360 |
||
1361 |
sizeChanged:how |
|
1362 |
"sent whenever size is changed by someone else - recompute the |
|
1363 |
logos position within the View." |
|
1364 |
||
1508
15d1b3e7e92a
oops - resize in Y must redraw
Claus Gittinger <cg@exept.de>
parents:
1428
diff
changeset
|
1365 |
|prevX prevY| |
202 | 1366 |
|
1367 |
super sizeChanged:how. |
|
1508
15d1b3e7e92a
oops - resize in Y must redraw
Claus Gittinger <cg@exept.de>
parents:
1428
diff
changeset
|
1368 |
|
15d1b3e7e92a
oops - resize in Y must redraw
Claus Gittinger <cg@exept.de>
parents:
1428
diff
changeset
|
1369 |
prevX := labelOriginX. |
15d1b3e7e92a
oops - resize in Y must redraw
Claus Gittinger <cg@exept.de>
parents:
1428
diff
changeset
|
1370 |
prevY := labelOriginY. |
1392 | 1371 |
self computeLabelOrigin. |
202 | 1372 |
shown ifTrue:[ |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
1373 |
(adjust == #fit |
1508
15d1b3e7e92a
oops - resize in Y must redraw
Claus Gittinger <cg@exept.de>
parents:
1428
diff
changeset
|
1374 |
or:[labelOriginX ~~ prevX |
15d1b3e7e92a
oops - resize in Y must redraw
Claus Gittinger <cg@exept.de>
parents:
1428
diff
changeset
|
1375 |
or:[labelOriginY ~~ prevY |
15d1b3e7e92a
oops - resize in Y must redraw
Claus Gittinger <cg@exept.de>
parents:
1428
diff
changeset
|
1376 |
or:[how ~~ #smaller]]]) ifTrue:[ |
1509 | 1377 |
"/ self clear. |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
1378 |
self invalidate. |
1509 | 1379 |
"/ self redrawEdges |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
1380 |
] |
105 | 1381 |
] |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
1382 |
|
1509 | 1383 |
"Modified: / 28.4.1998 / 17:07:57 / cg" |
0 | 1384 |
! ! |
1385 |
||
1867
d27de2b0705c
dont take the focus on click
Claus Gittinger <cg@exept.de>
parents:
1857
diff
changeset
|
1386 |
!Label methodsFor:'focus handling'! |
d27de2b0705c
dont take the focus on click
Claus Gittinger <cg@exept.de>
parents:
1857
diff
changeset
|
1387 |
|
d27de2b0705c
dont take the focus on click
Claus Gittinger <cg@exept.de>
parents:
1857
diff
changeset
|
1388 |
wantsFocusWithButtonPress |
d27de2b0705c
dont take the focus on click
Claus Gittinger <cg@exept.de>
parents:
1857
diff
changeset
|
1389 |
self class == Label ifTrue:[^ false]. |
d27de2b0705c
dont take the focus on click
Claus Gittinger <cg@exept.de>
parents:
1857
diff
changeset
|
1390 |
^ super wantsFocusWithButtonPress |
d27de2b0705c
dont take the focus on click
Claus Gittinger <cg@exept.de>
parents:
1857
diff
changeset
|
1391 |
|
d27de2b0705c
dont take the focus on click
Claus Gittinger <cg@exept.de>
parents:
1857
diff
changeset
|
1392 |
|
d27de2b0705c
dont take the focus on click
Claus Gittinger <cg@exept.de>
parents:
1857
diff
changeset
|
1393 |
! ! |
d27de2b0705c
dont take the focus on click
Claus Gittinger <cg@exept.de>
parents:
1857
diff
changeset
|
1394 |
|
2751 | 1395 |
!Label methodsFor:'initialization & release'! |
0 | 1396 |
|
935 | 1397 |
fetchDeviceResources |
1398 |
"fetch device colors, to avoid reallocation at redraw time" |
|
1399 |
||
1400 |
super fetchDeviceResources. |
|
1401 |
||
5633 | 1402 |
fgColor := fgColor onDevice:device. |
1403 |
bgColor := bgColor onDevice:device. |
|
935 | 1404 |
|
1414
b86d8f36f3a9
Use Color>>onDevice: instead of obsolete Color>>on:
Stefan Vogel <sv@exept.de>
parents:
1398
diff
changeset
|
1405 |
"Created: / 13.1.1997 / 23:34:30 / cg" |
b86d8f36f3a9
Use Color>>onDevice: instead of obsolete Color>>on:
Stefan Vogel <sv@exept.de>
parents:
1398
diff
changeset
|
1406 |
"Modified: / 15.1.1998 / 00:13:46 / stefan" |
935 | 1407 |
! |
1408 |
||
0 | 1409 |
initStyle |
967 | 1410 |
"setup viewStyle specifics" |
1411 |
||
0 | 1412 |
super initStyle. |
1413 |
||
59 | 1414 |
DefaultBackgroundColor notNil ifTrue:[ |
935 | 1415 |
bgColor := DefaultBackgroundColor |
38 | 1416 |
] ifFalse:[ |
935 | 1417 |
bgColor := viewBackground. |
59 | 1418 |
]. |
1419 |
DefaultForegroundColor notNil ifTrue:[ |
|
935 | 1420 |
fgColor := DefaultForegroundColor |
59 | 1421 |
] ifFalse:[ |
4915 | 1422 |
fgColor := self blackColor. |
1374 | 1423 |
]. |
1424 |
self class == Label ifTrue:[ |
|
4020
3b0d7d8915a8
no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
1425 |
self borderWidth:0. |
38 | 1426 |
] |
935 | 1427 |
|
4318 | 1428 |
"Modified: / 31-10-1997 / 14:57:23 / cg" |
1429 |
"Modified (comment): / 05-10-2011 / 15:51:09 / az" |
|
0 | 1430 |
! |
1431 |
||
105 | 1432 |
initialize |
4891 | 1433 |
|currentFont| |
1434 |
||
105 | 1435 |
super initialize. |
1436 |
||
5817 | 1437 |
currentFont := gc font. |
4891 | 1438 |
self initialHeight:(currentFont height + currentFont descent). |
105 | 1439 |
adjust := #center. |
118 | 1440 |
labelOriginX := labelOriginY := 0. |
1441 |
labelWidth := labelHeight := 0. |
|
105 | 1442 |
logo := nil. |
1443 |
fixSize := false. |
|
5943 | 1444 |
hSpace := ((self horizontalPixelPerMillimeter:0.5) max:2) rounded. |
1445 |
vSpace := ((self verticalPixelPerMillimeter:0.5) max:2) rounded |
|
105 | 1446 |
! |
1447 |
||
0 | 1448 |
recreate |
2258 | 1449 |
"after snapin or a migration, labels dimensions may have changed due to |
0 | 1450 |
different font parameters" |
1451 |
||
1452 |
super recreate. |
|
1453 |
self computeLabelSize. |
|
1454 |
self computeLabelOrigin |
|
2592 | 1455 |
! |
1456 |
||
1457 |
release |
|
1458 |
labelChannel notNil ifTrue:[ |
|
1459 |
labelChannel removeDependent:self. |
|
1460 |
labelChannel := nil. |
|
1461 |
]. |
|
5746 | 1462 |
self stopAnimation. |
2592 | 1463 |
super release |
0 | 1464 |
! ! |
1465 |
||
5746 | 1466 |
!Label methodsFor:'label animation'! |
1467 |
||
1468 |
animationDelay |
|
1469 |
^ 100 milliseconds |
|
1470 |
! |
|
1471 |
||
1472 |
animationDelayTopOrBottom |
|
1473 |
^ 3 seconds |
|
1474 |
! |
|
1475 |
||
1476 |
doAnimate |
|
1477 |
"by slow scrolling the label, ensure that the label's text is readable. |
|
1478 |
(stops when the cursor enters)" |
|
1479 |
||
5751 | 1480 |
|animatorState offset atTop atBottom nextOffset nextMoveDirection nextAnimationDelay focusView| |
5746 | 1481 |
|
5751 | 1482 |
animatorState := self objectAttributeAt:#animator. |
1483 |
animatorState isNil ifTrue:[^ self "I have been stopped in the meanwhile"]. |
|
5746 | 1484 |
|
5785 | 1485 |
(gc drawableId isNil) ifTrue:[ |
5749 | 1486 |
"/ view has been closed. |
5751 | 1487 |
self stopAnimation. |
5749 | 1488 |
^ self |
1489 |
]. |
|
5751 | 1490 |
logo == (animatorState logoShown) ifFalse:[ |
5750 | 1491 |
"/ logo changed - stop it |
5751 | 1492 |
self stopAnimation. |
5750 | 1493 |
^ self |
1494 |
]. |
|
5752 | 1495 |
shown ifFalse:[ |
1496 |
"/ currently invisible (iconified/hidden) |
|
1497 |
Processor addTimedBlock:(animatorState timedBlock) after:self animationDelayTopOrBottom. |
|
1498 |
self computeLabelOrigin. |
|
1499 |
^ self. |
|
1500 |
]. |
|
5755 | 1501 |
(controller notNil and:[controller entered]) ifTrue:[ |
1502 |
"/ pause animation |
|
1503 |
Processor addTimedBlock:(animatorState timedBlock) after:0.5 seconds. |
|
1504 |
^ self. |
|
1505 |
]. |
|
5750 | 1506 |
|
5752 | 1507 |
offset := animatorState nextOffset max:0. |
1508 |
||
1509 |
atTop := (offset <= 0). |
|
1510 |
"/ Transcript printf:'labelHeight: %d offset: %d fA: %d fH: %d height: %d\n' |
|
1511 |
"/ withAll:{ labelHeight . offset . self font ascent . self font height . height }. |
|
1512 |
"/ (labelHeight - offset) is restHeight |
|
1513 |
atBottom := (labelHeight - offset) < height. |
|
5746 | 1514 |
|
5749 | 1515 |
nextAnimationDelay := (atTop | atBottom) |
1516 |
ifTrue:[ self animationDelayTopOrBottom ] |
|
1517 |
ifFalse:[ self animationDelay ]. |
|
1518 |
||
5751 | 1519 |
nextMoveDirection := animatorState moveDirection. |
1520 |
atTop ifTrue:[ |
|
1521 |
nextMoveDirection := #down |
|
1522 |
]. |
|
1523 |
||
5746 | 1524 |
atBottom ifTrue:[ |
1525 |
"/ after a longer delay, start again from top |
|
5751 | 1526 |
"/ nextOffset := 0. |
1527 |
"/ nextMoveDirection := #down. |
|
1528 |
"/ after a longer delay, start moving up again (fast) |
|
1529 |
nextOffset := offset - 1. |
|
1530 |
nextMoveDirection := #up. |
|
1531 |
] ifFalse:[ |
|
1532 |
nextMoveDirection == #down ifTrue:[ |
|
1533 |
nextOffset := offset + 1. |
|
1534 |
] ifFalse:[ |
|
5752 | 1535 |
nextOffset := offset - 2. |
1536 |
nextAnimationDelay := nextAnimationDelay / 4. "/ fast |
|
5751 | 1537 |
]. |
5746 | 1538 |
]. |
5749 | 1539 |
|
1540 |
"/ If I am not part of the active window, scroll back to top and wait longer... |
|
1541 |
((focusView := Display focusView) notNil |
|
1542 |
and:[ focusView windowGroup == self windowGroup ]) ifFalse:[ |
|
1543 |
nextOffset := offset := 0. |
|
1544 |
nextAnimationDelay := self animationDelayTopOrBottom. |
|
5751 | 1545 |
nextMoveDirection := #down. |
5749 | 1546 |
]. |
1547 |
||
5746 | 1548 |
labelOriginY := offset negated. |
5751 | 1549 |
animatorState nextOffset:nextOffset. |
1550 |
animatorState moveDirection:nextMoveDirection. |
|
5749 | 1551 |
|
5746 | 1552 |
self invalidate. |
5751 | 1553 |
Processor addTimedBlock:(animatorState timedBlock) after:nextAnimationDelay. |
5746 | 1554 |
! |
1555 |
||
1556 |
startAnimation |
|
5749 | 1557 |
"start an animator, which scrolls the label's text. |
5746 | 1558 |
(slow scroll which stops when the cursor enters)" |
1559 |
||
5751 | 1560 |
|timedBlock| |
5746 | 1561 |
|
5755 | 1562 |
self enableEnterLeaveEvents. |
1563 |
||
5746 | 1564 |
self stopAnimation. |
5749 | 1565 |
|
5751 | 1566 |
timedBlock := [ self doAnimate ]. |
1567 |
self |
|
1568 |
objectAttributeAt:#animator |
|
1569 |
put:(AnimatorState new |
|
1570 |
timedBlock:timedBlock |
|
1571 |
nextOffset:0 |
|
1572 |
moveDirection:#down |
|
1573 |
logoShown:logo). |
|
1574 |
Processor addTimedBlock:timedBlock after:(self animationDelay) |
|
5746 | 1575 |
|
1576 |
" |
|
1577 |
|l| |
|
1578 |
l := Label new. |
|
1579 |
l height:30. |
|
1580 |
l sizeFixed:true. |
|
1581 |
l label:'Line1 |
|
1582 |
Line2 |
|
1583 |
Line3 |
|
1584 |
Line4'. |
|
1585 |
l openAndWait. |
|
1586 |
l startAnimation. |
|
1587 |
Delay waitForSeconds:10. |
|
1588 |
l stopAnimation. |
|
1589 |
" |
|
1590 |
! |
|
1591 |
||
1592 |
stopAnimation |
|
5751 | 1593 |
|animatorState timedBlock| |
5746 | 1594 |
|
5751 | 1595 |
animatorState := self removeObjectAttribute:#animator. |
1596 |
animatorState notNil ifTrue:[ |
|
1597 |
timedBlock := animatorState timedBlock. |
|
1598 |
Processor removeTimedBlock:timedBlock. |
|
1599 |
||
1600 |
"/ ensure that things are in their normal state again |
|
1601 |
self computeLabelOrigin. |
|
5749 | 1602 |
shown ifTrue:[ |
1603 |
self invalidate. |
|
1604 |
]. |
|
5746 | 1605 |
]. |
1606 |
! ! |
|
1607 |
||
4670 | 1608 |
!Label methodsFor:'menu'! |
1609 |
||
1610 |
copyLabelText |
|
1611 |
|text| |
|
1612 |
||
1613 |
text := logo asString. |
|
1614 |
self setClipboardText:text. |
|
1615 |
! |
|
1616 |
||
1617 |
middleButtonMenu |
|
1618 |
|m| |
|
1619 |
||
1620 |
m := super middleButtonMenu. |
|
1621 |
m isNil ifTrue:[ |
|
4672 | 1622 |
m := self yellowButtonMenu. |
1623 |
m isNil ifTrue:[ |
|
1624 |
"/ not a customized menu |
|
1625 |
self class == Label ifTrue:[ |
|
1626 |
m := self class middleButtonMenu |
|
1627 |
] |
|
4670 | 1628 |
]. |
1629 |
]. |
|
1630 |
^ m |
|
1631 |
! ! |
|
1632 |
||
5123 | 1633 |
!Label methodsFor:'native widget support'! |
1634 |
||
1635 |
nativeWindowType |
|
1636 |
"return a symbol describing my native window type |
|
5538 | 1637 |
(may be used internally by the device as a native window creation hint, |
1638 |
if the device supports native windows)" |
|
5123 | 1639 |
|
1640 |
self class == Label ifTrue:[ |
|
1641 |
^ #Label |
|
1642 |
]. |
|
1643 |
^ nil |
|
1644 |
! ! |
|
1645 |
||
202 | 1646 |
!Label methodsFor:'private'! |
1647 |
||
1648 |
computeLabelOrigin |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1649 |
"(re)compute the origin of the label whenever label, font or view-size changes" |
202 | 1650 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1651 |
|x y a| |
202 | 1652 |
|
1653 |
labelHeight isNil ifTrue:[^ self]. |
|
1654 |
||
1655 |
adjust == #fit ifTrue:[ |
|
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1656 |
labelOriginX := labelOriginY := margin. |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1657 |
^ self |
202 | 1658 |
]. |
1659 |
||
1660 |
"if it does not fit, should we make the origin visible, |
|
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1661 |
or the center ? |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1662 |
(for text, the center seems better. |
5587 | 1663 |
For images, I don't really know ...) |
202 | 1664 |
The commented code below makes the origin visible |
1665 |
" |
|
1666 |
"/ (labelHeight < height) ifTrue:[ |
|
1667 |
"/ y := (height - labelHeight) // 2 |
|
1668 |
"/ ] ifFalse:[ |
|
1669 |
"/ y := 0 |
|
1670 |
"/ ]. |
|
1671 |
||
1672 |
"always center vertically" |
|
1673 |
y := (height - labelHeight) // 2. |
|
1674 |
||
1675 |
labelOriginY := y. |
|
1676 |
||
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1677 |
a := adjust. |
1945 | 1678 |
a == #centerEach ifTrue:[a := #center]. |
1679 |
||
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1680 |
(width < labelWidth) ifTrue:[ |
1921 | 1681 |
((a == #centerRight) or:[a == #leftRight]) ifTrue:[ |
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1682 |
a := #right |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1683 |
] ifFalse:[ |
1921 | 1684 |
((a == #centerLeft) or:[a == #rightLeft]) ifTrue:[ |
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1685 |
a := #left |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1686 |
]. |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1687 |
] |
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1688 |
] ifFalse:[ |
1921 | 1689 |
((a == #centerRight) or:[a == #centerLeft]) ifTrue:[ |
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1690 |
a := #center |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1691 |
] ifFalse:[ |
1921 | 1692 |
a == #leftRight ifTrue:[ |
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1693 |
a := #left |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1694 |
] ifFalse:[ |
1921 | 1695 |
a == #rightLeft ifTrue:[ |
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1696 |
a := #right |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1697 |
] |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1698 |
] |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1699 |
] |
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1700 |
]. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1701 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1702 |
(a == #center) ifTrue:[ |
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1703 |
" center text/form in button " |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1704 |
x := (width - labelWidth) // 2. |
202 | 1705 |
] ifFalse:[ |
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1706 |
(a == #left) ifTrue:[ |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1707 |
x := margin |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1708 |
] ifFalse:[ |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1709 |
"/ #right |
5445 | 1710 |
x := width - labelWidth - margin - self extraMarginForBorder |
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1711 |
] |
202 | 1712 |
]. |
1713 |
labelOriginX := x |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1714 |
|
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1715 |
"Modified: 13.5.1996 / 10:55:17 / cg" |
202 | 1716 |
! |
1717 |
||
1718 |
computeLabelSize |
|
3999
f605cc13731e
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
1719 |
"compute the extent needed to hold the logo" |
202 | 1720 |
|
3999
f605cc13731e
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
1721 |
|ext| |
202 | 1722 |
|
1723 |
logo isNil ifTrue:[^ self]. |
|
1724 |
||
3999
f605cc13731e
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
1725 |
ext := self rawLabelSizeOf:logo. |
f605cc13731e
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
1726 |
labelWidth := ext x. |
f605cc13731e
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
1727 |
labelHeight := ext y. |
202 | 1728 |
! |
1729 |
||
1730 |
getLabelFromModel |
|
1731 |
"ask my model for the label to show. |
|
1732 |
Here, we use labelMsg (instead of aspectMsg). |
|
1733 |
This allows multiple labels to react on the same aspect, |
|
1734 |
but show different labels when changed |
|
1735 |
(also, since labelMsg defaults to nil, constant labels |
|
5782 | 1736 |
which have a nil labelMsg will not try to acquire a labelString)." |
202 | 1737 |
|
1738 |
|val| |
|
1739 |
||
1740 |
(model notNil |
|
1741 |
and:[labelMsg notNil]) ifTrue:[ |
|
5782 | 1742 |
val := model perform:labelMsg. |
1743 |
converter notNil ifTrue:[ |
|
1744 |
val := converter printStringFor:val |
|
1745 |
]. |
|
1746 |
self label:val. |
|
202 | 1747 |
]. |
1748 |
! |
|
1749 |
||
1750 |
newLayout |
|
1751 |
"recompute position/size after a change |
|
1752 |
- helper for form:/font: etc." |
|
1753 |
||
1754 |
self computeLabelSize. |
|
3499 | 1755 |
|
202 | 1756 |
fixSize ifFalse:[ |
3499 | 1757 |
self resize. |
1758 |
] ifTrue:[ |
|
1759 |
self computeLabelOrigin. |
|
202 | 1760 |
]. |
2913
bdf4fb09cfc0
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2751
diff
changeset
|
1761 |
self invalidate |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
1762 |
|
1554
b05a50854c76
redrawNow for visible changes.
Claus Gittinger <cg@exept.de>
parents:
1509
diff
changeset
|
1763 |
"Modified: / 6.6.1998 / 19:23:45 / cg" |
5943 | 1764 |
! |
1765 |
||
1766 |
rawLabelSizeOf:aLogo |
|
1767 |
"compute the extent needed to hold aLogo; aForm or aString" |
|
1768 |
||
1769 |
|logoUsed numberOfLines w h textHeight textWidth bounds| |
|
1770 |
||
1771 |
logoUsed := aLogo. |
|
1772 |
aLogo isString ifTrue:[ |
|
1773 |
numberOfLines := 1 + (aLogo occurrencesOf:(Character cr)). |
|
1774 |
(numberOfLines ~~ 1) ifTrue:[ |
|
1775 |
logoUsed := aLogo asStringCollection |
|
1776 |
] |
|
1777 |
] ifFalse:[ |
|
1778 |
(aLogo isStringCollection) ifTrue:[ |
|
1779 |
numberOfLines := aLogo size. |
|
1780 |
(numberOfLines <= 1) ifTrue:[ |
|
1781 |
logoUsed := aLogo asString |
|
1782 |
] |
|
1783 |
] |
|
1784 |
]. |
|
1785 |
||
1786 |
numberOfLines isNil ifTrue:[ |
|
1787 |
"logoUsed is neither a String nor a StringCollection" |
|
1788 |
(logoUsed respondsTo:#preferredBounds) ifTrue:[ |
|
1789 |
bounds := logoUsed preferredBounds. |
|
1790 |
w := bounds width. |
|
1791 |
h := bounds height. |
|
1792 |
] ifFalse:[ |
|
1793 |
w := logoUsed widthOn:self. |
|
1794 |
h := logoUsed heightOn:self. |
|
1795 |
]. |
|
1796 |
||
1797 |
"/ b := logoUsed bounds. |
|
1798 |
"/ labelWidth := b right. |
|
1799 |
"/ labelHeight := b bottom. |
|
1800 |
logoUsed isImageOrForm ifFalse:[ |
|
1801 |
w := w + (hSpace * 2). |
|
1802 |
h := h + (vSpace * 2). |
|
1803 |
]. |
|
1804 |
^ w@h |
|
1805 |
]. |
|
1806 |
||
1807 |
logoUsed isString ifTrue:[ |
|
1808 |
"/ a string or Text |
|
1809 |
textHeight := logoUsed heightOn:self. |
|
1810 |
textWidth := logoUsed widthOn:self. |
|
1811 |
] ifFalse:[ |
|
1812 |
"/ a StringCollection |
|
1813 |
textHeight := (gc font height) * numberOfLines. |
|
1814 |
||
1815 |
textWidth := 0. |
|
1816 |
logoUsed do:[:line | |
|
1817 |
|thisWidth| |
|
1818 |
||
1819 |
line notNil ifTrue:[ |
|
1820 |
thisWidth := line asString widthOn:self. |
|
1821 |
textWidth := textWidth max:thisWidth |
|
1822 |
] |
|
1823 |
]. |
|
1824 |
]. |
|
1825 |
||
1826 |
w := textWidth + (hSpace * 2). |
|
1827 |
h := textHeight + (vSpace * 2). |
|
1828 |
^ w@h |
|
1829 |
||
1830 |
"Modified: / 05-12-2011 / 22:35:44 / cg" |
|
202 | 1831 |
! ! |
1832 |
||
1833 |
!Label methodsFor:'queries'! |
|
1834 |
||
4670 | 1835 |
isTextLabel |
1836 |
^ logo isString |
|
1837 |
! |
|
1838 |
||
202 | 1839 |
preferredExtent |
1840 |
"return my preferred extent - this is the minimum size I would like to have" |
|
1841 |
||
5943 | 1842 |
|ext m2| |
202 | 1843 |
|
4003
1ec317f51033
preferredExtent code cleanup
Claus Gittinger <cg@exept.de>
parents:
3999
diff
changeset
|
1844 |
"/ If I have an explicit preferredExtent... |
3751
8c607457ad94
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3651
diff
changeset
|
1845 |
explicitExtent notNil ifTrue:[ |
8c607457ad94
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3651
diff
changeset
|
1846 |
^ explicitExtent |
8c607457ad94
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3651
diff
changeset
|
1847 |
]. |
4003
1ec317f51033
preferredExtent code cleanup
Claus Gittinger <cg@exept.de>
parents:
3999
diff
changeset
|
1848 |
"/ If I have a cached preferredExtent value... |
713
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
1849 |
preferredExtent notNil ifTrue:[ |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
1850 |
^ preferredExtent |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
1851 |
]. |
4003
1ec317f51033
preferredExtent code cleanup
Claus Gittinger <cg@exept.de>
parents:
3999
diff
changeset
|
1852 |
"/ If I have a frozen extent value... |
1ec317f51033
preferredExtent code cleanup
Claus Gittinger <cg@exept.de>
parents:
3999
diff
changeset
|
1853 |
fixSize ifTrue:[ |
1ec317f51033
preferredExtent code cleanup
Claus Gittinger <cg@exept.de>
parents:
3999
diff
changeset
|
1854 |
^ self extent |
1ec317f51033
preferredExtent code cleanup
Claus Gittinger <cg@exept.de>
parents:
3999
diff
changeset
|
1855 |
]. |
361
b5cb40f55316
if size is fixed, return my actual size in #preferredExtent
ca
parents:
318
diff
changeset
|
1856 |
|
303
8408cec09472
if undefined, set label to empty string when asked for preferredExtent (would otherwise return 0@0)
ah
parents:
275
diff
changeset
|
1857 |
logo isNil ifTrue:[ |
361
b5cb40f55316
if size is fixed, return my actual size in #preferredExtent
ca
parents:
318
diff
changeset
|
1858 |
self label:'' |
202 | 1859 |
]. |
4003
1ec317f51033
preferredExtent code cleanup
Claus Gittinger <cg@exept.de>
parents:
3999
diff
changeset
|
1860 |
ext := self rawLabelSizeOf:logo. |
5943 | 1861 |
m2 := (margin + self extraMarginForBorder) * 2. |
1862 |
^ (m2 + ext x + hSpace) @ (m2 + vSpace + ext y) |
|
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1863 |
|
799 | 1864 |
"Modified: 19.7.1996 / 20:44:41 / cg" |
993 | 1865 |
! |
1866 |
||
1867 |
redrawsFull |
|
1868 |
^ true |
|
1869 |
||
1870 |
"Created: 7.2.1997 / 16:41:41 / cg" |
|
202 | 1871 |
! ! |
1872 |
||
0 | 1873 |
!Label methodsFor:'redrawing'! |
1874 |
||
77 | 1875 |
clearInsideWith:bg |
1876 |
|cutOff mustClear| |
|
0 | 1877 |
|
1878 |
cutOff := margin * 2. |
|
1879 |
||
3 | 1880 |
mustClear := true. |
1881 |
||
87 | 1882 |
(logo notNil and:[logo isImageOrForm]) ifTrue:[ |
6052 | 1883 |
(labelOriginX == 0 and:[labelOriginY == 0]) ifTrue:[ |
1884 |
logo width >= (width - cutOff) ifTrue:[ |
|
1885 |
logo height >= (height - cutOff) ifTrue:[ |
|
1886 |
"no need to clear before - avoid flicker" |
|
1887 |
mustClear := false |
|
1888 |
] |
|
1889 |
] |
|
1890 |
]. |
|
3 | 1891 |
]. |
1892 |
||
1893 |
mustClear ifTrue:[ |
|
6052 | 1894 |
gc paint:bg. |
1895 |
gc fillRectangleX:margin y:margin width:(width - cutOff) height:(height - cutOff). |
|
3 | 1896 |
]. |
77 | 1897 |
! |
1898 |
||
3850
8886e358dfe1
refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents:
3751
diff
changeset
|
1899 |
drawImageLogo:imageOrForm x:x y:y opaque:opaque |
8886e358dfe1
refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents:
3751
diff
changeset
|
1900 |
(opaque not or:[imageOrForm mask notNil]) ifTrue:[ |
6052 | 1901 |
gc displayForm:imageOrForm x:x y:y |
3850
8886e358dfe1
refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents:
3751
diff
changeset
|
1902 |
] ifFalse:[ |
6052 | 1903 |
gc displayOpaqueForm:imageOrForm x:x y:y |
3850
8886e358dfe1
refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents:
3751
diff
changeset
|
1904 |
] |
8886e358dfe1
refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents:
3751
diff
changeset
|
1905 |
! |
8886e358dfe1
refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents:
3751
diff
changeset
|
1906 |
|
8886e358dfe1
refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents:
3751
diff
changeset
|
1907 |
drawOtherLogo:something x:x y:y opaque:opaque |
8886e358dfe1
refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents:
3751
diff
changeset
|
1908 |
something displayOn:self x:x y:y opaque:opaque |
8886e358dfe1
refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents:
3751
diff
changeset
|
1909 |
! |
8886e358dfe1
refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents:
3751
diff
changeset
|
1910 |
|
8886e358dfe1
refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents:
3751
diff
changeset
|
1911 |
drawStringLogo:aString x:x y:y |
6052 | 1912 |
gc displayString:aString x:x y:y |
3850
8886e358dfe1
refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents:
3751
diff
changeset
|
1913 |
! |
8886e358dfe1
refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents:
3751
diff
changeset
|
1914 |
|
1679 | 1915 |
drawWin95FocusFrame |
1891 | 1916 |
|m1 m2| |
1917 |
||
1918 |
m1 := margin + 1. |
|
1919 |
m2 := margin + margin + 2. |
|
1679 | 1920 |
self |
1891 | 1921 |
displayDottedRectangleX:m1 |
1922 |
y:m1 |
|
1923 |
width:(width - m2) |
|
1924 |
height:(height - m2). |
|
1679 | 1925 |
|
1926 |
"Created: / 17.9.1998 / 14:16:46 / cg" |
|
1891 | 1927 |
"Modified: / 29.4.1999 / 21:49:22 / cg" |
1679 | 1928 |
! |
1929 |
||
77 | 1930 |
drawWith:fg and:bg |
1931 |
"redraw my label with fg/bg - this generic method is also used by subclasses |
|
1932 |
(especially Button) to redraw the logo in different colors." |
|
1933 |
||
2496 | 1934 |
self drawWith:fg and:bg clearInside:true etchedFg:etchedFgColor. |
1935 |
! |
|
1936 |
||
1937 |
drawWith:fg and:bg clearInside:doClear etchedFg:etchedFg |
|
1938 |
"redraw my label with fg/bg - this generic method is also used by subclasses |
|
1939 |
(especially Button) to redraw the logo in different colors." |
|
1940 |
||
5983 | 1941 |
|x y scaleH scaleV nW nH hSep vSep m2 ascent currentTransformation |
1942 |
logoWidth logoHeight| |
|
77 | 1943 |
|
2496 | 1944 |
doClear ifTrue:[self clearInsideWith:bg]. |
0 | 1945 |
|
6052 | 1946 |
gc paint:fg on:bg. |
0 | 1947 |
logo notNil ifTrue:[ |
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1948 |
m2 := margin * 2. |
4899 | 1949 |
hSep := hSpace*2. |
1950 |
vSep := vSpace*2. |
|
133 | 1951 |
|
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1952 |
x := labelOriginX. |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1953 |
y := labelOriginY. |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1954 |
|
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1955 |
logo isImageOrForm ifTrue:[ |
5983 | 1956 |
logoWidth := logo width. |
1957 |
logoHeight := logo height. |
|
1958 |
((logoWidth == 0) or:[logoHeight == 0]) ifTrue:[ |
|
1959 |
"/ do nothing; also avoids followup errors in the image creation and division by zero... |
|
1960 |
^ self. |
|
1961 |
]. |
|
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1962 |
adjust == #fit ifTrue:[ |
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1963 |
"/ |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1964 |
"/ change scale to make the logo fit exactly |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1965 |
"/ |
5983 | 1966 |
scaleH := ((width - hSep) / logoWidth) asFloat. |
1967 |
scaleV := ((height - vSep) / logoHeight) asFloat. |
|
2968 | 1968 |
scaleH <= 0 ifTrue:[scaleH := Float epsilon]. |
1969 |
scaleV <= 0 ifTrue:[scaleV := Float epsilon]. |
|
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1970 |
self scale:(scaleH @ scaleV). |
4899 | 1971 |
x := currentTransformation applyInverseScaleX:x. |
1972 |
y := currentTransformation applyInverseScaleY:y. |
|
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1973 |
]. |
131 | 1974 |
|
5633 | 1975 |
logo := logo onDevice:device. |
59 | 1976 |
"/ self background:bg. |
3850
8886e358dfe1
refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents:
3751
diff
changeset
|
1977 |
self drawImageLogo:logo x:x y:y opaque:doClear. |
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1978 |
] ifFalse:[ |
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1979 |
x := x + hSpace. |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1980 |
y := y + vSpace. |
0 | 1981 |
|
1665 | 1982 |
level < 0 ifTrue:[ |
1983 |
x := x + 1. |
|
1984 |
y := y + 1 |
|
1659
9b2b15f77813
with positive level, draw string label offset by one pixel.
Claus Gittinger <cg@exept.de>
parents:
1650
diff
changeset
|
1985 |
]. |
9b2b15f77813
with positive level, draw string label offset by one pixel.
Claus Gittinger <cg@exept.de>
parents:
1650
diff
changeset
|
1986 |
|
3651
c47e8c3583cf
Remove type specific vodoo - ask logo for ascent instead.
Stefan Vogel <sv@exept.de>
parents:
3649
diff
changeset
|
1987 |
ascent := logo ascentOn:self. |
c47e8c3583cf
Remove type specific vodoo - ask logo for ascent instead.
Stefan Vogel <sv@exept.de>
parents:
3649
diff
changeset
|
1988 |
y := y + ascent. |
c47e8c3583cf
Remove type specific vodoo - ask logo for ascent instead.
Stefan Vogel <sv@exept.de>
parents:
3649
diff
changeset
|
1989 |
|
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1990 |
adjust == #fit ifTrue:[ |
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1991 |
"/ |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1992 |
"/ change scale to make the logo fit exactly |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1993 |
"/ |
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1994 |
scaleH := ((width - m2 - hSep) / (labelWidth - hSpace)) asFloat. |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1995 |
scaleV := ((height - m2 - vSep) / (labelHeight - vSpace)) asFloat. |
2968 | 1996 |
scaleH <= 0 ifTrue:[scaleH := Float epsilon]. |
1997 |
scaleV <= 0 ifTrue:[scaleV := Float epsilon]. |
|
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1998 |
|
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1999 |
self scale:(scaleH min:scaleV). |
4899 | 2000 |
currentTransformation := gc transformation. |
2001 |
x := currentTransformation applyInverseScaleX:x. |
|
3651
c47e8c3583cf
Remove type specific vodoo - ask logo for ascent instead.
Stefan Vogel <sv@exept.de>
parents:
3649
diff
changeset
|
2002 |
ascent ~~ 0 ifTrue:[ |
4899 | 2003 |
y := y - ascent + (currentTransformation applyScaleY:ascent). |
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
2004 |
]. |
4899 | 2005 |
y := currentTransformation applyInverseScaleY:y. |
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
2006 |
scaleH < scaleV ifTrue:[ |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
2007 |
nH := labelHeight * scaleH. |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
2008 |
"/ now, center vertically |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
2009 |
y := y + ((height - nH - m2 - vSep) / scaleH / 2). |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
2010 |
]. |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
2011 |
scaleV < scaleH ifTrue:[ |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
2012 |
"/ now, center horizontally |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
2013 |
nW := labelWidth * scaleV. |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
2014 |
x := x + ((width - nW - m2 - hSep) / scaleV / 2) |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
2015 |
]. |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
2016 |
]. |
131 | 2017 |
|
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
2018 |
logo isString ifTrue:[ |
2496 | 2019 |
"/ doClear ifTrue:[ |
2020 |
"/ self displayOpaqueString:logo x:x y:y |
|
2021 |
"/ ] ifFalse:[ |
|
2022 |
"/ self displayString:logo x:x y:y |
|
2023 |
"/ ] |
|
2024 |
etchedFg notNil ifTrue:[ |
|
6052 | 2025 |
gc paint:etchedFg. |
3850
8886e358dfe1
refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents:
3751
diff
changeset
|
2026 |
self drawStringLogo:logo x:x+1 y:y+1. |
6052 | 2027 |
gc paint:fg. |
2496 | 2028 |
]. |
3850
8886e358dfe1
refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents:
3751
diff
changeset
|
2029 |
self drawStringLogo:logo x:x y:y |
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
2030 |
] ifFalse:[ |
1754
e93ca7cf9d17
eliminated some #isKindOf: calls.
Claus Gittinger <cg@exept.de>
parents:
1679
diff
changeset
|
2031 |
(logo isStringCollection) ifTrue:[ |
2496 | 2032 |
logo do:[ :line | |
2033 |
|wThis str| |
|
2034 |
||
1945 | 2035 |
adjust == #centerEach ifTrue:[ |
2036 |
wThis := line asString widthOn:self. |
|
2037 |
x := (width - wThis) // 2. |
|
2038 |
]. |
|
2496 | 2039 |
str := line printString. |
2040 |
"/ doClear ifTrue:[ |
|
2041 |
"/ self displayOpaqueString:str x:x y:y. |
|
2042 |
"/ ] ifFalse:[ |
|
2043 |
"/ self displayString:str x:x y:y. |
|
2044 |
"/ ]. |
|
2045 |
etchedFg notNil ifTrue:[ |
|
6052 | 2046 |
gc paint:etchedFg. |
3850
8886e358dfe1
refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents:
3751
diff
changeset
|
2047 |
self drawStringLogo:str x:x+1 y:y+1. |
6052 | 2048 |
gc paint:fg. |
2496 | 2049 |
]. |
3850
8886e358dfe1
refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents:
3751
diff
changeset
|
2050 |
self drawStringLogo:str x:x y:y. |
4891 | 2051 |
y := y + (gc font height) |
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
2052 |
] |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
2053 |
] ifFalse:[ |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
2054 |
"/ anything |
3850
8886e358dfe1
refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents:
3751
diff
changeset
|
2055 |
self drawOtherLogo:logo x:x y:y opaque:doClear |
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
2056 |
] |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
2057 |
]. |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
2058 |
]. |
131 | 2059 |
|
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
2060 |
adjust == #fit ifTrue:[ |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
2061 |
self scale:1 |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
2062 |
]. |
0 | 2063 |
] |
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
2064 |
|
1659
9b2b15f77813
with positive level, draw string label offset by one pixel.
Claus Gittinger <cg@exept.de>
parents:
1650
diff
changeset
|
2065 |
"Modified: / 6.9.1998 / 22:35:53 / cg" |
0 | 2066 |
! |
2067 |
||
2068 |
redraw |
|
2069 |
"redraw my label" |
|
2070 |
||
2071 |
shown ifTrue:[ |
|
3924 | 2072 |
self clear. |
2073 |
self drawWith:fgColor and:bgColor |
|
0 | 2074 |
] |
2075 |
! ! |
|
105 | 2076 |
|
110 | 2077 |
!Label methodsFor:'resizing'! |
2078 |
||
2079 |
forceResize |
|
118 | 2080 |
"resize myself to make text fit into myself. Here, this is done even if |
2081 |
fixSize is set." |
|
110 | 2082 |
|
2664 | 2083 |
|prevFixSize| |
2084 |
||
110 | 2085 |
logo notNil ifTrue:[ |
2664 | 2086 |
prevFixSize := fixSize. |
2087 |
fixSize := false. |
|
2088 |
self extent:self preferredExtent. |
|
2089 |
self computeLabelOrigin. |
|
3499 | 2090 |
"/ this seems the only one which might depend on my contents. |
2091 |
layout isLayout ifTrue:[ |
|
2092 |
layout isAlignmentOrigin ifTrue:[ |
|
2093 |
self containerChangedSize. |
|
2094 |
] |
|
2095 |
]. |
|
2664 | 2096 |
fixSize := prevFixSize. |
2097 |
] |
|
2098 |
! |
|
2099 |
||
2100 |
forceResizeHorizontally |
|
2101 |
"resize myself horizontally to make text fit into myself. |
|
2102 |
Here, this is done even if fixSize is set." |
|
2103 |
||
2104 |
|prevFixSize| |
|
2105 |
||
2106 |
logo notNil ifTrue:[ |
|
2107 |
prevFixSize := fixSize. |
|
2108 |
fixSize := false. |
|
3615
a99127b32e61
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3597
diff
changeset
|
2109 |
self width:self preferredWidth. |
2664 | 2110 |
self computeLabelOrigin. |
2111 |
fixSize := prevFixSize. |
|
110 | 2112 |
] |
105 | 2113 |
! |
2114 |
||
2115 |
resize |
|
2116 |
"resize myself to make text fit into myself. |
|
118 | 2117 |
but only do so, if I am not fixedSize and I have NOT been |
2118 |
given a relative extent or an extend computation block." |
|
105 | 2119 |
|
110 | 2120 |
(logo notNil |
2121 |
and:[fixSize not |
|
2122 |
and:[relativeExtent isNil |
|
2123 |
and:[extentRule isNil |
|
2124 |
and:[relativeCorner isNil |
|
2125 |
and:[cornerRule isNil]]]]]) ifTrue:[ |
|
2126 |
self forceResize |
|
2127 |
] ifFalse:[ |
|
105 | 2128 |
self computeLabelOrigin |
2129 |
] |
|
2130 |
! ! |
|
2131 |
||
5751 | 2132 |
!Label::AnimatorState methodsFor:'accessing'! |
2133 |
||
2134 |
logoShown |
|
2135 |
^ logoShown |
|
2136 |
! |
|
2137 |
||
2138 |
moveDirection |
|
2139 |
^ moveDirection |
|
2140 |
! |
|
2141 |
||
2142 |
moveDirection:something |
|
2143 |
moveDirection := something. |
|
2144 |
! |
|
2145 |
||
2146 |
nextOffset |
|
2147 |
^ nextOffset |
|
2148 |
! |
|
2149 |
||
2150 |
nextOffset:something |
|
2151 |
nextOffset := something. |
|
2152 |
! |
|
2153 |
||
5755 | 2154 |
pointerEntered |
2155 |
^ pointerEntered |
|
2156 |
! |
|
2157 |
||
2158 |
pointerEntered:something |
|
2159 |
pointerEntered := something. |
|
2160 |
! |
|
2161 |
||
5751 | 2162 |
timedBlock |
2163 |
^ timedBlock |
|
2164 |
! |
|
2165 |
||
2166 |
timedBlock:timedBlockArg nextOffset:nextOffsetArg moveDirection:moveDirectionArg logoShown:logoShownArg |
|
2167 |
timedBlock := timedBlockArg. |
|
2168 |
nextOffset := nextOffsetArg. |
|
2169 |
moveDirection := moveDirectionArg. |
|
2170 |
logoShown := logoShownArg. |
|
2171 |
! ! |
|
2172 |
||
935 | 2173 |
!Label class methodsFor:'documentation'! |
205 | 2174 |
|
2175 |
version |
|
5445 | 2176 |
^ '$Header$' |
3999
f605cc13731e
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
2177 |
! |
f605cc13731e
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
2178 |
|
f605cc13731e
computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
2179 |
version_CVS |
5445 | 2180 |
^ '$Header$' |
205 | 2181 |
! ! |
4670 | 2182 |