author | Claus Gittinger <cg@exept.de> |
Mon, 21 Aug 2000 23:54:15 +0200 | |
changeset 1817 | e639d2a9d605 |
parent 1814 | a7697ca7f34f |
child 1860 | b4c0e45ad336 |
permissions | -rw-r--r-- |
172 | 1 |
" |
2 |
COPYRIGHT (c) 1996 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
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 |
||
1814
a7697ca7f34f
added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
14 |
"{ Package: 'stx:libwidg2' }" |
a7697ca7f34f
added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
15 |
|
172 | 16 |
ListEntry subclass:#LabelAndIcon |
981
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
17 |
instanceVariableNames:'icon gap string image offset' |
172 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'Views-Support' |
|
21 |
! |
|
22 |
||
23 |
!LabelAndIcon class methodsFor:'documentation'! |
|
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1996 by Claus Gittinger |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
||
38 |
! |
|
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
an icon and a string, side by side. |
|
178 | 43 |
Usable as list entries in a listView (a fileList), as |
179 | 44 |
popUpMenuItems or as Label/Button image. |
172 | 45 |
|
46 |
This is an example class - currently not used by the system. |
|
47 |
||
179 | 48 |
Notice: |
49 |
This is different from ST-80's LabelAndIcon class, which |
|
50 |
inherits from Label. Therefore, things may change in the future. |
|
51 |
||
172 | 52 |
[author:] |
53 |
Claus Gittinger |
|
54 |
||
55 |
[see also:] |
|
56 |
ListEntry Text String Icon |
|
57 |
ListView SelectionInListView |
|
58 |
" |
|
59 |
! |
|
60 |
||
61 |
examples |
|
62 |
" |
|
175 | 63 |
in a listView: |
172 | 64 |
[exBegin] |
65 |
|top slv wrapper l fileImage dirImage| |
|
66 |
||
67 |
fileImage := Image |
|
68 |
width:16 |
|
69 |
height:16 |
|
70 |
depth:1 |
|
71 |
fromArray:#[2r00000000 2r00000000 |
|
72 |
2r00000000 2r00000000 |
|
73 |
2r00011111 2r11100000 |
|
74 |
2r00010000 2r00100000 |
|
75 |
2r00010000 2r00011000 |
|
76 |
2r00010000 2r00001000 |
|
77 |
2r00010000 2r00001000 |
|
78 |
2r00010000 2r00001000 |
|
79 |
2r00010000 2r00001000 |
|
80 |
2r00010000 2r00001000 |
|
81 |
2r00010000 2r00001000 |
|
82 |
2r00010000 2r00001000 |
|
83 |
2r00010000 2r00001000 |
|
84 |
2r00011111 2r11111000 |
|
85 |
2r00000000 2r00000000 |
|
86 |
2r00000000 2r00000000]. |
|
87 |
fileImage photometric:#whiteIs0. |
|
88 |
||
89 |
dirImage := Image |
|
90 |
width:16 |
|
91 |
height:16 |
|
92 |
depth:1 |
|
93 |
fromArray:#[2r00000000 2r00000000 |
|
94 |
2r00000000 2r00000000 |
|
95 |
2r00000000 2r00000000 |
|
96 |
2r01111111 2r11110000 |
|
97 |
2r01000000 2r00001000 |
|
98 |
2r01000000 2r00000100 |
|
99 |
2r01000000 2r00000010 |
|
100 |
2r01000000 2r00000010 |
|
101 |
2r01000000 2r00000010 |
|
102 |
2r01000000 2r00000010 |
|
103 |
2r01000000 2r00000010 |
|
104 |
2r01000000 2r00000010 |
|
105 |
2r01111111 2r11111110 |
|
106 |
2r00000000 2r00000000 |
|
107 |
2r00000000 2r00000000 |
|
108 |
2r00000000 2r00000000]. |
|
109 |
dirImage photometric:#whiteIs0. |
|
110 |
||
111 |
||
112 |
l := OrderedCollection new. |
|
113 |
Filename currentDirectory directoryContents do:[:s | |
|
114 |
s asFilename isDirectory ifTrue:[ |
|
115 |
l add:(LabelAndIcon icon:dirImage string:s) |
|
116 |
] ifFalse:[ |
|
117 |
l add:(LabelAndIcon icon:fileImage string:s) |
|
118 |
] |
|
119 |
]. |
|
120 |
||
121 |
slv := SelectionInListView new. |
|
122 |
slv list:l. |
|
123 |
wrapper := HVScrollableView forView:slv miniScrollerH:true. |
|
124 |
||
125 |
top := StandardSystemView extent:150@200. |
|
126 |
top add:wrapper in:(0.0@0.0 corner:1.0@1.0). |
|
127 |
top open. |
|
128 |
[exEnd] |
|
175 | 129 |
in a selectionInListView: |
172 | 130 |
[exBegin] |
131 |
|top slv wrapper l fileImage dirImage| |
|
132 |
||
133 |
dirImage := Image fromFile:'DirObj.xbm'. |
|
134 |
fileImage := Image fromFile:'FileObj.xbm'. |
|
135 |
||
136 |
||
137 |
l := OrderedCollection new. |
|
138 |
Filename currentDirectory directoryContents do:[:s | |
|
139 |
s asFilename isDirectory ifTrue:[ |
|
140 |
l add:(LabelAndIcon icon:dirImage string:s) |
|
141 |
] ifFalse:[ |
|
142 |
l add:(LabelAndIcon icon:fileImage string:s) |
|
143 |
] |
|
144 |
]. |
|
145 |
||
146 |
slv := SelectionInListView new. |
|
147 |
slv list:l. |
|
148 |
wrapper := HVScrollableView forView:slv miniScrollerH:true. |
|
149 |
||
150 |
top := StandardSystemView extent:150@200. |
|
151 |
top add:wrapper in:(0.0@0.0 corner:1.0@1.0). |
|
152 |
top open. |
|
153 |
[exEnd] |
|
175 | 154 |
in a menu: |
155 |
[exBegin] |
|
156 |
|top l fileImage dirImage| |
|
157 |
||
158 |
dirImage := Image fromFile:'DirObj.xbm'. |
|
159 |
fileImage := Image fromFile:'FileObj.xbm'. |
|
160 |
||
161 |
||
162 |
l := OrderedCollection new. |
|
163 |
l add:(LabelAndIcon icon:dirImage string:'create directory'). |
|
164 |
l add:(LabelAndIcon icon:fileImage string:'create file'). |
|
165 |
||
166 |
top := View new. |
|
167 |
||
168 |
top middleButtonMenu:(PopUpMenu labels:l |
|
169 |
selectors:#(foo bar)). |
|
170 |
||
171 |
top open. |
|
172 |
[exEnd] |
|
178 | 173 |
in a button/label: |
174 |
[exBegin] |
|
175 |
|top l image| |
|
176 |
||
177 |
image := Image fromFile:'DirObj.xbm'. |
|
178 |
l := (LabelAndIcon icon:image string:'directory'). |
|
179 |
||
180 |
top := Button label:l. |
|
181 |
top open. |
|
182 |
[exEnd] |
|
172 | 183 |
" |
184 |
! ! |
|
185 |
||
186 |
!LabelAndIcon class methodsFor:'instance creation'! |
|
187 |
||
629 | 188 |
form:aForm image:anImage |
726 | 189 |
|
629 | 190 |
^self new form:aForm image:anImage string:'' |
191 |
! |
|
192 |
||
193 |
form:aForm image:anImage string:aString |
|
726 | 194 |
|
629 | 195 |
^self new form:aForm image:anImage string:aString |
196 |
! |
|
197 |
||
172 | 198 |
icon:anIcon string:aString |
726 | 199 |
|
172 | 200 |
^ self new icon:anIcon string:aString |
201 |
||
202 |
"Created: 12.5.1996 / 20:00:58 / cg" |
|
203 |
! |
|
204 |
||
205 |
new |
|
206 |
^ self basicNew initialize |
|
207 |
||
208 |
"Created: 12.5.1996 / 20:00:58 / cg" |
|
986
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
209 |
! |
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
210 |
|
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
211 |
string:aString |
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
212 |
|
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
213 |
^ self new icon:nil string:aString |
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
214 |
|
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
215 |
"Created: / 21.6.1998 / 04:57:28 / cg" |
172 | 216 |
! ! |
217 |
||
218 |
!LabelAndIcon methodsFor:'accessing'! |
|
219 |
||
986
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
220 |
beCheckMark |
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
221 |
self icon:(CheckToggle checkFormOn:Screen current) |
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
222 |
|
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
223 |
"Created: / 21.6.1998 / 05:01:01 / cg" |
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
224 |
"Modified: / 21.6.1998 / 05:03:23 / cg" |
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
225 |
! |
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
226 |
|
629 | 227 |
form:aForm image:anImage string:aString |
228 |
||
229 |
icon := aForm. |
|
230 |
image:= anImage. |
|
231 |
string := aString. |
|
232 |
! |
|
233 |
||
172 | 234 |
gap:pixels |
235 |
"set the spacing between the icon and the labelString. |
|
236 |
The default is 4." |
|
237 |
||
238 |
gap := pixels. |
|
239 |
||
240 |
"Created: 12.5.1996 / 20:00:52 / cg" |
|
241 |
! |
|
242 |
||
286 | 243 |
icon |
244 |
"return my icon part" |
|
245 |
||
246 |
^ icon |
|
247 |
! |
|
248 |
||
172 | 249 |
icon:anIcon |
250 |
"set the icon image" |
|
251 |
||
252 |
icon := anIcon. |
|
253 |
||
254 |
"Created: 12.5.1996 / 20:00:52 / cg" |
|
255 |
! |
|
256 |
||
257 |
icon:anIcon string:aString |
|
258 |
"set both iconImage and the labelString" |
|
259 |
||
260 |
icon := anIcon. |
|
261 |
string := aString |
|
262 |
||
263 |
"Created: 12.5.1996 / 20:00:52 / cg" |
|
175 | 264 |
! |
265 |
||
719 | 266 |
image |
267 |
"return my image" |
|
268 |
||
269 |
^ image |
|
270 |
! |
|
271 |
||
272 |
image:anImage |
|
273 |
"set the image" |
|
274 |
||
275 |
image := anImage |
|
276 |
! |
|
277 |
||
981
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
278 |
offset:pixels |
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
279 |
"set the left offset (i.e. spacing to the left of the icon). |
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
280 |
The default is 0." |
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
281 |
|
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
282 |
offset := pixels. |
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
283 |
|
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
284 |
"Created: / 21.6.1998 / 03:11:03 / cg" |
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
285 |
! |
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
286 |
|
175 | 287 |
string |
180 | 288 |
"return my string part" |
289 |
||
175 | 290 |
^ string |
258 | 291 |
! |
292 |
||
293 |
string:aString |
|
294 |
"set the labelString" |
|
295 |
||
296 |
string := aString |
|
297 |
||
298 |
"Created: 12.5.1996 / 20:00:52 / cg" |
|
172 | 299 |
! ! |
300 |
||
1814
a7697ca7f34f
added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
301 |
!LabelAndIcon methodsFor:'comparing'! |
a7697ca7f34f
added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
302 |
|
a7697ca7f34f
added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
303 |
sameStringAndEmphasisAs:someStringOrLabelAndIcon |
1817 | 304 |
someStringOrLabelAndIcon class == self class ifTrue:[ |
305 |
icon = someStringOrLabelAndIcon icon ifFalse:[^ false]. |
|
306 |
image = someStringOrLabelAndIcon image ifFalse:[^ false]. |
|
307 |
(string sameStringAndEmphasisAs:someStringOrLabelAndIcon string) ifFalse:[ ^ false]. |
|
308 |
^ true. |
|
309 |
]. |
|
310 |
||
1814
a7697ca7f34f
added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
311 |
(string sameStringAndEmphasisAs:someStringOrLabelAndIcon) ifFalse:[ ^ false]. |
a7697ca7f34f
added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
312 |
(icon isNil and:[image isNil]) ifTrue:[^ true]. |
1817 | 313 |
^ false |
1814
a7697ca7f34f
added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
314 |
! ! |
a7697ca7f34f
added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
315 |
|
177 | 316 |
!LabelAndIcon methodsFor:'conversion'! |
317 |
||
318 |
asString |
|
180 | 319 |
"return my string part" |
320 |
||
177 | 321 |
^ string |
322 |
||
323 |
"Created: 12.5.1996 / 21:26:47 / cg" |
|
324 |
! ! |
|
325 |
||
172 | 326 |
!LabelAndIcon methodsFor:'displaying'! |
327 |
||
328 |
displayOn:aGC x:x y:y opaque:opaque |
|
329 |
"display the receiver on a GC" |
|
330 |
||
726 | 331 |
|y1 x1 iconHeight imageHeight stringHeight maxHeight gapY asc| |
332 |
||
333 |
gapY := (aGC device pixelPerMillimeter x) rounded. |
|
1479 | 334 |
asc := (aGC font onDevice:aGC device) ascent. |
180 | 335 |
|
726 | 336 |
iconHeight := icon notNil ifTrue:[icon height] ifFalse:[0]. |
337 |
imageHeight := image notNil ifTrue:[image height] ifFalse:[0]. |
|
338 |
stringHeight := string size > 0 ifTrue:[string heightOn:aGC] ifFalse:[0]. |
|
172 | 339 |
|
726 | 340 |
maxHeight := ((iconHeight max: imageHeight) + gapY) max: stringHeight. |
981
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
341 |
x1 := x + offset. |
258 | 342 |
|
306 | 343 |
icon notNil ifTrue:[ |
726 | 344 |
y1 := y - asc + (maxHeight - iconHeight + 1 // 2). |
345 |
icon := icon onDevice:aGC device. |
|
578
72916ad0a5f3
fixed centering of the image w.r.t. the fontHeight
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
346 |
|
726 | 347 |
(opaque and:[icon mask isNil]) ifTrue:[aGC displayOpaqueForm:icon x:x1 y:y1] |
348 |
ifFalse:[aGC displayForm:icon x:x1 y:y1]. |
|
578
72916ad0a5f3
fixed centering of the image w.r.t. the fontHeight
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
349 |
|
726 | 350 |
x1 := x1 + icon width + gap |
258 | 351 |
]. |
352 |
||
629 | 353 |
image notNil ifTrue:[ |
726 | 354 |
y1 := y - asc + (maxHeight - imageHeight + 1 // 2). |
355 |
image := image onDevice:aGC device. |
|
356 |
||
357 |
(opaque and:[image mask isNil]) ifTrue:[aGC displayOpaqueForm:image x:x1 y:y1] |
|
358 |
ifFalse:[aGC displayForm:image x:x1 y:y1]. |
|
629 | 359 |
|
726 | 360 |
x1 := x1 + image width + gap |
629 | 361 |
]. |
172 | 362 |
|
726 | 363 |
stringHeight ~~ 0 ifTrue:[ |
364 |
y1 := y + (maxHeight - stringHeight + 1 // 2). |
|
981
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
365 |
string displayOn:aGC x:x1 y:y1 opaque:opaque |
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
366 |
] |
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
367 |
|
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
368 |
"Modified: / 21.6.1998 / 03:52:12 / cg" |
810 | 369 |
! |
370 |
||
371 |
on:aDevice |
|
372 |
"return a new image on a device |
|
373 |
" |
|
1604
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
374 |
^ self onDevice:aDevice |
810 | 375 |
|
376 |
! |
|
377 |
||
378 |
onDevice:aDevice |
|
379 |
"return a new image on a device |
|
380 |
" |
|
1604
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
381 |
|form img| |
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
382 |
|
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
383 |
aDevice isNil ifTrue:[^ self]. |
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
384 |
icon notNil ifTrue:[form := icon onDevice:aDevice]. |
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
385 |
image notNil ifTrue:[img := image onDevice:aDevice]. |
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
386 |
|
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
387 |
^ LabelAndIcon form:form image:img string:string |
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
388 |
|
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
389 |
|
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
390 |
|
172 | 391 |
! ! |
392 |
||
393 |
!LabelAndIcon methodsFor:'initialization'! |
|
394 |
||
395 |
initialize |
|
981
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
396 |
gap := 4. |
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
397 |
offset := 0. |
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
398 |
|
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
399 |
"Modified: / 21.6.1998 / 03:10:19 / cg" |
172 | 400 |
! ! |
401 |
||
402 |
!LabelAndIcon methodsFor:'queries'! |
|
403 |
||
404 |
heightOn:aGC |
|
405 |
"return the height of the receiver, if it is to be displayed on aGC" |
|
406 |
||
719 | 407 |
|iconHeight imageHeight stringHeight oneMillimeter| |
682 | 408 |
|
409 |
oneMillimeter := aGC device pixelPerMillimeter x rounded. |
|
306 | 410 |
|
411 |
icon notNil ifTrue:[ |
|
682 | 412 |
iconHeight := icon height + oneMillimeter |
306 | 413 |
] ifFalse:[ |
414 |
iconHeight := 0 |
|
415 |
]. |
|
629 | 416 |
image notNil ifTrue:[ |
682 | 417 |
imageHeight := image height + oneMillimeter |
629 | 418 |
] ifFalse:[ |
419 |
imageHeight := 0 |
|
420 |
]. |
|
719 | 421 |
string size > 0 ifTrue:[ |
422 |
stringHeight := string heightOn:aGC |
|
423 |
] ifFalse:[ |
|
424 |
stringHeight := 0 |
|
425 |
]. |
|
726 | 426 |
^ ((iconHeight max: imageHeight) max: stringHeight) |
172 | 427 |
! |
428 |
||
429 |
widthOn:aGC |
|
430 |
"return the width of the receiver, if it is to be displayed on aGC" |
|
431 |
||
719 | 432 |
|width| |
306 | 433 |
|
981
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
434 |
width := offset. |
306 | 435 |
icon notNil ifTrue:[ |
719 | 436 |
width := width + icon width |
306 | 437 |
]. |
629 | 438 |
image notNil ifTrue:[ |
719 | 439 |
width := width + gap + image width |
629 | 440 |
]. |
719 | 441 |
string size > 0 ifTrue:[ |
442 |
width := width + gap + (string widthOn:aGC) |
|
443 |
]. |
|
444 |
^width |
|
981
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
445 |
|
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
446 |
"Modified: / 21.6.1998 / 03:11:14 / cg" |
172 | 447 |
! ! |
448 |
||
449 |
!LabelAndIcon class methodsFor:'documentation'! |
|
450 |
||
451 |
version |
|
1817 | 452 |
^ '$Header: /cvs/stx/stx/libwidg2/LabelAndIcon.st,v 1.27 2000-08-21 21:54:15 cg Exp $' |
172 | 453 |
! ! |