author | ca |
Mon, 24 Feb 1997 21:10:55 +0100 | |
changeset 1039 | 28ff56306e31 |
parent 993 | 51cce445b5d5 |
child 1089 | abb0c3d4b5f4 |
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 |
" |
|
12 |
||
13 |
View subclass:#Label |
|
254
aa15cac0670f
oops - foregroundColor was overwritten by backgroundColor (if defined in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
250
diff
changeset
|
14 |
instanceVariableNames:'logo labelWidth labelHeight labelOriginX labelOriginY adjust |
250
77012e65ac84
draw strings as opaque strings - OS/2 server has a bug with non-image strings
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
15 |
hSpace vSpace bgColor fgColor fixSize labelMsg converter |
77012e65ac84
draw strings as opaque strings - OS/2 server has a bug with non-image strings
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
16 |
labelChannel foregroundChannel backgroundChannel' |
392
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
17 |
classVariableNames:'DefaultForegroundColor DefaultBackgroundColor' |
254
aa15cac0670f
oops - foregroundColor was overwritten by backgroundColor (if defined in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
250
diff
changeset
|
18 |
poolDictionaries:'' |
aa15cac0670f
oops - foregroundColor was overwritten by backgroundColor (if defined in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
250
diff
changeset
|
19 |
category:'Views-Layout' |
0 | 20 |
! |
21 |
||
935 | 22 |
!Label class methodsFor:'documentation'! |
3 | 23 |
|
38 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
59 | 27 |
All Rights Reserved |
38 | 28 |
|
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
3 | 38 |
documentation |
39 |
" |
|
38 | 40 |
This class implements labels, which are views to display a string or image. |
41 |
The Label will try to do its best to make its contents fit into the |
|
42 |
view. The contents can be a String, a collection of Strings (i.e. |
|
118 | 43 |
a StringCollection) or a Form/Image. |
63 | 44 |
|
45 |
The contents is drawn in fgColor/bgColor, which can be changed using: |
|
46 |
||
585 | 47 |
aLabel foregroundColor:aColor |
48 |
aLabel backgroundColor:aColor |
|
3 | 49 |
|
38 | 50 |
When a label is assigned a contents, it will resize itself to fit |
51 |
the required size. This resizing can be suppressed by setting the |
|
52 |
fixsize attribute to true using: |
|
63 | 53 |
|
585 | 54 |
aLabel sizeFixed:true |
3 | 55 |
|
38 | 56 |
This can be used, if resizing of the label is not wanted. |
63 | 57 |
However, in this case you have to make certain that the size is big enough |
118 | 58 |
to hold any changed logos later. (usually, you create the label first with |
59 |
the longest string first to have it compute its size, then set the fixSize |
|
60 |
attribute to avoid resizing later). |
|
125 | 61 |
Be careful when placing self-resizing labels into panels - by default, |
62 |
panels do not react on the size change - leading to ugly looking geometry. |
|
63 |
(but you can tell the panel to watch for changes with #elementsCHangeSize:) |
|
38 | 64 |
|
65 |
The placement of the contents within the label is controlled by |
|
63 | 66 |
the adjust attribute, it can be set with: |
67 |
||
585 | 68 |
aLabel adjust:how |
3 | 69 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
70 |
where how is one of the symbols left, #right, #center, #centerLeft, |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
71 |
#centerRight, #leftRight or #rightLeft (see the comment in Label>>adjust:). |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
72 |
The default is #center. |
3 | 73 |
|
145 | 74 |
model-less operation (ok for static labels): |
118 | 75 |
if no model is set, the labels contents is set with: |
76 |
||
585 | 77 |
aLabel label:aStringOrImage |
118 | 78 |
|
79 |
and stays constant unless changed by new calls to #label:. |
|
80 |
||
81 |
||
145 | 82 |
model operation (ST-80 style): |
118 | 83 |
labels with a model, aspectMsg and labelMsg react to |
84 |
changes of the aspect, and send a labelMsg-message |
|
85 |
to the model in order to aquire a new labelString or image. |
|
86 |
The model should send 'self changed:aspectMsg' if it thinks the label |
|
87 |
should change and return a string or image from the labelMsg-message. |
|
88 |
||
585 | 89 |
label model:aModel. |
90 |
label aspect:aspectSymbol. |
|
91 |
label labelMessage:labelSymbol. |
|
118 | 92 |
|
585 | 93 |
model sends #changed:aspectSymbol |
94 |
---> label will redraw its label from value of model perform:labelSymbol |
|
118 | 95 |
|
96 |
Having a labelSymbol different from the aspectSymbol allows for two labels |
|
97 |
to react on the same aspect-change, but use different messages when asking |
|
98 |
the model for a new label contents. By default, the labelMsg is nil, |
|
99 |
so the label does NOT update its shown contents. |
|
100 |
The aspectMsg defaults to #value. |
|
101 |
||
125 | 102 |
|
145 | 103 |
|
104 |
channel operation (new ST/X style): |
|
105 |
||
106 |
the label will react on changes of the token found in the |
|
107 |
channels: foregroundChannel, backgroundChannel and labelChannel. |
|
108 |
These are valueHolders and can be shared between labels. |
|
109 |
||
110 |
||
111 |
||
585 | 112 |
[Instance variables:] |
3 | 113 |
|
585 | 114 |
logo <Object> the logo, can be a Form, String or Text |
115 |
labelWidth <Integer> the width of the logo in device units |
|
116 |
labelHeight <Integer> the height of the logo in device units |
|
117 |
labelOriginX <Integer> the x-position of the logo withing the Label |
|
118 |
labelOriginY <Integer> the y-position of the logo withing the Label |
|
119 |
adjust <Symbol> controls how the logo is positioned within the |
|
120 |
label. Can be one of:#left,#right,#center, |
|
121 |
#centerLeft or #centerRight (see comment in adjust:) |
|
122 |
hSpace <Integer> number of horizontal pixels around logo |
|
123 |
vSpace <Integer> number of vertical pixels around logo |
|
3 | 124 |
|
585 | 125 |
bgColor <Color> background color |
126 |
fgColor <Color> foreground color |
|
38 | 127 |
|
585 | 128 |
fixSize <Boolean> if true, a change of the logo change will not |
129 |
resize the label; otherwise, its size is adjusted. |
|
130 |
default:false. |
|
50 | 131 |
|
585 | 132 |
labelMsg <Symbol> if non-nil, this is sent to the model to |
133 |
aquire the labelString or labelImage. |
|
134 |
If nil, the label stays as is |
|
113 | 135 |
|
585 | 136 |
[styleSheet parameters:] |
50 | 137 |
|
118 | 138 |
labelForegroundColor <Color> color to draw foreground pixels (i.e. the string) |
139 |
labelBackgroundColor <Color> color to draw background pixels |
|
140 |
labelFont <Font> font to use for textual labels |
|
585 | 141 |
|
142 |
[author:] |
|
143 |
Claus Gittinger |
|
593 | 144 |
|
145 |
[see also:] |
|
146 |
Panel HorizontalPanel VerticalPanel |
|
147 |
TextView EditTextView |
|
148 |
Button |
|
149 |
InfoBox WarningBox |
|
3 | 150 |
" |
63 | 151 |
! |
152 |
||
153 |
examples |
|
154 |
" |
|
155 |
Notice, that Buttons and others inherit from Label; |
|
156 |
therefore, the following geometry examples apply to all subclasses too. |
|
157 |
||
158 |
||
113 | 159 |
simple (default position is 0@0): |
593 | 160 |
[exBegin] |
161 |
|top l| |
|
63 | 162 |
|
593 | 163 |
top := StandardSystemView new. |
164 |
top extent:(200 @ 200). |
|
63 | 165 |
|
593 | 166 |
l := Label in:top. |
167 |
l label:'hello world'. |
|
63 | 168 |
|
593 | 169 |
top open |
170 |
[exEnd] |
|
63 | 171 |
|
113 | 172 |
|
626 | 173 |
simple with emphasis: |
174 |
[exBegin] |
|
175 |
|top l| |
|
176 |
||
177 |
top := StandardSystemView new. |
|
178 |
top extent:(300 @ 100). |
|
179 |
||
180 |
l := Label in:top. |
|
181 |
l level:-1. |
|
182 |
l label:('hello world - this is text in a label ' asText |
|
183 |
emphasizeFrom:7 to:11 with:#italic; |
|
184 |
emphasizeFrom:23 to:26 with:#bold). |
|
185 |
top open |
|
186 |
[exEnd] |
|
187 |
||
188 |
||
113 | 189 |
there is also a creation message which sets the label: |
593 | 190 |
[exBegin] |
191 |
|top l| |
|
113 | 192 |
|
593 | 193 |
top := StandardSystemView new. |
194 |
top extent:(200 @ 200). |
|
113 | 195 |
|
593 | 196 |
l := Label label:'hello world' in:top. |
113 | 197 |
|
593 | 198 |
top open |
199 |
[exEnd] |
|
113 | 200 |
|
201 |
||
63 | 202 |
placement: |
593 | 203 |
[exBegin] |
204 |
|top l| |
|
63 | 205 |
|
593 | 206 |
top := StandardSystemView new. |
207 |
top extent:(200 @ 200). |
|
63 | 208 |
|
593 | 209 |
l := Label in:top. |
210 |
l label:'hello world'. |
|
211 |
l origin:50@100. |
|
63 | 212 |
|
593 | 213 |
top open |
214 |
[exEnd] |
|
63 | 215 |
|
113 | 216 |
|
63 | 217 |
level: |
593 | 218 |
[exBegin] |
219 |
|top l| |
|
63 | 220 |
|
593 | 221 |
top := StandardSystemView new. |
222 |
top extent:(200 @ 200). |
|
63 | 223 |
|
593 | 224 |
l := Label in:top. |
225 |
l level:5. |
|
226 |
l label:'hello world'. |
|
227 |
l origin:50@100. |
|
63 | 228 |
|
593 | 229 |
top open |
230 |
[exEnd] |
|
63 | 231 |
|
113 | 232 |
|
63 | 233 |
another level: |
593 | 234 |
[exBegin] |
235 |
|top l| |
|
63 | 236 |
|
593 | 237 |
top := StandardSystemView new. |
238 |
top extent:(200 @ 200). |
|
63 | 239 |
|
593 | 240 |
l := Label in:top. |
241 |
l level:-1. |
|
242 |
l label:'hello world'. |
|
243 |
l origin:50@100. |
|
63 | 244 |
|
593 | 245 |
top open |
246 |
[exEnd] |
|
63 | 247 |
|
113 | 248 |
|
118 | 249 |
colors & font: |
593 | 250 |
[exBegin] |
251 |
|top l| |
|
118 | 252 |
|
593 | 253 |
top := StandardSystemView new. |
254 |
top extent:(200 @ 200). |
|
118 | 255 |
|
593 | 256 |
l := Label in:top. |
257 |
l level:-1. |
|
258 |
l font:(Font family:'Times' size:18). |
|
259 |
l foregroundColor:Color yellow. |
|
260 |
l backgroundColor:Color red. |
|
261 |
l label:'hello world'. |
|
262 |
l origin:50@100. |
|
118 | 263 |
|
593 | 264 |
top open |
265 |
[exEnd] |
|
118 | 266 |
|
267 |
||
63 | 268 |
border & colors: |
593 | 269 |
[exBegin] |
270 |
|top l| |
|
63 | 271 |
|
593 | 272 |
top := StandardSystemView new. |
273 |
top extent:(200 @ 200). |
|
63 | 274 |
|
593 | 275 |
l := Label in:top. |
276 |
l level:0. |
|
277 |
l borderWidth:1. |
|
278 |
l borderColor:Color red. |
|
279 |
l foregroundColor:Color green darkened. |
|
280 |
l backgroundColor:Color green lightened. |
|
281 |
l label:'hello world'. |
|
282 |
l origin:50@100. |
|
63 | 283 |
|
593 | 284 |
top open |
285 |
[exEnd] |
|
63 | 286 |
|
113 | 287 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
288 |
different adjusts (resize to see): |
593 | 289 |
[exBegin] |
290 |
|top l| |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
291 |
|
593 | 292 |
top := StandardSystemView new. |
293 |
top extent:(300 @ 250). |
|
294 |
top label:'make me smaller'. |
|
295 |
||
296 |
l := Label in:top. |
|
297 |
l borderWidth:1. |
|
298 |
l label:'default - #centered'. |
|
299 |
l origin:0.1@40. |
|
300 |
l width:0.8. |
|
63 | 301 |
|
593 | 302 |
l := Label in:top. |
303 |
l borderWidth:1. |
|
304 |
l adjust:#left. |
|
305 |
l label:'#left adjust'. |
|
306 |
l origin:0.1@70. |
|
307 |
l width:0.8. |
|
63 | 308 |
|
593 | 309 |
l := Label in:top. |
310 |
l borderWidth:1. |
|
311 |
l adjust:#right. |
|
312 |
l label:'#right adjust'. |
|
313 |
l origin:0.1@100. |
|
314 |
l width:0.8. |
|
118 | 315 |
|
593 | 316 |
l := Label in:top. |
317 |
l borderWidth:1. |
|
318 |
l adjust:#centerLeft. |
|
319 |
l label:'#centerLeft adjust with a long text'. |
|
320 |
l origin:0.1@130. |
|
321 |
l width:0.8. |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
322 |
|
593 | 323 |
l := Label in:top. |
324 |
l borderWidth:1. |
|
325 |
l adjust:#centerRight. |
|
326 |
l label:'#centerRight adjust with a long text'. |
|
327 |
l origin:0.1@160. |
|
328 |
l width:0.8. |
|
63 | 329 |
|
593 | 330 |
l := Label in:top. |
331 |
l borderWidth:1. |
|
332 |
l adjust:#leftRight. |
|
333 |
l label:'#leftRight adjust with a long text'. |
|
334 |
l origin:0.1@190. |
|
335 |
l width:0.8. |
|
63 | 336 |
|
593 | 337 |
l := Label in:top. |
338 |
l borderWidth:1. |
|
339 |
l adjust:#rightLeft. |
|
340 |
l label:'#rightLeft adjust with a long text'. |
|
341 |
l origin:0.1@220. |
|
342 |
l width:0.8. |
|
118 | 343 |
|
593 | 344 |
top open |
345 |
[exEnd] |
|
63 | 346 |
|
113 | 347 |
|
131 | 348 |
fitting-adjust (resize to see): |
349 |
Warning: #fit is experimental and should not be used. |
|
593 | 350 |
[exBegin] |
351 |
|top l| |
|
131 | 352 |
|
593 | 353 |
top := StandardSystemView new. |
354 |
top extent:(200 @ 200). |
|
131 | 355 |
|
593 | 356 |
l := Label origin:0.25 @ 0.25 corner:0.75@0.75 in:top. |
357 |
l label:'stretch'. |
|
358 |
l level:-1. |
|
359 |
l adjust:#fit. |
|
131 | 360 |
|
593 | 361 |
top open |
362 |
[exEnd] |
|
131 | 363 |
|
364 |
or: |
|
365 |
Warning: #fit is experimental and should not be used. |
|
593 | 366 |
[exBegin] |
367 |
|top l| |
|
131 | 368 |
|
593 | 369 |
top := StandardSystemView new. |
370 |
top extent:(200 @ 200). |
|
131 | 371 |
|
593 | 372 |
l := Label origin:0.25 @ 0.25 corner:0.75@0.75 in:top. |
373 |
l label:(Image fromFile:'bitmaps/SBrowser.xbm'). |
|
374 |
l level:-1. |
|
375 |
l adjust:#fit. |
|
131 | 376 |
|
593 | 377 |
top open |
378 |
[exEnd] |
|
131 | 379 |
|
380 |
||
63 | 381 |
just a reminder, that instead of doing placement manually |
113 | 382 |
as in ...: |
593 | 383 |
[exBegin] |
384 |
|top l| |
|
63 | 385 |
|
593 | 386 |
top := StandardSystemView new. |
387 |
top extent:(200 @ 200). |
|
63 | 388 |
|
593 | 389 |
l := Label in:top. |
390 |
l borderWidth:1. |
|
391 |
l label:'default - centered'. |
|
392 |
l origin:0.1@70. |
|
393 |
l width:0.8. |
|
63 | 394 |
|
593 | 395 |
l := Label in:top. |
396 |
l borderWidth:1. |
|
397 |
l adjust:#left. |
|
398 |
l label:'left adjust'. |
|
399 |
l origin:0.1@100. |
|
400 |
l width:0.8. |
|
63 | 401 |
|
593 | 402 |
l := Label in:top. |
403 |
l borderWidth:1. |
|
404 |
l adjust:#right. |
|
405 |
l label:'right adjust'. |
|
406 |
l origin:0.1@130. |
|
407 |
l width:0.8. |
|
63 | 408 |
|
593 | 409 |
top open |
410 |
[exEnd] |
|
63 | 411 |
|
113 | 412 |
|
413 |
... it is much easier, to use a geometry handler, such as |
|
63 | 414 |
a VerticalPanel. Try: |
593 | 415 |
[exBegin] |
416 |
|top panel l| |
|
63 | 417 |
|
593 | 418 |
top := StandardSystemView new. |
419 |
top extent:(200 @ 200). |
|
63 | 420 |
|
593 | 421 |
panel := VerticalPanelView |
422 |
origin:0.1 @ 0.0 |
|
423 |
corner:0.9 @ 1.0 |
|
424 |
in:top. |
|
63 | 425 |
|
593 | 426 |
panel horizontalLayout:#fit. |
427 |
panel verticalLayout:#center. |
|
63 | 428 |
|
593 | 429 |
l := Label in:panel. |
430 |
l borderWidth:1. |
|
431 |
l label:'default - centered'. |
|
63 | 432 |
|
593 | 433 |
l := Label in:panel. |
434 |
l borderWidth:1. |
|
435 |
l adjust:#left. |
|
436 |
l label:'left adjust'. |
|
63 | 437 |
|
593 | 438 |
l := Label in:panel. |
439 |
l borderWidth:1. |
|
440 |
l adjust:#right. |
|
441 |
l label:'right adjust'. |
|
63 | 442 |
|
593 | 443 |
top open |
444 |
[exEnd] |
|
63 | 445 |
|
113 | 446 |
|
63 | 447 |
labels with bitmaps or images: |
593 | 448 |
[exBegin] |
449 |
|top l| |
|
63 | 450 |
|
593 | 451 |
top := StandardSystemView new. |
452 |
top extent:(200 @ 200). |
|
63 | 453 |
|
593 | 454 |
l := Label in:top. |
455 |
l level:-1. |
|
456 |
l label:((Image fromFile:'bitmaps/garfield.gif') magnifyBy:0.2 @ 0.2). |
|
457 |
l origin:50@100. |
|
63 | 458 |
|
593 | 459 |
top open |
460 |
[exEnd] |
|
113 | 461 |
|
462 |
||
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
463 |
that even works with #fit: |
593 | 464 |
[exBegin] |
465 |
|top l| |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
466 |
|
593 | 467 |
top := StandardSystemView new. |
468 |
top extent:(200 @ 200). |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
469 |
|
593 | 470 |
l := Label in:top. |
471 |
l adjust:#fit. |
|
472 |
l level:-1. |
|
473 |
l label:(Image fromFile:'bitmaps/garfield.gif'). |
|
474 |
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
|
475 |
|
593 | 476 |
top open |
477 |
[exEnd] |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
478 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
479 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
480 |
notice, that Buttons inherit from Label; thus: |
593 | 481 |
[exBegin] |
482 |
|top b| |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
483 |
|
593 | 484 |
top := StandardSystemView new. |
485 |
top extent:(200 @ 200). |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
486 |
|
593 | 487 |
b := Button in:top. |
488 |
b adjust:#fit. |
|
489 |
b label:(Image fromFile:'bitmaps/garfield.gif'). |
|
490 |
b origin:0.2@0.2 corner:0.8@0.8. |
|
655 | 491 |
b action:[Transcript showCR:'wow']. |
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
492 |
|
593 | 493 |
top open |
494 |
[exEnd] |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
495 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
496 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
497 |
Channel operation (controlling gf, bg and labelText via ValueHolders) |
145 | 498 |
----------------- |
593 | 499 |
[exBegin] |
500 |
|top panel logoChannel fgChannel bgChannel l b| |
|
145 | 501 |
|
593 | 502 |
top := StandardSystemView new. |
503 |
top extent:(450 @ 200). |
|
145 | 504 |
|
593 | 505 |
panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
145 | 506 |
|
593 | 507 |
l := Label in:panel. |
508 |
l level:-1. |
|
509 |
l label:'change my colors'. |
|
510 |
l origin:50@100. |
|
511 |
l sizeFixed:true. |
|
145 | 512 |
|
593 | 513 |
fgChannel := Color blue asValue. |
514 |
bgChannel := Color grey asValue. |
|
515 |
logoChannel := 'change me' asValue. |
|
145 | 516 |
|
593 | 517 |
b := Toggle label:'change fg' in:panel. b showLamp:false; onLevel:-2. |
518 |
b pressAction:[fgChannel value:Color red]. |
|
519 |
b releaseAction:[fgChannel value:Color blue]. |
|
145 | 520 |
|
593 | 521 |
b := Toggle label:'change bg' in:panel. |
522 |
b pressAction:[bgChannel value:Color yellow]. |
|
523 |
b releaseAction:[bgChannel value:Color grey]. |
|
145 | 524 |
|
593 | 525 |
b := Toggle label:'change text' in:panel. |
526 |
b pressAction:[logoChannel value:'wow']. |
|
527 |
b releaseAction:[logoChannel value:'not bad' ]. |
|
145 | 528 |
|
593 | 529 |
l labelChannel:logoChannel. |
530 |
l foregroundChannel:fgChannel. |
|
531 |
l backgroundChannel:bgChannel. |
|
145 | 532 |
|
593 | 533 |
top open |
534 |
[exEnd] |
|
145 | 535 |
|
536 |
||
146 | 537 |
multiple labels on one channel: |
593 | 538 |
[exBegin] |
539 |
|l1 l2 b conv| |
|
146 | 540 |
|
593 | 541 |
l1 := Label label:'label1'. |
146 | 542 |
|
593 | 543 |
l2 := Label label:'label2'. |
146 | 544 |
|
593 | 545 |
b := Button label:'change'. |
546 |
conv := (ConvertedValue new |
|
547 |
conversion:[:input | |
|
548 |
input ifTrue:[ |
|
549 |
Color red |
|
550 |
] ifFalse:[ |
|
551 |
Color blue |
|
552 |
]]). |
|
553 |
conv value:false. |
|
146 | 554 |
|
593 | 555 |
b controller pressChannel:conv. |
556 |
l1 foregroundChannel:conv. |
|
557 |
l2 foregroundColor:Color white; backgroundChannel:conv. |
|
146 | 558 |
|
593 | 559 |
b open. |
560 |
l1 open. |
|
561 |
l2 open. |
|
562 |
[exEnd] |
|
146 | 563 |
|
564 |
||
125 | 565 |
MVC operation |
145 | 566 |
------------- |
567 |
||
125 | 568 |
model provides the label): |
569 |
(have to use a plug to simulate a model which responds to |
|
593 | 570 |
the #someAspect message): |
571 |
|top l model| |
|
113 | 572 |
|
593 | 573 |
model := Plug new. |
574 |
model respondTo:#someAspect with:['models labelString']. |
|
113 | 575 |
|
593 | 576 |
top := StandardSystemView new. |
577 |
top extent:(200 @ 200). |
|
113 | 578 |
|
593 | 579 |
l := Label in:top. |
580 |
l model:model; labelMessage:#someAspect. |
|
113 | 581 |
|
593 | 582 |
top open |
583 |
... |
|
118 | 584 |
|
593 | 585 |
model changed:#someAspect |
586 |
... |
|
113 | 587 |
|
588 |
||
118 | 589 |
concrete example (track a counters value): |
125 | 590 |
(here, the default aspect #value is used both to notify the label about |
591 |
changes and to aquire a new value from the model). |
|
593 | 592 |
[exBegin] |
593 |
|top l model| |
|
113 | 594 |
|
593 | 595 |
model := ValueHolder new. |
596 |
model value:'0'. |
|
597 |
[ |
|
598 |
1 to:20 do:[:i | |
|
599 |
(Delay forSeconds:1) wait. |
|
600 |
model value:i printString |
|
601 |
]. |
|
602 |
top destroy |
|
603 |
] fork. |
|
113 | 604 |
|
593 | 605 |
top := StandardSystemView new. |
606 |
top extent:(200 @ 200). |
|
113 | 607 |
|
593 | 608 |
l := Label in:top. |
609 |
l level:-1. |
|
610 |
l model:model; labelMessage:#value. |
|
118 | 611 |
|
593 | 612 |
top open |
613 |
[exEnd] |
|
118 | 614 |
|
615 |
||
133 | 616 |
with a printConverter: |
593 | 617 |
[exBegin] |
618 |
|top l model| |
|
133 | 619 |
|
593 | 620 |
model := Date today asValue. |
621 |
[ |
|
622 |
1 to:50 do:[:i | |
|
623 |
(Delay forSeconds:1) wait. |
|
624 |
model value:(model value addDays:1) |
|
625 |
]. |
|
626 |
top destroy |
|
627 |
] fork. |
|
133 | 628 |
|
593 | 629 |
top := StandardSystemView new. |
630 |
top extent:(200 @ 200). |
|
133 | 631 |
|
593 | 632 |
l := Label in:top. |
633 |
l level:-1. |
|
634 |
l converter:(PrintConverter new initForDate). |
|
635 |
l model:model; labelMessage:#value. |
|
133 | 636 |
|
593 | 637 |
top open |
638 |
[exEnd] |
|
133 | 639 |
|
640 |
||
125 | 641 |
model changes aspect after a while; two labels on the same model: |
593 | 642 |
[exBegin] |
643 |
|top l model| |
|
118 | 644 |
|
593 | 645 |
model := Plug new. |
646 |
model respondTo:#labelValue1 with:['models labelString1']. |
|
647 |
model respondTo:#labelValue2 with:['models labelString2']. |
|
118 | 648 |
|
593 | 649 |
top := StandardSystemView new. |
650 |
top extent:(200 @ 200). |
|
118 | 651 |
|
593 | 652 |
l := Label origin:0.0@0.0 corner:1.0@0.5 in:top. |
653 |
l model:model; aspect:#someAspect; labelMessage:#labelValue1. |
|
654 |
l := Label origin:0.0@0.5 corner:1.0@1.0 in:top. |
|
655 |
l model:model; aspect:#someAspect; labelMessage:#labelValue2. |
|
656 |
||
657 |
top open. |
|
113 | 658 |
|
593 | 659 |
(Delay forSeconds:5) wait. |
660 |
model respondTo:#labelValue1 with:['new string1']. |
|
661 |
model respondTo:#labelValue2 with:['new string2']. |
|
118 | 662 |
|
593 | 663 |
model changed:#someAspect |
664 |
[exEnd] |
|
118 | 665 |
|
666 |
||
125 | 667 |
plugged MVC operation (getBlock returns the label): |
593 | 668 |
[exBegin] |
669 |
|top l model| |
|
118 | 670 |
|
593 | 671 |
model := PluggableAdaptor new |
672 |
getBlock:[:m | 'hello'] |
|
673 |
putBlock:nil |
|
674 |
updateBlock:nil. |
|
118 | 675 |
|
593 | 676 |
top := StandardSystemView new. |
677 |
top extent:(200 @ 200). |
|
118 | 678 |
|
593 | 679 |
l := Label origin:0.0@0.0 corner:1.0@0.5 in:top. |
680 |
l model:model; labelMessage:#value. |
|
118 | 681 |
|
593 | 682 |
top open. |
683 |
[exEnd] |
|
125 | 684 |
|
685 |
||
686 |
use different label-selectors to access fields of a complex model: |
|
593 | 687 |
[exBegin] |
688 |
|top panel model| |
|
125 | 689 |
|
593 | 690 |
model := Plug new. |
691 |
model respondTo:#field1 with:['value1']. |
|
692 |
model respondTo:#field2 with:['value2']. |
|
693 |
model respondTo:#field3 with:['value3']. |
|
694 |
model respondTo:#field4 with:['value4']. |
|
125 | 695 |
|
593 | 696 |
top := StandardSystemView new. |
697 |
||
698 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
699 |
panel elementsChangeSize:true. |
|
125 | 700 |
|
593 | 701 |
panel addSubView:((Label on:model) labelMessage:#field1). |
702 |
panel addSubView:((Label on:model) labelMessage:#field2). |
|
703 |
panel addSubView:((Label on:model) labelMessage:#field3). |
|
704 |
panel addSubView:((Label on:model) labelMessage:#field4). |
|
125 | 705 |
|
593 | 706 |
top extent:(200 @ 200). |
707 |
top open. |
|
125 | 708 |
|
593 | 709 |
(Delay forSeconds:5) wait. |
125 | 710 |
|
593 | 711 |
model respondTo:#field2 with:['new value2']. |
712 |
model changed:#value |
|
713 |
[exEnd] |
|
125 | 714 |
|
715 |
||
716 |
same as above, using default aspects in the label, and an adaptor |
|
717 |
to translate aspects: |
|
593 | 718 |
[exBegin] |
719 |
|top panel model v1| |
|
125 | 720 |
|
593 | 721 |
model := Plug new. |
722 |
model respondTo:#field1 with:[v1]. |
|
723 |
model respondTo:#field1: with:[:arg | v1 := arg. model changed:#field1]. |
|
724 |
model respondTo:#field2 with:['value2']. |
|
725 |
model respondTo:#field2: with:[:arg |]. |
|
726 |
model respondTo:#field3 with:['value3']. |
|
727 |
model respondTo:#field3: with:[:arg |]. |
|
728 |
model respondTo:#field4 with:['value4']. |
|
729 |
model respondTo:#field4: with:[:arg |]. |
|
125 | 730 |
|
593 | 731 |
top := StandardSystemView new. |
125 | 732 |
|
593 | 733 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
734 |
panel elementsChangeSize:true. |
|
735 |
||
736 |
panel addSubView:((Label on:((AspectAdaptor subject:model) forAspect:#field1)) labelMessage:#value). |
|
737 |
panel addSubView:((Label on:((AspectAdaptor subject:model) forAspect:#field2)) labelMessage:#value). |
|
738 |
panel addSubView:((Label on:((AspectAdaptor subject:model) forAspect:#field3)) labelMessage:#value). |
|
739 |
panel addSubView:((Label on:((AspectAdaptor subject:model) forAspect:#field4)) labelMessage:#value). |
|
125 | 740 |
|
593 | 741 |
top extent:(200 @ 200). |
742 |
top open. |
|
125 | 743 |
|
593 | 744 |
(Delay forSeconds:5) wait. |
125 | 745 |
|
593 | 746 |
model field1:'new value1'. |
747 |
[exEnd] |
|
125 | 748 |
|
749 |
||
750 |
use an adapter to access fields of a complex model: |
|
593 | 751 |
[exBegin] |
752 |
|top l panel model| |
|
125 | 753 |
|
593 | 754 |
model := #('one' 'two' 'three') asValue. |
125 | 755 |
|
593 | 756 |
top := StandardSystemView new. |
125 | 757 |
|
593 | 758 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
759 |
panel elementsChangeSize:true. |
|
125 | 760 |
|
593 | 761 |
panel addSubView:((Label on:(ProtocolAdaptor |
762 |
subjectChannel:model |
|
763 |
accessPath:#(1))) labelMessage:#value). |
|
764 |
panel addSubView:((Label on:(ProtocolAdaptor |
|
765 |
subjectChannel:model |
|
766 |
accessPath:#(2))) labelMessage:#value). |
|
767 |
panel addSubView:((Label on:(ProtocolAdaptor |
|
768 |
subjectChannel:model |
|
769 |
accessPath:#(3))) labelMessage:#value). |
|
125 | 770 |
|
593 | 771 |
top extent:(200 @ 200). |
772 |
top open. |
|
125 | 773 |
|
593 | 774 |
(Delay forSeconds:5) wait. |
125 | 775 |
|
593 | 776 |
model value:#('oneone' 'twotwo' 'threethree'). |
777 |
[exEnd] |
|
63 | 778 |
" |
3 | 779 |
! ! |
780 |
||
935 | 781 |
!Label class methodsFor:'instance creation'! |
105 | 782 |
|
783 |
form:aForm |
|
118 | 784 |
"return a new Label showing a form. |
785 |
OBSOLETE: you should now use #label: for both text and bitmap labels." |
|
105 | 786 |
|
131 | 787 |
^ (self on:Screen current) form:aForm |
105 | 788 |
! |
789 |
||
790 |
form:aForm in:aView |
|
118 | 791 |
"return a new Label showing a form. |
792 |
OBSOLETE: you should now use #label:in: for both text and bitmap labels." |
|
105 | 793 |
|
794 |
^ (self in:aView) form:aForm |
|
795 |
! ! |
|
796 |
||
935 | 797 |
!Label class methodsFor:'defaults'! |
0 | 798 |
|
799 |
defaultExtent |
|
571 | 800 |
"return the default extent of my instances. |
801 |
The value returned here is usually ignored, and |
|
802 |
the value from preferredExtent taken instead." |
|
0 | 803 |
|
804 |
^ 16 @ 16 |
|
571 | 805 |
|
806 |
"Modified: 22.4.1996 / 23:36:11 / cg" |
|
59 | 807 |
! |
808 |
||
809 |
updateStyleCache |
|
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
416
diff
changeset
|
810 |
"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
|
811 |
|
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
416
diff
changeset
|
812 |
<resource: #style (#labelForegroundColor #labelBackgroundColor |
442 | 813 |
#foregroundColor #backgroundColor |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
416
diff
changeset
|
814 |
#labelFont)> |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
416
diff
changeset
|
815 |
|
77 | 816 |
DefaultForegroundColor := StyleSheet colorAt:'labelForegroundColor'. |
817 |
DefaultForegroundColor isNil ifTrue:[ |
|
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
416
diff
changeset
|
818 |
DefaultForegroundColor := StyleSheet colorAt:'foregroundColor' default:Black. |
77 | 819 |
]. |
60 | 820 |
DefaultBackgroundColor := StyleSheet colorAt:'labelBackgroundColor'. |
77 | 821 |
DefaultBackgroundColor isNil ifTrue:[ |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
416
diff
changeset
|
822 |
DefaultBackgroundColor := StyleSheet colorAt:'backgroundColor'. |
77 | 823 |
]. |
60 | 824 |
DefaultFont := StyleSheet fontAt:'labelFont'. |
825 |
||
826 |
" |
|
827 |
self updateStyleCache |
|
828 |
" |
|
254
aa15cac0670f
oops - foregroundColor was overwritten by backgroundColor (if defined in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
250
diff
changeset
|
829 |
|
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
416
diff
changeset
|
830 |
"Modified: 1.3.1996 / 13:45:36 / cg" |
0 | 831 |
! ! |
832 |
||
202 | 833 |
!Label methodsFor:'accessing-channels'! |
105 | 834 |
|
260 | 835 |
backgroundChannel |
836 |
^ backgroundChannel. |
|
837 |
||
838 |
"Created: 16.12.1995 / 15:50:08 / cg" |
|
839 |
! |
|
840 |
||
202 | 841 |
backgroundChannel:aValueHolder |
842 |
|prev| |
|
105 | 843 |
|
202 | 844 |
prev := backgroundChannel. |
845 |
backgroundChannel := aValueHolder. |
|
846 |
self setupChannel:aValueHolder for:#backgroundChannelChanged withOld:prev |
|
847 |
! |
|
145 | 848 |
|
260 | 849 |
foregroundChannel |
850 |
^ foregroundChannel. |
|
851 |
||
852 |
"Created: 16.12.1995 / 15:50:01 / cg" |
|
853 |
! |
|
854 |
||
145 | 855 |
foregroundChannel:aValueHolder |
146 | 856 |
|prev| |
857 |
||
858 |
prev := foregroundChannel. |
|
145 | 859 |
foregroundChannel := aValueHolder. |
146 | 860 |
self setupChannel:aValueHolder for:#foregroundChannelChanged withOld:prev |
145 | 861 |
! |
862 |
||
260 | 863 |
labelChannel |
864 |
^ labelChannel. |
|
865 |
||
866 |
"Created: 16.12.1995 / 15:50:18 / cg" |
|
867 |
! |
|
868 |
||
145 | 869 |
labelChannel:aValueHolder |
146 | 870 |
|prev| |
871 |
||
872 |
prev := labelChannel. |
|
145 | 873 |
labelChannel := aValueHolder. |
146 | 874 |
self setupChannel:aValueHolder for:#labelChannelChanged withOld:prev |
145 | 875 |
! ! |
876 |
||
202 | 877 |
!Label methodsFor:'accessing-colors'! |
125 | 878 |
|
202 | 879 |
backgroundColor |
880 |
"return the background color" |
|
125 | 881 |
|
202 | 882 |
^ bgColor |
125 | 883 |
! |
884 |
||
202 | 885 |
backgroundColor:aColor |
886 |
"set the background color" |
|
125 | 887 |
|
263 | 888 |
aColor ~~ bgColor ifTrue:[ |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
889 |
bgColor := aColor on:device. |
993 | 890 |
shown ifTrue:[self invalidate] |
263 | 891 |
] |
892 |
||
993 | 893 |
"Modified: 8.2.1997 / 15:19:31 / cg" |
105 | 894 |
! |
895 |
||
896 |
foregroundColor |
|
897 |
"return the foreground color" |
|
898 |
||
899 |
^ fgColor |
|
900 |
! |
|
901 |
||
202 | 902 |
foregroundColor:aColor |
903 |
"set the foreground color" |
|
105 | 904 |
|
263 | 905 |
aColor ~~ fgColor ifTrue:[ |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
906 |
fgColor := aColor on:device. |
993 | 907 |
shown ifTrue:[self invalidate] |
263 | 908 |
]. |
909 |
||
993 | 910 |
"Modified: 8.2.1997 / 15:19:29 / cg" |
105 | 911 |
! |
912 |
||
913 |
foregroundColor:fg backgroundColor:bg |
|
914 |
"set the colors to be used for drawing" |
|
915 |
||
993 | 916 |
(fgColor ~~ fg or:[bgColor ~~ bg]) ifTrue:[ |
917 |
fgColor := fg on:device. |
|
918 |
bgColor := bg on:device. |
|
919 |
shown ifTrue:[self invalidate] |
|
920 |
]. |
|
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
921 |
|
993 | 922 |
"Modified: 8.2.1997 / 15:19:22 / cg" |
133 | 923 |
! ! |
924 |
||
925 |
!Label methodsFor:'accessing-contents'! |
|
0 | 926 |
|
202 | 927 |
form:aForm |
928 |
"set the labels form; adjust extent if not already realized. |
|
929 |
OBSOLETE: you should now use #label: for both strings and images" |
|
118 | 930 |
|
202 | 931 |
self label:aForm |
932 |
! |
|
933 |
||
934 |
label |
|
935 |
"return the labels string or image" |
|
936 |
||
937 |
^ logo |
|
118 | 938 |
! |
105 | 939 |
|
118 | 940 |
label:aStringOrFormOrImage |
941 |
"set the labelString or image; adjust extent if not already realized and |
|
942 |
not fixedSize" |
|
943 |
||
944 |
(aStringOrFormOrImage ~~ logo) ifTrue:[ |
|
616
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
945 |
"/ |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
946 |
"/ avoid recompute of size, if its an image with |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
947 |
"/ the same size |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
948 |
"/ |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
949 |
aStringOrFormOrImage isImageOrForm ifTrue:[ |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
950 |
logo notNil ifTrue:[ |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
951 |
logo isImageOrForm ifTrue:[ |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
952 |
logo extent = aStringOrFormOrImage extent ifTrue:[ |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
953 |
logo := aStringOrFormOrImage. |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
954 |
shown ifTrue:[ |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
955 |
self invalidate |
616
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
956 |
]. |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
957 |
^ self |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
958 |
] |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
959 |
] |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
960 |
] |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
961 |
] ifFalse:[ |
806
a641ed42df70
dont ignore new label setting, if the emphasis changed
Claus Gittinger <cg@exept.de>
parents:
799
diff
changeset
|
962 |
"/ any change ? |
616
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
963 |
(logo = aStringOrFormOrImage) ifTrue:[ |
817
58c611fad735
check if label is a string, before asking for emphasis
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
964 |
(logo isString) ifTrue:[ |
58c611fad735
check if label is a string, before asking for emphasis
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
965 |
(logo emphasis = aStringOrFormOrImage emphasis) ifTrue:[ |
58c611fad735
check if label is a string, before asking for emphasis
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
966 |
^ self |
58c611fad735
check if label is a string, before asking for emphasis
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
967 |
] |
806
a641ed42df70
dont ignore new label setting, if the emphasis changed
Claus Gittinger <cg@exept.de>
parents:
799
diff
changeset
|
968 |
] |
616
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
969 |
] |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
970 |
]. |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
971 |
logo := aStringOrFormOrImage. |
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
972 |
self newLayout |
105 | 973 |
] |
616
f6d4c90abaec
redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
974 |
|
817
58c611fad735
check if label is a string, before asking for emphasis
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
975 |
"Modified: 2.8.1996 / 21:02:41 / cg" |
105 | 976 |
! |
0 | 977 |
|
202 | 978 |
labelString:aString |
979 |
"for ST-80 compatibility: same as #label: |
|
980 |
set the label-string; adjust extent if not already realized and not fixedSize" |
|
118 | 981 |
|
202 | 982 |
self label:aString |
983 |
! |
|
984 |
||
985 |
labelWidth |
|
986 |
"return the logos width in pixels" |
|
987 |
||
988 |
^ labelWidth |
|
118 | 989 |
! |
990 |
||
991 |
logo:something |
|
992 |
"set the labels form or string. |
|
993 |
OBSOLETE: the old version used #form: for images and #label: for strings. |
|
994 |
you should now use #label: for any." |
|
995 |
||
996 |
self label:something |
|
133 | 997 |
! ! |
998 |
||
999 |
!Label methodsFor:'accessing-layout'! |
|
1000 |
||
202 | 1001 |
adjust |
1002 |
"return the adjust symbol" |
|
0 | 1003 |
|
202 | 1004 |
^ adjust |
125 | 1005 |
! |
1006 |
||
105 | 1007 |
adjust:how |
1008 |
"set the adjust, how which must be one of |
|
0 | 1009 |
|
105 | 1010 |
#left -> left adjust logo |
1011 |
#right -> right adjust logo |
|
1012 |
#center -> center logo |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1013 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1014 |
#centerRight -> center logo if it fits; |
533 | 1015 |
BUT, if it does not fit, right adjust the logo |
1016 |
(use with filenames, where the interesting part is |
|
1017 |
at the right if the label is too small) |
|
1018 |
||
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1019 |
#centerLeft -> center logo if it fits; |
533 | 1020 |
BUT, if it does not fit, left adjust the logo |
1021 |
(use with strings where the interesting part is at the |
|
1022 |
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
|
1023 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1024 |
#leftRight -> left adjust logo if it fits |
533 | 1025 |
BUT, if it does not fit, right adjust the logo |
1026 |
(use with filenames, where the interesting part is |
|
1027 |
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
|
1028 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1029 |
#rightLeft -> right adjust logo if it fits |
533 | 1030 |
BUT, if it does not fit, left adjust the logo |
1031 |
(use with strings where the interesting part is at the |
|
1032 |
left if the label is too small) |
|
1033 |
||
1034 |
See examples in the documentation category. |
|
105 | 1035 |
" |
118 | 1036 |
|
105 | 1037 |
(adjust ~~ how) ifTrue:[ |
533 | 1038 |
adjust := how. |
1039 |
self newLayout |
|
105 | 1040 |
] |
533 | 1041 |
|
1042 |
"Modified: 13.4.1996 / 11:17:58 / cg" |
|
105 | 1043 |
! |
1044 |
||
202 | 1045 |
font:aFont |
665 | 1046 |
"set the font - if I'm not realized and not fixedSize, adjust my size. |
1047 |
CAVEAT: with the addition of Text objects, |
|
1048 |
this method is going to be obsoleted by a textStyle |
|
1049 |
method, which allows specific control over |
|
1050 |
normalFont/boldFont/italicFont parameters." |
|
125 | 1051 |
|
416 | 1052 |
(aFont notNil and:[aFont ~~ font]) ifTrue:[ |
1053 |
super font:(aFont on:device). |
|
1054 |
self newLayout |
|
202 | 1055 |
] |
416 | 1056 |
|
665 | 1057 |
"Modified: 22.5.1996 / 12:36:29 / cg" |
133 | 1058 |
! |
1059 |
||
1060 |
horizontalSpace:aNumber |
|
1061 |
"set the number of pixels by which the logo |
|
1062 |
is horizontally inset from the border" |
|
1063 |
||
162 | 1064 |
hSpace := aNumber. |
1065 |
self newLayout |
|
133 | 1066 |
! |
1067 |
||
202 | 1068 |
layout |
1069 |
"for protocol compatibility: alias for #adjust. |
|
1070 |
Please use #adjust, since #layout conflicts with a method |
|
1071 |
in VW (which has a completely different meaning). |
|
1072 |
In future versions of ST/X, #layout will behave the VW way." |
|
1073 |
||
1074 |
self obsoleteMethodWarning:'use #adjust'. |
|
1075 |
^ self adjust |
|
1076 |
! |
|
1077 |
||
1078 |
layout:something |
|
1079 |
"OBSOLETE compatibility interface. Will vanish. |
|
1080 |
for protocol compatibility: alias for #adjust:. |
|
1081 |
Please use #adjust:, since #layout: conflicts with a method |
|
1082 |
in VW (which has a completely different meaning). |
|
1083 |
In future versions of ST/X, #layout: will behave the VW way. |
|
1084 |
In the meantime, try to figure out what is meant ... a kludge" |
|
1085 |
||
1086 |
something isLayout ifTrue:[^ super layout:something]. |
|
1087 |
||
1088 |
self obsoleteMethodWarning:'use #adjust:'. |
|
1089 |
self adjust:something |
|
1090 |
||
1091 |
"Modified: 31.8.1995 / 23:08:13 / claus" |
|
1092 |
! |
|
1093 |
||
1094 |
sizeFixed |
|
1095 |
"return the fix-size attribute" |
|
1096 |
||
1097 |
^ fixSize |
|
1098 |
! |
|
1099 |
||
1100 |
sizeFixed:aBoolean |
|
1101 |
"set/clear the fix-size attribute. |
|
1102 |
If true, the receiver will not change its size when the labelString/logo |
|
1103 |
changes. If false (the default), it will resize itself to make the logo |
|
1104 |
fit." |
|
1105 |
||
1106 |
fixSize := aBoolean |
|
1107 |
! |
|
1108 |
||
1109 |
verticalSpace:aNumber |
|
1110 |
"set the number of pixels by which the logo |
|
1111 |
is vertically inset from the border" |
|
1112 |
||
1113 |
vSpace := aNumber. |
|
1114 |
self newLayout |
|
1115 |
! ! |
|
1116 |
||
1117 |
!Label methodsFor:'accessing-mvc'! |
|
1118 |
||
1119 |
addModelInterfaceTo:aDictionary |
|
1120 |
"see comment in View>>modelInterface" |
|
1121 |
||
1122 |
super addModelInterfaceTo:aDictionary. |
|
1123 |
aDictionary at:#labelMessage put:labelMsg |
|
1124 |
! |
|
1125 |
||
1126 |
converter:aConverter |
|
1127 |
"set the printConverter; |
|
1128 |
that one is asked to convert the models value to a printed |
|
1129 |
representation (if non-nil). If nil, the model is supposed to |
|
1130 |
return a string or bitmap image." |
|
1131 |
||
1132 |
converter := aConverter |
|
1133 |
! |
|
105 | 1134 |
|
202 | 1135 |
labelMessage |
1136 |
"return the symbol used to aquire the labelString/image from the model |
|
1137 |
when the aspect changes. |
|
1138 |
The default is nil, which means: leave the label unchanged." |
|
1139 |
||
1140 |
^ labelMsg |
|
1141 |
! |
|
1142 |
||
1143 |
labelMessage:aSymbol |
|
1144 |
"set the symbol used to aquire the labelString/image from the model. |
|
1145 |
The default is nil, which means: leave the label unchanged." |
|
1146 |
||
1147 |
labelMsg ~~ aSymbol ifTrue:[ |
|
1148 |
labelMsg := aSymbol. |
|
1149 |
self getLabelFromModel |
|
1150 |
] |
|
1151 |
! |
|
1152 |
||
1153 |
model:aModel |
|
1154 |
super model:aModel. |
|
1039 | 1155 |
labelMsg notNil ifTrue:[ |
1156 |
self getLabelFromModel. |
|
1157 |
] |
|
202 | 1158 |
! ! |
1159 |
||
1160 |
!Label methodsFor:'change & update'! |
|
1161 |
||
1162 |
backgroundChannelChanged |
|
1163 |
self backgroundColor:(backgroundChannel value) |
|
1164 |
! |
|
1165 |
||
1166 |
foregroundChannelChanged |
|
1167 |
self foregroundColor:(foregroundChannel value) |
|
1168 |
! |
|
1169 |
||
1170 |
labelChannelChanged |
|
1171 |
self label:(labelChannel value) |
|
1172 |
! |
|
1173 |
||
1174 |
update:something with:aParameter from:changedObject |
|
1175 |
"the MVC way of changing the label ..." |
|
1176 |
||
1177 |
changedObject == model ifTrue:[ |
|
1178 |
something == aspectMsg ifTrue:[ |
|
1179 |
self getLabelFromModel. |
|
1180 |
^ self. |
|
1181 |
] |
|
1182 |
]. |
|
1183 |
^ super update:something with:aParameter from:changedObject |
|
1184 |
! ! |
|
1185 |
||
1186 |
!Label methodsFor:'event handling'! |
|
1187 |
||
1188 |
sizeChanged:how |
|
1189 |
"sent whenever size is changed by someone else - recompute the |
|
1190 |
logos position within the View." |
|
1191 |
||
1192 |
|prevPosition| |
|
1193 |
||
1194 |
super sizeChanged:how. |
|
1195 |
prevPosition := labelOriginX. |
|
1196 |
self computeLabelOrigin |
|
1197 |
shown ifTrue:[ |
|
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
1198 |
(adjust == #fit |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
1199 |
or:[labelOriginX ~~ prevPosition |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
1200 |
or:[how ~~ #smaller]]) ifTrue:[ |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
1201 |
"/ self clear. |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
1202 |
self invalidate. |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
1203 |
"/ self redrawEdges |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
1204 |
] |
105 | 1205 |
] |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
1206 |
|
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
1207 |
"Modified: 26.5.1996 / 18:09:58 / cg" |
0 | 1208 |
! ! |
1209 |
||
1210 |
!Label methodsFor:'initialization'! |
|
1211 |
||
935 | 1212 |
fetchDeviceResources |
1213 |
"fetch device colors, to avoid reallocation at redraw time" |
|
1214 |
||
1215 |
super fetchDeviceResources. |
|
1216 |
||
1217 |
fgColor := fgColor on:device. |
|
1218 |
bgColor := bgColor on:device. |
|
1219 |
||
1220 |
"Created: 13.1.1997 / 23:34:30 / cg" |
|
1221 |
! |
|
1222 |
||
0 | 1223 |
initStyle |
967 | 1224 |
"setup viewStyle specifics" |
1225 |
||
0 | 1226 |
super initStyle. |
1227 |
||
392
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
1228 |
"/ DefaultFont notNil ifTrue:[font := DefaultFont on:device]. |
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
1229 |
|
59 | 1230 |
DefaultBackgroundColor notNil ifTrue:[ |
935 | 1231 |
bgColor := DefaultBackgroundColor |
38 | 1232 |
] ifFalse:[ |
935 | 1233 |
bgColor := viewBackground. |
59 | 1234 |
]. |
1235 |
DefaultForegroundColor notNil ifTrue:[ |
|
935 | 1236 |
fgColor := DefaultForegroundColor |
59 | 1237 |
] ifFalse:[ |
935 | 1238 |
fgColor := Black. |
38 | 1239 |
] |
935 | 1240 |
|
967 | 1241 |
"Modified: 22.1.1997 / 11:57:19 / cg" |
0 | 1242 |
! |
1243 |
||
105 | 1244 |
initialize |
1245 |
super initialize. |
|
1246 |
||
1247 |
font := font on:device. |
|
832 | 1248 |
self initialHeight:(font height + font descent). |
105 | 1249 |
adjust := #center. |
118 | 1250 |
labelOriginX := labelOriginY := 0. |
1251 |
labelWidth := labelHeight := 0. |
|
105 | 1252 |
logo := nil. |
1253 |
fixSize := false. |
|
1254 |
hSpace := (self horizontalPixelPerMillimeter:0.5) rounded. |
|
131 | 1255 |
vSpace := (self verticalPixelPerMillimeter:0.25) rounded |
105 | 1256 |
! |
1257 |
||
0 | 1258 |
recreate |
1259 |
"after snapin, labels dimensions may have changed due to |
|
1260 |
different font parameters" |
|
1261 |
||
1262 |
super recreate. |
|
3 | 1263 |
font := font on:device. |
0 | 1264 |
self computeLabelSize. |
1265 |
self computeLabelOrigin |
|
1266 |
! ! |
|
1267 |
||
202 | 1268 |
!Label methodsFor:'private'! |
1269 |
||
1270 |
computeLabelOrigin |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1271 |
"(re)compute the origin of the label whenever label, font or view-size changes" |
202 | 1272 |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1273 |
|x y a| |
202 | 1274 |
|
1275 |
labelHeight isNil ifTrue:[^ self]. |
|
1276 |
||
1277 |
adjust == #fit ifTrue:[ |
|
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1278 |
labelOriginX := labelOriginY := margin. |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1279 |
^ self |
202 | 1280 |
]. |
1281 |
||
1282 |
"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
|
1283 |
or the center ? |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1284 |
(for text, the center seems better. |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1285 |
For images, I dont really know ...) |
202 | 1286 |
The commented code below makes the origin visible |
1287 |
" |
|
1288 |
"/ (labelHeight < height) ifTrue:[ |
|
1289 |
"/ y := (height - labelHeight) // 2 |
|
1290 |
"/ ] ifFalse:[ |
|
1291 |
"/ y := 0 |
|
1292 |
"/ ]. |
|
1293 |
||
1294 |
"always center vertically" |
|
1295 |
y := (height - labelHeight) // 2. |
|
1296 |
||
1297 |
labelOriginY := y. |
|
1298 |
||
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1299 |
a := adjust. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1300 |
(width < labelWidth) ifTrue:[ |
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1301 |
((adjust == #centerRight) or:[adjust == #leftRight]) ifTrue:[ |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1302 |
a := #right |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1303 |
] ifFalse:[ |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1304 |
((adjust == #centerLeft) or:[adjust == #rightLeft]) ifTrue:[ |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1305 |
a := #left |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1306 |
]. |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1307 |
] |
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1308 |
] ifFalse:[ |
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1309 |
((adjust == #centerRight) or:[adjust == #centerLeft]) ifTrue:[ |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1310 |
a := #center |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1311 |
] ifFalse:[ |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1312 |
adjust == #leftRight ifTrue:[ |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1313 |
a := #left |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1314 |
] ifFalse:[ |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1315 |
adjust == #rightLeft ifTrue:[ |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1316 |
a := #right |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1317 |
] |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1318 |
] |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1319 |
] |
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1320 |
]. |
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1321 |
|
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1322 |
(a == #center) ifTrue:[ |
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1323 |
" center text/form in button " |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1324 |
x := (width - labelWidth) // 2. |
202 | 1325 |
] ifFalse:[ |
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1326 |
(a == #left) ifTrue:[ |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1327 |
x := margin |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1328 |
] ifFalse:[ |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1329 |
"/ #right |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1330 |
x := width - labelWidth - margin |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1331 |
] |
202 | 1332 |
]. |
1333 |
labelOriginX := x |
|
318
73ea409232c0
new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
1334 |
|
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1335 |
"Modified: 13.5.1996 / 10:55:17 / cg" |
202 | 1336 |
! |
1337 |
||
1338 |
computeLabelSize |
|
1339 |
"compute the extent needed to hold the label; aForm or aString" |
|
1340 |
||
794 | 1341 |
|numberOfLines textHeight textWidth b max| |
202 | 1342 |
|
1343 |
logo isNil ifTrue:[^ self]. |
|
1344 |
||
1345 |
logo isString ifTrue:[ |
|
626 | 1346 |
numberOfLines := 1 + (logo occurrencesOf:(Character cr)). |
1347 |
(numberOfLines ~~ 1) ifTrue:[ |
|
1348 |
logo := logo asStringCollection |
|
1349 |
] |
|
202 | 1350 |
] ifFalse:[ |
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1351 |
(logo isKindOf:StringCollection) ifTrue:[ |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1352 |
numberOfLines := logo size. |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1353 |
(numberOfLines <= 1) ifTrue:[ |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1354 |
logo := logo asString |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1355 |
] |
626 | 1356 |
] |
202 | 1357 |
]. |
1358 |
||
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1359 |
numberOfLines isNil ifTrue:[ |
756 | 1360 |
(logo respondsTo:#preferredBounds) ifTrue:[ |
1361 |
b := logo preferredBounds. |
|
1362 |
labelWidth := b width. |
|
1363 |
labelHeight := b height. |
|
1364 |
] ifFalse:[ |
|
1365 |
labelWidth := logo widthOn:self. |
|
1366 |
labelHeight := logo heightOn:self. |
|
1367 |
]. |
|
640 | 1368 |
|
1369 |
"/ b := logo bounds. |
|
1370 |
"/ labelWidth := b right. |
|
1371 |
"/ labelHeight := b bottom. |
|
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1372 |
logo isImageOrForm ifFalse:[ |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1373 |
labelWidth := labelWidth + (hSpace * 2). |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1374 |
labelHeight := labelHeight + (vSpace * 2). |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1375 |
]. |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1376 |
|
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1377 |
^ self |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1378 |
]. |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1379 |
|
202 | 1380 |
"/ textHeight := font height * numberOfLines + font descent. |
626 | 1381 |
|
640 | 1382 |
logo isString ifTrue:[ |
1383 |
"/ a string or Text |
|
1384 |
textHeight := logo heightOn:self. |
|
1385 |
textWidth := logo widthOn:self. |
|
1386 |
] ifFalse:[ |
|
1387 |
"/ a StringCollection |
|
1388 |
textHeight := font height * numberOfLines. |
|
794 | 1389 |
"/ textWidth := font widthOf:logo. |
1390 |
||
1391 |
textWidth := 0. |
|
1392 |
logo do:[:line | |
|
1393 |
|this| |
|
1394 |
||
1395 |
line notNil ifTrue:[ |
|
1396 |
this := line asString widthOn:self. |
|
1397 |
(this > textWidth) ifTrue:[textWidth := this] |
|
1398 |
] |
|
1399 |
]. |
|
640 | 1400 |
]. |
1401 |
||
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1402 |
labelWidth := textWidth + (hSpace * 2). |
202 | 1403 |
labelHeight := textHeight + (vSpace * 2) |
626 | 1404 |
|
794 | 1405 |
"Modified: 17.7.1996 / 14:33:10 / cg" |
202 | 1406 |
! |
1407 |
||
1408 |
getLabelFromModel |
|
1409 |
"ask my model for the label to show. |
|
1410 |
Here, we use labelMsg (instead of aspectMsg). |
|
1411 |
This allows multiple labels to react on the same aspect, |
|
1412 |
but show different labels when changed |
|
1413 |
(also, since labelMsg defaults to nil, constant labels |
|
1414 |
which have a nil labelMsg will not try to aquire a labelString)." |
|
1415 |
||
1416 |
|val| |
|
1417 |
||
1418 |
(model notNil |
|
1419 |
and:[labelMsg notNil]) ifTrue:[ |
|
1420 |
val := model perform:labelMsg. |
|
1421 |
converter notNil ifTrue:[ |
|
1422 |
val := converter printStringFor:val |
|
1423 |
]. |
|
1424 |
self label:val. |
|
1425 |
]. |
|
1426 |
! |
|
1427 |
||
1428 |
newLayout |
|
1429 |
"recompute position/size after a change |
|
1430 |
- helper for form:/font: etc." |
|
1431 |
||
1432 |
self computeLabelSize. |
|
1433 |
fixSize ifFalse:[ |
|
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
1434 |
self resize |
202 | 1435 |
] ifTrue:[ |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
1436 |
self computeLabelOrigin |
202 | 1437 |
]. |
1438 |
shown ifTrue:[ |
|
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
1439 |
self invalidate |
202 | 1440 |
] |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
1441 |
|
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
1442 |
"Modified: 26.5.1996 / 18:09:52 / cg" |
202 | 1443 |
! ! |
1444 |
||
1445 |
!Label methodsFor:'queries'! |
|
1446 |
||
1447 |
preferredExtent |
|
1448 |
"return my preferred extent - this is the minimum size I would like to have" |
|
1449 |
||
1450 |
|extra| |
|
1451 |
||
799 | 1452 |
"/ If I have an explicit preferredExtent .. |
1453 |
||
713
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
1454 |
preferredExtent notNil ifTrue:[ |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
1455 |
^ preferredExtent |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
1456 |
]. |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
1457 |
|
361
b5cb40f55316
if size is fixed, return my actual size in #preferredExtent
ca
parents:
318
diff
changeset
|
1458 |
fixSize ifTrue:[^ self extent]. |
b5cb40f55316
if size is fixed, return my actual size in #preferredExtent
ca
parents:
318
diff
changeset
|
1459 |
|
303
8408cec09472
if undefined, set label to empty string when asked for preferredExtent (would otherwise return 0@0)
ah
parents:
275
diff
changeset
|
1460 |
logo isNil ifTrue:[ |
361
b5cb40f55316
if size is fixed, return my actual size in #preferredExtent
ca
parents:
318
diff
changeset
|
1461 |
self label:'' |
202 | 1462 |
]. |
1463 |
||
303
8408cec09472
if undefined, set label to empty string when asked for preferredExtent (would otherwise return 0@0)
ah
parents:
275
diff
changeset
|
1464 |
logo notNil ifTrue:[ |
361
b5cb40f55316
if size is fixed, return my actual size in #preferredExtent
ca
parents:
318
diff
changeset
|
1465 |
extra := margin * 2. |
b5cb40f55316
if size is fixed, return my actual size in #preferredExtent
ca
parents:
318
diff
changeset
|
1466 |
^ (labelWidth + extra + hSpace) @ (labelHeight + extra + vSpace) |
303
8408cec09472
if undefined, set label to empty string when asked for preferredExtent (would otherwise return 0@0)
ah
parents:
275
diff
changeset
|
1467 |
]. |
8408cec09472
if undefined, set label to empty string when asked for preferredExtent (would otherwise return 0@0)
ah
parents:
275
diff
changeset
|
1468 |
|
202 | 1469 |
^ super preferredExtent |
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1470 |
|
799 | 1471 |
"Modified: 19.7.1996 / 20:44:41 / cg" |
993 | 1472 |
! |
1473 |
||
1474 |
redrawsFull |
|
1475 |
^ true |
|
1476 |
||
1477 |
"Created: 7.2.1997 / 16:41:41 / cg" |
|
202 | 1478 |
! ! |
1479 |
||
0 | 1480 |
!Label methodsFor:'redrawing'! |
1481 |
||
77 | 1482 |
clearInsideWith:bg |
1483 |
|cutOff mustClear| |
|
0 | 1484 |
|
1485 |
cutOff := margin * 2. |
|
1486 |
||
3 | 1487 |
mustClear := true. |
1488 |
||
87 | 1489 |
(logo notNil and:[logo isImageOrForm]) ifTrue:[ |
59 | 1490 |
(labelOriginX == 0 and:[labelOriginY == 0]) ifTrue:[ |
1491 |
logo width >= (width - cutOff) ifTrue:[ |
|
1492 |
logo height >= (height - cutOff) ifTrue:[ |
|
1493 |
"no need to clear before - avoid flicker" |
|
1494 |
mustClear := false |
|
1495 |
] |
|
1496 |
] |
|
1497 |
]. |
|
3 | 1498 |
]. |
1499 |
||
1500 |
mustClear ifTrue:[ |
|
59 | 1501 |
self paint:bg. |
1502 |
self fillRectangleX:margin y:margin |
|
1503 |
width:(width - cutOff) |
|
1504 |
height:(height - cutOff). |
|
3 | 1505 |
]. |
77 | 1506 |
! |
1507 |
||
1508 |
drawWith:fg and:bg |
|
1509 |
"redraw my label with fg/bg - this generic method is also used by subclasses |
|
1510 |
(especially Button) to redraw the logo in different colors." |
|
1511 |
||
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1512 |
|x y scaleH scaleV nW nH hSep vSep m2 stringLogo| |
77 | 1513 |
|
1514 |
self clearInsideWith:bg. |
|
0 | 1515 |
|
1516 |
logo notNil ifTrue:[ |
|
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1517 |
self paint:fg on:bg. |
131 | 1518 |
|
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1519 |
m2 := margin * 2. |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1520 |
hSep := (hSpace*2). |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1521 |
vSep := (vSpace*2). |
133 | 1522 |
|
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1523 |
x := labelOriginX. |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1524 |
y := labelOriginY. |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1525 |
|
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1526 |
logo isImageOrForm ifTrue:[ |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1527 |
adjust == #fit ifTrue:[ |
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1528 |
"/ |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1529 |
"/ 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
|
1530 |
"/ |
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1531 |
scaleH := ((width - hSep) / (logo width)) asFloat. |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1532 |
scaleV := ((height - vSep) / (logo height)) asFloat. |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1533 |
self scale:(scaleH @ scaleV). |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1534 |
x := transformation applyInverseScaleX:x. |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1535 |
y := transformation applyInverseScaleY:y. |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1536 |
]. |
131 | 1537 |
|
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1538 |
logo := logo on:device. |
59 | 1539 |
"/ self background:bg. |
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1540 |
self displayOpaqueForm:logo x:x y:y |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1541 |
] ifFalse:[ |
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1542 |
x := x + hSpace. |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1543 |
y := y + vSpace. |
0 | 1544 |
|
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1545 |
(logo isString |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1546 |
or:[logo isKindOf:StringCollection]) ifTrue:[ |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1547 |
stringLogo := true. |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1548 |
y := y + (font ascent). |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1549 |
] ifFalse:[ |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1550 |
stringLogo := false. |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1551 |
]. |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1552 |
|
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1553 |
adjust == #fit ifTrue:[ |
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1554 |
"/ |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1555 |
"/ 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
|
1556 |
"/ |
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1557 |
scaleH := ((width - m2 - hSep) / (labelWidth - hSpace)) asFloat. |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1558 |
scaleV := ((height - m2 - vSep) / (labelHeight - vSpace)) asFloat. |
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1559 |
|
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1560 |
self scale:(scaleH min:scaleV). |
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1561 |
x := transformation applyInverseScaleX:x. |
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1562 |
stringLogo ifTrue:[ |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1563 |
y := y - font ascent + (transformation applyScaleY:font ascent). |
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1564 |
]. |
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1565 |
y := transformation applyInverseScaleY:y. |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1566 |
scaleH < scaleV ifTrue:[ |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1567 |
nH := labelHeight * scaleH. |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1568 |
"/ now, center vertically |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1569 |
y := y + ((height - nH - m2 - vSep) / scaleH / 2). |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1570 |
]. |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1571 |
scaleV < scaleH ifTrue:[ |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1572 |
"/ now, center horizontally |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1573 |
nW := labelWidth * scaleV. |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1574 |
x := x + ((width - nW - m2 - hSep) / scaleV / 2) |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1575 |
]. |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1576 |
]. |
131 | 1577 |
|
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1578 |
logo isString ifTrue:[ |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1579 |
self displayOpaqueString:logo x:x y:y |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1580 |
] ifFalse:[ |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1581 |
(logo isKindOf:StringCollection) ifTrue:[ |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1582 |
logo do:[ :line | |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1583 |
self displayOpaqueString:(line printString) x:x y:y. |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1584 |
y := y + (font height) |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1585 |
] |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1586 |
] ifFalse:[ |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1587 |
"/ anything |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1588 |
logo displayOn:self x:x y:y |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1589 |
] |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1590 |
]. |
131 | 1591 |
|
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1592 |
]. |
131 | 1593 |
|
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1594 |
adjust == #fit ifTrue:[ |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1595 |
self scale:1 |
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1596 |
]. |
131 | 1597 |
|
0 | 1598 |
] |
636
02b141814b92
unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
1599 |
|
639
26c56f23fa19
fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
1600 |
"Modified: 13.5.1996 / 11:16:37 / cg" |
0 | 1601 |
! |
1602 |
||
1603 |
redraw |
|
1604 |
"redraw my label" |
|
1605 |
||
1606 |
shown ifTrue:[ |
|
59 | 1607 |
self drawWith:fgColor and:bgColor |
0 | 1608 |
] |
1609 |
! ! |
|
105 | 1610 |
|
110 | 1611 |
!Label methodsFor:'resizing'! |
1612 |
||
1613 |
forceResize |
|
118 | 1614 |
"resize myself to make text fit into myself. Here, this is done even if |
1615 |
fixSize is set." |
|
110 | 1616 |
|
1617 |
logo notNil ifTrue:[ |
|
130 | 1618 |
self extent:self preferredExtent. |
110 | 1619 |
self computeLabelOrigin |
1620 |
] |
|
105 | 1621 |
! |
1622 |
||
1623 |
resize |
|
1624 |
"resize myself to make text fit into myself. |
|
118 | 1625 |
but only do so, if I am not fixedSize and I have NOT been |
1626 |
given a relative extent or an extend computation block." |
|
105 | 1627 |
|
110 | 1628 |
(logo notNil |
1629 |
and:[fixSize not |
|
1630 |
and:[relativeExtent isNil |
|
1631 |
and:[extentRule isNil |
|
1632 |
and:[relativeCorner isNil |
|
1633 |
and:[cornerRule isNil]]]]]) ifTrue:[ |
|
1634 |
self forceResize |
|
1635 |
] ifFalse:[ |
|
105 | 1636 |
self computeLabelOrigin |
1637 |
] |
|
1638 |
! ! |
|
1639 |
||
935 | 1640 |
!Label class methodsFor:'documentation'! |
205 | 1641 |
|
1642 |
version |
|
1039 | 1643 |
^ '$Header: /cvs/stx/stx/libwidg/Label.st,v 1.74 1997-02-24 20:10:55 ca Exp $' |
205 | 1644 |
! ! |