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