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