author | Claus Gittinger <cg@exept.de> |
Wed, 10 Nov 2004 13:41:39 +0100 | |
changeset 2773 | ba1b2f93afee |
parent 2674 | e877ecb7d8b7 |
child 3132 | 9ee61ede263a |
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 |
|
2197
7ad026a1ae93
Make subclass of ModelListEntry
Stefan Vogel <sv@exept.de>
parents:
1977
diff
changeset
|
16 |
ModelListEntry subclass:#LabelAndIcon |
7ad026a1ae93
Make subclass of ModelListEntry
Stefan Vogel <sv@exept.de>
parents:
1977
diff
changeset
|
17 |
instanceVariableNames:'icon gap 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 |
||
1977 | 205 |
label:aString icon:anIcon |
206 |
^ self new icon:anIcon string:aString |
|
207 |
! |
|
208 |
||
172 | 209 |
new |
210 |
^ self basicNew initialize |
|
211 |
||
212 |
"Created: 12.5.1996 / 20:00:58 / cg" |
|
986
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
213 |
! |
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 |
string:aString |
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
216 |
|
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
217 |
^ self new icon:nil string:aString |
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
218 |
|
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
219 |
"Created: / 21.6.1998 / 04:57:28 / cg" |
172 | 220 |
! ! |
221 |
||
222 |
!LabelAndIcon methodsFor:'accessing'! |
|
223 |
||
986
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
224 |
beCheckMark |
1860 | 225 |
"/ self icon:(CheckToggle checkFormOn:Screen current) |
226 |
self icon:((CheckToggle smallCheckImageForStyle:#borderedFatcross) onDevice:Screen current) |
|
986
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
227 |
|
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
228 |
"Created: / 21.6.1998 / 05:01:01 / cg" |
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
229 |
"Modified: / 21.6.1998 / 05:03:23 / cg" |
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
230 |
! |
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
231 |
|
629 | 232 |
form:aForm image:anImage string:aString |
233 |
||
234 |
icon := aForm. |
|
235 |
image:= anImage. |
|
236 |
string := aString. |
|
237 |
! |
|
238 |
||
1975 | 239 |
gap |
240 |
"return the spacing between the icon and the labelString. |
|
241 |
The default is 4" |
|
242 |
||
243 |
^ gap |
|
244 |
! |
|
245 |
||
172 | 246 |
gap:pixels |
247 |
"set the spacing between the icon and the labelString. |
|
248 |
The default is 4." |
|
249 |
||
250 |
gap := pixels. |
|
251 |
||
252 |
"Created: 12.5.1996 / 20:00:52 / cg" |
|
253 |
! |
|
254 |
||
286 | 255 |
icon |
256 |
"return my icon part" |
|
257 |
||
258 |
^ icon |
|
259 |
! |
|
260 |
||
172 | 261 |
icon:anIcon |
262 |
"set the icon image" |
|
263 |
||
264 |
icon := anIcon. |
|
265 |
||
266 |
"Created: 12.5.1996 / 20:00:52 / cg" |
|
267 |
! |
|
268 |
||
269 |
icon:anIcon string:aString |
|
270 |
"set both iconImage and the labelString" |
|
271 |
||
272 |
icon := anIcon. |
|
273 |
string := aString |
|
274 |
||
275 |
"Created: 12.5.1996 / 20:00:52 / cg" |
|
175 | 276 |
! |
277 |
||
719 | 278 |
image |
279 |
"return my image" |
|
280 |
||
281 |
^ image |
|
282 |
! |
|
283 |
||
284 |
image:anImage |
|
285 |
"set the image" |
|
286 |
||
287 |
image := anImage |
|
288 |
! |
|
289 |
||
981
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
290 |
offset:pixels |
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
291 |
"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
|
292 |
The default is 0." |
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
293 |
|
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
294 |
offset := pixels. |
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
295 |
|
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
296 |
"Created: / 21.6.1998 / 03:11:03 / cg" |
172 | 297 |
! ! |
298 |
||
1814
a7697ca7f34f
added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
299 |
!LabelAndIcon methodsFor:'comparing'! |
a7697ca7f34f
added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
300 |
|
2657
20d7ed550989
also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
301 |
= aStringOrLabelAndIcon |
2674
e877ecb7d8b7
Allow #= comparison against nil
Stefan Vogel <sv@exept.de>
parents:
2657
diff
changeset
|
302 |
|
e877ecb7d8b7
Allow #= comparison against nil
Stefan Vogel <sv@exept.de>
parents:
2657
diff
changeset
|
303 |
aStringOrLabelAndIcon isNil ifTrue:[^ false]. |
e877ecb7d8b7
Allow #= comparison against nil
Stefan Vogel <sv@exept.de>
parents:
2657
diff
changeset
|
304 |
|
2657
20d7ed550989
also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
305 |
self hasIcon == aStringOrLabelAndIcon hasIcon ifFalse:[^ false]. |
20d7ed550989
also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
306 |
aStringOrLabelAndIcon hasIcon ifTrue:[ |
20d7ed550989
also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
307 |
icon = aStringOrLabelAndIcon icon ifFalse:[^ false]. |
20d7ed550989
also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
308 |
]. |
20d7ed550989
also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
309 |
self hasImage == aStringOrLabelAndIcon hasImage ifFalse:[^ false]. |
20d7ed550989
also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
310 |
aStringOrLabelAndIcon hasImage ifTrue:[ |
20d7ed550989
also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
311 |
image = aStringOrLabelAndIcon image ifFalse:[^ false]. |
20d7ed550989
also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
312 |
]. |
20d7ed550989
also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
313 |
^ super = aStringOrLabelAndIcon |
20d7ed550989
also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
314 |
! |
20d7ed550989
also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
315 |
|
1814
a7697ca7f34f
added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
316 |
sameStringAndEmphasisAs:someStringOrLabelAndIcon |
1817 | 317 |
someStringOrLabelAndIcon class == self class ifTrue:[ |
318 |
icon = someStringOrLabelAndIcon icon ifFalse:[^ false]. |
|
319 |
image = someStringOrLabelAndIcon image ifFalse:[^ false]. |
|
320 |
(string sameStringAndEmphasisAs:someStringOrLabelAndIcon string) ifFalse:[ ^ false]. |
|
321 |
^ true. |
|
322 |
]. |
|
323 |
||
1814
a7697ca7f34f
added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
324 |
(string sameStringAndEmphasisAs:someStringOrLabelAndIcon) ifFalse:[ ^ false]. |
a7697ca7f34f
added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
325 |
(icon isNil and:[image isNil]) ifTrue:[^ true]. |
1817 | 326 |
^ false |
1814
a7697ca7f34f
added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
327 |
! ! |
a7697ca7f34f
added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
328 |
|
172 | 329 |
!LabelAndIcon methodsFor:'displaying'! |
330 |
||
2453
3dad4e5c2fbe
ascentOn: (is this correct ?)
Claus Gittinger <cg@exept.de>
parents:
2197
diff
changeset
|
331 |
ascentOn:aGC |
2454 | 332 |
^ aGC font ascentOn:aGC device. |
2453
3dad4e5c2fbe
ascentOn: (is this correct ?)
Claus Gittinger <cg@exept.de>
parents:
2197
diff
changeset
|
333 |
! |
3dad4e5c2fbe
ascentOn: (is this correct ?)
Claus Gittinger <cg@exept.de>
parents:
2197
diff
changeset
|
334 |
|
172 | 335 |
displayOn:aGC x:x y:y opaque:opaque |
336 |
"display the receiver on a GC" |
|
337 |
||
2773 | 338 |
|y1 x1 iconValue imageValue iconHeight imageHeight stringHeight maxHeight gapY asc| |
726 | 339 |
|
340 |
gapY := (aGC device pixelPerMillimeter x) rounded. |
|
1860 | 341 |
"/ gapY := 0. |
1479 | 342 |
asc := (aGC font onDevice:aGC device) ascent. |
180 | 343 |
|
2773 | 344 |
iconValue := icon value. |
345 |
imageValue := image value. |
|
346 |
||
347 |
iconHeight := iconValue notNil ifTrue:[iconValue height] ifFalse:[0]. |
|
348 |
imageHeight := imageValue notNil ifTrue:[imageValue height] ifFalse:[0]. |
|
726 | 349 |
stringHeight := string size > 0 ifTrue:[string heightOn:aGC] ifFalse:[0]. |
172 | 350 |
|
726 | 351 |
maxHeight := ((iconHeight max: imageHeight) + gapY) max: stringHeight. |
981
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
352 |
x1 := x + offset. |
258 | 353 |
|
2773 | 354 |
iconValue notNil ifTrue:[ |
726 | 355 |
y1 := y - asc + (maxHeight - iconHeight + 1 // 2). |
1860 | 356 |
|
2773 | 357 |
icon := iconValue onDevice:aGC device. |
578
72916ad0a5f3
fixed centering of the image w.r.t. the fontHeight
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
358 |
|
2773 | 359 |
(opaque and:[iconValue mask isNil]) ifTrue:[aGC displayOpaqueForm:iconValue x:x1 y:y1] |
360 |
ifFalse:[aGC displayForm:iconValue 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
|
361 |
|
2773 | 362 |
x1 := x1 + iconValue width + gap |
258 | 363 |
]. |
364 |
||
2773 | 365 |
imageValue notNil ifTrue:[ |
726 | 366 |
y1 := y - asc + (maxHeight - imageHeight + 1 // 2). |
2773 | 367 |
image := imageValue onDevice:aGC device. |
726 | 368 |
|
2773 | 369 |
(opaque and:[imageValue mask isNil]) ifTrue:[aGC displayOpaqueForm:imageValue x:x1 y:y1] |
370 |
ifFalse:[aGC displayForm:imageValue x:x1 y:y1]. |
|
629 | 371 |
|
2773 | 372 |
x1 := x1 + imageValue width + gap |
629 | 373 |
]. |
172 | 374 |
|
726 | 375 |
stringHeight ~~ 0 ifTrue:[ |
376 |
y1 := y + (maxHeight - stringHeight + 1 // 2). |
|
981
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
377 |
string displayOn:aGC x:x1 y:y1 opaque:opaque |
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
378 |
] |
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
379 |
|
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
380 |
"Modified: / 21.6.1998 / 03:52:12 / cg" |
810 | 381 |
! |
382 |
||
383 |
on:aDevice |
|
384 |
"return a new image on a device |
|
385 |
" |
|
1604
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
386 |
^ self onDevice:aDevice |
810 | 387 |
|
388 |
! |
|
389 |
||
390 |
onDevice:aDevice |
|
391 |
"return a new image on a device |
|
392 |
" |
|
1604
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
393 |
|form img| |
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
394 |
|
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
395 |
aDevice isNil ifTrue:[^ self]. |
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
396 |
icon notNil ifTrue:[form := icon onDevice:aDevice]. |
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
397 |
image notNil ifTrue:[img := image onDevice:aDevice]. |
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
398 |
|
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
399 |
^ LabelAndIcon form:form image:img string:string |
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
400 |
|
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
401 |
|
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
402 |
|
172 | 403 |
! ! |
404 |
||
405 |
!LabelAndIcon methodsFor:'initialization'! |
|
406 |
||
407 |
initialize |
|
981
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
408 |
gap := 4. |
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
409 |
offset := 0. |
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
410 |
|
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
411 |
"Modified: / 21.6.1998 / 03:10:19 / cg" |
172 | 412 |
! ! |
413 |
||
414 |
!LabelAndIcon methodsFor:'queries'! |
|
415 |
||
2657
20d7ed550989
also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
416 |
hasIcon |
20d7ed550989
also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
417 |
^ icon notNil |
20d7ed550989
also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
418 |
! |
20d7ed550989
also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
419 |
|
20d7ed550989
also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
420 |
hasImage |
20d7ed550989
also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
421 |
^ image notNil |
20d7ed550989
also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
422 |
! |
20d7ed550989
also coare for icon and image when comparing
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
423 |
|
172 | 424 |
heightOn:aGC |
425 |
"return the height of the receiver, if it is to be displayed on aGC" |
|
426 |
||
719 | 427 |
|iconHeight imageHeight stringHeight oneMillimeter| |
682 | 428 |
|
429 |
oneMillimeter := aGC device pixelPerMillimeter x rounded. |
|
1860 | 430 |
"/ oneMillimeter := 0. |
306 | 431 |
|
432 |
icon notNil ifTrue:[ |
|
2773 | 433 |
iconHeight := icon value height + oneMillimeter |
306 | 434 |
] ifFalse:[ |
435 |
iconHeight := 0 |
|
436 |
]. |
|
629 | 437 |
image notNil ifTrue:[ |
2773 | 438 |
imageHeight := image value height + oneMillimeter |
629 | 439 |
] ifFalse:[ |
440 |
imageHeight := 0 |
|
441 |
]. |
|
719 | 442 |
string size > 0 ifTrue:[ |
443 |
stringHeight := string heightOn:aGC |
|
444 |
] ifFalse:[ |
|
445 |
stringHeight := 0 |
|
446 |
]. |
|
726 | 447 |
^ ((iconHeight max: imageHeight) max: stringHeight) |
172 | 448 |
! |
449 |
||
450 |
widthOn:aGC |
|
451 |
"return the width of the receiver, if it is to be displayed on aGC" |
|
452 |
||
719 | 453 |
|width| |
306 | 454 |
|
981
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
455 |
width := offset. |
306 | 456 |
icon notNil ifTrue:[ |
2773 | 457 |
width := width + icon value width |
306 | 458 |
]. |
629 | 459 |
image notNil ifTrue:[ |
2773 | 460 |
width := width + gap + image value width |
629 | 461 |
]. |
719 | 462 |
string size > 0 ifTrue:[ |
463 |
width := width + gap + (string widthOn:aGC) |
|
464 |
]. |
|
465 |
^width |
|
981
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
466 |
|
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
467 |
"Modified: / 21.6.1998 / 03:11:14 / cg" |
172 | 468 |
! ! |
469 |
||
470 |
!LabelAndIcon class methodsFor:'documentation'! |
|
471 |
||
472 |
version |
|
2773 | 473 |
^ '$Header: /cvs/stx/stx/libwidg2/LabelAndIcon.st,v 1.36 2004-11-10 12:41:39 cg Exp $' |
172 | 474 |
! ! |