256 !LabelAndIcon methodsFor:'displaying'! |
256 !LabelAndIcon methodsFor:'displaying'! |
257 |
257 |
258 displayOn:aGC x:x y:y opaque:opaque |
258 displayOn:aGC x:x y:y opaque:opaque |
259 "display the receiver on a GC" |
259 "display the receiver on a GC" |
260 |
260 |
261 |yOffs font fH iH fA yI| |
261 |yOffs font fH iH fA yI xOffs| |
262 |
262 |
263 font := aGC font. |
263 font := aGC font. |
264 fH := font height. |
264 fH := font height. |
265 iH := icon height. |
265 icon isNil ifTrue:[ |
|
266 iH := 0. |
|
267 xOffs := 0. |
|
268 ] ifFalse:[ |
|
269 iH := icon height. |
|
270 xOffs := icon width + gap. |
|
271 ]. |
266 fA := font ascent. |
272 fA := font ascent. |
267 |
273 |
268 iH <= fA ifTrue:[ |
274 iH <= fA ifTrue:[ |
269 "/ place the icon on the baseLine |
275 "/ place the icon on the baseLine |
270 yI := y-fA. |
276 yI := y-fA. |
271 ] ifFalse:[ |
277 ] ifFalse:[ |
272 yI := y-fA+(font descent // 2)-1. |
278 yI := y-fA+(font descent // 2)-1. |
273 ]. |
279 ]. |
274 |
280 |
275 icon := icon on:aGC device. |
281 icon notNil ifTrue:[ |
276 |
282 icon := icon on:aGC device. |
277 (opaque |
283 |
278 and:[icon mask isNil]) ifTrue:[ |
284 (opaque |
279 aGC displayOpaqueForm:icon x:x y:yI. |
285 and:[icon mask isNil]) ifTrue:[ |
280 ] ifFalse:[ |
286 aGC displayOpaqueForm:icon x:x y:yI. |
281 aGC displayForm:icon x:x y:yI. |
287 ] ifFalse:[ |
|
288 aGC displayForm:icon x:x y:yI. |
|
289 ]. |
282 ]. |
290 ]. |
283 |
291 |
284 (iH > fH) ifTrue:[ |
292 (iH > fH) ifTrue:[ |
285 yOffs := (iH - fH) // 2 |
293 yOffs := (iH - fH) // 2 |
286 ] ifFalse:[ |
294 ] ifFalse:[ |
287 yOffs := 0 |
295 yOffs := 0 |
288 ]. |
296 ]. |
289 |
297 |
290 string |
298 string |
291 displayOn:aGC |
299 displayOn:aGC |
292 x:x + icon width + gap |
300 x:x+xOffs |
293 y:y+yOffs. |
301 y:y+yOffs. |
294 |
302 |
295 "Modified: 12.5.1996 / 20:36:43 / cg" |
303 "Modified: 27.2.1997 / 14:56:19 / cg" |
296 ! ! |
304 ! ! |
297 |
305 |
298 !LabelAndIcon methodsFor:'initialization'! |
306 !LabelAndIcon methodsFor:'initialization'! |
299 |
307 |
300 initialize |
308 initialize |
304 !LabelAndIcon methodsFor:'queries'! |
312 !LabelAndIcon methodsFor:'queries'! |
305 |
313 |
306 heightOn:aGC |
314 heightOn:aGC |
307 "return the height of the receiver, if it is to be displayed on aGC" |
315 "return the height of the receiver, if it is to be displayed on aGC" |
308 |
316 |
309 ^ icon height + (aGC device pixelPerMillimeter x rounded) |
317 |iconHeight| |
310 max:(string heightOn:aGC) |
318 |
|
319 icon notNil ifTrue:[ |
|
320 iconHeight := icon height + (aGC device pixelPerMillimeter x rounded) |
|
321 ] ifFalse:[ |
|
322 iconHeight := 0 |
|
323 ]. |
|
324 ^ iconHeight max:(string heightOn:aGC) |
311 |
325 |
312 "Created: 12.5.1996 / 20:26:20 / cg" |
326 "Created: 12.5.1996 / 20:26:20 / cg" |
313 "Modified: 12.5.1996 / 20:34:23 / cg" |
327 "Modified: 27.2.1997 / 14:53:36 / cg" |
314 ! |
328 ! |
315 |
329 |
316 widthOn:aGC |
330 widthOn:aGC |
317 "return the width of the receiver, if it is to be displayed on aGC" |
331 "return the width of the receiver, if it is to be displayed on aGC" |
318 |
332 |
319 ^ icon width + gap + (string widthOn:aGC) |
333 |iconWidth| |
|
334 |
|
335 icon notNil ifTrue:[ |
|
336 iconWidth := icon width + gap |
|
337 ] ifFalse:[ |
|
338 iconWidth := 0 |
|
339 ]. |
|
340 ^ iconWidth + (string widthOn:aGC) |
320 |
341 |
321 "Created: 12.5.1996 / 20:10:06 / cg" |
342 "Created: 12.5.1996 / 20:10:06 / cg" |
322 "Modified: 12.5.1996 / 20:13:49 / cg" |
343 "Modified: 27.2.1997 / 14:53:58 / cg" |
323 ! ! |
344 ! ! |
324 |
345 |
325 !LabelAndIcon class methodsFor:'documentation'! |
346 !LabelAndIcon class methodsFor:'documentation'! |
326 |
347 |
327 version |
348 version |
328 ^ '$Header: /cvs/stx/stx/libwidg2/LabelAndIcon.st,v 1.10 1997-01-27 14:17:57 ca Exp $' |
349 ^ '$Header: /cvs/stx/stx/libwidg2/LabelAndIcon.st,v 1.11 1997-02-27 14:06:19 cg Exp $' |
329 ! ! |
350 ! ! |