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