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