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 |
"
|
|
12 |
|
105
|
13 |
'From Smalltalk/X, Version:2.10.5 on 14-mar-1995 at 11:13:27 am'!
|
|
14 |
|
0
|
15 |
View subclass:#Label
|
105
|
16 |
instanceVariableNames:'logo labelWidth labelHeight labelOriginX labelOriginY adjust
|
118
|
17 |
hSpace vSpace bgColor fgColor fixSize labelMsg'
|
105
|
18 |
classVariableNames:'DefaultFont DefaultForegroundColor DefaultBackgroundColor'
|
|
19 |
poolDictionaries:''
|
|
20 |
category:'Views-Layout'
|
0
|
21 |
!
|
|
22 |
|
|
23 |
Label comment:'
|
5
|
24 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
59
|
25 |
All Rights Reserved
|
0
|
26 |
|
131
|
27 |
$Header: /cvs/stx/stx/libwidg/Label.st,v 1.25 1995-06-27 02:23:15 claus Exp $
|
0
|
28 |
'!
|
|
29 |
|
3
|
30 |
!Label class methodsFor:'documentation'!
|
|
31 |
|
38
|
32 |
copyright
|
|
33 |
"
|
|
34 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
59
|
35 |
All Rights Reserved
|
38
|
36 |
|
|
37 |
This software is furnished under a license and may be used
|
|
38 |
only in accordance with the terms of that license and with the
|
|
39 |
inclusion of the above copyright notice. This software may not
|
|
40 |
be provided or otherwise made available to, or used by, any
|
|
41 |
other person. No title to or ownership of the software is
|
|
42 |
hereby transferred.
|
|
43 |
"
|
|
44 |
!
|
|
45 |
|
|
46 |
version
|
|
47 |
"
|
131
|
48 |
$Header: /cvs/stx/stx/libwidg/Label.st,v 1.25 1995-06-27 02:23:15 claus Exp $
|
38
|
49 |
"
|
|
50 |
!
|
|
51 |
|
3
|
52 |
documentation
|
|
53 |
"
|
38
|
54 |
This class implements labels, which are views to display a string or image.
|
|
55 |
The Label will try to do its best to make its contents fit into the
|
|
56 |
view. The contents can be a String, a collection of Strings (i.e.
|
118
|
57 |
a StringCollection) or a Form/Image.
|
63
|
58 |
|
|
59 |
The contents is drawn in fgColor/bgColor, which can be changed using:
|
|
60 |
|
59
|
61 |
aLabel foregroundColor:aColor
|
|
62 |
aLabel backgroundColor:aColor
|
3
|
63 |
|
38
|
64 |
When a label is assigned a contents, it will resize itself to fit
|
|
65 |
the required size. This resizing can be suppressed by setting the
|
|
66 |
fixsize attribute to true using:
|
63
|
67 |
|
59
|
68 |
aLabel sizeFixed:true
|
3
|
69 |
|
38
|
70 |
This can be used, if resizing of the label is not wanted.
|
63
|
71 |
However, in this case you have to make certain that the size is big enough
|
118
|
72 |
to hold any changed logos later. (usually, you create the label first with
|
|
73 |
the longest string first to have it compute its size, then set the fixSize
|
|
74 |
attribute to avoid resizing later).
|
125
|
75 |
Be careful when placing self-resizing labels into panels - by default,
|
|
76 |
panels do not react on the size change - leading to ugly looking geometry.
|
|
77 |
(but you can tell the panel to watch for changes with #elementsCHangeSize:)
|
38
|
78 |
|
|
79 |
The placement of the contents within the label is controlled by
|
63
|
80 |
the adjust attribute, it can be set with:
|
|
81 |
|
59
|
82 |
aLabel adjust:how
|
3
|
83 |
|
63
|
84 |
where how is one of the symbols left, #right, #center, #centerLeft or
|
|
85 |
#centerRight (see the comment in Label>>adjust:). The default is #center.
|
3
|
86 |
|
118
|
87 |
model-less operation:
|
|
88 |
if no model is set, the labels contents is set with:
|
|
89 |
|
|
90 |
aLabel label:aStringOrImage
|
|
91 |
|
|
92 |
and stays constant unless changed by new calls to #label:.
|
|
93 |
|
|
94 |
|
|
95 |
model operation:
|
|
96 |
labels with a model, aspectMsg and labelMsg react to
|
|
97 |
changes of the aspect, and send a labelMsg-message
|
|
98 |
to the model in order to aquire a new labelString or image.
|
|
99 |
The model should send 'self changed:aspectMsg' if it thinks the label
|
|
100 |
should change and return a string or image from the labelMsg-message.
|
|
101 |
|
|
102 |
label model:aModel.
|
|
103 |
label aspect:aspectSymbol.
|
|
104 |
label labelMessage:labelSymbol.
|
|
105 |
|
|
106 |
model sends #changed:aspectSymbol
|
|
107 |
---> label will redraw its label from value of model perform:labelSymbol
|
|
108 |
|
|
109 |
Having a labelSymbol different from the aspectSymbol allows for two labels
|
|
110 |
to react on the same aspect-change, but use different messages when asking
|
|
111 |
the model for a new label contents. By default, the labelMsg is nil,
|
|
112 |
so the label does NOT update its shown contents.
|
|
113 |
The aspectMsg defaults to #value.
|
|
114 |
|
125
|
115 |
|
38
|
116 |
Instance variables:
|
3
|
117 |
|
59
|
118 |
logo <Object> the logo, can be a Form, String or Text
|
|
119 |
labelWidth <Integer> the width of the logo in device units
|
|
120 |
labelHeight <Integer> the height of the logo in device units
|
|
121 |
labelOriginX <Integer> the x-position of the logo withing the Label
|
|
122 |
labelOriginY <Integer> the y-position of the logo withing the Label
|
|
123 |
adjust <Symbol> controls how the logo is positioned within the
|
|
124 |
label. Can be one of:#left,#right,#center,
|
|
125 |
#centerLeft or #centerRight (see comment in adjust:)
|
|
126 |
hSpace <Integer> number of horizontal pixels around logo
|
|
127 |
vSpace <Integer> number of vertical pixels around logo
|
3
|
128 |
|
59
|
129 |
bgColor <Color> background color
|
|
130 |
fgColor <Color> foreground color
|
38
|
131 |
|
59
|
132 |
fixSize <Boolean> if true, a change of the logo change will not
|
|
133 |
resize the label; otherwise, its size is adjusted.
|
|
134 |
default:false.
|
50
|
135 |
|
118
|
136 |
labelMsg <Symbol> if non-nil, this is sent to the model to
|
|
137 |
aquire the labelString or labelImage.
|
|
138 |
If nil, the label stays as is
|
113
|
139 |
|
118
|
140 |
styleSheet parameters:
|
50
|
141 |
|
118
|
142 |
labelForegroundColor <Color> color to draw foreground pixels (i.e. the string)
|
|
143 |
labelBackgroundColor <Color> color to draw background pixels
|
|
144 |
labelFont <Font> font to use for textual labels
|
3
|
145 |
"
|
63
|
146 |
!
|
|
147 |
|
|
148 |
examples
|
|
149 |
"
|
|
150 |
Notice, that Buttons and others inherit from Label;
|
|
151 |
therefore, the following geometry examples apply to all subclasses too.
|
|
152 |
|
|
153 |
|
113
|
154 |
simple (default position is 0@0):
|
63
|
155 |
|top l|
|
|
156 |
|
|
157 |
top := StandardSystemView new.
|
|
158 |
top extent:(200 @ 200).
|
|
159 |
|
|
160 |
l := Label in:top.
|
|
161 |
l label:'hello world'.
|
|
162 |
|
|
163 |
top open
|
|
164 |
|
113
|
165 |
|
|
166 |
there is also a creation message which sets the label:
|
|
167 |
|top l|
|
|
168 |
|
|
169 |
top := StandardSystemView new.
|
|
170 |
top extent:(200 @ 200).
|
|
171 |
|
|
172 |
l := Label label:'hello world' in:top.
|
|
173 |
|
|
174 |
top open
|
|
175 |
|
|
176 |
|
63
|
177 |
placement:
|
|
178 |
|top l|
|
|
179 |
|
|
180 |
top := StandardSystemView new.
|
|
181 |
top extent:(200 @ 200).
|
|
182 |
|
|
183 |
l := Label in:top.
|
|
184 |
l label:'hello world'.
|
|
185 |
l origin:50@100.
|
|
186 |
|
|
187 |
top open
|
|
188 |
|
113
|
189 |
|
63
|
190 |
level:
|
|
191 |
|top l|
|
|
192 |
|
|
193 |
top := StandardSystemView new.
|
|
194 |
top extent:(200 @ 200).
|
|
195 |
|
|
196 |
l := Label in:top.
|
|
197 |
l level:5.
|
|
198 |
l label:'hello world'.
|
|
199 |
l origin:50@100.
|
|
200 |
|
|
201 |
top open
|
|
202 |
|
113
|
203 |
|
63
|
204 |
another level:
|
|
205 |
|top l|
|
|
206 |
|
|
207 |
top := StandardSystemView new.
|
|
208 |
top extent:(200 @ 200).
|
|
209 |
|
|
210 |
l := Label in:top.
|
|
211 |
l level:-1.
|
|
212 |
l label:'hello world'.
|
|
213 |
l origin:50@100.
|
|
214 |
|
|
215 |
top open
|
|
216 |
|
113
|
217 |
|
118
|
218 |
colors & font:
|
|
219 |
|top l|
|
|
220 |
|
|
221 |
top := StandardSystemView new.
|
|
222 |
top extent:(200 @ 200).
|
|
223 |
|
|
224 |
l := Label in:top.
|
|
225 |
l level:-1.
|
|
226 |
l font:(Font family:'Times' size:18).
|
|
227 |
l foregroundColor:Color yellow.
|
|
228 |
l backgroundColor:Color red.
|
|
229 |
l label:'hello world'.
|
|
230 |
l origin:50@100.
|
|
231 |
|
|
232 |
top open
|
|
233 |
|
|
234 |
|
63
|
235 |
border & colors:
|
|
236 |
|top l|
|
|
237 |
|
|
238 |
top := StandardSystemView new.
|
|
239 |
top extent:(200 @ 200).
|
|
240 |
|
|
241 |
l := Label in:top.
|
|
242 |
l level:0.
|
|
243 |
l borderWidth:1.
|
|
244 |
l borderColor:Color red.
|
|
245 |
l foregroundColor:Color green darkened.
|
|
246 |
l backgroundColor:Color green lightened.
|
|
247 |
l label:'hello world'.
|
|
248 |
l origin:50@100.
|
|
249 |
|
|
250 |
top open
|
|
251 |
|
113
|
252 |
|
63
|
253 |
adjust (resize to see):
|
|
254 |
|top l|
|
|
255 |
|
|
256 |
top := StandardSystemView new.
|
|
257 |
top extent:(200 @ 200).
|
|
258 |
|
|
259 |
l := Label in:top.
|
|
260 |
l borderWidth:1.
|
|
261 |
l label:'default - centered'.
|
118
|
262 |
l origin:0.0@40.
|
63
|
263 |
l width:1.0.
|
|
264 |
|
|
265 |
l := Label in:top.
|
|
266 |
l borderWidth:1.
|
|
267 |
l adjust:#left.
|
|
268 |
l label:'left adjust'.
|
118
|
269 |
l origin:0.0@70.
|
|
270 |
l width:1.0.
|
|
271 |
|
|
272 |
l := Label in:top.
|
|
273 |
l borderWidth:1.
|
|
274 |
l adjust:#centerLeft.
|
|
275 |
l label:'centerLeft adjust and a bit too long'.
|
63
|
276 |
l origin:0.0@100.
|
|
277 |
l width:1.0.
|
|
278 |
|
|
279 |
l := Label in:top.
|
|
280 |
l borderWidth:1.
|
|
281 |
l adjust:#right.
|
|
282 |
l label:'right adjust'.
|
|
283 |
l origin:0.0@130.
|
|
284 |
l width:1.0.
|
|
285 |
|
118
|
286 |
l := Label in:top.
|
|
287 |
l borderWidth:1.
|
|
288 |
l adjust:#centerRight.
|
|
289 |
l label:'centerRight adjust and a bit too long'.
|
|
290 |
l origin:0.0@160.
|
|
291 |
l width:1.0.
|
|
292 |
|
63
|
293 |
top open
|
|
294 |
|
113
|
295 |
|
131
|
296 |
fitting-adjust (resize to see):
|
|
297 |
Warning: #fit is experimental and should not be used.
|
|
298 |
|
|
299 |
|top l|
|
|
300 |
|
|
301 |
top := StandardSystemView new.
|
|
302 |
top extent:(200 @ 200).
|
|
303 |
|
|
304 |
l := Label origin:0.25 @ 0.25 corner:0.75@0.75 in:top.
|
|
305 |
l label:'stretch'.
|
|
306 |
l level:-1.
|
|
307 |
l adjust:#fit.
|
|
308 |
|
|
309 |
top open
|
|
310 |
|
|
311 |
or:
|
|
312 |
Warning: #fit is experimental and should not be used.
|
|
313 |
|
|
314 |
|top l|
|
|
315 |
|
|
316 |
top := StandardSystemView new.
|
|
317 |
top extent:(200 @ 200).
|
|
318 |
|
|
319 |
l := Label origin:0.25 @ 0.25 corner:0.75@0.75 in:top.
|
|
320 |
l label:(Image fromFile:'bitmaps/SBrowser.xbm').
|
|
321 |
l level:-1.
|
|
322 |
l adjust:#fit.
|
|
323 |
|
|
324 |
top open
|
|
325 |
|
|
326 |
|
63
|
327 |
just a reminder, that instead of doing placement manually
|
113
|
328 |
as in ...:
|
118
|
329 |
|
63
|
330 |
|top l|
|
|
331 |
|
|
332 |
top := StandardSystemView new.
|
|
333 |
top extent:(200 @ 200).
|
|
334 |
|
|
335 |
l := Label in:top.
|
|
336 |
l borderWidth:1.
|
|
337 |
l label:'default - centered'.
|
|
338 |
l origin:0.1@70.
|
|
339 |
l width:0.8.
|
|
340 |
|
|
341 |
l := Label in:top.
|
|
342 |
l borderWidth:1.
|
|
343 |
l adjust:#left.
|
|
344 |
l label:'left adjust'.
|
|
345 |
l origin:0.1@100.
|
|
346 |
l width:0.8.
|
|
347 |
|
|
348 |
l := Label in:top.
|
|
349 |
l borderWidth:1.
|
|
350 |
l adjust:#right.
|
|
351 |
l label:'right adjust'.
|
|
352 |
l origin:0.1@130.
|
|
353 |
l width:0.8.
|
|
354 |
|
|
355 |
top open
|
|
356 |
|
113
|
357 |
|
|
358 |
... it is much easier, to use a geometry handler, such as
|
63
|
359 |
a VerticalPanel. Try:
|
113
|
360 |
|
63
|
361 |
|top panel l|
|
|
362 |
|
|
363 |
top := StandardSystemView new.
|
|
364 |
top extent:(200 @ 200).
|
|
365 |
|
|
366 |
panel := VerticalPanelView
|
|
367 |
origin:0.0 @ 0.0
|
|
368 |
corner:1.0 @ 1.0
|
|
369 |
in:top.
|
|
370 |
|
|
371 |
panel horizontalLayout:#fit.
|
|
372 |
panel verticalLayout:#center.
|
|
373 |
|
|
374 |
l := Label in:panel.
|
|
375 |
l borderWidth:1.
|
|
376 |
l label:'default - centered'.
|
|
377 |
|
|
378 |
l := Label in:panel.
|
|
379 |
l borderWidth:1.
|
|
380 |
l adjust:#left.
|
|
381 |
l label:'left adjust'.
|
|
382 |
|
|
383 |
l := Label in:panel.
|
|
384 |
l borderWidth:1.
|
|
385 |
l adjust:#right.
|
|
386 |
l label:'right adjust'.
|
|
387 |
|
|
388 |
top open
|
|
389 |
|
113
|
390 |
|
63
|
391 |
labels with bitmaps or images:
|
|
392 |
|
|
393 |
|top l|
|
|
394 |
|
|
395 |
top := StandardSystemView new.
|
|
396 |
top extent:(200 @ 200).
|
|
397 |
|
|
398 |
l := Label in:top.
|
|
399 |
l level:-1.
|
118
|
400 |
l label:((Image fromFile:'bitmaps/garfield.gif') magnifyBy:0.2 @ 0.2).
|
63
|
401 |
l origin:50@100.
|
|
402 |
|
|
403 |
top open
|
113
|
404 |
|
|
405 |
|
125
|
406 |
MVC operation
|
|
407 |
model provides the label):
|
|
408 |
(have to use a plug to simulate a model which responds to
|
|
409 |
the #someAspect message):
|
113
|
410 |
|
|
411 |
|top l model|
|
|
412 |
|
|
413 |
model := Plug new.
|
|
414 |
model respondTo:#someAspect with:['models labelString'].
|
|
415 |
|
|
416 |
top := StandardSystemView new.
|
|
417 |
top extent:(200 @ 200).
|
|
418 |
|
|
419 |
l := Label in:top.
|
118
|
420 |
l model:model; labelMessage:#someAspect.
|
113
|
421 |
|
|
422 |
top open
|
118
|
423 |
...
|
|
424 |
|
|
425 |
model changed:#someAspect
|
|
426 |
...
|
113
|
427 |
|
|
428 |
|
118
|
429 |
concrete example (track a counters value):
|
125
|
430 |
(here, the default aspect #value is used both to notify the label about
|
|
431 |
changes and to aquire a new value from the model).
|
113
|
432 |
|
|
433 |
|top l model|
|
|
434 |
|
118
|
435 |
model := ValueHolder new.
|
|
436 |
model value:0.
|
|
437 |
[
|
|
438 |
1 to:20 do:[:i |
|
|
439 |
(Delay forSeconds:1) wait.
|
|
440 |
model value:i
|
|
441 |
].
|
|
442 |
top destroy
|
|
443 |
] fork.
|
113
|
444 |
|
|
445 |
top := StandardSystemView new.
|
|
446 |
top extent:(200 @ 200).
|
|
447 |
|
|
448 |
l := Label in:top.
|
125
|
449 |
l level:-1.
|
118
|
450 |
l model:model; labelMessage:#value.
|
|
451 |
|
|
452 |
top open
|
|
453 |
|
|
454 |
|
125
|
455 |
model changes aspect after a while; two labels on the same model:
|
118
|
456 |
|
|
457 |
|top l model|
|
|
458 |
|
|
459 |
model := Plug new.
|
|
460 |
model respondTo:#labelValue1 with:['models labelString1'].
|
|
461 |
model respondTo:#labelValue2 with:['models labelString2'].
|
|
462 |
|
|
463 |
top := StandardSystemView new.
|
|
464 |
top extent:(200 @ 200).
|
|
465 |
|
|
466 |
l := Label origin:0.0@0.0 corner:1.0@0.5 in:top.
|
|
467 |
l model:model; aspect:#someAspect; labelMessage:#labelValue1.
|
|
468 |
l := Label origin:0.0@0.5 corner:1.0@1.0 in:top.
|
|
469 |
l model:model; aspect:#someAspect; labelMessage:#labelValue2.
|
113
|
470 |
|
|
471 |
top open.
|
118
|
472 |
|
113
|
473 |
(Delay forSeconds:5) wait.
|
118
|
474 |
model respondTo:#labelValue1 with:['new string1'].
|
|
475 |
model respondTo:#labelValue2 with:['new string2'].
|
|
476 |
|
113
|
477 |
model changed:#someAspect
|
118
|
478 |
|
|
479 |
|
125
|
480 |
plugged MVC operation (getBlock returns the label):
|
118
|
481 |
|
|
482 |
|top l model|
|
|
483 |
|
|
484 |
model := PluggableAdaptor new
|
|
485 |
getBlock:[:m | 'hello']
|
|
486 |
putBlock:nil
|
|
487 |
updateBlock:nil.
|
|
488 |
|
|
489 |
top := StandardSystemView new.
|
|
490 |
top extent:(200 @ 200).
|
|
491 |
|
|
492 |
l := Label origin:0.0@0.0 corner:1.0@0.5 in:top.
|
|
493 |
l model:model; labelMessage:#value.
|
|
494 |
|
|
495 |
top open.
|
125
|
496 |
|
|
497 |
|
|
498 |
use different label-selectors to access fields of a complex model:
|
|
499 |
|
|
500 |
|top panel model|
|
|
501 |
|
|
502 |
model := Plug new.
|
|
503 |
model respondTo:#field1 with:['value1'].
|
|
504 |
model respondTo:#field2 with:['value2'].
|
|
505 |
model respondTo:#field3 with:['value3'].
|
|
506 |
model respondTo:#field4 with:['value4'].
|
|
507 |
|
|
508 |
top := StandardSystemView new.
|
|
509 |
|
|
510 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
|
|
511 |
panel elementsChangeSize:true.
|
|
512 |
|
|
513 |
panel addSubView:((Label on:model) labelMessage:#field1).
|
|
514 |
panel addSubView:((Label on:model) labelMessage:#field2).
|
|
515 |
panel addSubView:((Label on:model) labelMessage:#field3).
|
|
516 |
panel addSubView:((Label on:model) labelMessage:#field4).
|
|
517 |
|
|
518 |
top extent:(200 @ 200).
|
|
519 |
top open.
|
|
520 |
|
|
521 |
(Delay forSeconds:5) wait.
|
|
522 |
|
|
523 |
model respondTo:#field2 with:['new value2'].
|
|
524 |
model changed:#value
|
|
525 |
|
|
526 |
|
|
527 |
same as above, using default aspects in the label, and an adaptor
|
|
528 |
to translate aspects:
|
|
529 |
|
|
530 |
|top panel model v1|
|
|
531 |
|
|
532 |
model := Plug new.
|
|
533 |
model respondTo:#field1 with:[v1].
|
|
534 |
model respondTo:#field1: with:[:arg | v1 := arg. model changed:#field1].
|
|
535 |
model respondTo:#field2 with:['value2'].
|
|
536 |
model respondTo:#field2: with:[:arg |].
|
|
537 |
model respondTo:#field3 with:['value3'].
|
|
538 |
model respondTo:#field3: with:[:arg |].
|
|
539 |
model respondTo:#field4 with:['value4'].
|
|
540 |
model respondTo:#field4: with:[:arg |].
|
|
541 |
|
|
542 |
top := StandardSystemView new.
|
|
543 |
|
|
544 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
|
|
545 |
panel elementsChangeSize:true.
|
|
546 |
|
|
547 |
panel addSubView:((Label on:((AspectAdaptor subject:model) forAspect:#field1)) labelMessage:#value).
|
|
548 |
panel addSubView:((Label on:((AspectAdaptor subject:model) forAspect:#field2)) labelMessage:#value).
|
|
549 |
panel addSubView:((Label on:((AspectAdaptor subject:model) forAspect:#field3)) labelMessage:#value).
|
|
550 |
panel addSubView:((Label on:((AspectAdaptor subject:model) forAspect:#field4)) labelMessage:#value).
|
|
551 |
|
|
552 |
top extent:(200 @ 200).
|
|
553 |
top open.
|
|
554 |
|
|
555 |
(Delay forSeconds:5) wait.
|
|
556 |
|
|
557 |
model field1:'new value1'.
|
|
558 |
|
|
559 |
|
|
560 |
use an adapter to access fields of a complex model:
|
|
561 |
|
|
562 |
|top l panel model|
|
|
563 |
|
|
564 |
model := #('one' 'two' 'three') asValue.
|
|
565 |
|
|
566 |
top := StandardSystemView new.
|
|
567 |
|
|
568 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
|
|
569 |
panel elementsChangeSize:true.
|
|
570 |
|
|
571 |
panel addSubView:((Label on:(ProtocolAdaptor
|
|
572 |
subjectChannel:model
|
|
573 |
accessPath:#(1))) labelMessage:#value).
|
|
574 |
panel addSubView:((Label on:(ProtocolAdaptor
|
|
575 |
subjectChannel:model
|
|
576 |
accessPath:#(2))) labelMessage:#value).
|
|
577 |
panel addSubView:((Label on:(ProtocolAdaptor
|
|
578 |
subjectChannel:model
|
|
579 |
accessPath:#(3))) labelMessage:#value).
|
|
580 |
|
|
581 |
top extent:(200 @ 200).
|
|
582 |
top open.
|
|
583 |
|
|
584 |
(Delay forSeconds:5) wait.
|
|
585 |
|
|
586 |
model value:#('oneone' 'twotwo' 'threethree').
|
63
|
587 |
"
|
3
|
588 |
! !
|
|
589 |
|
105
|
590 |
!Label class methodsFor:'instance creation'!
|
|
591 |
|
|
592 |
form:aForm
|
118
|
593 |
"return a new Label showing a form.
|
|
594 |
OBSOLETE: you should now use #label: for both text and bitmap labels."
|
105
|
595 |
|
131
|
596 |
^ (self on:Screen current) form:aForm
|
105
|
597 |
!
|
|
598 |
|
|
599 |
form:aForm in:aView
|
118
|
600 |
"return a new Label showing a form.
|
|
601 |
OBSOLETE: you should now use #label:in: for both text and bitmap labels."
|
105
|
602 |
|
|
603 |
^ (self in:aView) form:aForm
|
|
604 |
! !
|
|
605 |
|
0
|
606 |
!Label class methodsFor:'defaults'!
|
|
607 |
|
|
608 |
defaultExtent
|
3
|
609 |
"return default extent"
|
0
|
610 |
|
|
611 |
^ 16 @ 16
|
59
|
612 |
!
|
|
613 |
|
118
|
614 |
defaultFont
|
|
615 |
^ DefaultFont notNil ifTrue:[DefaultFont] ifFalse:[super defaultFont]
|
|
616 |
!
|
|
617 |
|
59
|
618 |
updateStyleCache
|
77
|
619 |
DefaultForegroundColor := StyleSheet colorAt:'labelForegroundColor'.
|
|
620 |
DefaultForegroundColor isNil ifTrue:[
|
|
621 |
DefaultForegroundColor := StyleSheet colorAt:'foregroundColor' default:Black.
|
|
622 |
].
|
60
|
623 |
DefaultBackgroundColor := StyleSheet colorAt:'labelBackgroundColor'.
|
77
|
624 |
DefaultBackgroundColor isNil ifTrue:[
|
|
625 |
DefaultForegroundColor := StyleSheet colorAt:'backgroundColor'.
|
|
626 |
].
|
60
|
627 |
DefaultFont := StyleSheet fontAt:'labelFont'.
|
|
628 |
|
|
629 |
"
|
|
630 |
self updateStyleCache
|
|
631 |
"
|
0
|
632 |
! !
|
|
633 |
|
105
|
634 |
!Label methodsFor:'event handling'!
|
|
635 |
|
|
636 |
sizeChanged:how
|
|
637 |
"sent whenever size is changed by someone else - recompute the
|
|
638 |
logos position within the View."
|
|
639 |
|
|
640 |
|prevPosition|
|
|
641 |
|
|
642 |
super sizeChanged:how.
|
|
643 |
prevPosition := labelOriginX.
|
|
644 |
self computeLabelOrigin
|
|
645 |
shown ifTrue:[
|
131
|
646 |
(adjust == #fit
|
|
647 |
or:[labelOriginX ~~ prevPosition
|
|
648 |
or:[how ~~ #smaller]]) ifTrue:[
|
|
649 |
"/ self clear.
|
|
650 |
self redraw.
|
|
651 |
self redrawEdges
|
110
|
652 |
]
|
105
|
653 |
]
|
|
654 |
! !
|
|
655 |
|
125
|
656 |
!Label methodsFor:'accessing-mvc'!
|
|
657 |
|
|
658 |
model:aModel
|
|
659 |
super model:aModel.
|
|
660 |
self getLabelFromModel.
|
|
661 |
!
|
|
662 |
|
|
663 |
labelMessage
|
|
664 |
"return the symbol used to aquire the labelString/image from the model
|
|
665 |
when the aspect changes.
|
|
666 |
The default is nil, which means: leave the label unchanged."
|
|
667 |
|
|
668 |
^ labelMsg
|
|
669 |
!
|
|
670 |
|
|
671 |
labelMessage:aSymbol
|
|
672 |
"set the symbol used to aquire the labelString/image from the model.
|
|
673 |
The default is nil, which means: leave the label unchanged."
|
|
674 |
|
|
675 |
labelMsg ~~ aSymbol ifTrue:[
|
|
676 |
labelMsg := aSymbol.
|
|
677 |
self getLabelFromModel
|
|
678 |
]
|
|
679 |
!
|
|
680 |
|
|
681 |
addModelInterfaceTo:aDictionary
|
|
682 |
"see comment in View>>modelInterface"
|
|
683 |
|
|
684 |
super addModelInterfaceTo:aDictionary.
|
|
685 |
aDictionary at:#labelMessage put:labelMsg
|
|
686 |
! !
|
|
687 |
|
105
|
688 |
!Label methodsFor:'accessing'!
|
|
689 |
|
|
690 |
foregroundColor:aColor
|
|
691 |
"set the foreground color"
|
|
692 |
|
|
693 |
fgColor := aColor on:device.
|
131
|
694 |
shown ifTrue:[self redraw]
|
105
|
695 |
!
|
|
696 |
|
|
697 |
foregroundColor
|
|
698 |
"return the foreground color"
|
|
699 |
|
|
700 |
^ fgColor
|
|
701 |
!
|
|
702 |
|
|
703 |
backgroundColor:aColor
|
|
704 |
"set the background color"
|
|
705 |
|
|
706 |
bgColor := aColor on:device.
|
131
|
707 |
shown ifTrue:[self redraw]
|
105
|
708 |
!
|
|
709 |
|
|
710 |
backgroundColor
|
|
711 |
"return the background color"
|
|
712 |
|
|
713 |
^ bgColor
|
|
714 |
!
|
|
715 |
|
|
716 |
foregroundColor:fg backgroundColor:bg
|
|
717 |
"set the colors to be used for drawing"
|
|
718 |
|
|
719 |
fgColor := fg on:device.
|
|
720 |
bgColor := bg on:device.
|
131
|
721 |
shown ifTrue:[self redraw]
|
105
|
722 |
!
|
0
|
723 |
|
118
|
724 |
labelString:aString
|
|
725 |
"for ST-80 compatibility: same as #label:
|
|
726 |
set the label-string; adjust extent if not already realized and not fixedSize"
|
|
727 |
|
|
728 |
self label:aString
|
|
729 |
!
|
105
|
730 |
|
118
|
731 |
label:aStringOrFormOrImage
|
|
732 |
"set the labelString or image; adjust extent if not already realized and
|
|
733 |
not fixedSize"
|
|
734 |
|
|
735 |
(aStringOrFormOrImage ~~ logo) ifTrue:[
|
|
736 |
"/
|
|
737 |
"/ avoid recompute of size, if its an image with
|
|
738 |
"/ the same size
|
|
739 |
"/
|
|
740 |
aStringOrFormOrImage isImageOrForm ifTrue:[
|
|
741 |
logo notNil ifTrue:[
|
|
742 |
logo isImageOrForm ifTrue:[
|
|
743 |
logo extent = aStringOrFormOrImage extent ifTrue:[
|
|
744 |
logo := aStringOrFormOrImage.
|
|
745 |
^ self
|
|
746 |
]
|
105
|
747 |
]
|
|
748 |
]
|
118
|
749 |
] ifFalse:[
|
|
750 |
(logo = aStringOrFormOrImage) ifTrue:[
|
|
751 |
^ self
|
|
752 |
]
|
105
|
753 |
].
|
118
|
754 |
logo := aStringOrFormOrImage.
|
105
|
755 |
self newLayout
|
|
756 |
]
|
|
757 |
!
|
0
|
758 |
|
118
|
759 |
form:aForm
|
|
760 |
"set the labels form; adjust extent if not already realized.
|
|
761 |
OBSOLETE: you should now use #label: for both strings and images"
|
|
762 |
|
|
763 |
self label:aForm
|
|
764 |
!
|
|
765 |
|
|
766 |
logo:something
|
|
767 |
"set the labels form or string.
|
|
768 |
OBSOLETE: the old version used #form: for images and #label: for strings.
|
|
769 |
you should now use #label: for any."
|
|
770 |
|
|
771 |
self label:something
|
|
772 |
!
|
|
773 |
|
105
|
774 |
label
|
118
|
775 |
"return the labels string or image"
|
105
|
776 |
|
|
777 |
^ logo
|
|
778 |
!
|
|
779 |
|
|
780 |
sizeFixed:aBoolean
|
128
|
781 |
"set/clear the fix-size attribute.
|
|
782 |
If true, the receiver will not change its size when the labelString/logo
|
|
783 |
changes. If false (the default), it will resize itself to make the logo
|
|
784 |
fit."
|
105
|
785 |
|
|
786 |
fixSize := aBoolean
|
|
787 |
!
|
|
788 |
|
|
789 |
sizeFixed
|
|
790 |
"return the fix-size attribute"
|
|
791 |
|
|
792 |
^ fixSize
|
0
|
793 |
!
|
|
794 |
|
105
|
795 |
labelWidth
|
|
796 |
"return the logos width in pixels"
|
|
797 |
|
|
798 |
^ labelWidth
|
|
799 |
!
|
|
800 |
|
125
|
801 |
layout:how
|
131
|
802 |
"for protocol compatibility: alias for #adjust:.
|
|
803 |
Please use #adjust:, since #layout: conflicts with a method
|
|
804 |
in VW (which has a completely different meaning).
|
|
805 |
In future versions of ST/X, #layout: will behave the VW way."
|
125
|
806 |
|
131
|
807 |
self obsoleteMethodWarning:'use #adjust:'.
|
125
|
808 |
self adjust:how
|
|
809 |
!
|
|
810 |
|
|
811 |
layout
|
131
|
812 |
"for protocol compatibility: alias for #adjust.
|
|
813 |
Please use #adjust, since #layout conflicts with a method
|
|
814 |
in VW (which has a completely different meaning).
|
|
815 |
In future versions of ST/X, #layout will behave the VW way."
|
125
|
816 |
|
131
|
817 |
self obsoleteMethodWarning:'use #adjust'.
|
125
|
818 |
^ self adjust
|
|
819 |
!
|
|
820 |
|
105
|
821 |
adjust:how
|
|
822 |
"set the adjust, how which must be one of
|
0
|
823 |
|
105
|
824 |
#left -> left adjust logo
|
|
825 |
#right -> right adjust logo
|
|
826 |
#center -> center logo
|
118
|
827 |
#centerRight -> center logo; if no fit, right adjust
|
|
828 |
(use with filenames, where the interresting part is
|
|
829 |
at the right if the label is too small)
|
105
|
830 |
#centerLeft -> center logo; if it does not fit, left adjust it
|
118
|
831 |
(use with strings where the interresting part is at the
|
|
832 |
left if the label is too small)
|
105
|
833 |
"
|
118
|
834 |
|
105
|
835 |
(adjust ~~ how) ifTrue:[
|
|
836 |
adjust := how.
|
|
837 |
self newLayout
|
|
838 |
]
|
|
839 |
!
|
|
840 |
|
125
|
841 |
adjust
|
|
842 |
"return the adjust symbol"
|
|
843 |
|
|
844 |
^ adjust
|
|
845 |
!
|
|
846 |
|
105
|
847 |
font:aFont
|
118
|
848 |
"set the font - if I'm not realized and not fixedSize, adjust my size"
|
105
|
849 |
|
|
850 |
(aFont ~~ font) ifTrue:[
|
|
851 |
super font:(aFont on:device).
|
|
852 |
self newLayout
|
|
853 |
]
|
0
|
854 |
! !
|
|
855 |
|
|
856 |
!Label methodsFor:'initialization'!
|
|
857 |
|
|
858 |
initStyle
|
|
859 |
super initStyle.
|
|
860 |
|
59
|
861 |
DefaultFont notNil ifTrue:[font := DefaultFont on:device].
|
|
862 |
DefaultBackgroundColor notNil ifTrue:[
|
|
863 |
bgColor := DefaultBackgroundColor on:device
|
38
|
864 |
] ifFalse:[
|
59
|
865 |
bgColor := viewBackground on:device.
|
|
866 |
].
|
|
867 |
DefaultForegroundColor notNil ifTrue:[
|
|
868 |
fgColor := DefaultForegroundColor on:device
|
|
869 |
] ifFalse:[
|
|
870 |
fgColor := Black on:device.
|
38
|
871 |
]
|
0
|
872 |
!
|
|
873 |
|
105
|
874 |
initialize
|
|
875 |
super initialize.
|
|
876 |
|
|
877 |
font := font on:device.
|
|
878 |
self height:(font height + font descent).
|
|
879 |
adjust := #center.
|
118
|
880 |
labelOriginX := labelOriginY := 0.
|
|
881 |
labelWidth := labelHeight := 0.
|
105
|
882 |
logo := nil.
|
|
883 |
fixSize := false.
|
|
884 |
hSpace := (self horizontalPixelPerMillimeter:0.5) rounded.
|
131
|
885 |
vSpace := (self verticalPixelPerMillimeter:0.25) rounded
|
105
|
886 |
!
|
|
887 |
|
0
|
888 |
recreate
|
|
889 |
"after snapin, labels dimensions may have changed due to
|
|
890 |
different font parameters"
|
|
891 |
|
|
892 |
super recreate.
|
3
|
893 |
font := font on:device.
|
0
|
894 |
self computeLabelSize.
|
|
895 |
self computeLabelOrigin
|
|
896 |
! !
|
|
897 |
|
|
898 |
!Label methodsFor:'redrawing'!
|
|
899 |
|
77
|
900 |
clearInsideWith:bg
|
|
901 |
|cutOff mustClear|
|
0
|
902 |
|
|
903 |
cutOff := margin * 2.
|
|
904 |
|
3
|
905 |
mustClear := true.
|
|
906 |
|
87
|
907 |
(logo notNil and:[logo isImageOrForm]) ifTrue:[
|
59
|
908 |
(labelOriginX == 0 and:[labelOriginY == 0]) ifTrue:[
|
|
909 |
logo width >= (width - cutOff) ifTrue:[
|
|
910 |
logo height >= (height - cutOff) ifTrue:[
|
|
911 |
"no need to clear before - avoid flicker"
|
|
912 |
mustClear := false
|
|
913 |
]
|
|
914 |
]
|
|
915 |
].
|
3
|
916 |
].
|
|
917 |
|
|
918 |
mustClear ifTrue:[
|
59
|
919 |
self paint:bg.
|
|
920 |
self fillRectangleX:margin y:margin
|
|
921 |
width:(width - cutOff)
|
|
922 |
height:(height - cutOff).
|
3
|
923 |
].
|
77
|
924 |
!
|
|
925 |
|
|
926 |
drawWith:fg and:bg
|
|
927 |
"redraw my label with fg/bg - this generic method is also used by subclasses
|
|
928 |
(especially Button) to redraw the logo in different colors."
|
|
929 |
|
131
|
930 |
|x y logoScaled scaleH scaleV img delta nW nH hSep vSep m2|
|
77
|
931 |
|
|
932 |
self clearInsideWith:bg.
|
0
|
933 |
|
|
934 |
logo notNil ifTrue:[
|
59
|
935 |
self paint:fg on:bg.
|
131
|
936 |
|
87
|
937 |
logo isImageOrForm ifTrue:[
|
131
|
938 |
x := labelOriginX.
|
|
939 |
y := labelOriginY.
|
|
940 |
|
|
941 |
adjust == #fit ifTrue:[
|
|
942 |
hSep := (hSpace*2).
|
|
943 |
vSep := (vSpace*2).
|
|
944 |
m2 := margin * 2.
|
|
945 |
|
|
946 |
scaleH := ((width - hSep) / (logo width)) asFloat.
|
|
947 |
scaleV := ((height - vSep) / (logo height)) asFloat.
|
|
948 |
self scale:(scaleH @ scaleV).
|
|
949 |
x := transformation applyInverseScaleX:x.
|
|
950 |
y := transformation applyInverseScaleY:y.
|
|
951 |
].
|
|
952 |
|
87
|
953 |
logo := logo on:device.
|
59
|
954 |
"/ self background:bg.
|
131
|
955 |
self displayOpaqueForm:logo x:x y:y
|
59
|
956 |
] ifFalse:[
|
|
957 |
x := labelOriginX + hSpace.
|
|
958 |
y := labelOriginY + (font ascent) + vSpace.
|
0
|
959 |
|
131
|
960 |
adjust == #fit ifTrue:[
|
|
961 |
scaleH := ((width - m2 - hSep) / (labelWidth - hSpace)) asFloat.
|
|
962 |
scaleV := ((height - m2 - vSep) / (labelHeight - vSpace)) asFloat.
|
|
963 |
self scale:(scaleH min: scaleV).
|
|
964 |
x := transformation applyInverseScaleX:x.
|
|
965 |
y := y - font ascent + (transformation applyScaleY:font ascent).
|
|
966 |
y := transformation applyInverseScaleY:y.
|
|
967 |
scaleH < scaleV ifTrue:[
|
|
968 |
nH := labelHeight * scaleH.
|
|
969 |
"/ now, center vertically
|
|
970 |
y := y + ((height - nH - m2 - vSep) / scaleH / 2).
|
|
971 |
].
|
|
972 |
scaleV < scaleH ifTrue:[
|
|
973 |
"/ now, center horizontally
|
|
974 |
nW := labelWidth * scaleV.
|
|
975 |
x := x + ((width - nW - m2 - hSep) / scaleV / 2)
|
|
976 |
].
|
|
977 |
].
|
|
978 |
|
87
|
979 |
logo isString ifTrue:[
|
59
|
980 |
self displayString:logo x:x y:y
|
|
981 |
] ifFalse:[
|
|
982 |
logo do:[ :line |
|
|
983 |
self displayString:(line printString) x:x y:y.
|
|
984 |
y := y + (font height)
|
|
985 |
]
|
131
|
986 |
].
|
|
987 |
|
|
988 |
].
|
|
989 |
|
|
990 |
adjust == #fit ifTrue:[
|
|
991 |
self scale:1
|
|
992 |
].
|
|
993 |
|
0
|
994 |
]
|
|
995 |
!
|
|
996 |
|
|
997 |
redraw
|
|
998 |
"redraw my label"
|
|
999 |
|
|
1000 |
shown ifTrue:[
|
59
|
1001 |
self drawWith:fgColor and:bgColor
|
0
|
1002 |
]
|
|
1003 |
! !
|
105
|
1004 |
|
|
1005 |
!Label methodsFor:'private'!
|
|
1006 |
|
110
|
1007 |
getLabelFromModel
|
118
|
1008 |
"ask my model for the label to show.
|
|
1009 |
Here, we use labelMsg.
|
|
1010 |
This allows multiple labels to react on the same aspect,
|
|
1011 |
but show different labels when changed (also, constant labels
|
|
1012 |
which have a nil labelMsg will not try to aquire a labelString)."
|
110
|
1013 |
|
125
|
1014 |
(model notNil
|
|
1015 |
and:[labelMsg notNil]) ifTrue:[
|
|
1016 |
self label:(model perform:labelMsg) printString.
|
110
|
1017 |
].
|
|
1018 |
!
|
|
1019 |
|
105
|
1020 |
newLayout
|
|
1021 |
"recompute position/size after a change
|
|
1022 |
- helper for form:/font: etc."
|
|
1023 |
|
|
1024 |
self computeLabelSize.
|
|
1025 |
fixSize ifFalse:[
|
|
1026 |
self resize
|
|
1027 |
] ifTrue:[
|
|
1028 |
self computeLabelOrigin
|
|
1029 |
].
|
|
1030 |
shown ifTrue:[
|
|
1031 |
self redraw
|
|
1032 |
]
|
|
1033 |
!
|
|
1034 |
|
|
1035 |
computeLabelOrigin
|
|
1036 |
"(re)compute the origin of the label whenever label or font changes"
|
|
1037 |
|
|
1038 |
|x y|
|
|
1039 |
|
|
1040 |
labelHeight isNil ifTrue:[^ self].
|
|
1041 |
|
131
|
1042 |
adjust == #fit ifTrue:[
|
|
1043 |
labelOriginX := labelOriginY := margin.
|
|
1044 |
^ self
|
|
1045 |
].
|
|
1046 |
|
105
|
1047 |
"if it does not fit, should we make the origin visible,
|
|
1048 |
or the center (for text, the center seems better. For images,
|
|
1049 |
I dont really know ehich is better ...
|
|
1050 |
The commented code below makes the origin visible
|
|
1051 |
"
|
|
1052 |
"/ (labelHeight < height) ifTrue:[
|
|
1053 |
"/ y := (height - labelHeight) // 2
|
|
1054 |
"/ ] ifFalse:[
|
|
1055 |
"/ y := 0
|
|
1056 |
"/ ].
|
|
1057 |
|
|
1058 |
"always center vertically"
|
|
1059 |
y := (height - labelHeight) // 2.
|
|
1060 |
|
|
1061 |
labelOriginY := y.
|
|
1062 |
|
|
1063 |
(((adjust == #center)
|
|
1064 |
or:[adjust == #centerRight])
|
|
1065 |
or:[adjust == #centerLeft]) ifTrue:[
|
|
1066 |
" center text/form in button "
|
|
1067 |
x := (width - labelWidth) // 2.
|
|
1068 |
(width < labelWidth) ifTrue:[
|
|
1069 |
"no fit"
|
|
1070 |
(adjust == #centerLeft) ifTrue:[
|
|
1071 |
x := margin
|
|
1072 |
] ifFalse:[
|
|
1073 |
(adjust == #centerRight) ifTrue:[
|
|
1074 |
x := width - labelWidth - margin
|
|
1075 |
]
|
|
1076 |
]
|
|
1077 |
]
|
|
1078 |
] ifFalse:[
|
|
1079 |
(adjust == #left) ifTrue:[
|
|
1080 |
x := margin
|
|
1081 |
] ifFalse:[
|
|
1082 |
x := width - labelWidth - margin
|
|
1083 |
]
|
|
1084 |
].
|
|
1085 |
labelOriginX := x
|
|
1086 |
!
|
|
1087 |
|
|
1088 |
computeLabelSize
|
|
1089 |
"compute the extent needed to hold the label; aForm or aString"
|
|
1090 |
|
|
1091 |
|numberOfLines textHeight textWidth|
|
|
1092 |
|
|
1093 |
logo isNil ifTrue:[^ self].
|
|
1094 |
|
|
1095 |
logo isImageOrForm ifTrue:[
|
|
1096 |
labelWidth := logo width.
|
|
1097 |
labelHeight := logo height.
|
|
1098 |
^ self
|
|
1099 |
].
|
|
1100 |
|
|
1101 |
"must be a String or collection of strings"
|
|
1102 |
logo isString ifTrue:[
|
|
1103 |
numberOfLines := 1 + (logo occurrencesOf:(Character cr)).
|
|
1104 |
(numberOfLines ~~ 1) ifTrue:[
|
|
1105 |
logo := logo asStringCollection
|
|
1106 |
]
|
|
1107 |
] ifFalse:[
|
|
1108 |
numberOfLines := logo size.
|
128
|
1109 |
(numberOfLines <= 1) ifTrue:[
|
105
|
1110 |
logo := logo asString
|
|
1111 |
]
|
|
1112 |
].
|
|
1113 |
|
|
1114 |
textHeight := font height * numberOfLines + font descent.
|
|
1115 |
textWidth := font widthOf:logo.
|
|
1116 |
labelWidth := textWidth + (hSpace * 2) .
|
|
1117 |
labelHeight := textHeight + (vSpace * 2)
|
110
|
1118 |
! !
|
|
1119 |
|
|
1120 |
!Label methodsFor:'resizing'!
|
|
1121 |
|
|
1122 |
forceResize
|
118
|
1123 |
"resize myself to make text fit into myself. Here, this is done even if
|
|
1124 |
fixSize is set."
|
110
|
1125 |
|
|
1126 |
logo notNil ifTrue:[
|
130
|
1127 |
self extent:self preferredExtent.
|
110
|
1128 |
self computeLabelOrigin
|
|
1129 |
]
|
105
|
1130 |
!
|
|
1131 |
|
|
1132 |
resize
|
|
1133 |
"resize myself to make text fit into myself.
|
118
|
1134 |
but only do so, if I am not fixedSize and I have NOT been
|
|
1135 |
given a relative extent or an extend computation block."
|
105
|
1136 |
|
110
|
1137 |
(logo notNil
|
|
1138 |
and:[fixSize not
|
|
1139 |
and:[relativeExtent isNil
|
|
1140 |
and:[extentRule isNil
|
|
1141 |
and:[relativeCorner isNil
|
|
1142 |
and:[cornerRule isNil]]]]]) ifTrue:[
|
|
1143 |
self forceResize
|
|
1144 |
] ifFalse:[
|
105
|
1145 |
self computeLabelOrigin
|
|
1146 |
]
|
|
1147 |
! !
|
|
1148 |
|
|
1149 |
!Label methodsFor:'change & update'!
|
|
1150 |
|
118
|
1151 |
update:something with:aParameter from:changedObject
|
105
|
1152 |
"the MVC way of changing the label ..."
|
|
1153 |
|
118
|
1154 |
changedObject == model ifTrue:[
|
|
1155 |
something == aspectMsg ifTrue:[
|
125
|
1156 |
self getLabelFromModel.
|
118
|
1157 |
^ self.
|
|
1158 |
]
|
105
|
1159 |
].
|
125
|
1160 |
^ super update:something with:aParameter from:changedObject
|
105
|
1161 |
! !
|
|
1162 |
|
|
1163 |
!Label methodsFor:'queries'!
|
|
1164 |
|
130
|
1165 |
preferredExtent
|
|
1166 |
"return my preferred extent - this is the minimum size I would like to have"
|
105
|
1167 |
|
|
1168 |
|extra|
|
|
1169 |
|
|
1170 |
logo notNil ifTrue:[
|
|
1171 |
extra := margin * 2.
|
|
1172 |
^ (labelWidth + extra) @ (labelHeight + extra)
|
|
1173 |
].
|
|
1174 |
|
130
|
1175 |
^ super preferredExtent
|
105
|
1176 |
! !
|