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