author | Claus Gittinger <cg@exept.de> |
Thu, 30 Jun 2011 21:15:12 +0200 | |
changeset 4043 | 532a328a9e0e |
parent 3885 | 602f5ef8532a |
child 4549 | 397584f3c72f |
permissions | -rw-r--r-- |
1716 | 1 |
" |
2 |
COPYRIGHT (c) 1997 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 |
" |
|
1818 | 12 |
"{ Package: 'stx:libwidg2' }" |
13 |
||
1150 | 14 |
Object subclass:#DataSetLabel |
3772 | 15 |
instanceVariableNames:'label selector argument adjust font fgColor bgColor |
16 |
preferredHeight preferredWidth description' |
|
17 |
classVariableNames:'' |
|
18 |
poolDictionaries:'' |
|
19 |
category:'Views-DataSet' |
|
1150 | 20 |
! |
21 |
||
1716 | 22 |
!DataSetLabel class methodsFor:'documentation'! |
23 |
||
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
27 |
All Rights Reserved |
|
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
||
37 |
||
38 |
||
39 |
||
3649 | 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 |
||
3763 | 73 |
sortIndicatorGrey |
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 sortIndicatorGrey inspect |
|
82 |
ImageEditor openOnClass:self andSelector:#sortIndicatorGrey |
|
83 |
Icon flushCachedIcons |
|
84 |
" |
|
85 |
||
86 |
<resource: #image> |
|
87 |
||
88 |
^Icon |
|
89 |
constantNamed:#'DataSetLabel class sortIndicatorGrey' |
|
90 |
ifAbsentPut:[(Depth1Image new) width: 7; height: 5; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 255 255]; mask:((Depth1Image new) width: 7; height: 5; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@A@(UJ(b') ; yourself); yourself] |
|
91 |
! |
|
92 |
||
3768 | 93 |
sortIndicatorGreyIcon |
94 |
^ ToolbarIconLibrary sortIndicatorGreyIcon |
|
95 |
! |
|
96 |
||
97 |
sortIndicatorIcon |
|
98 |
"This resource specification was automatically generated |
|
99 |
by the ImageEditor of ST/X." |
|
100 |
||
101 |
"Do not manually edit this!! If it is corrupted, |
|
102 |
the ImageEditor may not be able to read the specification." |
|
103 |
||
104 |
" |
|
105 |
self sortIndicatorIcon inspect |
|
106 |
ImageEditor openOnClass:self andSelector:#sortIndicatorIcon |
|
107 |
Icon flushCachedIcons |
|
108 |
" |
|
109 |
||
110 |
<resource: #image> |
|
111 |
||
112 |
^Icon |
|
113 |
constantNamed:'DataSetLabel class sortIndicatorIcon' |
|
114 |
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] |
|
115 |
! |
|
116 |
||
3649 | 117 |
sortReverseIndicator |
118 |
"This resource specification was automatically generated |
|
119 |
by the ImageEditor of ST/X." |
|
120 |
||
121 |
"Do not manually edit this!! If it is corrupted, |
|
122 |
the ImageEditor may not be able to read the specification." |
|
123 |
||
124 |
" |
|
125 |
self sortReverseIndicator inspect |
|
126 |
ImageEditor openOnClass:self andSelector:#sortReverseIndicator |
|
127 |
Icon flushCachedIcons |
|
128 |
" |
|
129 |
||
130 |
<resource: #image> |
|
131 |
||
132 |
^Icon |
|
133 |
constantNamed:'DataSetLabel class sortReverseIndicator' |
|
134 |
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] |
|
3763 | 135 |
! |
136 |
||
137 |
sortReverseIndicatorGrey |
|
138 |
"This resource specification was automatically generated |
|
139 |
by the ImageEditor of ST/X." |
|
140 |
||
141 |
"Do not manually edit this!! If it is corrupted, |
|
142 |
the ImageEditor may not be able to read the specification." |
|
143 |
||
144 |
" |
|
145 |
self sortReverseIndicatorGrey inspect |
|
146 |
ImageEditor openOnClass:self andSelector:#sortReverseIndicatorGrey |
|
147 |
Icon flushCachedIcons |
|
148 |
" |
|
149 |
||
150 |
<resource: #image> |
|
151 |
||
152 |
^Icon |
|
153 |
constantNamed:#'DataSetLabel class sortReverseIndicatorGrey' |
|
154 |
ifAbsentPut:[(Depth1Image new) width: 7; height: 5; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 255 255]; mask:((Depth1Image new) width: 7; height: 5; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'*%P(D@@b') ; yourself); yourself] |
|
3768 | 155 |
! |
156 |
||
157 |
sortReverseIndicatorGreyIcon |
|
158 |
"This resource specification was automatically generated |
|
159 |
by the ImageEditor of ST/X." |
|
160 |
||
161 |
"Do not manually edit this!! If it is corrupted, |
|
162 |
the ImageEditor may not be able to read the specification." |
|
163 |
||
164 |
" |
|
165 |
self sortReverseIndicatorGreyIcon inspect |
|
166 |
ImageEditor openOnClass:self andSelector:#sortReverseIndicatorGreyIcon |
|
167 |
Icon flushCachedIcons |
|
168 |
" |
|
169 |
||
170 |
<resource: #image> |
|
171 |
||
172 |
^Icon |
|
173 |
constantNamed:#'DataSetLabel class sortReverseIndicatorGreyIcon' |
|
174 |
ifAbsentPut:[(Depth1Image new) width: 7; height: 5; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 255 255]; mask:((Depth1Image new) width: 7; height: 5; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'*%P(D@@b') ; yourself); yourself] |
|
175 |
! |
|
176 |
||
177 |
sortReverseIndicatorIcon |
|
178 |
"This resource specification was automatically generated |
|
179 |
by the ImageEditor of ST/X." |
|
180 |
||
181 |
"Do not manually edit this!! If it is corrupted, |
|
182 |
the ImageEditor may not be able to read the specification." |
|
183 |
||
184 |
" |
|
185 |
self sortReverseIndicatorIcon inspect |
|
186 |
ImageEditor openOnClass:self andSelector:#sortReverseIndicatorIcon |
|
187 |
Icon flushCachedIcons |
|
188 |
" |
|
189 |
||
190 |
<resource: #image> |
|
191 |
||
192 |
^Icon |
|
193 |
constantNamed:'DataSetLabel class sortReverseIndicatorIcon' |
|
194 |
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] |
|
1716 | 195 |
! ! |
1150 | 196 |
|
1818 | 197 |
!DataSetLabel methodsFor:'accessing-colors'! |
1150 | 198 |
|
199 |
backgroundColor |
|
1487 | 200 |
"returns the background color or nil |
1150 | 201 |
" |
202 |
^ bgColor |
|
203 |
||
204 |
||
205 |
! |
|
206 |
||
2699 | 207 |
backgroundColor:aColor |
208 |
"set the background color or nil |
|
209 |
" |
|
210 |
bgColor := aColor |
|
211 |
! |
|
212 |
||
1150 | 213 |
foregroundColor |
1487 | 214 |
"returns the foreground color or nil |
1150 | 215 |
" |
216 |
^ fgColor |
|
217 |
||
2699 | 218 |
! |
219 |
||
220 |
foregroundColor:aColor |
|
221 |
"set the foreground color or nil |
|
222 |
" |
|
223 |
fgColor := aColor |
|
1150 | 224 |
! ! |
225 |
||
1818 | 226 |
!DataSetLabel methodsFor:'accessing-dimensions'! |
1150 | 227 |
|
1487 | 228 |
preferredHeight |
229 |
"returns my preferred height |
|
1150 | 230 |
" |
1487 | 231 |
^ preferredHeight |
1150 | 232 |
! |
233 |
||
1487 | 234 |
preferredWidth |
235 |
"returns my preferred width |
|
1150 | 236 |
" |
1487 | 237 |
^ preferredWidth |
1150 | 238 |
! ! |
239 |
||
240 |
!DataSetLabel methodsFor:'drawing'! |
|
241 |
||
3649 | 242 |
redrawX:xLeft w:width h:height inset:inset on:aLabelView |
1150 | 243 |
"redraw the label; the background is cleared and the paint is set |
244 |
" |
|
3763 | 245 |
|y0 x iconOffset gcFont labelWidth |
3768 | 246 |
netWidth goodLookingVerticalSpacing colNr sortIcon| |
1150 | 247 |
|
248 |
label isNil ifTrue:[ ^ self ]. |
|
249 |
||
1487 | 250 |
font notNil ifTrue:[ |
3649 | 251 |
gcFont := aLabelView font. "save original font" |
252 |
aLabelView font:font. |
|
1487 | 253 |
]. |
3582
2927b1b12e8f
Get the label from a value holder
Stefan Vogel <sv@exept.de>
parents:
3553
diff
changeset
|
254 |
|
2927b1b12e8f
Get the label from a value holder
Stefan Vogel <sv@exept.de>
parents:
3553
diff
changeset
|
255 |
y0 := (height - preferredHeight) // 2. |
3649 | 256 |
goodLookingVerticalSpacing := aLabelView font descent. |
3490
f46a3c50dc15
preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents:
3468
diff
changeset
|
257 |
y0 := y0 + goodLookingVerticalSpacing. |
1150 | 258 |
|
2144 | 259 |
netWidth := width-inset-inset. |
260 |
||
3763 | 261 |
iconOffset := 0. |
3768 | 262 |
description isSortable ifTrue:[ |
263 |
iconOffset := 12. |
|
264 |
colNr := aLabelView columnIndexOfDescription:description. |
|
265 |
colNr == aLabelView indexOfSortColumn ifTrue:[ |
|
266 |
aLabelView reverseSort ifTrue:[ |
|
267 |
sortIcon := ToolbarIconLibrary sortIndicatorGreyIcon |
|
268 |
] ifFalse:[ |
|
269 |
sortIcon := ToolbarIconLibrary sortReverseIndicatorGreyIcon |
|
270 |
]. |
|
271 |
sortIcon displayOn:aLabelView x:xLeft+inset y:y0. |
|
3765 | 272 |
]. |
273 |
]. |
|
274 |
||
275 |
label do:[:eachLabelLine| |
|
3763 | 276 |
|restWidth xOffset shownLabel mustUndoClip prevClip| |
277 |
||
3765 | 278 |
shownLabel := eachLabelLine. |
2144 | 279 |
|
1588
e6039e46cae2
clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
280 |
mustUndoClip := false. |
3649 | 281 |
labelWidth := shownLabel widthOn:aLabelView. |
2144 | 282 |
labelWidth > netWidth ifTrue:[ |
3765 | 283 |
shownLabel := DataSetColumn shortenedStringFor:eachLabelLine on:aLabelView maxWidth:netWidth. |
3649 | 284 |
labelWidth := shownLabel widthOn:aLabelView. |
2144 | 285 |
]. |
286 |
||
1487 | 287 |
adjust == #left ifTrue:[ |
3763 | 288 |
x := xLeft + iconOffset + inset. |
1487 | 289 |
] ifFalse:[ |
3763 | 290 |
restWidth := width - labelWidth - iconOffset. |
1150 | 291 |
|
3649 | 292 |
adjust == #right ifTrue:[ |
3763 | 293 |
xOffset := restWidth - inset |
3649 | 294 |
] ifFalse:[ |
3763 | 295 |
xOffset := restWidth // 2. "/ center |
3649 | 296 |
]. |
3763 | 297 |
x := xLeft + xOffset. |
1588
e6039e46cae2
clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
298 |
|
e6039e46cae2
clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
299 |
"/ cg: must clip left, if string is too large |
e6039e46cae2
clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
300 |
x < xLeft ifTrue:[ |
e6039e46cae2
clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
301 |
"/ must clip ... |
3649 | 302 |
prevClip := aLabelView clippingRectangleOrNil. |
1588
e6039e46cae2
clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
303 |
mustUndoClip := true. |
3649 | 304 |
aLabelView clippingRectangle:(Rectangle |
1588
e6039e46cae2
clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
305 |
left:xLeft top:y0 |
e6039e46cae2
clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
306 |
width:width height:height). |
e6039e46cae2
clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
307 |
]. |
1487 | 308 |
]. |
3582
2927b1b12e8f
Get the label from a value holder
Stefan Vogel <sv@exept.de>
parents:
3553
diff
changeset
|
309 |
|
3649 | 310 |
shownLabel displayOn:aLabelView x:x y:y0 + (shownLabel ascentOn:aLabelView). |
311 |
y0 := y0 + (shownLabel heightOn:aLabelView) + goodLookingVerticalSpacing. |
|
1588
e6039e46cae2
clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
312 |
|
e6039e46cae2
clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
313 |
mustUndoClip == true ifTrue:[ |
3649 | 314 |
aLabelView clippingRectangle:prevClip |
1588
e6039e46cae2
clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
315 |
]. |
1487 | 316 |
]. |
3649 | 317 |
|
3582
2927b1b12e8f
Get the label from a value holder
Stefan Vogel <sv@exept.de>
parents:
3553
diff
changeset
|
318 |
gcFont notNil ifTrue:[ |
3649 | 319 |
aLabelView font:gcFont "/ restore font |
2451 | 320 |
]. |
1150 | 321 |
! ! |
322 |
||
323 |
!DataSetLabel methodsFor:'instance creation'! |
|
324 |
||
1487 | 325 |
description:aDescription builder:aBuilder on:aGC |
3490
f46a3c50dc15
preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents:
3468
diff
changeset
|
326 |
|device gcFont verticalSpace| |
1150 | 327 |
|
3649 | 328 |
description := aDescription. |
329 |
||
330 |
"/ stupid code - could simply access things via the description. |
|
331 |
"/ I leave it here for subclasses which depend on it (for a while). |
|
1605 | 332 |
label := self resolveLabelFromDescription:aDescription withBuilder:aBuilder. |
333 |
selector := aDescription labelActionSelector. |
|
334 |
argument := (aDescription labelActionArgument) ? label. |
|
335 |
adjust := (aDescription labelAlignment) ? #left. |
|
336 |
device := aGC device. |
|
337 |
fgColor := aDescription labelForegroundColor. |
|
338 |
bgColor := aDescription labelBackgroundColor. |
|
1150 | 339 |
|
1480 | 340 |
fgColor notNil ifTrue:[ fgColor := fgColor onDevice:device ]. |
341 |
bgColor notNil ifTrue:[ bgColor := bgColor onDevice:device ]. |
|
1150 | 342 |
|
1487 | 343 |
preferredHeight := preferredWidth := 0. |
344 |
||
3490
f46a3c50dc15
preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents:
3468
diff
changeset
|
345 |
(label isEmptyOrNil) ifTrue:[ |
1487 | 346 |
label := nil. |
3490
f46a3c50dc15
preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents:
3468
diff
changeset
|
347 |
^ self |
1150 | 348 |
]. |
349 |
||
3553 | 350 |
font := aDescription labelFont. |
351 |
font notNil ifTrue:[ |
|
352 |
font := aBuilder resolveFont:font. |
|
353 |
font notNil ifTrue:[ |
|
354 |
gcFont := aGC font. |
|
355 |
gcFont = font ifTrue:[ |
|
356 |
font := nil |
|
357 |
] ifFalse:[ |
|
358 |
font := font onDevice:device. |
|
359 |
aGC font:font. |
|
360 |
]. |
|
361 |
]. |
|
1487 | 362 |
]. |
1150 | 363 |
|
3490
f46a3c50dc15
preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents:
3468
diff
changeset
|
364 |
label isString ifTrue:[ |
f46a3c50dc15
preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents:
3468
diff
changeset
|
365 |
label := Array with:label. |
f46a3c50dc15
preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents:
3468
diff
changeset
|
366 |
] ifFalse:[ |
3885 | 367 |
label isSequenceable ifFalse:[ |
3490
f46a3c50dc15
preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents:
3468
diff
changeset
|
368 |
label := Array with:label. |
f46a3c50dc15
preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents:
3468
diff
changeset
|
369 |
] |
1150 | 370 |
]. |
371 |
||
3490
f46a3c50dc15
preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents:
3468
diff
changeset
|
372 |
verticalSpace := aGC font descent. "/ goodLookingVerticalSpacing |
f46a3c50dc15
preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents:
3468
diff
changeset
|
373 |
label := label |
f46a3c50dc15
preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents:
3468
diff
changeset
|
374 |
collect:[:el| |
f46a3c50dc15
preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents:
3468
diff
changeset
|
375 |
|lbl| |
f46a3c50dc15
preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents:
3468
diff
changeset
|
376 |
|
f46a3c50dc15
preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents:
3468
diff
changeset
|
377 |
lbl := self label:el on:device. |
f46a3c50dc15
preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents:
3468
diff
changeset
|
378 |
preferredWidth := (lbl widthOn:aGC) max:preferredWidth. |
f46a3c50dc15
preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents:
3468
diff
changeset
|
379 |
preferredHeight := preferredHeight + verticalSpace + (lbl heightOn:aGC) + verticalSpace. |
f46a3c50dc15
preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents:
3468
diff
changeset
|
380 |
lbl |
f46a3c50dc15
preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents:
3468
diff
changeset
|
381 |
]. |
1487 | 382 |
font notNil ifTrue:[aGC font:gcFont]. "/ restore font |
1150 | 383 |
! ! |
384 |
||
385 |
!DataSetLabel methodsFor:'private'! |
|
386 |
||
387 |
label:aLabel on:aDevice |
|
388 |
"returns registered label on a device |
|
389 |
" |
|
390 |
|lbl img| |
|
391 |
||
1487 | 392 |
aLabel isNil ifTrue:[^ '']. |
393 |
||
1150 | 394 |
aLabel isString ifFalse:[ |
395 |
aLabel isImageOrForm ifTrue:[ |
|
2291 | 396 |
aLabel device ~~ aDevice ifTrue:[ |
397 |
lbl := aLabel copy onDevice:aDevice |
|
398 |
] ifFalse:[ |
|
399 |
lbl := aLabel |
|
400 |
]. |
|
1150 | 401 |
lbl isImage ifTrue:[ |
402 |
lbl clearMaskedPixels |
|
403 |
]. |
|
404 |
^ lbl |
|
405 |
]. |
|
1588
e6039e46cae2
clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
406 |
|
1150 | 407 |
aLabel class == LabelAndIcon ifTrue:[ |
2291 | 408 |
lbl := aLabel onDevice:aDevice. |
1150 | 409 |
(img := lbl image) isImage ifTrue:[img clearMaskedPixels]. |
410 |
(img := lbl icon) isImage ifTrue:[img clearMaskedPixels]. |
|
411 |
^ lbl |
|
412 |
] |
|
413 |
]. |
|
414 |
^ aLabel |
|
415 |
! |
|
416 |
||
417 |
resolveLabelFromDescription:aDescription withBuilder:aBuilder |
|
3763 | 418 |
"the rawLabel can be a string, icon, labelAndIcon or collection of strings. |
419 |
if labelIsImage is true, the string is actually the appModel-labelFor-access key" |
|
420 |
||
3468 | 421 |
|rawLabel appl resources lbl| |
1150 | 422 |
|
423 |
aBuilder isNil ifTrue:[ |
|
3468 | 424 |
rawLabel := aDescription rawLabel. |
3763 | 425 |
] ifFalse:[ |
426 |
rawLabel := aDescription label. |
|
427 |
rawLabel isNil ifTrue:[^ nil ]. |
|
428 |
||
429 |
aBuilder isEditing ifFalse:[ |
|
430 |
appl := aBuilder application. |
|
431 |
appl notNil ifTrue:[ resources := appl resources ]. |
|
432 |
]. |
|
3468 | 433 |
|
434 |
rawLabel isString ifTrue:[ |
|
3763 | 435 |
aDescription labelIsImage ifTrue:[ |
436 |
(aBuilder isEditing or:[(rawLabel := aBuilder labelFor:(rawLabel asSymbol)) isNil]) ifTrue:[ |
|
437 |
rawLabel := aDescription class defaultIcon |
|
438 |
]. |
|
439 |
^ rawLabel |
|
440 |
] ifFalse:[ |
|
441 |
aDescription translateLabel == true ifTrue:[ |
|
442 |
lbl := (aBuilder labelAt:(rawLabel asSymbol)) value. |
|
443 |
lbl isNil ifTrue:[ |
|
444 |
lbl := (aBuilder aspectAt:(rawLabel asSymbol)) value. |
|
445 |
]. |
|
446 |
(lbl isNil and:[resources notNil]) ifTrue:[ |
|
447 |
lbl := resources string:rawLabel default:nil. |
|
448 |
]. |
|
449 |
lbl notNil ifTrue:[ rawLabel := lbl ]. |
|
450 |
]. |
|
451 |
]. |
|
3468 | 452 |
] ifFalse:[ |
3763 | 453 |
(rawLabel isKindOf:LabelAndIcon) ifTrue:[ |
454 |
rawLabel := rawLabel copy string:(resources string:rawLabel string). |
|
1150 | 455 |
]. |
3468 | 456 |
|
3763 | 457 |
rawLabel isSequenceable ifFalse:[^ rawLabel]. |
458 |
rawLabel isEmptyOrNil ifTrue:[^ nil ]. |
|
459 |
||
460 |
resources notNil ifTrue:[ |
|
461 |
lbl := resources string:rawLabel default:nil. |
|
3468 | 462 |
|
3763 | 463 |
lbl notNil ifTrue:[ |
464 |
rawLabel := lbl. |
|
465 |
] ifFalse:[ |
|
466 |
lbl := resources array:rawLabel. |
|
467 |
lbl notEmptyOrNil ifTrue:[ |
|
468 |
lbl size == 1 ifTrue:[ rawLabel := lbl first ] |
|
469 |
ifFalse:[ rawLabel := lbl ]. |
|
470 |
]. |
|
3468 | 471 |
]. |
472 |
]. |
|
1150 | 473 |
]. |
474 |
]. |
|
3763 | 475 |
|
3468 | 476 |
rawLabel isString ifTrue:[ |
477 |
rawLabel isEmpty ifTrue:[ ^ nil ]. |
|
478 |
lbl := rawLabel asStringCollection. |
|
479 |
lbl size > 1 ifTrue:[^ lbl ]. |
|
480 |
]. |
|
481 |
^ rawLabel |
|
1150 | 482 |
! ! |
483 |
||
484 |
!DataSetLabel methodsFor:'queries'! |
|
485 |
||
1605 | 486 |
hasSeparator |
487 |
|l| |
|
488 |
||
489 |
label size == 1 ifTrue:[ |
|
490 |
"/ ^ (label at:1) ~= 'Alarm' |
|
491 |
^ (label at:1) ~= 'Area' |
|
492 |
]. |
|
493 |
^ true |
|
494 |
! |
|
495 |
||
1150 | 496 |
isSelectable |
497 |
"returns true if the item is selectable; a valid selector |
|
498 |
to notify the receiver for a release button event exists |
|
499 |
" |
|
500 |
^ selector notNil |
|
501 |
||
502 |
||
3765 | 503 |
! |
504 |
||
3768 | 505 |
isSortable |
3765 | 506 |
^ description isSortable |
1150 | 507 |
! ! |
508 |
||
509 |
!DataSetLabel class methodsFor:'documentation'! |
|
510 |
||
511 |
version |
|
3885 | 512 |
^ '$Header: /cvs/stx/stx/libwidg2/DataSetLabel.st,v 1.29 2010-03-09 12:08:18 cg Exp $' |
3763 | 513 |
! |
514 |
||
515 |
version_CVS |
|
3885 | 516 |
^ '$Header: /cvs/stx/stx/libwidg2/DataSetLabel.st,v 1.29 2010-03-09 12:08:18 cg Exp $' |
1150 | 517 |
! ! |