3871
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2009 by eXept Software AG
|
|
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 |
"
|
3783
|
12 |
"{ Package: 'stx:libwidg2' }"
|
|
13 |
|
5210
|
14 |
"{ NameSpace: Smalltalk }"
|
|
15 |
|
3783
|
16 |
LabelAndIcon subclass:#LabelAndTwoIcons
|
|
17 |
instanceVariableNames:'image2'
|
|
18 |
classVariableNames:''
|
|
19 |
poolDictionaries:''
|
|
20 |
category:'Views-Support'
|
|
21 |
!
|
|
22 |
|
|
23 |
!LabelAndTwoIcons class methodsFor:'documentation'!
|
|
24 |
|
3871
|
25 |
copyright
|
|
26 |
"
|
|
27 |
COPYRIGHT (c) 2009 by eXept Software AG
|
|
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 |
|
3783
|
39 |
documentation
|
|
40 |
"
|
|
41 |
like a LabelAndIcon, but adds another image to the right of the string.
|
|
42 |
|
|
43 |
Notice:
|
|
44 |
This is different from ST-80's LabelAndIcon class, which
|
|
45 |
inherits from Label. Therefore, things may change in the future.
|
|
46 |
|
|
47 |
[author:]
|
|
48 |
Claus Gittinger
|
|
49 |
|
|
50 |
[see also:]
|
|
51 |
ListEntry Text String Icon
|
|
52 |
ListView SelectionInListView
|
|
53 |
"
|
|
54 |
!
|
|
55 |
|
|
56 |
examples
|
|
57 |
"
|
|
58 |
in a button/label:
|
|
59 |
[exBegin]
|
|
60 |
|top l image|
|
|
61 |
|
|
62 |
image := Image fromFile:'../../goodies/bitmaps/xpmBitmaps/countries/brazil.xpm'.
|
3794
|
63 |
l := (LabelAndTwoIcons icon:image string:'brazil').
|
|
64 |
l image2:image.
|
3783
|
65 |
|
|
66 |
top := Button label:l.
|
|
67 |
top open.
|
|
68 |
[exEnd]
|
|
69 |
two images in a button/label:
|
|
70 |
[exBegin]
|
|
71 |
|top l image1 image2|
|
|
72 |
|
|
73 |
image1 := Image fromFile:'../../goodies/bitmaps/xpmBitmaps/countries/brazil.xpm'.
|
|
74 |
image2 := Image fromFile:'../../goodies/bitmaps/xpmBitmaps/countries/germany.xpm'.
|
|
75 |
l := (LabelAndIcon form:image1 image:image2 string:'directory').
|
|
76 |
|
|
77 |
top := Button label:l.
|
|
78 |
top open.
|
|
79 |
[exEnd]
|
|
80 |
"
|
|
81 |
! !
|
|
82 |
|
|
83 |
!LabelAndTwoIcons methodsFor:'accessing'!
|
|
84 |
|
|
85 |
image2
|
|
86 |
"return my second image (right of string)"
|
|
87 |
|
|
88 |
^ image2
|
|
89 |
!
|
|
90 |
|
|
91 |
image2:anImage
|
|
92 |
"set the image2 (right of string)"
|
|
93 |
|
|
94 |
image2 := anImage
|
|
95 |
! !
|
|
96 |
|
|
97 |
!LabelAndTwoIcons methodsFor:'displaying'!
|
|
98 |
|
|
99 |
displayOn:aGC x:x y:y opaque:opaque
|
|
100 |
"display the receiver on a GC"
|
|
101 |
|
|
102 |
|y1 x1 image2Value image2Height maxHeight asc|
|
|
103 |
|
|
104 |
super displayOn:aGC x:x y:y opaque:opaque.
|
|
105 |
|
|
106 |
image2Value := image2 value.
|
|
107 |
image2Value notNil ifTrue:[
|
5210
|
108 |
asc := aGC deviceFont ascent.
|
3783
|
109 |
image2Height := image2Value notNil ifTrue:[image2Value height] ifFalse:[0].
|
|
110 |
maxHeight := self heightOn:aGC.
|
|
111 |
x1 := x + gap + (super widthOn:aGC).
|
|
112 |
|
|
113 |
image2Value notNil ifTrue:[
|
|
114 |
y1 := y - asc + (maxHeight - image2Height + 1 // 2).
|
|
115 |
image2 := image2Value onDevice:aGC device.
|
|
116 |
|
|
117 |
(opaque and:[image2Value mask isNil]) ifTrue:[aGC displayOpaqueForm:image2Value x:x1 y:y1]
|
|
118 |
ifFalse:[aGC displayForm:image2Value x:x1 y:y1].
|
|
119 |
|
|
120 |
].
|
|
121 |
]
|
|
122 |
! !
|
|
123 |
|
|
124 |
!LabelAndTwoIcons methodsFor:'queries'!
|
|
125 |
|
3795
|
126 |
heightOn:aGC
|
|
127 |
"return the height of the receiver, if it is to be displayed on aGC"
|
|
128 |
|
|
129 |
|image2Height oneMillimeter|
|
|
130 |
|
|
131 |
image2 notNil ifTrue:[
|
5210
|
132 |
oneMillimeter := aGC device isNil ifTrue:[2] ifFalse:[aGC verticalIntegerPixelPerMillimeter].
|
3795
|
133 |
image2Height := image2 value height + oneMillimeter
|
|
134 |
] ifFalse:[
|
|
135 |
image2Height := 0
|
|
136 |
].
|
|
137 |
^ (super heightOn:aGC) max: image2Height
|
|
138 |
!
|
|
139 |
|
3783
|
140 |
widthOn:aGC
|
|
141 |
"return the width of the receiver, if it is to be displayed on aGC"
|
|
142 |
|
|
143 |
|width|
|
|
144 |
|
|
145 |
width := super widthOn:aGC.
|
|
146 |
image2 notNil ifTrue:[
|
|
147 |
width := width + gap + image2 value width
|
|
148 |
].
|
|
149 |
^ width
|
|
150 |
! !
|
|
151 |
|
|
152 |
!LabelAndTwoIcons class methodsFor:'documentation'!
|
|
153 |
|
|
154 |
version_CVS
|
5210
|
155 |
^ '$Header$'
|
3783
|
156 |
! !
|
5210
|
157 |
|