author | Claus Gittinger <cg@exept.de> |
Mon, 23 Jun 2008 20:13:26 +0200 | |
changeset 3448 | ef7d76d6bcfd |
parent 3364 | b7f6e426cd60 |
child 3459 | 6d1feb9745b8 |
permissions | -rw-r--r-- |
542 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by Claus Gittinger / 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 |
||
542 | 14 |
Object subclass:#DataSetColumn |
2444 | 15 |
instanceVariableNames:'columnNumber dataSet width description buttonExtent rendererType |
16 |
backgroundColor foregroundColor rowSeparatorSelector |
|
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
17 |
showColSeparator showRowSeparator columnAlignment label |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
18 |
containsText columnAdaptor descWidth descMinWidth |
2693 | 19 |
longStringCompression minValue maxValue' |
1712 | 20 |
classVariableNames:'' |
21 |
poolDictionaries:'' |
|
22 |
category:'Views-DataSet' |
|
542 | 23 |
! |
24 |
||
25 |
!DataSetColumn class methodsFor:'documentation'! |
|
26 |
||
27 |
copyright |
|
28 |
" |
|
29 |
COPYRIGHT (c) 1997 by Claus Gittinger / eXept Software AG |
|
30 |
All Rights Reserved |
|
31 |
||
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
||
40 |
||
41 |
||
42 |
! |
|
43 |
||
44 |
documentation |
|
45 |
" |
|
46 |
represent one single column description of a DataSetView |
|
47 |
||
48 |
[Instance variables:] |
|
49 |
||
647 | 50 |
columnNumber <Integer> sequence number (into list of columns) |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
51 |
|
542 | 52 |
dataSet <DSVColumnView> the view it belongs to |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
53 |
|
1088 | 54 |
width <Integer> width of column |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
55 |
|
2710
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
56 |
description <DataSetColumnSpec> the column description (a spec) |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
57 |
|
1088 | 58 |
buttonExtent <Point> extent of drawable form |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
59 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
60 |
rendererType <Type> renderer type (cached value from |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
61 |
the column specification). |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
62 |
|
647 | 63 |
backgroundColor <Color or nil> background color of all cells or nil |
64 |
(nil: use default background color). |
|
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
65 |
|
647 | 66 |
foregroundColor <Color or nil> foreground color of all cells or nil |
67 |
(nil: use default foreground color). |
|
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
68 |
|
1088 | 69 |
columnAlignment <Symbol> align text/icon #left #right or #center |
70 |
in row (on default: #left). |
|
71 |
||
72 |
label <label/icon or nil> label resolved by the builder shown |
|
73 |
in the column description field. |
|
74 |
||
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
75 |
readSelector <Symbol> cached readSelector (from the spec) |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
76 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
77 |
columnAdaptor <nil or any> if non-nil, that one is asked (via |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
78 |
read-writeSelectors to extract a column |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
79 |
from a row object. |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
80 |
If nil, the row object is used itself. |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
81 |
|
1113 | 82 |
showColSeparator <Boolean> true: vertical separators are enabled; |
83 |
separator between columns |
|
84 |
||
85 |
showRowSeparator <Boolean> true: horizontal separators are enabled; |
|
86 |
separator between rows |
|
87 |
||
88 |
rowSeparatorSelector <Selector or nil> access specific showRowSeparator state |
|
89 |
for a cell |
|
542 | 90 |
|
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
91 |
[from description:] |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
92 |
fgSelector <Selector or nil> access specific foreground color for |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
93 |
a cell |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
94 |
|
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
95 |
bgSelector <Selector or nil> access specific background color for |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
96 |
a cell |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
97 |
|
1725
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
98 |
numberOfRowsProbedForColumnSize the number of rows which are queries |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
99 |
<Integer> in order to compute the columns width. |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
100 |
(for scrollBar/col width computation) |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
101 |
Notice, if its expensive to fetch rows |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
102 |
(dataBase apps), this should be small. |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
103 |
Default:15 |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
104 |
|
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
105 |
|
542 | 106 |
[author:] |
107 |
Claus Atzkern |
|
108 |
||
109 |
[see also:] |
|
110 |
DataSetColumnSpec |
|
111 |
DSVColumnView |
|
112 |
DataSetView |
|
113 |
" |
|
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
114 |
! ! |
542 | 115 |
|
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
116 |
!DataSetColumn class methodsFor:'utilities'! |
542 | 117 |
|
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
118 |
shortenedStringFor:aString on:aGC maxWidth:maxWidth |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
119 |
"common code to shorten a string; used in both the DSV label- and column Views, |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
120 |
if the string is too long for the column" |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
121 |
|
2221 | 122 |
|widthOf3Dots wRest shortenedLabel lUsed lMin lMax| |
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
123 |
|
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
124 |
aString isString ifFalse:[^ aString]. |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
125 |
(aString widthOn:aGC) > maxWidth ifFalse:[aString]. |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
126 |
|
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
127 |
widthOf3Dots := '...' widthOn:aGC. |
2221 | 128 |
|
129 |
lMin := 1. |
|
130 |
lMax := aString size. |
|
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
131 |
[ |
2221 | 132 |
lUsed := (lMax + lMin) // 2. |
133 |
wRest := aString widthFrom:1 to:lUsed on:aGC. |
|
134 |
wRest > (maxWidth-widthOf3Dots) ifTrue:[ |
|
135 |
lMax := lUsed - 1. |
|
136 |
] ifFalse:[ |
|
137 |
lMin := lUsed + 1. |
|
138 |
]. |
|
139 |
lMin < lMax |
|
140 |
] whileTrue. |
|
141 |
shortenedLabel := aString copyFrom:1 to:lUsed. |
|
142 |
||
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
143 |
shortenedLabel isEmpty ifTrue:[ |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
144 |
((aString first asString , '..') widthOn:aGC) < maxWidth ifTrue:[ |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
145 |
"/ only two dots and the first character |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
146 |
^ (aString first asString , '..') |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
147 |
] |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
148 |
]. |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
149 |
^ (shortenedLabel , '...'). |
542 | 150 |
! ! |
151 |
||
152 |
!DataSetColumn methodsFor:'accessing'! |
|
153 |
||
3211 | 154 |
activeHelpText |
155 |
"get the active helpText or nil" |
|
156 |
||
157 |
|app key| |
|
158 |
||
159 |
((key := description activeHelpKey) notNil |
|
160 |
and:[(app := dataSet application) notNil]) ifTrue:[ |
|
3213 | 161 |
^ app flyByHelpTextForKey:key. |
3211 | 162 |
]. |
3218 | 163 |
^ nil |
3211 | 164 |
|
165 |
"Created: / 26-03-2007 / 13:39:11 / cg" |
|
3218 | 166 |
"Modified: / 26-03-2007 / 17:51:15 / cg" |
3211 | 167 |
! |
168 |
||
542 | 169 |
at:aRowNr |
170 |
"get the value of the raw at an index, aRowNr |
|
171 |
" |
|
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
172 |
|
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
173 |
|row| |
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
174 |
|
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
175 |
row := dataSet at:aRowNr. |
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
176 |
^ self extractColFromRow:row rowNr:aRowNr. |
542 | 177 |
! |
178 |
||
179 |
at:aRowNr put:something |
|
180 |
"set the value of the raw at an index, aRowNr |
|
181 |
" |
|
1059 | 182 |
|row newRow| |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
183 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
184 |
row := dataSet at:aRowNr. |
2419
e0121908fffe
added longStringCompression flag
Claus Gittinger <cg@exept.de>
parents:
2222
diff
changeset
|
185 |
self storeCol:something inRow:row. |
542 | 186 |
! |
187 |
||
1558
00b34d71898a
columnAdaptor also used when retrieving a ComboBoxes list.
Claus Gittinger <cg@exept.de>
parents:
1526
diff
changeset
|
188 |
columnAdaptor |
00b34d71898a
columnAdaptor also used when retrieving a ComboBoxes list.
Claus Gittinger <cg@exept.de>
parents:
1526
diff
changeset
|
189 |
^ columnAdaptor |
00b34d71898a
columnAdaptor also used when retrieving a ComboBoxes list.
Claus Gittinger <cg@exept.de>
parents:
1526
diff
changeset
|
190 |
! |
00b34d71898a
columnAdaptor also used when retrieving a ComboBoxes list.
Claus Gittinger <cg@exept.de>
parents:
1526
diff
changeset
|
191 |
|
1712 | 192 |
columnAdaptor:anAdapter |
193 |
columnAdaptor := anAdapter. |
|
194 |
! |
|
195 |
||
807 | 196 |
description |
2710
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
197 |
"returns the column spec |
807 | 198 |
" |
199 |
^ description |
|
200 |
! |
|
201 |
||
542 | 202 |
label |
203 |
"get the label assigned to the column |
|
204 |
" |
|
891 | 205 |
^ label |
542 | 206 |
|
207 |
||
208 |
! |
|
209 |
||
2419
e0121908fffe
added longStringCompression flag
Claus Gittinger <cg@exept.de>
parents:
2222
diff
changeset
|
210 |
longStringCompression:aBoolean |
e0121908fffe
added longStringCompression flag
Claus Gittinger <cg@exept.de>
parents:
2222
diff
changeset
|
211 |
^ longStringCompression ? true |
e0121908fffe
added longStringCompression flag
Claus Gittinger <cg@exept.de>
parents:
2222
diff
changeset
|
212 |
! |
e0121908fffe
added longStringCompression flag
Claus Gittinger <cg@exept.de>
parents:
2222
diff
changeset
|
213 |
|
1487 | 214 |
rendererType |
215 |
"returns my renderer type |
|
216 |
" |
|
217 |
^ rendererType |
|
218 |
! ! |
|
219 |
||
1818 | 220 |
!DataSetColumn methodsFor:'accessing-colors'! |
1565 | 221 |
|
222 |
backgroundColor |
|
223 |
"returns the background color or nil |
|
224 |
" |
|
2710
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
225 |
^ backgroundColor == dataSet backgroundColor ifTrue:[nil] ifFalse:[backgroundColor] |
1565 | 226 |
! |
227 |
||
2693 | 228 |
backgroundColor: aColor |
229 |
backgroundColor := aColor |
|
230 |
! |
|
231 |
||
1565 | 232 |
backgroundColorAt:aRowNr |
233 |
"returns the background color for a row at list index a rowNr |
|
234 |
" |
|
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
235 |
description backgroundSelector notNil ifTrue:[ |
1565 | 236 |
^ self backgroundColorFor:(dataSet at:aRowNr) at:aRowNr |
237 |
]. |
|
238 |
^ backgroundColor |
|
239 |
! |
|
240 |
||
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
241 |
backgroundColorFor:aRow at:aRowNr |
2727
5cb5708a6982
No extra handling needed for LimitedPrecisionReal
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
242 |
"return the background color for a row at list index a rowNr" |
5cb5708a6982
No extra handling needed for LimitedPrecisionReal
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
243 |
|
3210 | 244 |
"/ backgroundColor has already been fetched from description/dataSet (see #initialize) |
245 |
^ self |
|
246 |
colorFor:aRow at:aRowNr |
|
247 |
descriptionSelector:(description backgroundSelector) |
|
248 |
descriptionColor:backgroundColor |
|
249 |
dataSetDefaultColor:nil |
|
1565 | 250 |
|
3210 | 251 |
"Modified: / 26-03-2007 / 13:27:19 / cg" |
252 |
! |
|
253 |
||
254 |
colorFor:aRow at:aRowNr descriptionSelector:descriptionSelector descriptionColor:descriptionColor dataSetDefaultColor:dataSetColor |
|
255 |
"common code for returning a color for a row at list index a rowNr, asking both description and dataSet as fallBack" |
|
256 |
||
257 |
|clr| |
|
258 |
||
259 |
descriptionSelector notNil ifTrue:[ |
|
1924 | 260 |
columnAdaptor notNil ifTrue:[ |
3210 | 261 |
clr := columnAdaptor perform:descriptionSelector withOptionalArgument:aRow and:aRowNr and:columnNumber and:dataSet |
1565 | 262 |
] ifFalse:[ |
3210 | 263 |
clr := aRow perform:descriptionSelector withOptionalArgument:aRowNr and:columnNumber and:dataSet |
1565 | 264 |
]. |
3210 | 265 |
clr notNil ifTrue:[ |
266 |
(clr isColor or:[clr isImageOrForm]) ifTrue:[ |
|
267 |
^ clr |
|
1928
2dcf8e62af64
debug: care for non-color to be returned from fg/bg message.
Claus Gittinger <cg@exept.de>
parents:
1924
diff
changeset
|
268 |
]. |
3210 | 269 |
self error:'unexpected color (not a color or image)'. |
1928
2dcf8e62af64
debug: care for non-color to be returned from fg/bg message.
Claus Gittinger <cg@exept.de>
parents:
1924
diff
changeset
|
270 |
] |
1565 | 271 |
]. |
3210 | 272 |
^ descriptionColor ? dataSetColor |
273 |
||
274 |
"Created: / 26-03-2007 / 13:05:24 / cg" |
|
1565 | 275 |
! |
276 |
||
277 |
foregroundColor |
|
278 |
"returns the foreground color or nil |
|
279 |
" |
|
2710
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
280 |
^ foregroundColor == dataSet foregroundColor ifTrue:[nil] ifFalse:[foregroundColor] |
1565 | 281 |
! |
282 |
||
2693 | 283 |
foregroundColor: aColor |
284 |
foregroundColor := aColor |
|
285 |
! |
|
286 |
||
1565 | 287 |
foregroundColorFor:aRow at:aRowNr |
288 |
"returns the foreground color for a row at list index a rowNr |
|
289 |
" |
|
290 |
||
3210 | 291 |
"/ foregroundColor has already been fetched from description/dataSet (see #initialize) |
292 |
^ self |
|
293 |
colorFor:aRow at:aRowNr |
|
294 |
descriptionSelector:(description foregroundSelector) |
|
295 |
descriptionColor:foregroundColor |
|
296 |
dataSetDefaultColor:nil |
|
297 |
||
298 |
"Modified: / 26-03-2007 / 13:27:39 / cg" |
|
2710
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
299 |
! |
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
300 |
|
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
301 |
selectedBackgroundColorFor:aRow at:aRowNr |
3210 | 302 |
"returns the selected background color for a row at list index a rowNr" |
2710
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
303 |
|
3210 | 304 |
^ self |
305 |
colorFor:aRow at:aRowNr |
|
306 |
descriptionSelector:(description selectedBackgroundSelector) |
|
307 |
descriptionColor:(description selectedBackgroundColor) |
|
308 |
dataSetDefaultColor:(dataSet selectionBackgroundColor) |
|
3139 | 309 |
|
3210 | 310 |
"Modified: / 26-03-2007 / 13:06:06 / cg" |
2710
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
311 |
! |
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
312 |
|
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
313 |
selectedForegroundColorFor:aRow at:aRowNr |
3210 | 314 |
"returns the selected foreground color for a row at list index a rowNr" |
2710
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
315 |
|
3210 | 316 |
^ self |
317 |
colorFor:aRow at:aRowNr |
|
318 |
descriptionSelector:(description selectedForegroundSelector) |
|
319 |
descriptionColor:(description selectedForegroundColor) |
|
320 |
dataSetDefaultColor:(dataSet selectionForegroundColor) |
|
321 |
||
322 |
"Modified: / 26-03-2007 / 13:05:31 / cg" |
|
1565 | 323 |
! ! |
324 |
||
1818 | 325 |
!DataSetColumn methodsFor:'accessing-dimension'! |
1487 | 326 |
|
1484 | 327 |
minWidth |
1490 | 328 |
"get the minimum width required by the column |
1484 | 329 |
" |
1490 | 330 |
descMinWidth notNil ifTrue:[ |
331 |
^ descMinWidth |
|
332 |
]. |
|
333 |
width := nil. |
|
334 |
^ self width |
|
1484 | 335 |
|
1490 | 336 |
! |
337 |
||
1492 | 338 |
minimumRequiredWidth |
339 |
"returns the minimum required width |
|
340 |
" |
|
341 |
|minWidth| |
|
342 |
||
1940 | 343 |
descMinWidth notNil ifTrue:[ |
344 |
minWidth := DSVLabelView tabSpacing max:2. |
|
345 |
^ minWidth // 2 + minWidth |
|
346 |
]. |
|
1492 | 347 |
|
1940 | 348 |
minWidth := dataSet separatorSize + (2 * dataSet horizontalSpacing). |
349 |
^ minWidth + label preferredWidth. |
|
1492 | 350 |
! |
351 |
||
1490 | 352 |
setDescWidth:aWidth |
353 |
"set a fixed width |
|
354 |
" |
|
1940 | 355 |
descMinWidth := 1. |
356 |
descMinWidth := width := descWidth := self minimumRequiredWidth max:aWidth. |
|
1484 | 357 |
! |
358 |
||
542 | 359 |
width |
360 |
"returns the width in pixels |
|
1725
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
361 |
Warning: |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
362 |
only the first numberOfRowsProbedForColumnSize are probed, |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
363 |
in case the access is expensive (dataBase apps) |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
364 |
If the descriptor defines a width, that is used, and the items |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
365 |
are not probed at all." |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
366 |
|
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
367 |
|max "{ Class:SmallInteger }" |
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
368 |
listSize "{ Class:SmallInteger }"| |
542 | 369 |
|
1484 | 370 |
width notNil ifTrue:[^ width]. "/ already computed |
542 | 371 |
|
1490 | 372 |
descMinWidth notNil ifTrue:[ |
373 |
width := descMinWidth. |
|
374 |
^ width |
|
1484 | 375 |
]. |
1482 | 376 |
|
2017
5cbe1d46c01d
isReal -> isLimitedPrecisionReal
Claus Gittinger <cg@exept.de>
parents:
1984
diff
changeset
|
377 |
(descWidth ~~ 0 and:[descWidth isLimitedPrecisionReal not]) ifTrue:[ |
1493 | 378 |
width := descMinWidth := descWidth. |
379 |
^ width |
|
380 |
]. |
|
381 |
||
1490 | 382 |
width := description minWidth max:(label preferredWidth). |
383 |
||
2017
5cbe1d46c01d
isReal -> isLimitedPrecisionReal
Claus Gittinger <cg@exept.de>
parents:
1984
diff
changeset
|
384 |
descWidth isLimitedPrecisionReal ifTrue:[ |
2093 | 385 |
width := width max:(descWidth * dataSet innerWidth) rounded. |
1490 | 386 |
^ width |
1482 | 387 |
]. |
388 |
||
1496 | 389 |
containsText ifTrue:[ |
1725
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
390 |
"/ take maximum numberOfRowsProbedForColumnSize entries to calculate the width; |
1484 | 391 |
"/ can be resized later if neccessary |
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
392 |
listSize := dataSet size. |
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
393 |
max := listSize min:description numberOfRowsProbedForColumnSize. |
542 | 394 |
|
1526 | 395 |
max ~~ 0 ifTrue:[ |
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
396 |
1 to:max do:[:rowNr| |row| |
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
397 |
row := dataSet at:rowNr. |
2444 | 398 |
width := width max:(self widthOfLabel:(self shownValueForRow:row rowNr:rowNr)) |
1526 | 399 |
]. |
2444 | 400 |
width := width max:(self widthOfLabel:(self shownValueForRow:(dataSet at:listSize) rowNr:listSize)) |
1484 | 401 |
]. |
402 |
description editorType ~~ #None ifTrue:[ |
|
403 |
width := width + (dataSet font widthOn:dataSet device) |
|
542 | 404 |
]. |
1493 | 405 |
] ifFalse:[ |
406 |
max := 1 |
|
1484 | 407 |
]. |
1490 | 408 |
width := width + buttonExtent x + dataSet separatorSize + (2 * dataSet horizontalSpacing). |
1493 | 409 |
|
410 |
max ~~ 0 ifTrue:[ |
|
1526 | 411 |
descMinWidth := width. |
412 |
description usePreferredWidth ifTrue:[ |
|
413 |
descWidth := width |
|
414 |
] |
|
1493 | 415 |
]. |
1490 | 416 |
^ width |
1484 | 417 |
|
1725
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
418 |
"Modified: / 25.2.2000 / 14:29:16 / cg" |
542 | 419 |
! ! |
420 |
||
421 |
!DataSetColumn methodsFor:'drawing'! |
|
422 |
||
3330 | 423 |
drawLabel:aLabelToDraw atX:xLeft y:yTop |
424 |
"draw aLabelToDraw; handle columnAlignment" |
|
425 |
||
426 |
|drawnLabel x space prevClip mustUndoClip cashedWidth |
|
427 |
labelWidth leftPart leftShift indexOfFirstDigit indexOfFirstNonDigit| |
|
428 |
||
429 |
cashedWidth := self width. |
|
430 |
cashedWidth isNil ifTrue:[ ^ self ]. |
|
431 |
||
432 |
space := dataSet horizontalSpacing. |
|
433 |
||
434 |
drawnLabel := aLabelToDraw. |
|
435 |
labelWidth := drawnLabel widthOn:dataSet. |
|
436 |
||
437 |
(longStringCompression ~~ false |
|
438 |
and:[ drawnLabel isString |
|
439 |
and:[ labelWidth > cashedWidth]]) ifTrue:[ |
|
440 |
drawnLabel := self class shortenedStringFor:drawnLabel on:dataSet maxWidth:cashedWidth-space. |
|
441 |
labelWidth := drawnLabel widthOn:dataSet. |
|
442 |
]. |
|
443 |
||
444 |
columnAlignment == #left ifTrue:[ |
|
445 |
x := xLeft + space. |
|
446 |
] ifFalse:[ |
|
447 |
columnAlignment == #decimal ifTrue:[ |
|
448 |
drawnLabel := drawnLabel asString. |
|
449 |
(drawnLabel includes:$.) ifTrue:[ |
|
450 |
leftPart := drawnLabel upTo:$.. |
|
451 |
] ifFalse:[ |
|
452 |
leftPart := drawnLabel. |
|
453 |
||
454 |
indexOfFirstDigit := drawnLabel findFirst:[:char | char isDigit]. |
|
455 |
indexOfFirstDigit ~~ 0 ifTrue:[ |
|
456 |
indexOfFirstNonDigit := drawnLabel findFirst:[:char | char isDigit not] startingAt:indexOfFirstDigit+1. |
|
457 |
indexOfFirstNonDigit ~~ 0 ifTrue:[ |
|
458 |
leftPart := drawnLabel copyTo:indexOfFirstNonDigit-1. |
|
459 |
]. |
|
460 |
]. |
|
461 |
]. |
|
462 |
leftShift := leftPart widthOn:dataSet. |
|
463 |
x := (cashedWidth // 2) - leftShift. |
|
464 |
] ifFalse:[ |
|
465 |
x := cashedWidth - labelWidth. |
|
466 |
||
467 |
columnAlignment == #right ifTrue:[x := x - space] |
|
468 |
ifFalse:[x := x // 2]. |
|
469 |
]. |
|
470 |
"/ cg: old code (did not right-align if string is larger than width |
|
471 |
"/ x := xLeft + (x max:0). |
|
472 |
||
473 |
"/ new code: always right-align. |
|
474 |
x := xLeft + x. |
|
475 |
||
476 |
"/ must clip left, if string is too large |
|
477 |
x < xLeft ifTrue:[ |
|
478 |
"/ must clip ... |
|
479 |
prevClip := dataSet clippingRectangleOrNil. |
|
480 |
mustUndoClip := true. |
|
481 |
dataSet clippingRectangle:(Rectangle |
|
482 |
left:xLeft top:yTop |
|
483 |
width:cashedWidth height:(drawnLabel heightOn:dataSet)). |
|
484 |
]. |
|
485 |
]. |
|
486 |
||
487 |
"/ drawnLabel isImageOrForm ifTrue:[ |
|
488 |
"/ y := yTop. |
|
489 |
"/ ] ifFalse:[ |
|
490 |
"/ y := (yTop + dataSet rowFontAscent) |
|
491 |
"/ ]. |
|
492 |
||
493 |
"/ drawnLabel isString ifFalse:[ |
|
494 |
"/ y := yTop + (drawnLabel ascentOn:dataSet). |
|
495 |
"/ ] ifTrue:[ |
|
496 |
"/ y := yTop + dataSet rowFontAscent |
|
497 |
"/ ]. |
|
498 |
"/ drawnLabel displayOn:dataSet x:x y:y. |
|
499 |
||
500 |
dataSet displayLabel:drawnLabel x:x y:yTop. |
|
501 |
||
502 |
mustUndoClip == true ifTrue:[ |
|
503 |
dataSet clippingRectangle:prevClip |
|
504 |
]. |
|
505 |
! |
|
506 |
||
1132 | 507 |
drawLabelsAtX:xLeft y:yTop h:h from:start to:stop |
508 |
"redraw labels from start to stop |
|
1088 | 509 |
" |
3298
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
510 |
|fg y yT x hspace lblHg bg label row isSel cashedWidth| |
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
511 |
|
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
512 |
cashedWidth := self width. |
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
513 |
cashedWidth isNil ifTrue:[ ^ self ]. |
2578 | 514 |
|
1132 | 515 |
yT := yTop. |
516 |
hspace := dataSet horizontalSpacing. |
|
1100 | 517 |
|
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
518 |
start to:stop do:[:aRowNr| |
3364
b7f6e426cd60
care for list change while drawing
Claus Gittinger <cg@exept.de>
parents:
3330
diff
changeset
|
519 |
row := dataSet at:aRowNr ifAbsent:[^ self]. |
1132 | 520 |
y := yT. |
521 |
x := xLeft. |
|
522 |
||
2710
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
523 |
"/ GET BACKGROUND AND FOREGROUND-COLOR |
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
524 |
"/ =================================== |
1132 | 525 |
|
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
526 |
isSel := dataSet isSelected:aRowNr inColumn:columnNumber. |
1132 | 527 |
|
528 |
(isSel and:[description showSelectionHighLighted]) ifTrue:[ |
|
529 |
"/ SHOW SELECTED( MUST REDRAW BACKGROUND ) |
|
530 |
"/ ======================================= |
|
2710
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
531 |
bg := self selectedBackgroundColorFor:row at:aRowNr. |
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
532 |
fg := self selectedForegroundColorFor:row at:aRowNr. |
2578 | 533 |
|
1132 | 534 |
dataSet paint:bg. |
3298
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
535 |
dataSet fillRectangleX:x y:y width:cashedWidth height:h. |
1113 | 536 |
] ifFalse:[ |
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
537 |
description backgroundSelector notNil ifTrue:[ |
1132 | 538 |
"/ MUST REDRAW BACKGROUND |
539 |
"/ ====================== |
|
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
540 |
bg := self backgroundColorFor:row at:aRowNr. |
1565 | 541 |
|
542 |
bg ~~ backgroundColor ifTrue:[ |
|
1132 | 543 |
bg := dataSet colorOnDevice:bg |
544 |
]. |
|
545 |
dataSet paint:bg. |
|
3298
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
546 |
dataSet fillRectangleX:x y:y width:cashedWidth height:h. |
1132 | 547 |
] ifFalse:[ |
548 |
bg := backgroundColor |
|
549 |
]. |
|
1100 | 550 |
|
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
551 |
fg := self foregroundColorFor:row at:aRowNr. |
1565 | 552 |
|
553 |
fg ~~ foregroundColor ifTrue:[ |
|
1132 | 554 |
fg := dataSet colorOnDevice:fg |
1565 | 555 |
]. |
1132 | 556 |
]. |
833 | 557 |
|
1132 | 558 |
"/ GET AND DRAW LABEL |
559 |
"/ ================== |
|
2542 | 560 |
(self isRowVisible:aRowNr) ifTrue:[ |
561 |
rendererType == #rowSelector ifTrue:[ |
|
562 |
isSel ifTrue:[ |
|
563 |
label := dataSet rowSelectorForm. |
|
564 |
x := x + hspace. |
|
565 |
] ifFalse:[ |
|
566 |
label := nil |
|
567 |
] |
|
1132 | 568 |
] ifFalse:[ |
2542 | 569 |
(isSel and:[dataSet hasOpenEditor]) ifTrue:[ |
570 |
label := nil |
|
571 |
] ifFalse:[ |
|
572 |
label := self shownValueForRow:row rowNr:aRowNr |
|
573 |
] |
|
1589
8bb71707b51a
remove any color emphasis when displaying the selection.
Claus Gittinger <cg@exept.de>
parents:
1587
diff
changeset
|
574 |
]. |
2542 | 575 |
label notNil ifTrue:[ |
576 |
"/ care for a dark-colored label, |
|
577 |
"/ with a dark selection-bg color |
|
578 |
(isSel and:[label isString and:[label hasChangeOfEmphasis]]) ifTrue:[ |
|
579 |
"/ take away the labels own color info |
|
580 |
label := label emphasisAllRemove:#color. |
|
581 |
]. |
|
582 |
||
583 |
lblHg := self heightOfLabel:label. |
|
1589
8bb71707b51a
remove any color emphasis when displaying the selection.
Claus Gittinger <cg@exept.de>
parents:
1587
diff
changeset
|
584 |
|
2542 | 585 |
lblHg ~~ 0 ifTrue:[ |
3139 | 586 |
y := y + ((h - lblHg) // 2). |
2542 | 587 |
dataSet paint:fg on:bg. |
1113 | 588 |
|
2542 | 589 |
(label isSequenceable and:[label isString not]) ifFalse:[ |
590 |
self drawLabel:label atX:x y:y |
|
591 |
] ifTrue:[ |
|
592 |
label do:[:el| |
|
593 |
el notNil ifTrue:[ |
|
594 |
self drawLabel:el atX:x y:y. |
|
595 |
y := y + (el heightOn:dataSet). |
|
596 |
] |
|
1147 | 597 |
] |
2542 | 598 |
]. |
599 |
] |
|
600 |
]. |
|
1132 | 601 |
]. |
602 |
yT := yT + h |
|
603 |
] |
|
833 | 604 |
! |
605 |
||
1132 | 606 |
drawSeparatorsAtX:xLeft y:yTop h:h from:start to:stop |
607 |
"redraw separators for cells between start and stop |
|
1088 | 608 |
" |
3298
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
609 |
|cashedWidth is3D xL xR yB yT times| |
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
610 |
|
1132 | 611 |
(showColSeparator or:[showRowSeparator]) ifFalse:[ |
612 |
^ self |
|
613 |
]. |
|
3298
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
614 |
cashedWidth := self width. |
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
615 |
cashedWidth isNil ifTrue:[ ^ self ]. |
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
616 |
|
1132 | 617 |
is3D := dataSet has3Dseparators. |
618 |
||
1113 | 619 |
is3D ifTrue:[dataSet paint:(dataSet separatorDarkColor)] |
2638
f2b2ecc2c851
use user defined color for drawing separators in OneD mode
ca
parents:
2636
diff
changeset
|
620 |
ifFalse:[dataSet paint:(dataSet separatorOneDColor)]. |
1088 | 621 |
|
1132 | 622 |
times := stop - start + 1. |
623 |
xL := xLeft. |
|
3298
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
624 |
xR := xL - 1 + cashedWidth. |
1088 | 625 |
|
1113 | 626 |
showRowSeparator ifTrue:[ |
1132 | 627 |
"/ DRAW SEPARATORS AT BOTTOM( DARK COLOR ) |
628 |
"/ ======================================= |
|
629 |
yB := yTop - 1 + h. |
|
630 |
||
631 |
rowSeparatorSelector isNil ifTrue:[ |
|
632 |
times timesRepeat:[ |
|
633 |
dataSet displayLineFromX:xL y:yB toX:xR y:yB. |
|
634 |
yB := yB + h. |
|
635 |
] |
|
636 |
] ifFalse:[ |
|
637 |
start to:stop do:[:idx| |
|
3240
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
638 |
(self hasRowSeparatorAt:idx) ifTrue:[ |
1132 | 639 |
dataSet displayLineFromX:xL y:yB toX:xR y:yB |
640 |
]. |
|
641 |
yB := yB + h. |
|
3240
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
642 |
]. |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
643 |
]. |
1113 | 644 |
]. |
1132 | 645 |
|
1113 | 646 |
showColSeparator ifTrue:[ |
1132 | 647 |
"/ DRAW SEPARATORS AT RIGHT( DARK COLOR ) |
648 |
"/ ====================================== |
|
649 |
yT := yTop. |
|
650 |
||
651 |
times timesRepeat:[ |
|
652 |
dataSet displayLineFromX:xR y:yT toX:xR y:(yT - 1 + h). |
|
653 |
yT := yT + h. |
|
654 |
] |
|
1113 | 655 |
]. |
1089 | 656 |
|
1113 | 657 |
is3D ifFalse:[ |
658 |
^ self |
|
659 |
]. |
|
1088 | 660 |
|
1113 | 661 |
dataSet paint:(dataSet separatorLightColor). |
1040
c8e6a2ed7928
use the same background color for a selected rowSelector
ca
parents:
1007
diff
changeset
|
662 |
|
1113 | 663 |
( columnNumber == 1 |
664 |
or:[(dataSet columnAt:(columnNumber - 1)) showColSeparator] |
|
665 |
) ifTrue:[ |
|
1132 | 666 |
|
667 |
"/ DRAW SEPARATORS AT LEFT( LIGHT COLOR ) |
|
668 |
"/ ====================================== |
|
669 |
yT := yTop. |
|
670 |
||
671 |
times timesRepeat:[ |
|
672 |
dataSet displayLineFromX:xL y:yT toX:xL y:(yT - 1 + h). |
|
673 |
yT := yT + h. |
|
674 |
]. |
|
1113 | 675 |
] ifFalse:[ |
1132 | 676 |
xL := xL - 1 |
1113 | 677 |
]. |
1092 | 678 |
|
1113 | 679 |
showRowSeparator ifTrue:[ |
1132 | 680 |
"/ DRAW SEPARATORS AT TOP( LIGHT COLOR ) |
681 |
"/ ===================================== |
|
682 |
yT := yTop. |
|
683 |
||
684 |
rowSeparatorSelector isNil ifTrue:[ |
|
685 |
times timesRepeat:[ |
|
686 |
dataSet displayLineFromX:xL y:yT toX:xR y:yT. |
|
687 |
yT := yT + h. |
|
688 |
] |
|
689 |
] ifFalse:[ |
|
690 |
"/ CHECK WHETHER PREVIOUS ROW HAS A SEPARATOR AT BOTTOM |
|
691 |
"/ ==================================================== |
|
692 |
start to:stop do:[:idx| |
|
3240
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
693 |
(idx == 1 or:[self hasRowSeparatorAt:(idx - 1)]) ifTrue:[ |
1132 | 694 |
dataSet displayLineFromX:xL y:yT toX:xR y:yT. |
695 |
]. |
|
696 |
yT := yT + h. |
|
697 |
] |
|
1088 | 698 |
] |
542 | 699 |
]. |
607 | 700 |
! |
701 |
||
542 | 702 |
invalidate |
1484 | 703 |
"invalidate width of column; forces a recomputation |
542 | 704 |
" |
1484 | 705 |
width := nil. |
542 | 706 |
|
1088 | 707 |
! |
708 |
||
1132 | 709 |
redrawX:xLeft y:yTop h:h from:start to:stop |
1088 | 710 |
"redraw rows between start and stop |
711 |
" |
|
3298
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
712 |
|rH y cashedWidth| |
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
713 |
|
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
714 |
cashedWidth := self width. |
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
715 |
cashedWidth isNil ifTrue:[ ^ self ]. |
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
716 |
|
1132 | 717 |
rH := dataSet rowHeight. |
1088 | 718 |
|
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
719 |
description backgroundSelector isNil ifTrue:[ |
1132 | 720 |
dataSet paint:backgroundColor. |
3298
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
721 |
dataSet fillRectangleX:xLeft y:yTop width:cashedWidth height:h |
1115 | 722 |
]. |
723 |
||
1132 | 724 |
"/ DRAW CELLS: BACKGROUND/FOREGROUND/LABEL |
725 |
"/ ======================================= |
|
726 |
self drawLabelsAtX:xLeft y:yTop h:rH from:start to:stop. |
|
1113 | 727 |
|
728 |
"/ DRAW INDICATORS |
|
729 |
"/ =============== |
|
730 |
(rendererType == #ComboBox or:[rendererType == #ComboList]) ifTrue:[ |
|
1132 | 731 |
y := yTop. |
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
732 |
start to:stop do:[:rowNr| |
2542 | 733 |
(self isRowVisible:rowNr) ifTrue:[ |
734 |
(self hasChoices:rowNr) ifTrue:[ |
|
3298
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
735 |
dataSet drawComboButtonAtX:xLeft y:y w:cashedWidth |
2542 | 736 |
]. |
1113 | 737 |
]. |
1132 | 738 |
y := y + rH. |
1113 | 739 |
] |
740 |
] ifFalse:[ |
|
741 |
rendererType == #CheckToggle ifTrue:[ |
|
1132 | 742 |
y := yTop. |
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
743 |
start to:stop do:[:rowNr| |state| |
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
744 |
state := self at:rowNr. |
2542 | 745 |
(self isRowVisible:rowNr) ifTrue:[ |
3298
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
746 |
dataSet drawCheckToggleAtX:xLeft y:y w:cashedWidth state:state. |
2542 | 747 |
]. |
1132 | 748 |
y := y + rH. |
1113 | 749 |
] |
750 |
] |
|
1088 | 751 |
]. |
752 |
||
753 |
"/ DRAW SEPARATORS |
|
1113 | 754 |
"/ =============== |
1132 | 755 |
self drawSeparatorsAtX:xLeft y:yTop h:rH from:start to:stop |
2693 | 756 |
! |
757 |
||
758 |
shownValueForRow:aRow rowNr:aRowNr |
|
3325
8d2a6394f01a
added/fixed printConverter handling
Claus Gittinger <cg@exept.de>
parents:
3320
diff
changeset
|
759 |
|selector format value type choices translatedChoices idx converter| |
2693 | 760 |
|
761 |
rendererType == #CheckToggle ifTrue:[ |
|
762 |
^ nil |
|
763 |
]. |
|
764 |
||
765 |
rendererType == #rowSelector ifTrue:[ |
|
766 |
^ nil |
|
767 |
]. |
|
768 |
||
769 |
selector := description printSelector. |
|
770 |
selector notNil ifTrue:[ |
|
771 |
^ aRow |
|
772 |
perform:selector |
|
773 |
withOptionalArgument:dataSet and:columnNumber and:aRowNr and:dataSet. |
|
774 |
]. |
|
775 |
||
776 |
value := self extractColFromRow:aRow rowNr:aRowNr. |
|
2865 | 777 |
description translatedChoices notNil ifTrue:[ |
778 |
choices := self choicesFor:aRow at:aRowNr. |
|
779 |
idx := choices indexOf:value. |
|
780 |
idx ~~ 0 ifTrue:[ |
|
781 |
translatedChoices := self translatedChoicesFor:aRow at:aRowNr. |
|
782 |
translatedChoices notNil ifTrue:[ |
|
783 |
value := translatedChoices at:idx. |
|
784 |
]. |
|
785 |
]. |
|
786 |
]. |
|
2693 | 787 |
|
788 |
selector := description formatSelector. |
|
789 |
selector notNil ifTrue:[ |
|
790 |
format := aRow |
|
791 |
perform:selector |
|
792 |
withOptionalArgument:dataSet and:columnNumber and:aRowNr and:dataSet. |
|
793 |
] ifFalse:[ |
|
794 |
format := description formatString. |
|
795 |
]. |
|
796 |
format notNil ifTrue:[ |
|
797 |
"/ cannot remember what this was used for ... |
|
798 |
"/ (idx := format indexOf:$.) ~~ 0 ifTrue:[ |
|
799 |
"/ idx := format size - idx |
|
800 |
"/ ]. |
|
801 |
"/ format := '%0.', idx printString, 'f'. |
|
802 |
||
3325
8d2a6394f01a
added/fixed printConverter handling
Claus Gittinger <cg@exept.de>
parents:
3320
diff
changeset
|
803 |
^ value printfPrintString:format |
8d2a6394f01a
added/fixed printConverter handling
Claus Gittinger <cg@exept.de>
parents:
3320
diff
changeset
|
804 |
]. |
8d2a6394f01a
added/fixed printConverter handling
Claus Gittinger <cg@exept.de>
parents:
3320
diff
changeset
|
805 |
|
8d2a6394f01a
added/fixed printConverter handling
Claus Gittinger <cg@exept.de>
parents:
3320
diff
changeset
|
806 |
type := description type. |
8d2a6394f01a
added/fixed printConverter handling
Claus Gittinger <cg@exept.de>
parents:
3320
diff
changeset
|
807 |
type ~~ #string ifTrue:[ |
8d2a6394f01a
added/fixed printConverter handling
Claus Gittinger <cg@exept.de>
parents:
3320
diff
changeset
|
808 |
converter := TypeConverter new perform:type. |
8d2a6394f01a
added/fixed printConverter handling
Claus Gittinger <cg@exept.de>
parents:
3320
diff
changeset
|
809 |
converter model:value. |
8d2a6394f01a
added/fixed printConverter handling
Claus Gittinger <cg@exept.de>
parents:
3320
diff
changeset
|
810 |
^ converter value. |
2693 | 811 |
]. |
812 |
||
813 |
^ value |
|
542 | 814 |
! ! |
815 |
||
614 | 816 |
!DataSetColumn methodsFor:'editing'! |
817 |
||
833 | 818 |
editorAt:aRowNr |
1268 | 819 |
|val row| |
614 | 820 |
|
3264
642d79a1b0d6
care for non-exisiting columns (race condition)
Claus Gittinger <cg@exept.de>
parents:
3240
diff
changeset
|
821 |
row := dataSet at:aRowNr ifAbsent:[^ nil]. |
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
822 |
val := self extractColFromRow:row rowNr:aRowNr. |
614 | 823 |
|
833 | 824 |
val isText ifTrue:[val := val string]. |
2864
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
825 |
^ description editorOn:row at:aRowNr column:self value:val usingAdaptor:columnAdaptor. |
3264
642d79a1b0d6
care for non-exisiting columns (race condition)
Claus Gittinger <cg@exept.de>
parents:
3240
diff
changeset
|
826 |
|
642d79a1b0d6
care for non-exisiting columns (race condition)
Claus Gittinger <cg@exept.de>
parents:
3240
diff
changeset
|
827 |
"Modified: / 27-10-2007 / 10:26:15 / cg" |
2693 | 828 |
! ! |
829 |
||
830 |
!DataSetColumn methodsFor:'event handling'! |
|
831 |
||
832 |
doesNotUnderstand:aMessage |
|
833 |
||
834 |
(description respondsTo:(aMessage selector)) ifTrue:[ |
|
835 |
^ aMessage sendTo:description |
|
836 |
]. |
|
837 |
^ super doesNotUnderstand:aMessage |
|
838 |
||
839 |
! ! |
|
840 |
||
841 |
!DataSetColumn methodsFor:'grow & shrink'! |
|
842 |
||
843 |
growWidth:n |
|
844 |
"grow the width for n pixels |
|
845 |
" |
|
846 |
width := self width + n. |
|
847 |
||
848 |
||
849 |
! ! |
|
850 |
||
851 |
!DataSetColumn methodsFor:'initialization'! |
|
542 | 852 |
|
1147 | 853 |
on:aDSVColumnView description:aDescription columnNumber:aNumber label:aLabel |
542 | 854 |
"instance creation; set attributes dependent on the description |
855 |
" |
|
1089 | 856 |
columnNumber := aNumber. |
857 |
dataSet := aDSVColumnView. |
|
1147 | 858 |
label := aLabel. |
1487 | 859 |
|
1089 | 860 |
description := aDescription. |
861 |
rendererType := description rendererType. |
|
1496 | 862 |
containsText := ( rendererType ~~ #CheckToggle |
863 |
and:[rendererType ~~ #rowSelector] |
|
864 |
). |
|
1490 | 865 |
descWidth := description width. |
2424
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
866 |
longStringCompression := description longStringCompression. |
1526 | 867 |
|
868 |
description usePreferredWidth ifTrue:[ |
|
869 |
descWidth := 0 |
|
870 |
]. |
|
871 |
||
1565 | 872 |
width := nil. |
873 |
||
2693 | 874 |
minValue := description minValue. |
875 |
maxValue := description maxValue. |
|
1113 | 876 |
rowSeparatorSelector := description rowSeparatorSelector. |
1565 | 877 |
|
1113 | 878 |
showColSeparator := description showColSeparator. |
879 |
showRowSeparator := description showRowSeparator. |
|
1089 | 880 |
columnAdaptor := dataSet columnAdaptor. |
881 |
buttonExtent := 0 @ 0. |
|
882 |
columnAlignment := #left. |
|
584 | 883 |
|
1132 | 884 |
(backgroundColor := description backgroundColor) isNil ifTrue:[ |
885 |
backgroundColor := dataSet backgroundColor |
|
886 |
] ifFalse:[ |
|
1480 | 887 |
backgroundColor := backgroundColor onDevice:dataSet device |
584 | 888 |
]. |
1113 | 889 |
|
890 |
(foregroundColor := description foregroundColor) isNil ifTrue:[ |
|
891 |
foregroundColor := dataSet foregroundColor |
|
892 |
] ifFalse:[ |
|
1480 | 893 |
foregroundColor := foregroundColor onDevice:dataSet device |
584 | 894 |
]. |
542 | 895 |
|
896 |
rendererType == #CheckToggle ifTrue:[ |
|
1113 | 897 |
buttonExtent := dataSet checkToggleExtent. |
2067
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
898 |
^ self |
542 | 899 |
]. |
900 |
||
901 |
rendererType == #rowSelector ifTrue:[ |
|
807 | 902 |
buttonExtent := dataSet rowSelectorExtent. |
2067
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
903 |
^ self |
542 | 904 |
]. |
905 |
||
906 |
(rendererType == #ComboBox or:[rendererType == #ComboList]) ifTrue:[ |
|
807 | 907 |
buttonExtent := dataSet comboButtonExtent. |
883 | 908 |
] ifFalse:[ |
909 |
columnAlignment := description columnAlignment |
|
542 | 910 |
]. |
911 |
||
2444 | 912 |
"Modified: / 25.2.2000 / 14:25:56 / cg" |
2424
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
913 |
! ! |
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
914 |
|
621 | 915 |
!DataSetColumn methodsFor:'private'! |
916 |
||
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
917 |
extractColFromRow:aRow rowNr:rowNr |
3320 | 918 |
|readSelector col numArgs| |
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
919 |
|
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
920 |
readSelector := description readSelector. |
1226 | 921 |
readSelector isNil ifTrue:[^ nil]. |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
922 |
|
2862
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
923 |
readSelector isBlock ifTrue:[ |
3320 | 924 |
numArgs := readSelector numArgs. |
925 |
numArgs == 0 ifTrue:[ |
|
2862
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
926 |
^ readSelector value |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
927 |
]. |
3320 | 928 |
numArgs == 1 ifTrue:[ |
2862
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
929 |
^ readSelector value:aRow |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
930 |
]. |
3320 | 931 |
numArgs == 2 ifTrue:[ |
2862
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
932 |
^ readSelector value:aRow value:columnNumber |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
933 |
]. |
3320 | 934 |
numArgs == 3 ifTrue:[ |
2862
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
935 |
^ readSelector value:aRow value:columnNumber value:rowNr |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
936 |
]. |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
937 |
^ readSelector value:aRow value:columnNumber value:rowNr value:dataSet |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
938 |
]. |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
939 |
|
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
940 |
columnAdaptor notNil ifTrue:[ |
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
941 |
^ columnAdaptor perform:readSelector withOptionalArgument:aRow and:columnNumber and:rowNr and:dataSet |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
942 |
]. |
2635
a8add4698dea
care for nil rows when extracting columns
Claus Gittinger <cg@exept.de>
parents:
2613
diff
changeset
|
943 |
aRow isNil ifTrue:[^ nil]. |
a8add4698dea
care for nil rows when extracting columns
Claus Gittinger <cg@exept.de>
parents:
2613
diff
changeset
|
944 |
|
2444 | 945 |
col := aRow perform:readSelector withOptionalArgument:columnNumber and:rowNr and:dataSet. |
946 |
^ col |
|
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
947 |
! |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
948 |
|
2693 | 949 |
storeCol:newValueArg inRow:aRow |
2862
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
950 |
|writeSelector numArgs newValue| |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
951 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
952 |
writeSelector := description writeSelector. |
1226 | 953 |
writeSelector isNil ifTrue:[^ aRow]. |
954 |
||
2693 | 955 |
newValue := newValueArg. |
956 |
(newValue isNumber) ifTrue:[ |
|
2862
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
957 |
minValue notNil ifTrue:[ |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
958 |
newValue < minValue ifTrue:[ |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
959 |
newValue := minValue |
2693 | 960 |
] |
961 |
]. |
|
2862
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
962 |
maxValue notNil ifTrue:[ |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
963 |
newValue > maxValue ifTrue:[ |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
964 |
newValue := maxValue |
2693 | 965 |
] |
966 |
]. |
|
967 |
]. |
|
968 |
||
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
969 |
numArgs := writeSelector numArgs. |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
970 |
|
2862
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
971 |
writeSelector isBlock ifTrue:[ |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
972 |
numArgs == 2 ifTrue:[ |
2863
c0585cbcd922
argument order when using write-store-blocks
Claus Gittinger <cg@exept.de>
parents:
2862
diff
changeset
|
973 |
^ writeSelector value:newValue value:aRow |
2862
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
974 |
]. |
2863
c0585cbcd922
argument order when using write-store-blocks
Claus Gittinger <cg@exept.de>
parents:
2862
diff
changeset
|
975 |
^ writeSelector value:newValue value:aRow value:columnNumber |
2862
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
976 |
]. |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
977 |
|
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
978 |
columnAdaptor notNil ifTrue:[ |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
979 |
numArgs == 2 ifTrue:[ |
2419
e0121908fffe
added longStringCompression flag
Claus Gittinger <cg@exept.de>
parents:
2222
diff
changeset
|
980 |
columnAdaptor perform:writeSelector with:aRow with:newValue. |
e0121908fffe
added longStringCompression flag
Claus Gittinger <cg@exept.de>
parents:
2222
diff
changeset
|
981 |
^ self |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
982 |
]. |
2419
e0121908fffe
added longStringCompression flag
Claus Gittinger <cg@exept.de>
parents:
2222
diff
changeset
|
983 |
columnAdaptor perform:writeSelector with:aRow with:columnNumber with:newValue. |
e0121908fffe
added longStringCompression flag
Claus Gittinger <cg@exept.de>
parents:
2222
diff
changeset
|
984 |
^ self |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
985 |
]. |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
986 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
987 |
numArgs == 1 ifTrue:[ |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
988 |
aRow perform:writeSelector with:newValue |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
989 |
] ifFalse:[ |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
990 |
aRow perform:writeSelector with:columnNumber with:newValue |
1059 | 991 |
]. |
621 | 992 |
! ! |
993 |
||
542 | 994 |
!DataSetColumn methodsFor:'queries'! |
995 |
||
1492 | 996 |
canResize |
997 |
||
1496 | 998 |
containsText ifTrue:[ |
2017
5cbe1d46c01d
isReal -> isLimitedPrecisionReal
Claus Gittinger <cg@exept.de>
parents:
1984
diff
changeset
|
999 |
^ descWidth == 0 or:[self hasRelativeWidth] |
1492 | 1000 |
]. |
1001 |
^ false |
|
1002 |
! |
|
1003 |
||
607 | 1004 |
canSelect:aRowNr |
3448
ef7d76d6bcfd
some comments changed into reasonable english
Claus Gittinger <cg@exept.de>
parents:
3364
diff
changeset
|
1005 |
"returns true if the cell in column is selectable. |
ef7d76d6bcfd
some comments changed into reasonable english
Claus Gittinger <cg@exept.de>
parents:
3364
diff
changeset
|
1006 |
(possibly calls the selectSelector, if any)" |
ef7d76d6bcfd
some comments changed into reasonable english
Claus Gittinger <cg@exept.de>
parents:
3364
diff
changeset
|
1007 |
|
2067
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
1008 |
|s row| |
607 | 1009 |
|
2067
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
1010 |
description canSelect ifFalse:[^ false]. |
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
1011 |
s := description selectSelector. |
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
1012 |
s isNil ifTrue:[^ true]. |
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
1013 |
|
3264
642d79a1b0d6
care for non-exisiting columns (race condition)
Claus Gittinger <cg@exept.de>
parents:
3240
diff
changeset
|
1014 |
row := dataSet at:aRowNr ifAbsent:[^ false]. |
2067
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
1015 |
columnAdaptor notNil ifTrue:[ |
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
1016 |
^ columnAdaptor perform:s withOptionalArgument:row and:columnNumber and:aRowNr and:dataSet |
607 | 1017 |
]. |
1018 |
||
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
1019 |
^ row perform:s withOptionalArgument:columnNumber and:aRowNr and:dataSet |
3264
642d79a1b0d6
care for non-exisiting columns (race condition)
Claus Gittinger <cg@exept.de>
parents:
3240
diff
changeset
|
1020 |
|
642d79a1b0d6
care for non-exisiting columns (race condition)
Claus Gittinger <cg@exept.de>
parents:
3240
diff
changeset
|
1021 |
"Modified: / 27-10-2007 / 10:27:20 / cg" |
607 | 1022 |
! |
1023 |
||
2864
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1024 |
choicesFor:aRow at:aRowNr |
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1025 |
|choicesSelector| |
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1026 |
|
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1027 |
choicesSelector := description choices. |
2897 | 1028 |
choicesSelector isNil ifTrue:[^ nil]. |
2864
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1029 |
|
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1030 |
columnAdaptor notNil ifTrue:[ |
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1031 |
^ columnAdaptor perform:choicesSelector withOptionalArgument:aRow and:columnNumber and:aRowNr and:dataSet |
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1032 |
]. |
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1033 |
^ aRow perform:choicesSelector withOptionalArgument:aRowNr and:columnNumber and:dataSet |
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1034 |
! |
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1035 |
|
647 | 1036 |
containsText |
1037 |
"returns true if text might exist |
|
1038 |
" |
|
1496 | 1039 |
^ containsText |
647 | 1040 |
! |
1041 |
||
2074 | 1042 |
doubleClickOn:aRowNr |
2694 | 1043 |
|sel row| |
2074 | 1044 |
|
1045 |
(sel := self doubleClickedSelector) notNil ifTrue:[ |
|
2694 | 1046 |
row := dataSet at:aRowNr. |
2074 | 1047 |
columnAdaptor notNil ifTrue:[ |
2694 | 1048 |
^ columnAdaptor perform:sel withOptionalArgument:row and:columnNumber and:aRowNr and:dataSet |
2074 | 1049 |
]. |
2694 | 1050 |
^ row perform:sel withOptionalArgument:columnNumber and:aRowNr and:dataSet |
2074 | 1051 |
]. |
1052 |
! |
|
1053 |
||
833 | 1054 |
hasChoices:aRowNr |
2864
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1055 |
|row| |
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1056 |
|
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1057 |
row := dataSet at:aRowNr. |
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1058 |
^ (self choicesFor:row at:aRowNr) notNil |
833 | 1059 |
! |
1060 |
||
1950 | 1061 |
hasPotentialNonConstantBackground |
1062 |
(backgroundColor notNil and:[backgroundColor isImageOrForm]) ifTrue:[^ true]. |
|
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1063 |
description backgroundSelector notNil ifTrue:[^ true]. |
1950 | 1064 |
^ false. |
1065 |
! |
|
1066 |
||
1484 | 1067 |
hasRelativeWidth |
1068 |
"returns true if width is relative |
|
1069 |
" |
|
2017
5cbe1d46c01d
isReal -> isLimitedPrecisionReal
Claus Gittinger <cg@exept.de>
parents:
1984
diff
changeset
|
1070 |
^ descWidth isLimitedPrecisionReal |
1484 | 1071 |
! |
1072 |
||
3240
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1073 |
hasRowSeparatorAt:rowNumber |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1074 |
|row bool| |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1075 |
|
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1076 |
rowSeparatorSelector isNil ifTrue:[^ true ]. |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1077 |
row := dataSet at:rowNumber. |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1078 |
|
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1079 |
columnAdaptor isNil ifTrue:[ |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1080 |
bool := row perform:rowSeparatorSelector. |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1081 |
] ifFalse:[ |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1082 |
bool := columnAdaptor perform:rowSeparatorSelector |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1083 |
withOptionalArgument:row and:columnNumber and:rowNumber and:dataSet. |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1084 |
]. |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1085 |
^ bool ~~ false |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1086 |
! |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1087 |
|
542 | 1088 |
heightOfHighestRow |
1725
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
1089 |
"returns the height of the highest row in pixels. |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
1090 |
Warning: |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
1091 |
only the first numberOfRowsProbedForColumnSize are probed, |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
1092 |
in case the access is expensive (dataBase apps) |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
1093 |
If the descriptor defines a height, that is used, and the items |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
1094 |
are not probed at all. |
542 | 1095 |
" |
1559
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
1096 |
|h end bE editor| |
542 | 1097 |
|
1496 | 1098 |
(h := description height) == 0 ifTrue:[ |
1099 |
containsText ifTrue:[ |
|
542 | 1100 |
"/ search first none empty drawable object |
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1101 |
end := description numberOfRowsProbedForColumnSize min:dataSet size. |
542 | 1102 |
|
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
1103 |
1 to:end do:[:rowNr| |row| |
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
1104 |
row := dataSet at:rowNr. |
2444 | 1105 |
h := h max:(self heightOfLabel:(self shownValueForRow:row rowNr:rowNr)) |
542 | 1106 |
] |
1107 |
] |
|
1108 |
]. |
|
1559
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
1109 |
(bE := buttonExtent y) = 0 ifTrue:[ |
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
1110 |
((editor := description editorType) == #ComboList |
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
1111 |
or:[ editor == #ComboBox]) ifTrue:[ |
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
1112 |
bE := dataSet comboButtonExtent y. |
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
1113 |
]. |
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
1114 |
]. |
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
1115 |
^ h max:bE |
1725
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
1116 |
|
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
1117 |
"Modified: / 25.2.2000 / 14:29:20 / cg" |
1113 | 1118 |
! |
1119 |
||
1147 | 1120 |
heightOfLabel:aLabel |
1121 |
"returns the height of the label |
|
1122 |
" |
|
1496 | 1123 |
|h| |
1147 | 1124 |
|
1496 | 1125 |
(aLabel isString or:[aLabel isImageOrForm]) ifTrue:[ |
1126 |
^ aLabel heightOn:dataSet |
|
1127 |
]. |
|
1147 | 1128 |
aLabel isNil ifTrue:[ ^ 0 ]. |
1129 |
||
1496 | 1130 |
aLabel isSequenceable ifFalse:[ |
1131 |
^ aLabel perform:#heightOn: with:dataSet ifNotUnderstood:[ |
|
1132 |
aLabel displayString heightOn:dataSet |
|
1133 |
] |
|
1147 | 1134 |
]. |
1135 |
||
1496 | 1136 |
h := 0. |
1137 |
aLabel do:[:el|h := h + (el heightOn:dataSet)]. |
|
1138 |
^ h |
|
1147 | 1139 |
|
1140 |
! |
|
1141 |
||
1937 | 1142 |
isResizeable |
1143 |
"returns true if the row is resizeable |
|
1144 |
" |
|
1145 |
^ description isResizeable |
|
1146 |
! |
|
1147 |
||
2542 | 1148 |
isRowVisible:rowNr |
1149 |
^ description rowIsVisible:(dataSet at:rowNr) |
|
1150 |
! |
|
1151 |
||
1113 | 1152 |
showColSeparator |
1153 |
"returns true if column separator is on |
|
1154 |
" |
|
1155 |
^ showColSeparator |
|
1133 | 1156 |
! |
1157 |
||
1158 |
showSelectionHighLighted |
|
1159 |
"returns true if selection is highLighted |
|
1160 |
" |
|
1161 |
^ description showSelectionHighLighted ~~ false |
|
1147 | 1162 |
! |
1163 |
||
2865 | 1164 |
translatedChoicesFor:aRow at:aRowNr |
1165 |
|translatedChoicesSelector| |
|
1166 |
||
1167 |
translatedChoicesSelector := description translatedChoices. |
|
1168 |
||
1169 |
columnAdaptor notNil ifTrue:[ |
|
1170 |
^ columnAdaptor perform:translatedChoicesSelector withOptionalArgument:aRow and:columnNumber and:aRowNr and:dataSet |
|
1171 |
]. |
|
1172 |
^ aRow perform:translatedChoicesSelector withOptionalArgument:aRowNr and:columnNumber and:dataSet |
|
1173 |
! |
|
1174 |
||
1147 | 1175 |
widthOfLabel:aLabel |
1176 |
"returns the width of the label |
|
1177 |
" |
|
1496 | 1178 |
|w| |
1147 | 1179 |
|
1496 | 1180 |
(aLabel isString or:[aLabel isImageOrForm]) ifTrue:[ |
1181 |
^ aLabel widthOn:dataSet |
|
1182 |
]. |
|
1147 | 1183 |
aLabel isNil ifTrue:[ ^ 0 ]. |
1184 |
||
1496 | 1185 |
aLabel isSequenceable ifFalse:[ |
1186 |
^ aLabel perform:#widthOn: with:dataSet ifNotUnderstood:[ |
|
1187 |
aLabel displayString widthOn:dataSet |
|
1188 |
] |
|
1147 | 1189 |
]. |
1190 |
||
1496 | 1191 |
w := 0. |
1192 |
aLabel do:[:el|w := w max:(el widthOn:dataSet)]. |
|
1193 |
^ w |
|
542 | 1194 |
! ! |
1195 |
||
1196 |
!DataSetColumn methodsFor:'searching'! |
|
1197 |
||
1198 |
findRowNrStartingWithChar:aChar start:start stop:stop |
|
1199 |
"find the first row starting at start to stop, which drawable label |
|
1200 |
starts with the character, aChar. The index of the detected row is |
|
1201 |
returned or if no row is found 0. |
|
1202 |
" |
|
1203 |
|char| |
|
1204 |
||
1496 | 1205 |
containsText ifTrue:[ |
542 | 1206 |
char := aChar asLowercase. |
1207 |
||
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
1208 |
start to:stop do:[:eachNr| |row lbl| |
2636
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1209 |
(dataSet isRowSelectable:eachNr) ifTrue:[ |
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1210 |
row := dataSet at:eachNr. |
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1211 |
lbl := self shownValueForRow:row rowNr:eachNr. |
1147 | 1212 |
|
2636
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1213 |
(lbl isSequenceable and:[lbl isString not]) ifTrue:[ |
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1214 |
lbl := lbl at:1 ifAbsent:nil |
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1215 |
]. |
542 | 1216 |
|
2636
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1217 |
(lbl respondsTo:#string) ifTrue:[ |
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1218 |
lbl := lbl string. |
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1219 |
(lbl size ~~ 0 and:[(lbl at:1) asLowercase == char]) ifTrue:[ |
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1220 |
^ eachNr |
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1221 |
] |
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1222 |
] ifFalse:[ |
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1223 |
lbl isNil ifFalse:[ |
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1224 |
^ 0 |
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1225 |
]. |
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1226 |
]. |
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1227 |
]. |
542 | 1228 |
] |
1229 |
]. |
|
1230 |
^ 0 |
|
1231 |
! ! |
|
1232 |
||
1233 |
!DataSetColumn class methodsFor:'documentation'! |
|
1234 |
||
1235 |
version |
|
3448
ef7d76d6bcfd
some comments changed into reasonable english
Claus Gittinger <cg@exept.de>
parents:
3364
diff
changeset
|
1236 |
^ '$Header: /cvs/stx/stx/libwidg2/DataSetColumn.st,v 1.116 2008-06-23 18:13:26 cg Exp $' |
542 | 1237 |
! ! |