author | Claus Gittinger <cg@exept.de> |
Tue, 09 Oct 2001 19:44:27 +0200 | |
changeset 2017 | 5cbe1d46c01d |
parent 1984 | ccdfdf1c89af |
child 2067 | cda10b41aa0f |
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 |
" |
|
1268 | 711 |
|device selector format idx type args| |
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. |
647 | 774 |
^ self |
542 | 775 |
]. |
776 |
||
777 |
rendererType == #rowSelector ifTrue:[ |
|
807 | 778 |
buttonExtent := dataSet rowSelectorExtent. |
647 | 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:[ |
|
1113 | 791 |
args := selector numArgs. |
792 |
args == 0 ifTrue:[ |
|
1147 | 793 |
shownValue := [:aRow| aRow perform:selector ] |
1113 | 794 |
] ifFalse:[ |
795 |
args == 1 ifTrue:[ |
|
1147 | 796 |
shownValue := [:aRow| aRow perform:selector with:dataSet ] |
1113 | 797 |
] ifFalse:[ |
1147 | 798 |
shownValue := [:aRow| aRow perform:selector with:dataSet with:columnNumber ] |
1113 | 799 |
] |
800 |
]. |
|
542 | 801 |
^ self |
802 |
]. |
|
803 |
||
614 | 804 |
( (format := description formatString) notNil |
805 |
and:[(type := description type) == #number or:[type == #numberOrNil]] |
|
806 |
) ifTrue:[ |
|
542 | 807 |
"/ has a format string for number (supports only floats) |
808 |
||
614 | 809 |
(idx := format indexOf:$.) ~~ 0 ifTrue:[ |
810 |
idx := format size - idx |
|
542 | 811 |
]. |
614 | 812 |
format := '%0.', idx printString, 'f'. |
542 | 813 |
|
1147 | 814 |
shownValue := [:aRow||n| |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
815 |
n := self extractColFromRow:aRow. |
2017
5cbe1d46c01d
isReal -> isLimitedPrecisionReal
Claus Gittinger <cg@exept.de>
parents:
1984
diff
changeset
|
816 |
n isLimitedPrecisionReal ifTrue:[n := n asFloat printfPrintString:format]. |
621 | 817 |
n |
614 | 818 |
] |
621 | 819 |
] ifFalse:[ "/ default: no format string |
1147 | 820 |
shownValue := [:aRow| self extractColFromRow:aRow ] |
614 | 821 |
] |
542 | 822 |
|
1725
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
823 |
"Modified: / 25.2.2000 / 14:25:56 / cg" |
542 | 824 |
! ! |
825 |
||
621 | 826 |
!DataSetColumn methodsFor:'private'! |
827 |
||
1113 | 828 |
extractColFromRow:aRow |
1226 | 829 |
readSelector isNil ifTrue:[^ nil]. |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
830 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
831 |
columnAdaptor notNil ifTrue:[ |
1113 | 832 |
numArgsToReadSelector == 1 ifTrue:[ |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
833 |
^ columnAdaptor perform:readSelector with:aRow |
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 |
^ columnAdaptor perform:readSelector with:aRow with:columnNumber |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
836 |
]. |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
837 |
|
1113 | 838 |
numArgsToReadSelector == 0 ifTrue:[ |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
839 |
^ aRow perform:readSelector |
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 |
^ aRow perform:readSelector with:columnNumber |
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 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
844 |
storeCol:newValue inRow:aRow |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
845 |
|writeSelector numArgs| |
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 |
writeSelector := description writeSelector. |
1226 | 848 |
writeSelector isNil ifTrue:[^ aRow]. |
849 |
||
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
850 |
numArgs := writeSelector numArgs. |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
851 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
852 |
columnAdaptor notNil ifTrue:[ |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
853 |
numArgs == 2 ifTrue:[ |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
854 |
^ columnAdaptor perform:writeSelector with:aRow with:newValue |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
855 |
]. |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
856 |
^ columnAdaptor perform:writeSelector with:aRow with:columnNumber with:newValue |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
857 |
]. |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
858 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
859 |
numArgs == 1 ifTrue:[ |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
860 |
aRow perform:writeSelector with:newValue |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
861 |
] ifFalse:[ |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
862 |
aRow perform:writeSelector with:columnNumber with:newValue |
1059 | 863 |
]. |
864 |
^ aRow |
|
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
865 |
|
621 | 866 |
! ! |
867 |
||
542 | 868 |
!DataSetColumn methodsFor:'queries'! |
869 |
||
1492 | 870 |
canResize |
871 |
||
1496 | 872 |
containsText ifTrue:[ |
2017
5cbe1d46c01d
isReal -> isLimitedPrecisionReal
Claus Gittinger <cg@exept.de>
parents:
1984
diff
changeset
|
873 |
^ descWidth == 0 or:[self hasRelativeWidth] |
1492 | 874 |
]. |
875 |
^ false |
|
876 |
! |
|
877 |
||
607 | 878 |
canSelect:aRowNr |
879 |
"returns true if cell in column is selectable |
|
880 |
" |
|
881 |
|s| |
|
882 |
||
883 |
description canSelect ifTrue:[ |
|
1065
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
884 |
(s := description selectSelector) notNil ifTrue:[ |
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
885 |
columnAdaptor notNil ifTrue:[ |
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
886 |
s numArgs == 2 ifTrue:[ |
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
887 |
^ columnAdaptor perform:s with:(dataSet at:aRowNr) with:columnNumber |
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
888 |
]. |
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
889 |
^ columnAdaptor perform:s with:(dataSet at:aRowNr) |
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
890 |
]. |
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
891 |
s numArgs == 1 ifTrue:[ |
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
892 |
^ (dataSet at:aRowNr) perform:s with:columnNumber |
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
893 |
]. |
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
894 |
^ (dataSet at:aRowNr) perform:s |
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
895 |
]. |
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
896 |
^ true |
607 | 897 |
]. |
898 |
^ false |
|
899 |
||
1065
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
900 |
"Modified: / 7.8.1998 / 22:49:20 / cg" |
607 | 901 |
! |
902 |
||
647 | 903 |
containsText |
904 |
"returns true if text might exist |
|
905 |
" |
|
1496 | 906 |
^ containsText |
647 | 907 |
! |
908 |
||
833 | 909 |
hasChoices:aRowNr |
910 |
^ (description choicesFor:(dataSet at:aRowNr)) notNil |
|
911 |
! |
|
912 |
||
1950 | 913 |
hasPotentialNonConstantBackground |
914 |
(backgroundColor notNil and:[backgroundColor isImageOrForm]) ifTrue:[^ true]. |
|
915 |
bgSelector notNil ifTrue:[^ true]. |
|
916 |
^ false. |
|
917 |
! |
|
918 |
||
1484 | 919 |
hasRelativeWidth |
920 |
"returns true if width is relative |
|
921 |
" |
|
2017
5cbe1d46c01d
isReal -> isLimitedPrecisionReal
Claus Gittinger <cg@exept.de>
parents:
1984
diff
changeset
|
922 |
^ descWidth isLimitedPrecisionReal |
1484 | 923 |
! |
924 |
||
542 | 925 |
heightOfHighestRow |
1725
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
926 |
"returns the height of the highest row in pixels. |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
927 |
Warning: |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
928 |
only the first numberOfRowsProbedForColumnSize are probed, |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
929 |
in case the access is expensive (dataBase apps) |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
930 |
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
|
931 |
are not probed at all. |
542 | 932 |
" |
1559
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
933 |
|h end bE editor| |
542 | 934 |
|
1496 | 935 |
(h := description height) == 0 ifTrue:[ |
936 |
containsText ifTrue:[ |
|
542 | 937 |
"/ search first none empty drawable object |
1725
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
938 |
end := numberOfRowsProbedForColumnSize min:dataSet size. |
542 | 939 |
|
1496 | 940 |
1 to:end do:[:i| |
941 |
h := h max:(self heightOfLabel:(shownValue value:(dataSet at:i))) |
|
542 | 942 |
] |
943 |
] |
|
944 |
]. |
|
1559
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
945 |
(bE := buttonExtent y) = 0 ifTrue:[ |
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
946 |
((editor := description editorType) == #ComboList |
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
947 |
or:[ editor == #ComboBox]) ifTrue:[ |
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
948 |
bE := dataSet comboButtonExtent y. |
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
949 |
]. |
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
950 |
]. |
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
951 |
^ h max:bE |
1725
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
952 |
|
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
953 |
"Modified: / 25.2.2000 / 14:29:20 / cg" |
1113 | 954 |
! |
955 |
||
1147 | 956 |
heightOfLabel:aLabel |
957 |
"returns the height of the label |
|
958 |
" |
|
1496 | 959 |
|h| |
1147 | 960 |
|
1496 | 961 |
(aLabel isString or:[aLabel isImageOrForm]) ifTrue:[ |
962 |
^ aLabel heightOn:dataSet |
|
963 |
]. |
|
1147 | 964 |
aLabel isNil ifTrue:[ ^ 0 ]. |
965 |
||
1496 | 966 |
aLabel isSequenceable ifFalse:[ |
967 |
^ aLabel perform:#heightOn: with:dataSet ifNotUnderstood:[ |
|
968 |
aLabel displayString heightOn:dataSet |
|
969 |
] |
|
1147 | 970 |
]. |
971 |
||
1496 | 972 |
h := 0. |
973 |
aLabel do:[:el|h := h + (el heightOn:dataSet)]. |
|
974 |
^ h |
|
1147 | 975 |
|
976 |
! |
|
977 |
||
1937 | 978 |
isResizeable |
979 |
"returns true if the row is resizeable |
|
980 |
" |
|
981 |
^ description isResizeable |
|
982 |
! |
|
983 |
||
1113 | 984 |
showColSeparator |
985 |
"returns true if column separator is on |
|
986 |
" |
|
987 |
^ showColSeparator |
|
1133 | 988 |
! |
989 |
||
990 |
showSelectionHighLighted |
|
991 |
"returns true if selection is highLighted |
|
992 |
" |
|
993 |
^ description showSelectionHighLighted ~~ false |
|
1147 | 994 |
! |
995 |
||
996 |
widthOfLabel:aLabel |
|
997 |
"returns the width of the label |
|
998 |
" |
|
1496 | 999 |
|w| |
1147 | 1000 |
|
1496 | 1001 |
(aLabel isString or:[aLabel isImageOrForm]) ifTrue:[ |
1002 |
^ aLabel widthOn:dataSet |
|
1003 |
]. |
|
1147 | 1004 |
aLabel isNil ifTrue:[ ^ 0 ]. |
1005 |
||
1496 | 1006 |
aLabel isSequenceable ifFalse:[ |
1007 |
^ aLabel perform:#widthOn: with:dataSet ifNotUnderstood:[ |
|
1008 |
aLabel displayString widthOn:dataSet |
|
1009 |
] |
|
1147 | 1010 |
]. |
1011 |
||
1496 | 1012 |
w := 0. |
1013 |
aLabel do:[:el|w := w max:(el widthOn:dataSet)]. |
|
1014 |
^ w |
|
542 | 1015 |
! ! |
1016 |
||
1017 |
!DataSetColumn methodsFor:'searching'! |
|
1018 |
||
1019 |
findRowNrStartingWithChar:aChar start:start stop:stop |
|
1020 |
"find the first row starting at start to stop, which drawable label |
|
1021 |
starts with the character, aChar. The index of the detected row is |
|
1022 |
returned or if no row is found 0. |
|
1023 |
" |
|
1024 |
|char| |
|
1025 |
||
1496 | 1026 |
containsText ifTrue:[ |
542 | 1027 |
char := aChar asLowercase. |
1028 |
||
1029 |
start to:stop do:[:aRowNr| |lbl| |
|
1147 | 1030 |
lbl := shownValue value:(dataSet at:aRowNr). |
1031 |
||
1032 |
(lbl isSequenceable and:[lbl isString not]) ifTrue:[ |
|
1033 |
lbl := lbl at:1 ifAbsent:nil |
|
1034 |
]. |
|
542 | 1035 |
|
1113 | 1036 |
(lbl respondsTo:#string) ifTrue:[ |
1037 |
lbl := lbl string. |
|
542 | 1038 |
(lbl size ~~ 0 and:[(lbl at:1) asLowercase == char]) ifTrue:[ |
1039 |
^ aRowNr |
|
1040 |
] |
|
1041 |
] ifFalse:[ |
|
1042 |
lbl isNil ifFalse:[ |
|
1043 |
^ 0 |
|
1044 |
] |
|
1045 |
] |
|
1046 |
] |
|
1047 |
]. |
|
1048 |
^ 0 |
|
1049 |
||
1050 |
! ! |
|
1051 |
||
1052 |
!DataSetColumn class methodsFor:'documentation'! |
|
1053 |
||
1054 |
version |
|
2017
5cbe1d46c01d
isReal -> isLimitedPrecisionReal
Claus Gittinger <cg@exept.de>
parents:
1984
diff
changeset
|
1055 |
^ '$Header: /cvs/stx/stx/libwidg2/DataSetColumn.st,v 1.70 2001-10-09 17:44:27 cg Exp $' |
542 | 1056 |
! ! |