author | ca |
Wed, 17 Dec 2003 12:37:24 +0100 | |
changeset 2592 | ab64fbe4fb1e |
parent 2581 | 2b6656c0b046 |
child 2613 | 2de5a812418b |
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 |
|
2581
2b6656c0b046
care for numbers without decimal point in decimal adjust
Claus Gittinger <cg@exept.de>
parents:
2578
diff
changeset
|
383 |
|drawnLabel x space prevClip mustUndoClip |
2592
ab64fbe4fb1e
resize #rowHeight if a display label does not match the computed rowHeight
ca
parents:
2581
diff
changeset
|
384 |
labelWidth leftPart leftShift indexOfFirstDigit indexOfFirstNonDigit| |
1147 | 385 |
|
386 |
space := dataSet horizontalSpacing. |
|
387 |
||
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
388 |
drawnLabel := aLabelToDraw. |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
389 |
labelWidth := drawnLabel widthOn:dataSet. |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
390 |
|
2419
e0121908fffe
added longStringCompression flag
Claus Gittinger <cg@exept.de>
parents:
2222
diff
changeset
|
391 |
(longStringCompression ~~ false |
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
392 |
and:[ drawnLabel isString |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
393 |
and:[ labelWidth > width]]) ifTrue:[ |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
394 |
drawnLabel := self class shortenedStringFor:drawnLabel on:dataSet maxWidth:width-space. |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
395 |
labelWidth := drawnLabel widthOn:dataSet. |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
396 |
]. |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
397 |
|
1147 | 398 |
columnAlignment == #left ifTrue:[ |
399 |
x := xLeft + space. |
|
400 |
] ifFalse:[ |
|
2420
9b4e4333004a
added #decimal columnAlignment.
Claus Gittinger <cg@exept.de>
parents:
2419
diff
changeset
|
401 |
columnAlignment == #decimal ifTrue:[ |
2581
2b6656c0b046
care for numbers without decimal point in decimal adjust
Claus Gittinger <cg@exept.de>
parents:
2578
diff
changeset
|
402 |
(drawnLabel includes:$.) ifTrue:[ |
2b6656c0b046
care for numbers without decimal point in decimal adjust
Claus Gittinger <cg@exept.de>
parents:
2578
diff
changeset
|
403 |
leftPart := drawnLabel upTo:$.. |
2b6656c0b046
care for numbers without decimal point in decimal adjust
Claus Gittinger <cg@exept.de>
parents:
2578
diff
changeset
|
404 |
] ifFalse:[ |
2b6656c0b046
care for numbers without decimal point in decimal adjust
Claus Gittinger <cg@exept.de>
parents:
2578
diff
changeset
|
405 |
leftPart := drawnLabel. |
2b6656c0b046
care for numbers without decimal point in decimal adjust
Claus Gittinger <cg@exept.de>
parents:
2578
diff
changeset
|
406 |
|
2b6656c0b046
care for numbers without decimal point in decimal adjust
Claus Gittinger <cg@exept.de>
parents:
2578
diff
changeset
|
407 |
indexOfFirstDigit := drawnLabel findFirst:[:char | char isDigit]. |
2b6656c0b046
care for numbers without decimal point in decimal adjust
Claus Gittinger <cg@exept.de>
parents:
2578
diff
changeset
|
408 |
indexOfFirstDigit ~~ 0 ifTrue:[ |
2b6656c0b046
care for numbers without decimal point in decimal adjust
Claus Gittinger <cg@exept.de>
parents:
2578
diff
changeset
|
409 |
indexOfFirstNonDigit := drawnLabel findFirst:[:char | char isDigit not] startingAt:indexOfFirstDigit+1. |
2b6656c0b046
care for numbers without decimal point in decimal adjust
Claus Gittinger <cg@exept.de>
parents:
2578
diff
changeset
|
410 |
indexOfFirstNonDigit ~~ 0 ifTrue:[ |
2b6656c0b046
care for numbers without decimal point in decimal adjust
Claus Gittinger <cg@exept.de>
parents:
2578
diff
changeset
|
411 |
leftPart := drawnLabel copyTo:indexOfFirstNonDigit-1. |
2b6656c0b046
care for numbers without decimal point in decimal adjust
Claus Gittinger <cg@exept.de>
parents:
2578
diff
changeset
|
412 |
]. |
2b6656c0b046
care for numbers without decimal point in decimal adjust
Claus Gittinger <cg@exept.de>
parents:
2578
diff
changeset
|
413 |
]. |
2b6656c0b046
care for numbers without decimal point in decimal adjust
Claus Gittinger <cg@exept.de>
parents:
2578
diff
changeset
|
414 |
]. |
2b6656c0b046
care for numbers without decimal point in decimal adjust
Claus Gittinger <cg@exept.de>
parents:
2578
diff
changeset
|
415 |
leftShift := leftPart widthOn:dataSet. |
2b6656c0b046
care for numbers without decimal point in decimal adjust
Claus Gittinger <cg@exept.de>
parents:
2578
diff
changeset
|
416 |
x := (width // 2) - leftShift. |
2420
9b4e4333004a
added #decimal columnAlignment.
Claus Gittinger <cg@exept.de>
parents:
2419
diff
changeset
|
417 |
] ifFalse:[ |
9b4e4333004a
added #decimal columnAlignment.
Claus Gittinger <cg@exept.de>
parents:
2419
diff
changeset
|
418 |
x := width - labelWidth. |
1147 | 419 |
|
2420
9b4e4333004a
added #decimal columnAlignment.
Claus Gittinger <cg@exept.de>
parents:
2419
diff
changeset
|
420 |
columnAlignment == #right ifTrue:[x := x - space] |
9b4e4333004a
added #decimal columnAlignment.
Claus Gittinger <cg@exept.de>
parents:
2419
diff
changeset
|
421 |
ifFalse:[x := x // 2]. |
9b4e4333004a
added #decimal columnAlignment.
Claus Gittinger <cg@exept.de>
parents:
2419
diff
changeset
|
422 |
]. |
9b4e4333004a
added #decimal columnAlignment.
Claus Gittinger <cg@exept.de>
parents:
2419
diff
changeset
|
423 |
"/ 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
|
424 |
"/ x := xLeft + (x max:0). |
1586
c87e9c9b298f
always right-align a right-aligned field
Claus Gittinger <cg@exept.de>
parents:
1565
diff
changeset
|
425 |
|
1587 | 426 |
"/ new code: always right-align. |
427 |
x := xLeft + x. |
|
428 |
||
429 |
"/ must clip left, if string is too large |
|
430 |
x < xLeft ifTrue:[ |
|
1586
c87e9c9b298f
always right-align a right-aligned field
Claus Gittinger <cg@exept.de>
parents:
1565
diff
changeset
|
431 |
"/ must clip ... |
c87e9c9b298f
always right-align a right-aligned field
Claus Gittinger <cg@exept.de>
parents:
1565
diff
changeset
|
432 |
prevClip := dataSet clippingRectangleOrNil. |
c87e9c9b298f
always right-align a right-aligned field
Claus Gittinger <cg@exept.de>
parents:
1565
diff
changeset
|
433 |
mustUndoClip := true. |
1591
6996391ee3ba
Avoid obsolete method. (stefan)
Claus Gittinger <cg@exept.de>
parents:
1590
diff
changeset
|
434 |
dataSet clippingRectangle:(Rectangle |
1586
c87e9c9b298f
always right-align a right-aligned field
Claus Gittinger <cg@exept.de>
parents:
1565
diff
changeset
|
435 |
left:xLeft top:yTop |
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
436 |
width:width height:(drawnLabel heightOn:dataSet)). |
1586
c87e9c9b298f
always right-align a right-aligned field
Claus Gittinger <cg@exept.de>
parents:
1565
diff
changeset
|
437 |
]. |
1147 | 438 |
]. |
1447 | 439 |
|
2443
e88b4123061a
changes to allow for Object>>displayOn:x:y: to work correctly
Claus Gittinger <cg@exept.de>
parents:
2424
diff
changeset
|
440 |
"/ drawnLabel isImageOrForm ifTrue:[ |
e88b4123061a
changes to allow for Object>>displayOn:x:y: to work correctly
Claus Gittinger <cg@exept.de>
parents:
2424
diff
changeset
|
441 |
"/ y := yTop. |
e88b4123061a
changes to allow for Object>>displayOn:x:y: to work correctly
Claus Gittinger <cg@exept.de>
parents:
2424
diff
changeset
|
442 |
"/ ] ifFalse:[ |
e88b4123061a
changes to allow for Object>>displayOn:x:y: to work correctly
Claus Gittinger <cg@exept.de>
parents:
2424
diff
changeset
|
443 |
"/ 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
|
444 |
"/ ]. |
2592
ab64fbe4fb1e
resize #rowHeight if a display label does not match the computed rowHeight
ca
parents:
2581
diff
changeset
|
445 |
|
ab64fbe4fb1e
resize #rowHeight if a display label does not match the computed rowHeight
ca
parents:
2581
diff
changeset
|
446 |
"/ drawnLabel isString ifFalse:[ |
ab64fbe4fb1e
resize #rowHeight if a display label does not match the computed rowHeight
ca
parents:
2581
diff
changeset
|
447 |
"/ y := yTop + (drawnLabel ascentOn:dataSet). |
ab64fbe4fb1e
resize #rowHeight if a display label does not match the computed rowHeight
ca
parents:
2581
diff
changeset
|
448 |
"/ ] ifTrue:[ |
ab64fbe4fb1e
resize #rowHeight if a display label does not match the computed rowHeight
ca
parents:
2581
diff
changeset
|
449 |
"/ y := yTop + dataSet rowFontAscent |
ab64fbe4fb1e
resize #rowHeight if a display label does not match the computed rowHeight
ca
parents:
2581
diff
changeset
|
450 |
"/ ]. |
ab64fbe4fb1e
resize #rowHeight if a display label does not match the computed rowHeight
ca
parents:
2581
diff
changeset
|
451 |
"/ drawnLabel displayOn:dataSet x:x y:y. |
ab64fbe4fb1e
resize #rowHeight if a display label does not match the computed rowHeight
ca
parents:
2581
diff
changeset
|
452 |
|
ab64fbe4fb1e
resize #rowHeight if a display label does not match the computed rowHeight
ca
parents:
2581
diff
changeset
|
453 |
dataSet displayLabel:drawnLabel x:x y:yTop. |
1147 | 454 |
|
1586
c87e9c9b298f
always right-align a right-aligned field
Claus Gittinger <cg@exept.de>
parents:
1565
diff
changeset
|
455 |
mustUndoClip == true ifTrue:[ |
c87e9c9b298f
always right-align a right-aligned field
Claus Gittinger <cg@exept.de>
parents:
1565
diff
changeset
|
456 |
dataSet clippingRectangle:prevClip |
c87e9c9b298f
always right-align a right-aligned field
Claus Gittinger <cg@exept.de>
parents:
1565
diff
changeset
|
457 |
]. |
1147 | 458 |
! |
459 |
||
1132 | 460 |
drawLabelsAtX:xLeft y:yTop h:h from:start to:stop |
461 |
"redraw labels from start to stop |
|
1088 | 462 |
" |
2578 | 463 |
|fg y yT x hspace lblHg bg label row isSel selectionHeight| |
464 |
||
1132 | 465 |
yT := yTop. |
466 |
hspace := dataSet horizontalSpacing. |
|
1100 | 467 |
|
2578 | 468 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
469 |
selectionHeight := h - 1. |
|
470 |
] ifFalse:[ |
|
471 |
selectionHeight := h |
|
472 |
]. |
|
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
473 |
start to:stop do:[:aRowNr| |
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
474 |
row := dataSet at:aRowNr. |
1132 | 475 |
y := yT. |
476 |
x := xLeft. |
|
477 |
||
478 |
"/ GET BACKGROUND AND FOREGROUND-COLOR |
|
479 |
"/ =================================== |
|
480 |
||
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
481 |
isSel := dataSet isSelected:aRowNr inColumn:columnNumber. |
1132 | 482 |
|
2578 | 483 |
isSel ifTrue:[ |
1132 | 484 |
( description editorType ~~ #None |
485 |
and:[dataSet selectedColIndex == columnNumber] |
|
486 |
) ifTrue:[ |
|
487 |
isSel := false |
|
1115 | 488 |
] |
1113 | 489 |
]. |
490 |
||
1132 | 491 |
(isSel and:[description showSelectionHighLighted]) ifTrue:[ |
492 |
"/ SHOW SELECTED( MUST REDRAW BACKGROUND ) |
|
493 |
"/ ======================================= |
|
2151
50f8723054e7
selected row is highlighted over the full width;
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
494 |
fg := dataSet selectionForegroundColor. |
50f8723054e7
selected row is highlighted over the full width;
Claus Gittinger <cg@exept.de>
parents:
2093
diff
changeset
|
495 |
bg := dataSet selectionBackgroundColor. |
2578 | 496 |
|
1132 | 497 |
dataSet paint:bg. |
2578 | 498 |
dataSet fillRectangleX:x y:y width:width height:selectionHeight. |
1113 | 499 |
] ifFalse:[ |
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
500 |
description backgroundSelector notNil ifTrue:[ |
1132 | 501 |
"/ MUST REDRAW BACKGROUND |
502 |
"/ ====================== |
|
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
503 |
bg := self backgroundColorFor:row at:aRowNr. |
1565 | 504 |
|
505 |
bg ~~ backgroundColor ifTrue:[ |
|
1132 | 506 |
bg := dataSet colorOnDevice:bg |
507 |
]. |
|
508 |
dataSet paint:bg. |
|
509 |
dataSet fillRectangleX:x y:y width:width height:h. |
|
510 |
] ifFalse:[ |
|
511 |
bg := backgroundColor |
|
512 |
]. |
|
1100 | 513 |
|
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
514 |
fg := self foregroundColorFor:row at:aRowNr. |
1565 | 515 |
|
516 |
fg ~~ foregroundColor ifTrue:[ |
|
1132 | 517 |
fg := dataSet colorOnDevice:fg |
1565 | 518 |
]. |
1132 | 519 |
]. |
833 | 520 |
|
1132 | 521 |
"/ GET AND DRAW LABEL |
522 |
"/ ================== |
|
2542 | 523 |
(self isRowVisible:aRowNr) ifTrue:[ |
524 |
rendererType == #rowSelector ifTrue:[ |
|
525 |
isSel ifTrue:[ |
|
526 |
label := dataSet rowSelectorForm. |
|
527 |
x := x + hspace. |
|
528 |
] ifFalse:[ |
|
529 |
label := nil |
|
530 |
] |
|
1132 | 531 |
] ifFalse:[ |
2542 | 532 |
(isSel and:[dataSet hasOpenEditor]) ifTrue:[ |
533 |
label := nil |
|
534 |
] ifFalse:[ |
|
535 |
label := self shownValueForRow:row rowNr:aRowNr |
|
536 |
] |
|
1589
8bb71707b51a
remove any color emphasis when displaying the selection.
Claus Gittinger <cg@exept.de>
parents:
1587
diff
changeset
|
537 |
]. |
2542 | 538 |
label notNil ifTrue:[ |
539 |
"/ care for a dark-colored label, |
|
540 |
"/ with a dark selection-bg color |
|
541 |
(isSel and:[label isString and:[label hasChangeOfEmphasis]]) ifTrue:[ |
|
542 |
"/ take away the labels own color info |
|
543 |
label := label emphasisAllRemove:#color. |
|
544 |
]. |
|
545 |
||
546 |
lblHg := self heightOfLabel:label. |
|
1589
8bb71707b51a
remove any color emphasis when displaying the selection.
Claus Gittinger <cg@exept.de>
parents:
1587
diff
changeset
|
547 |
|
2542 | 548 |
lblHg ~~ 0 ifTrue:[ |
549 |
y := y + (h - lblHg // 2). |
|
550 |
dataSet paint:fg on:bg. |
|
1113 | 551 |
|
2542 | 552 |
(label isSequenceable and:[label isString not]) ifFalse:[ |
553 |
self drawLabel:label atX:x y:y |
|
554 |
] ifTrue:[ |
|
555 |
label do:[:el| |
|
556 |
el notNil ifTrue:[ |
|
557 |
self drawLabel:el atX:x y:y. |
|
558 |
y := y + (el heightOn:dataSet). |
|
559 |
] |
|
1147 | 560 |
] |
2542 | 561 |
]. |
562 |
] |
|
563 |
]. |
|
1132 | 564 |
]. |
565 |
yT := yT + h |
|
566 |
] |
|
833 | 567 |
! |
568 |
||
1132 | 569 |
drawSeparatorsAtX:xLeft y:yTop h:h from:start to:stop |
570 |
"redraw separators for cells between start and stop |
|
1088 | 571 |
" |
1132 | 572 |
|is3D |
573 |
xL "{ Class:SmallInteger }" |
|
1113 | 574 |
xR "{ Class:SmallInteger }" |
575 |
yB "{ Class:SmallInteger }" |
|
576 |
yT "{ Class:SmallInteger }" |
|
1132 | 577 |
times "{ Class:SmallInteger }" |
1088 | 578 |
| |
1132 | 579 |
(showColSeparator or:[showRowSeparator]) ifFalse:[ |
580 |
^ self |
|
581 |
]. |
|
582 |
is3D := dataSet has3Dseparators. |
|
583 |
||
1113 | 584 |
is3D ifTrue:[dataSet paint:(dataSet separatorDarkColor)] |
585 |
ifFalse:[dataSet paint:(dataSet foregroundColor)]. |
|
1088 | 586 |
|
1132 | 587 |
times := stop - start + 1. |
588 |
xL := xLeft. |
|
589 |
xR := xL - 1 + width. |
|
1088 | 590 |
|
1113 | 591 |
showRowSeparator ifTrue:[ |
1132 | 592 |
"/ DRAW SEPARATORS AT BOTTOM( DARK COLOR ) |
593 |
"/ ======================================= |
|
594 |
yB := yTop - 1 + h. |
|
595 |
||
596 |
rowSeparatorSelector isNil ifTrue:[ |
|
597 |
times timesRepeat:[ |
|
598 |
dataSet displayLineFromX:xL y:yB toX:xR y:yB. |
|
599 |
yB := yB + h. |
|
600 |
] |
|
601 |
] ifFalse:[ |
|
602 |
start to:stop do:[:idx| |
|
603 |
((dataSet at:idx) perform:rowSeparatorSelector) ~~ false ifTrue:[ |
|
604 |
dataSet displayLineFromX:xL y:yB toX:xR y:yB |
|
605 |
]. |
|
606 |
yB := yB + h. |
|
607 |
] |
|
1113 | 608 |
] |
609 |
]. |
|
1132 | 610 |
|
1113 | 611 |
showColSeparator ifTrue:[ |
1132 | 612 |
"/ DRAW SEPARATORS AT RIGHT( DARK COLOR ) |
613 |
"/ ====================================== |
|
614 |
yT := yTop. |
|
615 |
||
616 |
times timesRepeat:[ |
|
617 |
dataSet displayLineFromX:xR y:yT toX:xR y:(yT - 1 + h). |
|
618 |
yT := yT + h. |
|
619 |
] |
|
1113 | 620 |
]. |
1089 | 621 |
|
1113 | 622 |
is3D ifFalse:[ |
623 |
^ self |
|
624 |
]. |
|
1088 | 625 |
|
1113 | 626 |
dataSet paint:(dataSet separatorLightColor). |
1040
c8e6a2ed7928
use the same background color for a selected rowSelector
ca
parents:
1007
diff
changeset
|
627 |
|
1113 | 628 |
( columnNumber == 1 |
629 |
or:[(dataSet columnAt:(columnNumber - 1)) showColSeparator] |
|
630 |
) ifTrue:[ |
|
1132 | 631 |
|
632 |
"/ DRAW SEPARATORS AT LEFT( LIGHT COLOR ) |
|
633 |
"/ ====================================== |
|
634 |
yT := yTop. |
|
635 |
||
636 |
times timesRepeat:[ |
|
637 |
dataSet displayLineFromX:xL y:yT toX:xL y:(yT - 1 + h). |
|
638 |
yT := yT + h. |
|
639 |
]. |
|
1113 | 640 |
] ifFalse:[ |
1132 | 641 |
xL := xL - 1 |
1113 | 642 |
]. |
1092 | 643 |
|
1113 | 644 |
showRowSeparator ifTrue:[ |
1132 | 645 |
"/ DRAW SEPARATORS AT TOP( LIGHT COLOR ) |
646 |
"/ ===================================== |
|
647 |
yT := yTop. |
|
648 |
||
649 |
rowSeparatorSelector isNil ifTrue:[ |
|
650 |
times timesRepeat:[ |
|
651 |
dataSet displayLineFromX:xL y:yT toX:xR y:yT. |
|
652 |
yT := yT + h. |
|
653 |
] |
|
654 |
] ifFalse:[ |
|
655 |
"/ CHECK WHETHER PREVIOUS ROW HAS A SEPARATOR AT BOTTOM |
|
656 |
"/ ==================================================== |
|
657 |
start to:stop do:[:idx| |
|
658 |
( idx == 1 |
|
659 |
or:[((dataSet at:(idx - 1)) perform:rowSeparatorSelector) ~~ false] |
|
660 |
) ifTrue:[ |
|
661 |
dataSet displayLineFromX:xL y:yT toX:xR y:yT. |
|
662 |
]. |
|
663 |
yT := yT + h. |
|
664 |
] |
|
1088 | 665 |
] |
542 | 666 |
]. |
667 |
||
668 |
||
607 | 669 |
! |
670 |
||
542 | 671 |
invalidate |
1484 | 672 |
"invalidate width of column; forces a recomputation |
542 | 673 |
" |
1484 | 674 |
width := nil. |
542 | 675 |
|
1088 | 676 |
! |
677 |
||
1132 | 678 |
redrawX:xLeft y:yTop h:h from:start to:stop |
1088 | 679 |
"redraw rows between start and stop |
680 |
" |
|
1132 | 681 |
|rH "{ Class:SmallInteger }" |
682 |
y "{ Class:SmallInteger }" |
|
1088 | 683 |
| |
1132 | 684 |
rH := dataSet rowHeight. |
1088 | 685 |
|
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
686 |
description backgroundSelector isNil ifTrue:[ |
1132 | 687 |
dataSet paint:backgroundColor. |
688 |
dataSet fillRectangleX:xLeft y:yTop width:width height:h |
|
1115 | 689 |
]. |
690 |
||
1132 | 691 |
"/ DRAW CELLS: BACKGROUND/FOREGROUND/LABEL |
692 |
"/ ======================================= |
|
693 |
self drawLabelsAtX:xLeft y:yTop h:rH from:start to:stop. |
|
1113 | 694 |
|
695 |
"/ DRAW INDICATORS |
|
696 |
"/ =============== |
|
697 |
(rendererType == #ComboBox or:[rendererType == #ComboList]) ifTrue:[ |
|
1132 | 698 |
y := yTop. |
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
699 |
start to:stop do:[:rowNr| |
2542 | 700 |
(self isRowVisible:rowNr) ifTrue:[ |
701 |
(self hasChoices:rowNr) ifTrue:[ |
|
702 |
dataSet drawComboButtonAtX:xLeft y:y w:width |
|
703 |
]. |
|
1113 | 704 |
]. |
1132 | 705 |
y := y + rH. |
1113 | 706 |
] |
707 |
] ifFalse:[ |
|
708 |
rendererType == #CheckToggle ifTrue:[ |
|
1132 | 709 |
y := yTop. |
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
710 |
start to:stop do:[:rowNr| |state| |
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
711 |
state := self at:rowNr. |
2542 | 712 |
(self isRowVisible:rowNr) ifTrue:[ |
713 |
dataSet drawCheckToggleAtX:xLeft y:y w:width state:state. |
|
714 |
]. |
|
1132 | 715 |
y := y + rH. |
1113 | 716 |
] |
717 |
] |
|
1088 | 718 |
]. |
719 |
||
720 |
"/ DRAW SEPARATORS |
|
1113 | 721 |
"/ =============== |
1132 | 722 |
self drawSeparatorsAtX:xLeft y:yTop h:rH from:start to:stop |
542 | 723 |
! ! |
724 |
||
614 | 725 |
!DataSetColumn methodsFor:'editing'! |
726 |
||
833 | 727 |
editorAt:aRowNr |
1268 | 728 |
|val row| |
614 | 729 |
|
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
730 |
row := (dataSet at:aRowNr). |
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
731 |
val := self extractColFromRow:row rowNr:aRowNr. |
614 | 732 |
|
833 | 733 |
val isText ifTrue:[val := val string]. |
1984
ccdfdf1c89af
fetch editor from adaptor if not nil.
Claus Gittinger <cg@exept.de>
parents:
1950
diff
changeset
|
734 |
^ description editorOn:row column:self value:val usingAdaptor:columnAdaptor. |
2424
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
735 |
! |
542 | 736 |
|
1147 | 737 |
on:aDSVColumnView description:aDescription columnNumber:aNumber label:aLabel |
542 | 738 |
"instance creation; set attributes dependent on the description |
739 |
" |
|
1089 | 740 |
columnNumber := aNumber. |
741 |
dataSet := aDSVColumnView. |
|
1147 | 742 |
label := aLabel. |
1487 | 743 |
|
1089 | 744 |
description := aDescription. |
745 |
rendererType := description rendererType. |
|
1496 | 746 |
containsText := ( rendererType ~~ #CheckToggle |
747 |
and:[rendererType ~~ #rowSelector] |
|
748 |
). |
|
1490 | 749 |
descWidth := description width. |
2424
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
750 |
longStringCompression := description longStringCompression. |
1526 | 751 |
|
752 |
description usePreferredWidth ifTrue:[ |
|
753 |
descWidth := 0 |
|
754 |
]. |
|
755 |
||
1565 | 756 |
width := nil. |
757 |
||
1113 | 758 |
rowSeparatorSelector := description rowSeparatorSelector. |
1565 | 759 |
|
1113 | 760 |
showColSeparator := description showColSeparator. |
761 |
showRowSeparator := description showRowSeparator. |
|
1089 | 762 |
columnAdaptor := dataSet columnAdaptor. |
763 |
buttonExtent := 0 @ 0. |
|
764 |
columnAlignment := #left. |
|
584 | 765 |
|
1132 | 766 |
(backgroundColor := description backgroundColor) isNil ifTrue:[ |
767 |
backgroundColor := dataSet backgroundColor |
|
768 |
] ifFalse:[ |
|
1480 | 769 |
backgroundColor := backgroundColor onDevice:dataSet device |
584 | 770 |
]. |
1113 | 771 |
|
772 |
(foregroundColor := description foregroundColor) isNil ifTrue:[ |
|
773 |
foregroundColor := dataSet foregroundColor |
|
774 |
] ifFalse:[ |
|
1480 | 775 |
foregroundColor := foregroundColor onDevice:dataSet device |
584 | 776 |
]. |
542 | 777 |
|
778 |
rendererType == #CheckToggle ifTrue:[ |
|
1113 | 779 |
buttonExtent := dataSet checkToggleExtent. |
2067
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
780 |
^ self |
542 | 781 |
]. |
782 |
||
783 |
rendererType == #rowSelector ifTrue:[ |
|
807 | 784 |
buttonExtent := dataSet rowSelectorExtent. |
2067
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
785 |
^ self |
542 | 786 |
]. |
787 |
||
788 |
(rendererType == #ComboBox or:[rendererType == #ComboList]) ifTrue:[ |
|
807 | 789 |
buttonExtent := dataSet comboButtonExtent. |
883 | 790 |
] ifFalse:[ |
791 |
columnAlignment := description columnAlignment |
|
542 | 792 |
]. |
793 |
||
2444 | 794 |
|
795 |
"Modified: / 25.2.2000 / 14:25:56 / cg" |
|
796 |
! |
|
797 |
||
798 |
shownValueForRow:aRow rowNr:aRowNr |
|
799 |
| selector format idx type n| |
|
800 |
||
801 |
rendererType == #CheckToggle ifTrue:[ |
|
802 |
^ nil |
|
803 |
]. |
|
804 |
||
805 |
rendererType == #rowSelector ifTrue:[ |
|
806 |
^ nil |
|
807 |
]. |
|
808 |
||
542 | 809 |
selector := description printSelector. |
810 |
selector notNil ifTrue:[ |
|
2444 | 811 |
^ aRow |
812 |
perform:selector |
|
813 |
withOptionalArgument:dataSet and:columnNumber and:aRowNr and:dataSet. |
|
542 | 814 |
]. |
815 |
||
614 | 816 |
( (format := description formatString) notNil |
817 |
and:[(type := description type) == #number or:[type == #numberOrNil]] |
|
818 |
) ifTrue:[ |
|
542 | 819 |
"/ has a format string for number (supports only floats) |
820 |
||
614 | 821 |
(idx := format indexOf:$.) ~~ 0 ifTrue:[ |
822 |
idx := format size - idx |
|
542 | 823 |
]. |
614 | 824 |
format := '%0.', idx printString, 'f'. |
542 | 825 |
|
2444 | 826 |
n := self extractColFromRow:aRow rowNr:aRowNr. |
827 |
n isLimitedPrecisionReal ifTrue:[n := n asFloat printfPrintString:format]. |
|
828 |
^ n |
|
829 |
]. |
|
542 | 830 |
|
2444 | 831 |
"/ default: no format string |
832 |
^ self extractColFromRow:aRow rowNr:aRowNr |
|
542 | 833 |
! ! |
834 |
||
2424
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
835 |
!DataSetColumn methodsFor:'event handling'! |
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 |
doesNotUnderstand:aMessage |
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
838 |
|
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
839 |
(description respondsTo:(aMessage selector)) ifTrue:[ |
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
840 |
^ aMessage sendTo:description |
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
841 |
]. |
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
842 |
^ super doesNotUnderstand:aMessage |
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
843 |
|
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
844 |
! ! |
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
845 |
|
2502 | 846 |
!DataSetColumn methodsFor:'grow & shrink'! |
2424
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
847 |
|
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
848 |
growWidth:n |
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
849 |
"grow the width for n pixels |
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
850 |
" |
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
851 |
width := self width + n. |
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
852 |
|
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
853 |
|
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
854 |
! ! |
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
855 |
|
621 | 856 |
!DataSetColumn methodsFor:'private'! |
857 |
||
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
858 |
extractColFromRow:aRow rowNr:rowNr |
2444 | 859 |
|readSelector col| |
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
860 |
|
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
861 |
readSelector := description readSelector. |
1226 | 862 |
readSelector isNil ifTrue:[^ nil]. |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
863 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
864 |
columnAdaptor notNil ifTrue:[ |
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
865 |
^ 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
|
866 |
]. |
2444 | 867 |
col := aRow perform:readSelector withOptionalArgument:columnNumber and:rowNr and:dataSet. |
868 |
^ col |
|
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 |
storeCol:newValue inRow:aRow |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
872 |
|writeSelector numArgs| |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
873 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
874 |
writeSelector := description writeSelector. |
1226 | 875 |
writeSelector isNil ifTrue:[^ aRow]. |
876 |
||
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
877 |
numArgs := writeSelector numArgs. |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
878 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
879 |
columnAdaptor notNil ifTrue:[ |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
880 |
numArgs == 2 ifTrue:[ |
2419
e0121908fffe
added longStringCompression flag
Claus Gittinger <cg@exept.de>
parents:
2222
diff
changeset
|
881 |
columnAdaptor perform:writeSelector with:aRow with:newValue. |
e0121908fffe
added longStringCompression flag
Claus Gittinger <cg@exept.de>
parents:
2222
diff
changeset
|
882 |
^ self |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
883 |
]. |
2419
e0121908fffe
added longStringCompression flag
Claus Gittinger <cg@exept.de>
parents:
2222
diff
changeset
|
884 |
columnAdaptor perform:writeSelector with:aRow with:columnNumber with:newValue. |
e0121908fffe
added longStringCompression flag
Claus Gittinger <cg@exept.de>
parents:
2222
diff
changeset
|
885 |
^ self |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
886 |
]. |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
887 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
888 |
numArgs == 1 ifTrue:[ |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
889 |
aRow perform:writeSelector with:newValue |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
890 |
] ifFalse:[ |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
891 |
aRow perform:writeSelector with:columnNumber with:newValue |
1059 | 892 |
]. |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
893 |
|
621 | 894 |
! ! |
895 |
||
542 | 896 |
!DataSetColumn methodsFor:'queries'! |
897 |
||
1492 | 898 |
canResize |
899 |
||
1496 | 900 |
containsText ifTrue:[ |
2017
5cbe1d46c01d
isReal -> isLimitedPrecisionReal
Claus Gittinger <cg@exept.de>
parents:
1984
diff
changeset
|
901 |
^ descWidth == 0 or:[self hasRelativeWidth] |
1492 | 902 |
]. |
903 |
^ false |
|
904 |
! |
|
905 |
||
607 | 906 |
canSelect:aRowNr |
2067
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
907 |
"returns true if the cell in column is selectable |
607 | 908 |
" |
2067
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
909 |
|s row| |
607 | 910 |
|
2067
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
911 |
description canSelect ifFalse:[^ false]. |
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
912 |
s := description selectSelector. |
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
913 |
s isNil ifTrue:[^ true]. |
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
914 |
|
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
915 |
row := dataSet at:aRowNr. |
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
916 |
columnAdaptor notNil ifTrue:[ |
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
917 |
^ columnAdaptor perform:s withOptionalArgument:row and:columnNumber and:aRowNr and:dataSet |
607 | 918 |
]. |
919 |
||
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
920 |
^ row perform:s withOptionalArgument:columnNumber and:aRowNr and:dataSet |
607 | 921 |
! |
922 |
||
647 | 923 |
containsText |
924 |
"returns true if text might exist |
|
925 |
" |
|
1496 | 926 |
^ containsText |
647 | 927 |
! |
928 |
||
2074 | 929 |
doubleClickOn:aRowNr |
930 |
|sel| |
|
931 |
||
932 |
(sel := self doubleClickedSelector) notNil ifTrue:[ |
|
933 |
columnAdaptor notNil ifTrue:[ |
|
934 |
sel numArgs == 2 ifTrue:[ |
|
935 |
^ columnAdaptor perform:sel with:(dataSet at:aRowNr) with:columnNumber |
|
936 |
]. |
|
937 |
^ columnAdaptor perform:sel with:(dataSet at:aRowNr) |
|
938 |
]. |
|
939 |
sel numArgs == 1 ifTrue:[ |
|
940 |
^ (dataSet at:aRowNr) perform:sel with:columnNumber |
|
941 |
]. |
|
942 |
^ (dataSet at:aRowNr) perform:sel |
|
943 |
]. |
|
944 |
! |
|
945 |
||
833 | 946 |
hasChoices:aRowNr |
947 |
^ (description choicesFor:(dataSet at:aRowNr)) notNil |
|
948 |
! |
|
949 |
||
1950 | 950 |
hasPotentialNonConstantBackground |
951 |
(backgroundColor notNil and:[backgroundColor isImageOrForm]) ifTrue:[^ true]. |
|
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
952 |
description backgroundSelector notNil ifTrue:[^ true]. |
1950 | 953 |
^ false. |
954 |
! |
|
955 |
||
1484 | 956 |
hasRelativeWidth |
957 |
"returns true if width is relative |
|
958 |
" |
|
2017
5cbe1d46c01d
isReal -> isLimitedPrecisionReal
Claus Gittinger <cg@exept.de>
parents:
1984
diff
changeset
|
959 |
^ descWidth isLimitedPrecisionReal |
1484 | 960 |
! |
961 |
||
542 | 962 |
heightOfHighestRow |
1725
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
963 |
"returns the height of the highest row in pixels. |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
964 |
Warning: |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
965 |
only the first numberOfRowsProbedForColumnSize are probed, |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
966 |
in case the access is expensive (dataBase apps) |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
967 |
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
|
968 |
are not probed at all. |
542 | 969 |
" |
1559
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
970 |
|h end bE editor| |
542 | 971 |
|
1496 | 972 |
(h := description height) == 0 ifTrue:[ |
973 |
containsText ifTrue:[ |
|
542 | 974 |
"/ search first none empty drawable object |
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
975 |
end := description numberOfRowsProbedForColumnSize min:dataSet size. |
542 | 976 |
|
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
977 |
1 to:end do:[:rowNr| |row| |
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
978 |
row := dataSet at:rowNr. |
2444 | 979 |
h := h max:(self heightOfLabel:(self shownValueForRow:row rowNr:rowNr)) |
542 | 980 |
] |
981 |
] |
|
982 |
]. |
|
1559
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
983 |
(bE := buttonExtent y) = 0 ifTrue:[ |
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
984 |
((editor := description editorType) == #ComboList |
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
985 |
or:[ editor == #ComboBox]) ifTrue:[ |
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
986 |
bE := dataSet comboButtonExtent y. |
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
987 |
]. |
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
988 |
]. |
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
989 |
^ h max:bE |
1725
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
990 |
|
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
991 |
"Modified: / 25.2.2000 / 14:29:20 / cg" |
1113 | 992 |
! |
993 |
||
1147 | 994 |
heightOfLabel:aLabel |
995 |
"returns the height of the label |
|
996 |
" |
|
1496 | 997 |
|h| |
1147 | 998 |
|
1496 | 999 |
(aLabel isString or:[aLabel isImageOrForm]) ifTrue:[ |
1000 |
^ aLabel heightOn:dataSet |
|
1001 |
]. |
|
1147 | 1002 |
aLabel isNil ifTrue:[ ^ 0 ]. |
1003 |
||
1496 | 1004 |
aLabel isSequenceable ifFalse:[ |
1005 |
^ aLabel perform:#heightOn: with:dataSet ifNotUnderstood:[ |
|
1006 |
aLabel displayString heightOn:dataSet |
|
1007 |
] |
|
1147 | 1008 |
]. |
1009 |
||
1496 | 1010 |
h := 0. |
1011 |
aLabel do:[:el|h := h + (el heightOn:dataSet)]. |
|
1012 |
^ h |
|
1147 | 1013 |
|
1014 |
! |
|
1015 |
||
1937 | 1016 |
isResizeable |
1017 |
"returns true if the row is resizeable |
|
1018 |
" |
|
1019 |
^ description isResizeable |
|
1020 |
! |
|
1021 |
||
2542 | 1022 |
isRowVisible:rowNr |
1023 |
^ description rowIsVisible:(dataSet at:rowNr) |
|
1024 |
! |
|
1025 |
||
1113 | 1026 |
showColSeparator |
1027 |
"returns true if column separator is on |
|
1028 |
" |
|
1029 |
^ showColSeparator |
|
1133 | 1030 |
! |
1031 |
||
1032 |
showSelectionHighLighted |
|
1033 |
"returns true if selection is highLighted |
|
1034 |
" |
|
1035 |
^ description showSelectionHighLighted ~~ false |
|
1147 | 1036 |
! |
1037 |
||
1038 |
widthOfLabel:aLabel |
|
1039 |
"returns the width of the label |
|
1040 |
" |
|
1496 | 1041 |
|w| |
1147 | 1042 |
|
1496 | 1043 |
(aLabel isString or:[aLabel isImageOrForm]) ifTrue:[ |
1044 |
^ aLabel widthOn:dataSet |
|
1045 |
]. |
|
1147 | 1046 |
aLabel isNil ifTrue:[ ^ 0 ]. |
1047 |
||
1496 | 1048 |
aLabel isSequenceable ifFalse:[ |
1049 |
^ aLabel perform:#widthOn: with:dataSet ifNotUnderstood:[ |
|
1050 |
aLabel displayString widthOn:dataSet |
|
1051 |
] |
|
1147 | 1052 |
]. |
1053 |
||
1496 | 1054 |
w := 0. |
1055 |
aLabel do:[:el|w := w max:(el widthOn:dataSet)]. |
|
1056 |
^ w |
|
542 | 1057 |
! ! |
1058 |
||
1059 |
!DataSetColumn methodsFor:'searching'! |
|
1060 |
||
1061 |
findRowNrStartingWithChar:aChar start:start stop:stop |
|
1062 |
"find the first row starting at start to stop, which drawable label |
|
1063 |
starts with the character, aChar. The index of the detected row is |
|
1064 |
returned or if no row is found 0. |
|
1065 |
" |
|
1066 |
|char| |
|
1067 |
||
1496 | 1068 |
containsText ifTrue:[ |
542 | 1069 |
char := aChar asLowercase. |
1070 |
||
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
1071 |
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
|
1072 |
row := dataSet at:eachNr. |
2444 | 1073 |
lbl := self shownValueForRow:row rowNr:eachNr. |
1147 | 1074 |
|
1075 |
(lbl isSequenceable and:[lbl isString not]) ifTrue:[ |
|
1076 |
lbl := lbl at:1 ifAbsent:nil |
|
1077 |
]. |
|
542 | 1078 |
|
1113 | 1079 |
(lbl respondsTo:#string) ifTrue:[ |
1080 |
lbl := lbl string. |
|
542 | 1081 |
(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
|
1082 |
^ eachNr |
542 | 1083 |
] |
1084 |
] ifFalse:[ |
|
1085 |
lbl isNil ifFalse:[ |
|
1086 |
^ 0 |
|
1087 |
] |
|
1088 |
] |
|
1089 |
] |
|
1090 |
]. |
|
1091 |
^ 0 |
|
1092 |
! ! |
|
1093 |
||
1094 |
!DataSetColumn class methodsFor:'documentation'! |
|
1095 |
||
1096 |
version |
|
2592
ab64fbe4fb1e
resize #rowHeight if a display label does not match the computed rowHeight
ca
parents:
2581
diff
changeset
|
1097 |
^ '$Header: /cvs/stx/stx/libwidg2/DataSetColumn.st,v 1.90 2003-12-17 11:37:24 ca Exp $' |
542 | 1098 |
! ! |