35 " |
35 " |
36 |
36 |
37 |
37 |
38 |
38 |
39 |
39 |
|
40 ! |
|
41 |
|
42 documentation |
|
43 " |
|
44 This class keeps some info about a label. |
|
45 |
|
46 [author:] |
|
47 Claus Atzkern |
|
48 " |
|
49 ! ! |
|
50 |
|
51 !DataSetLabel class methodsFor:'image specs'! |
|
52 |
|
53 sortIndicator |
|
54 "This resource specification was automatically generated |
|
55 by the ImageEditor of ST/X." |
|
56 |
|
57 "Do not manually edit this!! If it is corrupted, |
|
58 the ImageEditor may not be able to read the specification." |
|
59 |
|
60 " |
|
61 self sortIndicator inspect |
|
62 ImageEditor openOnClass:self andSelector:#sortIndicator |
|
63 Icon flushCachedIcons |
|
64 " |
|
65 |
|
66 <resource: #image> |
|
67 |
|
68 ^Icon |
|
69 constantNamed:'DataSetLabel class sortIndicator' |
|
70 ifAbsentPut:[(Depth1Image new) width: 7; height: 4; photometric:(#palette); bitsPerSample:(#(1)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@B@0 @a') ; colorMapFromArray:#[0 0 0 255 255 255]; mask:((Depth1Image new) width: 7; height: 4; photometric:(#blackIs0); bitsPerSample:(#(1)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'?''08D@@a') ; yourself); yourself] |
|
71 ! |
|
72 |
|
73 sortReverseIndicator |
|
74 "This resource specification was automatically generated |
|
75 by the ImageEditor of ST/X." |
|
76 |
|
77 "Do not manually edit this!! If it is corrupted, |
|
78 the ImageEditor may not be able to read the specification." |
|
79 |
|
80 " |
|
81 self sortReverseIndicator inspect |
|
82 ImageEditor openOnClass:self andSelector:#sortReverseIndicator |
|
83 Icon flushCachedIcons |
|
84 " |
|
85 |
|
86 <resource: #image> |
|
87 |
|
88 ^Icon |
|
89 constantNamed:'DataSetLabel class sortReverseIndicator' |
|
90 ifAbsentPut:[(Depth1Image new) width: 7; height: 4; photometric:(#palette); bitsPerSample:(#(1)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'0(@@@@@a') ; colorMapFromArray:#[0 0 0 255 255 255]; mask:((Depth1Image new) width: 7; height: 4; photometric:(#blackIs0); bitsPerSample:(#(1)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'DC!!<? @a') ; yourself); yourself] |
40 ! ! |
91 ! ! |
41 |
92 |
42 !DataSetLabel methodsFor:'accessing-colors'! |
93 !DataSetLabel methodsFor:'accessing-colors'! |
43 |
94 |
44 backgroundColor |
95 backgroundColor |
92 ] |
143 ] |
93 ! ! |
144 ! ! |
94 |
145 |
95 !DataSetLabel methodsFor:'drawing'! |
146 !DataSetLabel methodsFor:'drawing'! |
96 |
147 |
97 redrawX:xLeft w:width h:height inset:inset on:aGC |
148 redrawX:xLeft w:width h:height inset:inset on:aLabelView |
98 "redraw the label; the background is cleared and the paint is set |
149 "redraw the label; the background is cleared and the paint is set |
99 " |
150 " |
100 |y0 x gcFont labelWidth |
151 |y0 x gcFont labelWidth |
101 shownLabel prevClip mustUndoClip |
152 shownLabel prevClip mustUndoClip |
102 netWidth goodLookingVerticalSpacing| |
153 netWidth goodLookingVerticalSpacing| |
103 |
154 |
104 label isNil ifTrue:[ ^ self ]. |
155 label isNil ifTrue:[ ^ self ]. |
105 |
156 |
106 font notNil ifTrue:[ |
157 font notNil ifTrue:[ |
107 gcFont := aGC font. "save original font" |
158 gcFont := aLabelView font. "save original font" |
108 aGC font:font. |
159 aLabelView font:font. |
109 ]. |
160 ]. |
110 |
161 |
111 y0 := (height - preferredHeight) // 2. |
162 y0 := (height - preferredHeight) // 2. |
112 goodLookingVerticalSpacing := aGC font descent. |
163 goodLookingVerticalSpacing := aLabelView font descent. |
113 y0 := y0 + goodLookingVerticalSpacing. |
164 y0 := y0 + goodLookingVerticalSpacing. |
114 |
165 |
115 netWidth := width-inset-inset. |
166 netWidth := width-inset-inset. |
116 |
167 |
117 label do:[:aLabel| |
168 label do:[:aLabel| |
118 shownLabel := aLabel. |
169 shownLabel := aLabel. |
119 |
170 |
120 mustUndoClip := false. |
171 mustUndoClip := false. |
121 labelWidth := shownLabel widthOn:aGC. |
172 labelWidth := shownLabel widthOn:aLabelView. |
122 labelWidth > netWidth ifTrue:[ |
173 labelWidth > netWidth ifTrue:[ |
123 shownLabel := DataSetColumn shortenedStringFor:aLabel on:aGC maxWidth:netWidth. |
174 shownLabel := DataSetColumn shortenedStringFor:aLabel on:aLabelView maxWidth:netWidth. |
124 labelWidth := shownLabel widthOn:aGC. |
175 labelWidth := shownLabel widthOn:aLabelView. |
125 ]. |
176 ]. |
126 |
177 |
127 adjust == #left ifTrue:[ |
178 adjust == #left ifTrue:[ |
128 x := xLeft + inset. |
179 x := xLeft + inset. |
129 ] ifFalse:[ |
180 ] ifFalse:[ |
130 x := width - labelWidth. |
181 x := width - labelWidth. |
131 |
182 |
132 adjust == #right ifTrue:[x := x - inset] |
183 adjust == #right ifTrue:[ |
133 ifFalse:[x := x // 2]. |
184 x := x - inset |
|
185 ] ifFalse:[ |
|
186 x := x // 2. "/ center |
|
187 ]. |
134 x := xLeft + x. |
188 x := xLeft + x. |
135 |
189 |
136 "/ cg: must clip left, if string is too large |
190 "/ cg: must clip left, if string is too large |
137 x < xLeft ifTrue:[ |
191 x < xLeft ifTrue:[ |
138 "/ must clip ... |
192 "/ must clip ... |
139 prevClip := aGC clippingRectangleOrNil. |
193 prevClip := aLabelView clippingRectangleOrNil. |
140 mustUndoClip := true. |
194 mustUndoClip := true. |
141 aGC clippingRectangle:(Rectangle |
195 aLabelView clippingRectangle:(Rectangle |
142 left:xLeft top:y0 |
196 left:xLeft top:y0 |
143 width:width height:height). |
197 width:width height:height). |
144 ]. |
198 ]. |
145 ]. |
199 ]. |
146 |
200 |
147 shownLabel displayOn:aGC x:x y:y0 + (shownLabel ascentOn:aGC). |
201 shownLabel displayOn:aLabelView x:x y:y0 + (shownLabel ascentOn:aLabelView). |
148 y0 := y0 + (shownLabel heightOn:aGC) + goodLookingVerticalSpacing. |
202 y0 := y0 + (shownLabel heightOn:aLabelView) + goodLookingVerticalSpacing. |
149 |
203 |
150 mustUndoClip == true ifTrue:[ |
204 mustUndoClip == true ifTrue:[ |
151 aGC clippingRectangle:prevClip |
205 aLabelView clippingRectangle:prevClip |
152 ]. |
206 ]. |
153 ]. |
207 ]. |
|
208 |
|
209 description isSortable ifTrue:[ |
|
210 self halt. |
|
211 ]. |
|
212 |
154 gcFont notNil ifTrue:[ |
213 gcFont notNil ifTrue:[ |
155 aGC font:gcFont "/ restore font |
214 aLabelView font:gcFont "/ restore font |
156 ]. |
215 ]. |
157 ! ! |
216 ! ! |
158 |
217 |
159 !DataSetLabel methodsFor:'instance creation'! |
218 !DataSetLabel methodsFor:'instance creation'! |
160 |
219 |
161 description:aDescription builder:aBuilder on:aGC |
220 description:aDescription builder:aBuilder on:aGC |
162 |device gcFont verticalSpace| |
221 |device gcFont verticalSpace| |
163 |
222 |
|
223 description := aDescription. |
|
224 |
|
225 "/ stupid code - could simply access things via the description. |
|
226 "/ I leave it here for subclasses which depend on it (for a while). |
164 label := self resolveLabelFromDescription:aDescription withBuilder:aBuilder. |
227 label := self resolveLabelFromDescription:aDescription withBuilder:aBuilder. |
165 selector := aDescription labelActionSelector. |
228 selector := aDescription labelActionSelector. |
166 argument := (aDescription labelActionArgument) ? label. |
229 argument := (aDescription labelActionArgument) ? label. |
167 adjust := (aDescription labelAlignment) ? #left. |
230 adjust := (aDescription labelAlignment) ? #left. |
168 device := aGC device. |
231 device := aGC device. |