author | Claus Gittinger <cg@exept.de> |
Fri, 26 Feb 2016 12:56:48 +0100 | |
changeset 4963 | f6db5a9da095 |
parent 4821 | b53364768c88 |
child 5054 | a660f11bc670 |
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 |
" |
|
1818 | 12 |
"{ Package: 'stx:libwidg2' }" |
13 |
||
4821 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
542 | 16 |
Object subclass:#DataSetColumn |
3775 | 17 |
instanceVariableNames:'columnNumber dataSet width description buttonExtent rendererType |
18 |
backgroundColor foregroundColor rowSeparatorSelector |
|
19 |
showColSeparator showRowSeparator columnAlignment label |
|
20 |
containsText columnAdaptor descWidth descMinWidth |
|
21 |
longStringCompression minValue maxValue' |
|
22 |
classVariableNames:'' |
|
23 |
poolDictionaries:'' |
|
24 |
category:'Views-DataSet' |
|
542 | 25 |
! |
26 |
||
27 |
!DataSetColumn class methodsFor:'documentation'! |
|
28 |
||
29 |
copyright |
|
30 |
" |
|
31 |
COPYRIGHT (c) 1997 by Claus Gittinger / eXept Software AG |
|
32 |
All Rights Reserved |
|
33 |
||
34 |
This software is furnished under a license and may be used |
|
35 |
only in accordance with the terms of that license and with the |
|
36 |
inclusion of the above copyright notice. This software may not |
|
37 |
be provided or otherwise made available to, or used by, any |
|
38 |
other person. No title to or ownership of the software is |
|
39 |
hereby transferred. |
|
40 |
" |
|
41 |
||
42 |
||
43 |
||
44 |
! |
|
45 |
||
46 |
documentation |
|
47 |
" |
|
48 |
represent one single column description of a DataSetView |
|
49 |
||
50 |
[Instance variables:] |
|
51 |
||
647 | 52 |
columnNumber <Integer> sequence number (into list of columns) |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
53 |
|
542 | 54 |
dataSet <DSVColumnView> the view it belongs to |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
55 |
|
1088 | 56 |
width <Integer> width of column |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
57 |
|
2710
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
58 |
description <DataSetColumnSpec> the column description (a spec) |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
59 |
|
1088 | 60 |
buttonExtent <Point> extent of drawable form |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
61 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
62 |
rendererType <Type> renderer type (cached value from |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
63 |
the column specification). |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
64 |
|
647 | 65 |
backgroundColor <Color or nil> background color of all cells or nil |
66 |
(nil: use default background color). |
|
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
67 |
|
647 | 68 |
foregroundColor <Color or nil> foreground color of all cells or nil |
69 |
(nil: use default foreground color). |
|
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
70 |
|
1088 | 71 |
columnAlignment <Symbol> align text/icon #left #right or #center |
72 |
in row (on default: #left). |
|
73 |
||
74 |
label <label/icon or nil> label resolved by the builder shown |
|
75 |
in the column description field. |
|
76 |
||
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
77 |
readSelector <Symbol> cached readSelector (from the spec) |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
78 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
79 |
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
|
80 |
read-writeSelectors to extract a column |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
81 |
from a row object. |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
82 |
If nil, the row object is used itself. |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
83 |
|
1113 | 84 |
showColSeparator <Boolean> true: vertical separators are enabled; |
85 |
separator between columns |
|
86 |
||
87 |
showRowSeparator <Boolean> true: horizontal separators are enabled; |
|
88 |
separator between rows |
|
89 |
||
90 |
rowSeparatorSelector <Selector or nil> access specific showRowSeparator state |
|
91 |
for a cell |
|
542 | 92 |
|
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
93 |
[from description:] |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
94 |
fgSelector <Selector or nil> access specific foreground color for |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
95 |
a cell |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
96 |
|
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
97 |
bgSelector <Selector or nil> access specific background color for |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
98 |
a cell |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
99 |
|
1725
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
100 |
numberOfRowsProbedForColumnSize the number of rows which are queries |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
101 |
<Integer> in order to compute the columns width. |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
102 |
(for scrollBar/col width computation) |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
103 |
Notice, if its expensive to fetch rows |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
104 |
(dataBase apps), this should be small. |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
105 |
Default:15 |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
106 |
|
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
107 |
|
542 | 108 |
[author:] |
109 |
Claus Atzkern |
|
110 |
||
111 |
[see also:] |
|
112 |
DataSetColumnSpec |
|
113 |
DSVColumnView |
|
114 |
DataSetView |
|
115 |
" |
|
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
116 |
! ! |
542 | 117 |
|
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
118 |
!DataSetColumn class methodsFor:'utilities'! |
542 | 119 |
|
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
120 |
shortenedStringFor:aString on:aGC maxWidth:maxWidth |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
121 |
"common code to shorten a string; used in both the DSV label- and column Views, |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
122 |
if the string is too long for the column" |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
123 |
|
2221 | 124 |
|widthOf3Dots wRest shortenedLabel lUsed lMin lMax| |
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
125 |
|
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
126 |
aString isString ifFalse:[^ aString]. |
4234 | 127 |
(aString widthOn:aGC) <= maxWidth ifTrue:[^ aString]. |
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
128 |
|
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
129 |
widthOf3Dots := '...' widthOn:aGC. |
2221 | 130 |
|
131 |
lMin := 1. |
|
132 |
lMax := aString size. |
|
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
133 |
[ |
2221 | 134 |
lUsed := (lMax + lMin) // 2. |
135 |
wRest := aString widthFrom:1 to:lUsed on:aGC. |
|
136 |
wRest > (maxWidth-widthOf3Dots) ifTrue:[ |
|
137 |
lMax := lUsed - 1. |
|
138 |
] ifFalse:[ |
|
139 |
lMin := lUsed + 1. |
|
140 |
]. |
|
141 |
lMin < lMax |
|
142 |
] whileTrue. |
|
143 |
shortenedLabel := aString copyFrom:1 to:lUsed. |
|
144 |
||
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
145 |
shortenedLabel isEmpty ifTrue:[ |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
146 |
((aString first asString , '..') widthOn:aGC) < maxWidth ifTrue:[ |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
147 |
"/ only two dots and the first character |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
148 |
^ (aString first asString , '..') |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
149 |
] |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
150 |
]. |
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
151 |
^ (shortenedLabel , '...'). |
542 | 152 |
! ! |
153 |
||
154 |
!DataSetColumn methodsFor:'accessing'! |
|
155 |
||
3211 | 156 |
activeHelpText |
157 |
"get the active helpText or nil" |
|
158 |
||
159 |
|app key| |
|
160 |
||
3869 | 161 |
((key := description activeHelpKey) notEmptyOrNil |
3211 | 162 |
and:[(app := dataSet application) notNil]) ifTrue:[ |
3869 | 163 |
^ app flyByHelpTextForKey:key asSymbol. |
3211 | 164 |
]. |
3218 | 165 |
^ nil |
3211 | 166 |
|
167 |
"Created: / 26-03-2007 / 13:39:11 / cg" |
|
3218 | 168 |
"Modified: / 26-03-2007 / 17:51:15 / cg" |
3211 | 169 |
! |
170 |
||
3522
3a173979096d
allow for separate activeHelp for the label area
Claus Gittinger <cg@exept.de>
parents:
3511
diff
changeset
|
171 |
activeHelpTextForLabel |
3a173979096d
allow for separate activeHelp for the label area
Claus Gittinger <cg@exept.de>
parents:
3511
diff
changeset
|
172 |
"get the active helpText for the label or nil" |
3a173979096d
allow for separate activeHelp for the label area
Claus Gittinger <cg@exept.de>
parents:
3511
diff
changeset
|
173 |
|
3a173979096d
allow for separate activeHelp for the label area
Claus Gittinger <cg@exept.de>
parents:
3511
diff
changeset
|
174 |
|app key| |
3a173979096d
allow for separate activeHelp for the label area
Claus Gittinger <cg@exept.de>
parents:
3511
diff
changeset
|
175 |
|
3869 | 176 |
((key := description activeHelpKeyForLabel) notEmptyOrNil |
3522
3a173979096d
allow for separate activeHelp for the label area
Claus Gittinger <cg@exept.de>
parents:
3511
diff
changeset
|
177 |
and:[(app := dataSet application) notNil]) ifTrue:[ |
3869 | 178 |
^ app flyByHelpTextForKey:key asSymbol. |
3522
3a173979096d
allow for separate activeHelp for the label area
Claus Gittinger <cg@exept.de>
parents:
3511
diff
changeset
|
179 |
]. |
3a173979096d
allow for separate activeHelp for the label area
Claus Gittinger <cg@exept.de>
parents:
3511
diff
changeset
|
180 |
^ nil |
3a173979096d
allow for separate activeHelp for the label area
Claus Gittinger <cg@exept.de>
parents:
3511
diff
changeset
|
181 |
|
3a173979096d
allow for separate activeHelp for the label area
Claus Gittinger <cg@exept.de>
parents:
3511
diff
changeset
|
182 |
"Created: / 26-03-2007 / 13:39:11 / cg" |
3a173979096d
allow for separate activeHelp for the label area
Claus Gittinger <cg@exept.de>
parents:
3511
diff
changeset
|
183 |
"Modified: / 26-03-2007 / 17:51:15 / cg" |
3a173979096d
allow for separate activeHelp for the label area
Claus Gittinger <cg@exept.de>
parents:
3511
diff
changeset
|
184 |
! |
3a173979096d
allow for separate activeHelp for the label area
Claus Gittinger <cg@exept.de>
parents:
3511
diff
changeset
|
185 |
|
3459 | 186 |
activeHelpTextForRow:rowNr |
187 |
"get the active helpText or nil" |
|
188 |
||
189 |
|app key| |
|
190 |
||
3460 | 191 |
((key := description activeHelpKey) notEmptyOrNil |
3459 | 192 |
and:[(app := dataSet application) notNil]) ifTrue:[ |
3511 | 193 |
^ app flyByHelpTextForKey:key asSymbol row:rowNr. |
3459 | 194 |
]. |
195 |
^ nil |
|
196 |
||
197 |
"Created: / 26-03-2007 / 13:39:11 / cg" |
|
198 |
"Modified: / 26-03-2007 / 17:51:15 / cg" |
|
199 |
! |
|
200 |
||
542 | 201 |
at:aRowNr |
3505 | 202 |
"get the value of the cell at the row index, aRowNr" |
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
203 |
|
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
204 |
|row| |
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
205 |
|
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
206 |
row := dataSet at:aRowNr. |
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
207 |
^ self extractColFromRow:row rowNr:aRowNr. |
542 | 208 |
! |
209 |
||
210 |
at:aRowNr put:something |
|
3505 | 211 |
"set the value of the cell at the row index, aRowNr" |
212 |
||
213 |
|row| |
|
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
214 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
215 |
row := dataSet at:aRowNr. |
2419
e0121908fffe
added longStringCompression flag
Claus Gittinger <cg@exept.de>
parents:
2222
diff
changeset
|
216 |
self storeCol:something inRow:row. |
542 | 217 |
! |
218 |
||
1558
00b34d71898a
columnAdaptor also used when retrieving a ComboBoxes list.
Claus Gittinger <cg@exept.de>
parents:
1526
diff
changeset
|
219 |
columnAdaptor |
00b34d71898a
columnAdaptor also used when retrieving a ComboBoxes list.
Claus Gittinger <cg@exept.de>
parents:
1526
diff
changeset
|
220 |
^ columnAdaptor |
00b34d71898a
columnAdaptor also used when retrieving a ComboBoxes list.
Claus Gittinger <cg@exept.de>
parents:
1526
diff
changeset
|
221 |
! |
00b34d71898a
columnAdaptor also used when retrieving a ComboBoxes list.
Claus Gittinger <cg@exept.de>
parents:
1526
diff
changeset
|
222 |
|
1712 | 223 |
columnAdaptor:anAdapter |
224 |
columnAdaptor := anAdapter. |
|
225 |
! |
|
226 |
||
3505 | 227 |
columnNumber |
228 |
^ columnNumber |
|
229 |
! |
|
230 |
||
807 | 231 |
description |
2710
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
232 |
"returns the column spec |
807 | 233 |
" |
234 |
^ description |
|
235 |
! |
|
236 |
||
542 | 237 |
label |
238 |
"get the label assigned to the column |
|
239 |
" |
|
891 | 240 |
^ label |
542 | 241 |
|
242 |
||
243 |
! |
|
244 |
||
2419
e0121908fffe
added longStringCompression flag
Claus Gittinger <cg@exept.de>
parents:
2222
diff
changeset
|
245 |
longStringCompression:aBoolean |
e0121908fffe
added longStringCompression flag
Claus Gittinger <cg@exept.de>
parents:
2222
diff
changeset
|
246 |
^ longStringCompression ? true |
e0121908fffe
added longStringCompression flag
Claus Gittinger <cg@exept.de>
parents:
2222
diff
changeset
|
247 |
! |
e0121908fffe
added longStringCompression flag
Claus Gittinger <cg@exept.de>
parents:
2222
diff
changeset
|
248 |
|
1487 | 249 |
rendererType |
250 |
"returns my renderer type |
|
251 |
" |
|
252 |
^ rendererType |
|
253 |
! ! |
|
254 |
||
1818 | 255 |
!DataSetColumn methodsFor:'accessing-colors'! |
1565 | 256 |
|
257 |
backgroundColor |
|
258 |
"returns the background color or nil |
|
259 |
" |
|
2710
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
260 |
^ backgroundColor == dataSet backgroundColor ifTrue:[nil] ifFalse:[backgroundColor] |
1565 | 261 |
! |
262 |
||
2693 | 263 |
backgroundColor: aColor |
264 |
backgroundColor := aColor |
|
265 |
! |
|
266 |
||
1565 | 267 |
backgroundColorAt:aRowNr |
268 |
"returns the background color for a row at list index a rowNr |
|
269 |
" |
|
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
270 |
description backgroundSelector notNil ifTrue:[ |
1565 | 271 |
^ self backgroundColorFor:(dataSet at:aRowNr) at:aRowNr |
272 |
]. |
|
273 |
^ backgroundColor |
|
274 |
! |
|
275 |
||
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
276 |
backgroundColorFor:aRow at:aRowNr |
2727
5cb5708a6982
No extra handling needed for LimitedPrecisionReal
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
277 |
"return the background color for a row at list index a rowNr" |
5cb5708a6982
No extra handling needed for LimitedPrecisionReal
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
278 |
|
3210 | 279 |
"/ backgroundColor has already been fetched from description/dataSet (see #initialize) |
280 |
^ self |
|
281 |
colorFor:aRow at:aRowNr |
|
282 |
descriptionSelector:(description backgroundSelector) |
|
283 |
descriptionColor:backgroundColor |
|
284 |
dataSetDefaultColor:nil |
|
1565 | 285 |
|
3210 | 286 |
"Modified: / 26-03-2007 / 13:27:19 / cg" |
287 |
! |
|
288 |
||
289 |
colorFor:aRow at:aRowNr descriptionSelector:descriptionSelector descriptionColor:descriptionColor dataSetDefaultColor:dataSetColor |
|
290 |
"common code for returning a color for a row at list index a rowNr, asking both description and dataSet as fallBack" |
|
291 |
||
292 |
|clr| |
|
293 |
||
294 |
descriptionSelector notNil ifTrue:[ |
|
1924 | 295 |
columnAdaptor notNil ifTrue:[ |
3210 | 296 |
clr := columnAdaptor perform:descriptionSelector withOptionalArgument:aRow and:aRowNr and:columnNumber and:dataSet |
1565 | 297 |
] ifFalse:[ |
4660
985b9030eab6
When extracting color, send the color-message to the application itself it the
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4566
diff
changeset
|
298 |
"/ Check if row-object responds to the color message... |
985b9030eab6
When extracting color, send the color-message to the application itself it the
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4566
diff
changeset
|
299 |
(aRow respondsTo: descriptionSelector) ifTrue:[ |
985b9030eab6
When extracting color, send the color-message to the application itself it the
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4566
diff
changeset
|
300 |
clr := aRow perform:descriptionSelector withOptionalArgument:aRowNr and:columnNumber and:dataSet |
985b9030eab6
When extracting color, send the color-message to the application itself it the
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4566
diff
changeset
|
301 |
] ifFalse:[ |
985b9030eab6
When extracting color, send the color-message to the application itself it the
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4566
diff
changeset
|
302 |
"/ ...if not, send the message to the application model. This allows application models to |
985b9030eab6
When extracting color, send the color-message to the application itself it the
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4566
diff
changeset
|
303 |
"/ define visual aspects while data still could be extracted from the row-objects directly. |
985b9030eab6
When extracting color, send the color-message to the application itself it the
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4566
diff
changeset
|
304 |
|
985b9030eab6
When extracting color, send the color-message to the application itself it the
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4566
diff
changeset
|
305 |
| app | |
985b9030eab6
When extracting color, send the color-message to the application itself it the
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4566
diff
changeset
|
306 |
|
985b9030eab6
When extracting color, send the color-message to the application itself it the
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4566
diff
changeset
|
307 |
app := dataSet application. |
985b9030eab6
When extracting color, send the color-message to the application itself it the
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4566
diff
changeset
|
308 |
app notNil ifTrue:[ |
985b9030eab6
When extracting color, send the color-message to the application itself it the
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4566
diff
changeset
|
309 |
clr := app perform:descriptionSelector withOptionalArgument:aRow and:aRowNr and:columnNumber and:dataSet |
985b9030eab6
When extracting color, send the color-message to the application itself it the
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4566
diff
changeset
|
310 |
]. |
985b9030eab6
When extracting color, send the color-message to the application itself it the
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4566
diff
changeset
|
311 |
]. |
1565 | 312 |
]. |
3210 | 313 |
clr notNil ifTrue:[ |
314 |
(clr isColor or:[clr isImageOrForm]) ifTrue:[ |
|
315 |
^ clr |
|
1928
2dcf8e62af64
debug: care for non-color to be returned from fg/bg message.
Claus Gittinger <cg@exept.de>
parents:
1924
diff
changeset
|
316 |
]. |
3210 | 317 |
self error:'unexpected color (not a 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
|
318 |
] |
1565 | 319 |
]. |
3210 | 320 |
^ descriptionColor ? dataSetColor |
321 |
||
322 |
"Created: / 26-03-2007 / 13:05:24 / cg" |
|
4660
985b9030eab6
When extracting color, send the color-message to the application itself it the
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4566
diff
changeset
|
323 |
"Modified: / 23-09-2014 / 11:35:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1565 | 324 |
! |
325 |
||
326 |
foregroundColor |
|
327 |
"returns the foreground color or nil |
|
328 |
" |
|
2710
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
329 |
^ foregroundColor == dataSet foregroundColor ifTrue:[nil] ifFalse:[foregroundColor] |
1565 | 330 |
! |
331 |
||
2693 | 332 |
foregroundColor: aColor |
333 |
foregroundColor := aColor |
|
334 |
! |
|
335 |
||
1565 | 336 |
foregroundColorFor:aRow at:aRowNr |
337 |
"returns the foreground color for a row at list index a rowNr |
|
338 |
" |
|
339 |
||
3210 | 340 |
"/ foregroundColor has already been fetched from description/dataSet (see #initialize) |
341 |
^ self |
|
342 |
colorFor:aRow at:aRowNr |
|
343 |
descriptionSelector:(description foregroundSelector) |
|
344 |
descriptionColor:foregroundColor |
|
345 |
dataSetDefaultColor:nil |
|
346 |
||
347 |
"Modified: / 26-03-2007 / 13:27:39 / cg" |
|
2710
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
348 |
! |
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
349 |
|
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
350 |
selectedBackgroundColorFor:aRow at:aRowNr |
3210 | 351 |
"returns the selected background color for a row at list index a rowNr" |
2710
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
352 |
|
3210 | 353 |
^ self |
354 |
colorFor:aRow at:aRowNr |
|
355 |
descriptionSelector:(description selectedBackgroundSelector) |
|
356 |
descriptionColor:(description selectedBackgroundColor) |
|
357 |
dataSetDefaultColor:(dataSet selectionBackgroundColor) |
|
3139 | 358 |
|
3210 | 359 |
"Modified: / 26-03-2007 / 13:06:06 / cg" |
2710
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
360 |
! |
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
361 |
|
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
362 |
selectedForegroundColorFor:aRow at:aRowNr |
3210 | 363 |
"returns the selected foreground color for a row at list index a rowNr" |
2710
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
364 |
|
3210 | 365 |
^ self |
366 |
colorFor:aRow at:aRowNr |
|
367 |
descriptionSelector:(description selectedForegroundSelector) |
|
368 |
descriptionColor:(description selectedForegroundColor) |
|
369 |
dataSetDefaultColor:(dataSet selectionForegroundColor) |
|
370 |
||
371 |
"Modified: / 26-03-2007 / 13:05:31 / cg" |
|
3990
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
372 |
! |
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
373 |
|
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
374 |
selectedFrameColorFor:aRow at:aRowNr |
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
375 |
"returns the selected frame color for a row at list index a rowNr" |
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
376 |
|
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
377 |
^ self |
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
378 |
colorFor:aRow at:aRowNr |
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
379 |
descriptionSelector:(description selectedBackgroundSelector) |
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
380 |
descriptionColor:(description selectedBackgroundColor) |
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
381 |
dataSetDefaultColor:(dataSet selectionFrameColor) |
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
382 |
|
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
383 |
"Created: / 20-01-2011 / 08:46:32 / cg" |
1565 | 384 |
! ! |
385 |
||
1818 | 386 |
!DataSetColumn methodsFor:'accessing-dimension'! |
1487 | 387 |
|
1484 | 388 |
minWidth |
1490 | 389 |
"get the minimum width required by the column |
1484 | 390 |
" |
1490 | 391 |
descMinWidth notNil ifTrue:[ |
392 |
^ descMinWidth |
|
393 |
]. |
|
4414 | 394 |
descWidth isInteger ifTrue:[ |
395 |
^ descWidth |
|
396 |
]. |
|
397 |
^ 0. |
|
398 |
"/ width := nil. |
|
399 |
"/ ^ self width |
|
1490 | 400 |
! |
401 |
||
1492 | 402 |
minimumRequiredWidth |
403 |
"returns the minimum required width |
|
404 |
" |
|
405 |
|minWidth| |
|
406 |
||
1940 | 407 |
descMinWidth notNil ifTrue:[ |
408 |
minWidth := DSVLabelView tabSpacing max:2. |
|
409 |
^ minWidth // 2 + minWidth |
|
410 |
]. |
|
1492 | 411 |
|
1940 | 412 |
minWidth := dataSet separatorSize + (2 * dataSet horizontalSpacing). |
413 |
^ minWidth + label preferredWidth. |
|
1492 | 414 |
! |
415 |
||
1490 | 416 |
setDescWidth:aWidth |
417 |
"set a fixed width |
|
418 |
" |
|
1940 | 419 |
descMinWidth := 1. |
420 |
descMinWidth := width := descWidth := self minimumRequiredWidth max:aWidth. |
|
1484 | 421 |
! |
422 |
||
4414 | 423 |
setWidth:pixels |
424 |
width := pixels |
|
425 |
! |
|
426 |
||
542 | 427 |
width |
428 |
"returns the width in pixels |
|
1725
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
429 |
Warning: |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
430 |
only the first numberOfRowsProbedForColumnSize are probed, |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
431 |
in case the access is expensive (dataBase apps) |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
432 |
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
|
433 |
are not probed at all." |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
434 |
|
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
435 |
|max "{ Class:SmallInteger }" |
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
436 |
listSize "{ Class:SmallInteger }"| |
542 | 437 |
|
1484 | 438 |
width notNil ifTrue:[^ width]. "/ already computed |
542 | 439 |
|
1490 | 440 |
descMinWidth notNil ifTrue:[ |
441 |
width := descMinWidth. |
|
4963 | 442 |
^ width |
1484 | 443 |
]. |
1482 | 444 |
|
4963 | 445 |
(descWidth ~~ 0 and:[self hasRelativeWidth not "descWidth isLimitedPrecisionReal not"]) ifTrue:[ |
1493 | 446 |
width := descMinWidth := descWidth. |
4963 | 447 |
^ width |
1493 | 448 |
]. |
449 |
||
1490 | 450 |
width := description minWidth max:(label preferredWidth). |
451 |
||
4963 | 452 |
self hasRelativeWidth ifTrue:[ |
2093 | 453 |
width := width max:(descWidth * dataSet innerWidth) rounded. |
4963 | 454 |
^ width |
1482 | 455 |
]. |
456 |
||
1496 | 457 |
containsText ifTrue:[ |
1725
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
458 |
"/ take maximum numberOfRowsProbedForColumnSize entries to calculate the width; |
1484 | 459 |
"/ can be resized later if neccessary |
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
460 |
listSize := dataSet size. |
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
461 |
max := listSize min:description numberOfRowsProbedForColumnSize. |
542 | 462 |
|
1526 | 463 |
max ~~ 0 ifTrue:[ |
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
464 |
1 to:max do:[:rowNr| |row| |
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
465 |
row := dataSet at:rowNr. |
2444 | 466 |
width := width max:(self widthOfLabel:(self shownValueForRow:row rowNr:rowNr)) |
1526 | 467 |
]. |
2444 | 468 |
width := width max:(self widthOfLabel:(self shownValueForRow:(dataSet at:listSize) rowNr:listSize)) |
1484 | 469 |
]. |
470 |
description editorType ~~ #None ifTrue:[ |
|
471 |
width := width + (dataSet font widthOn:dataSet device) |
|
542 | 472 |
]. |
1493 | 473 |
] ifFalse:[ |
474 |
max := 1 |
|
1484 | 475 |
]. |
1490 | 476 |
width := width + buttonExtent x + dataSet separatorSize + (2 * dataSet horizontalSpacing). |
1493 | 477 |
|
478 |
max ~~ 0 ifTrue:[ |
|
1526 | 479 |
descMinWidth := width. |
480 |
description usePreferredWidth ifTrue:[ |
|
481 |
descWidth := width |
|
482 |
] |
|
1493 | 483 |
]. |
4963 | 484 |
^ width |
1484 | 485 |
|
1725
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
486 |
"Modified: / 25.2.2000 / 14:29:16 / cg" |
4566
19114315128c
Fox for column resizing bug.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4414
diff
changeset
|
487 |
! |
19114315128c
Fox for column resizing bug.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4414
diff
changeset
|
488 |
|
19114315128c
Fox for column resizing bug.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4414
diff
changeset
|
489 |
width: aWidth |
19114315128c
Fox for column resizing bug.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4414
diff
changeset
|
490 |
self setWidth: aWidth |
19114315128c
Fox for column resizing bug.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4414
diff
changeset
|
491 |
|
19114315128c
Fox for column resizing bug.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4414
diff
changeset
|
492 |
"Created: / 11-04-2014 / 10:01:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
542 | 493 |
! ! |
494 |
||
495 |
!DataSetColumn methodsFor:'drawing'! |
|
496 |
||
3330 | 497 |
drawLabel:aLabelToDraw atX:xLeft y:yTop |
498 |
"draw aLabelToDraw; handle columnAlignment" |
|
499 |
||
500 |
|drawnLabel x space prevClip mustUndoClip cashedWidth |
|
501 |
labelWidth leftPart leftShift indexOfFirstDigit indexOfFirstNonDigit| |
|
502 |
||
503 |
cashedWidth := self width. |
|
504 |
cashedWidth isNil ifTrue:[ ^ self ]. |
|
505 |
||
506 |
space := dataSet horizontalSpacing. |
|
507 |
||
508 |
drawnLabel := aLabelToDraw. |
|
509 |
labelWidth := drawnLabel widthOn:dataSet. |
|
510 |
||
511 |
(longStringCompression ~~ false |
|
512 |
and:[ drawnLabel isString |
|
513 |
and:[ labelWidth > cashedWidth]]) ifTrue:[ |
|
514 |
drawnLabel := self class shortenedStringFor:drawnLabel on:dataSet maxWidth:cashedWidth-space. |
|
515 |
labelWidth := drawnLabel widthOn:dataSet. |
|
516 |
]. |
|
517 |
||
518 |
columnAlignment == #left ifTrue:[ |
|
519 |
x := xLeft + space. |
|
520 |
] ifFalse:[ |
|
3675
e0e63070a210
support a hacky form of decimalRight alignmnet
Claus Gittinger <cg@exept.de>
parents:
3674
diff
changeset
|
521 |
(columnAlignment == #decimal |
e0e63070a210
support a hacky form of decimalRight alignmnet
Claus Gittinger <cg@exept.de>
parents:
3674
diff
changeset
|
522 |
or:[ columnAlignment == #decimalRight ]) ifTrue:[ |
3330 | 523 |
drawnLabel := drawnLabel asString. |
524 |
(drawnLabel includes:$.) ifTrue:[ |
|
525 |
leftPart := drawnLabel upTo:$.. |
|
526 |
] ifFalse:[ |
|
527 |
leftPart := drawnLabel. |
|
528 |
||
529 |
indexOfFirstDigit := drawnLabel findFirst:[:char | char isDigit]. |
|
530 |
indexOfFirstDigit ~~ 0 ifTrue:[ |
|
531 |
indexOfFirstNonDigit := drawnLabel findFirst:[:char | char isDigit not] startingAt:indexOfFirstDigit+1. |
|
532 |
indexOfFirstNonDigit ~~ 0 ifTrue:[ |
|
533 |
leftPart := drawnLabel copyTo:indexOfFirstNonDigit-1. |
|
534 |
]. |
|
535 |
]. |
|
536 |
]. |
|
537 |
leftShift := leftPart widthOn:dataSet. |
|
3675
e0e63070a210
support a hacky form of decimalRight alignmnet
Claus Gittinger <cg@exept.de>
parents:
3674
diff
changeset
|
538 |
columnAlignment == #decimalRight ifTrue:[ |
e0e63070a210
support a hacky form of decimalRight alignmnet
Claus Gittinger <cg@exept.de>
parents:
3674
diff
changeset
|
539 |
"/ decimal at the right |
e0e63070a210
support a hacky form of decimalRight alignmnet
Claus Gittinger <cg@exept.de>
parents:
3674
diff
changeset
|
540 |
x := (cashedWidth) - ('9999' widthOn:dataSet) - leftShift. |
e0e63070a210
support a hacky form of decimalRight alignmnet
Claus Gittinger <cg@exept.de>
parents:
3674
diff
changeset
|
541 |
] ifFalse:[ |
e0e63070a210
support a hacky form of decimalRight alignmnet
Claus Gittinger <cg@exept.de>
parents:
3674
diff
changeset
|
542 |
"/ decimal at the middle |
e0e63070a210
support a hacky form of decimalRight alignmnet
Claus Gittinger <cg@exept.de>
parents:
3674
diff
changeset
|
543 |
x := (cashedWidth // 2) - leftShift. |
e0e63070a210
support a hacky form of decimalRight alignmnet
Claus Gittinger <cg@exept.de>
parents:
3674
diff
changeset
|
544 |
]. |
3330 | 545 |
] ifFalse:[ |
546 |
x := cashedWidth - labelWidth. |
|
547 |
||
548 |
columnAlignment == #right ifTrue:[x := x - space] |
|
549 |
ifFalse:[x := x // 2]. |
|
550 |
]. |
|
551 |
"/ cg: old code (did not right-align if string is larger than width |
|
552 |
"/ x := xLeft + (x max:0). |
|
553 |
||
554 |
"/ new code: always right-align. |
|
555 |
x := xLeft + x. |
|
556 |
||
557 |
"/ must clip left, if string is too large |
|
558 |
x < xLeft ifTrue:[ |
|
559 |
"/ must clip ... |
|
560 |
prevClip := dataSet clippingRectangleOrNil. |
|
561 |
mustUndoClip := true. |
|
562 |
dataSet clippingRectangle:(Rectangle |
|
563 |
left:xLeft top:yTop |
|
564 |
width:cashedWidth height:(drawnLabel heightOn:dataSet)). |
|
565 |
]. |
|
566 |
]. |
|
567 |
||
568 |
"/ drawnLabel isImageOrForm ifTrue:[ |
|
569 |
"/ y := yTop. |
|
570 |
"/ ] ifFalse:[ |
|
571 |
"/ y := (yTop + dataSet rowFontAscent) |
|
572 |
"/ ]. |
|
573 |
||
574 |
"/ drawnLabel isString ifFalse:[ |
|
575 |
"/ y := yTop + (drawnLabel ascentOn:dataSet). |
|
576 |
"/ ] ifTrue:[ |
|
577 |
"/ y := yTop + dataSet rowFontAscent |
|
578 |
"/ ]. |
|
579 |
"/ drawnLabel displayOn:dataSet x:x y:y. |
|
580 |
||
581 |
dataSet displayLabel:drawnLabel x:x y:yTop. |
|
582 |
||
583 |
mustUndoClip == true ifTrue:[ |
|
584 |
dataSet clippingRectangle:prevClip |
|
585 |
]. |
|
586 |
! |
|
587 |
||
1132 | 588 |
drawLabelsAtX:xLeft y:yTop h:h from:start to:stop |
589 |
"redraw labels from start to stop |
|
1088 | 590 |
" |
3990
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
591 |
|fg y yT x hspace lblHg bg label row isSel cachedWidth lineColor| |
3298
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
592 |
|
3990
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
593 |
cachedWidth := self width. |
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
594 |
cachedWidth isNil ifTrue:[ ^ self ]. |
2578 | 595 |
|
1132 | 596 |
yT := yTop. |
597 |
hspace := dataSet horizontalSpacing. |
|
1100 | 598 |
|
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
599 |
start to:stop do:[:aRowNr| |
3364
b7f6e426cd60
care for list change while drawing
Claus Gittinger <cg@exept.de>
parents:
3330
diff
changeset
|
600 |
row := dataSet at:aRowNr ifAbsent:[^ self]. |
1132 | 601 |
y := yT. |
602 |
x := xLeft. |
|
603 |
||
3990
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
604 |
"/ GET BACKGROUND AND FOREGROUND-COLOR |
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
605 |
"/ =================================== |
1132 | 606 |
|
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
607 |
isSel := dataSet isSelected:aRowNr inColumn:columnNumber. |
1132 | 608 |
|
609 |
(isSel and:[description showSelectionHighLighted]) ifTrue:[ |
|
610 |
"/ SHOW SELECTED( MUST REDRAW BACKGROUND ) |
|
611 |
"/ ======================================= |
|
2710
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
612 |
bg := self selectedBackgroundColorFor:row at:aRowNr. |
fcfa161492ae
added selectedFg/selectedBG attributes
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
613 |
fg := self selectedForegroundColorFor:row at:aRowNr. |
2578 | 614 |
|
1132 | 615 |
dataSet paint:bg. |
3990
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
616 |
dataSet fillRectangleX:x y:y width:cachedWidth height:h. |
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
617 |
|
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
618 |
dataSet hasRowSelection ifFalse:[ |
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
619 |
lineColor := self selectedFrameColorFor:row at:aRowNr. |
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
620 |
lineColor notNil ifTrue:[ |
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
621 |
dataSet paint:lineColor. |
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
622 |
dataSet displayRectangleX:x y:y width:cachedWidth height:h. |
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
623 |
] |
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
624 |
] |
1113 | 625 |
] ifFalse:[ |
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
626 |
description backgroundSelector notNil ifTrue:[ |
1132 | 627 |
"/ MUST REDRAW BACKGROUND |
628 |
"/ ====================== |
|
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
629 |
bg := self backgroundColorFor:row at:aRowNr. |
1565 | 630 |
|
631 |
bg ~~ backgroundColor ifTrue:[ |
|
1132 | 632 |
bg := dataSet colorOnDevice:bg |
633 |
]. |
|
634 |
dataSet paint:bg. |
|
3990
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
635 |
dataSet fillRectangleX:x y:y width:cachedWidth height:h. |
1132 | 636 |
] ifFalse:[ |
637 |
bg := backgroundColor |
|
638 |
]. |
|
1100 | 639 |
|
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
640 |
fg := self foregroundColorFor:row at:aRowNr. |
1565 | 641 |
|
642 |
fg ~~ foregroundColor ifTrue:[ |
|
1132 | 643 |
fg := dataSet colorOnDevice:fg |
1565 | 644 |
]. |
1132 | 645 |
]. |
833 | 646 |
|
3990
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
647 |
"/ GET AND DRAW LABEL |
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
648 |
"/ ================== |
2542 | 649 |
(self isRowVisible:aRowNr) ifTrue:[ |
650 |
rendererType == #rowSelector ifTrue:[ |
|
651 |
isSel ifTrue:[ |
|
652 |
label := dataSet rowSelectorForm. |
|
653 |
x := x + hspace. |
|
654 |
] ifFalse:[ |
|
655 |
label := nil |
|
656 |
] |
|
1132 | 657 |
] ifFalse:[ |
2542 | 658 |
(isSel and:[dataSet hasOpenEditor]) ifTrue:[ |
659 |
label := nil |
|
660 |
] ifFalse:[ |
|
661 |
label := self shownValueForRow:row rowNr:aRowNr |
|
662 |
] |
|
1589
8bb71707b51a
remove any color emphasis when displaying the selection.
Claus Gittinger <cg@exept.de>
parents:
1587
diff
changeset
|
663 |
]. |
2542 | 664 |
label notNil ifTrue:[ |
665 |
"/ care for a dark-colored label, |
|
666 |
"/ with a dark selection-bg color |
|
667 |
(isSel and:[label isString and:[label hasChangeOfEmphasis]]) ifTrue:[ |
|
4821 | 668 |
"/ take away the label's own color info |
669 |
label := label copy emphasisAllRemove:#color. |
|
2542 | 670 |
]. |
671 |
||
672 |
lblHg := self heightOfLabel:label. |
|
1589
8bb71707b51a
remove any color emphasis when displaying the selection.
Claus Gittinger <cg@exept.de>
parents:
1587
diff
changeset
|
673 |
|
2542 | 674 |
lblHg ~~ 0 ifTrue:[ |
3139 | 675 |
y := y + ((h - lblHg) // 2). |
2542 | 676 |
dataSet paint:fg on:bg. |
1113 | 677 |
|
3462
d2df3607bfb5
mass operations: color selected-color
Claus Gittinger <cg@exept.de>
parents:
3460
diff
changeset
|
678 |
label isString ifTrue:[ |
d2df3607bfb5
mass operations: color selected-color
Claus Gittinger <cg@exept.de>
parents:
3460
diff
changeset
|
679 |
(label includes:Character cr) ifTrue:[ |
d2df3607bfb5
mass operations: color selected-color
Claus Gittinger <cg@exept.de>
parents:
3460
diff
changeset
|
680 |
label := label asCollectionOfLines |
d2df3607bfb5
mass operations: color selected-color
Claus Gittinger <cg@exept.de>
parents:
3460
diff
changeset
|
681 |
]. |
d2df3607bfb5
mass operations: color selected-color
Claus Gittinger <cg@exept.de>
parents:
3460
diff
changeset
|
682 |
]. |
d2df3607bfb5
mass operations: color selected-color
Claus Gittinger <cg@exept.de>
parents:
3460
diff
changeset
|
683 |
|
2542 | 684 |
(label isSequenceable and:[label isString not]) ifFalse:[ |
685 |
self drawLabel:label atX:x y:y |
|
686 |
] ifTrue:[ |
|
687 |
label do:[:el| |
|
688 |
el notNil ifTrue:[ |
|
689 |
self drawLabel:el atX:x y:y. |
|
690 |
y := y + (el heightOn:dataSet). |
|
691 |
] |
|
1147 | 692 |
] |
2542 | 693 |
]. |
694 |
] |
|
695 |
]. |
|
1132 | 696 |
]. |
697 |
yT := yT + h |
|
698 |
] |
|
3990
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
699 |
|
a1ed686544e0
added: #selectedFrameColorFor:at:
Claus Gittinger <cg@exept.de>
parents:
3920
diff
changeset
|
700 |
"Modified: / 20-01-2011 / 08:50:18 / cg" |
833 | 701 |
! |
702 |
||
3505 | 703 |
drawRendererInRow:rowNr x:xLeft y:y width:cellWidth value:cellValue |
704 |
(rendererType == #ComboBox or:[rendererType == #ComboList]) ifTrue:[ |
|
705 |
(self hasChoices:rowNr) ifTrue:[ |
|
706 |
dataSet drawComboButtonAtX:xLeft y:y w:cellWidth |
|
707 |
]. |
|
708 |
^ self |
|
709 |
]. |
|
710 |
rendererType == #CheckToggle ifTrue:[ |
|
711 |
dataSet drawCheckToggleAtX:xLeft y:y w:cellWidth state:cellValue. |
|
712 |
^ self |
|
713 |
]. |
|
714 |
rendererType == #RadioButton ifTrue:[ |
|
715 |
dataSet drawRadioButtonAtX:xLeft y:y w:cellWidth state:cellValue. |
|
716 |
^ self |
|
717 |
]. |
|
718 |
! |
|
719 |
||
1132 | 720 |
drawSeparatorsAtX:xLeft y:yTop h:h from:start to:stop |
721 |
"redraw separators for cells between start and stop |
|
1088 | 722 |
" |
3298
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
723 |
|cashedWidth is3D xL xR yB yT times| |
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
724 |
|
1132 | 725 |
(showColSeparator or:[showRowSeparator]) ifFalse:[ |
726 |
^ self |
|
727 |
]. |
|
3298
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
728 |
cashedWidth := self width. |
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
729 |
cashedWidth isNil ifTrue:[ ^ self ]. |
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
730 |
|
1132 | 731 |
is3D := dataSet has3Dseparators. |
732 |
||
1113 | 733 |
is3D ifTrue:[dataSet paint:(dataSet separatorDarkColor)] |
2638
f2b2ecc2c851
use user defined color for drawing separators in OneD mode
ca
parents:
2636
diff
changeset
|
734 |
ifFalse:[dataSet paint:(dataSet separatorOneDColor)]. |
1088 | 735 |
|
1132 | 736 |
times := stop - start + 1. |
737 |
xL := xLeft. |
|
3298
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
738 |
xR := xL - 1 + cashedWidth. |
1088 | 739 |
|
1113 | 740 |
showRowSeparator ifTrue:[ |
1132 | 741 |
"/ DRAW SEPARATORS AT BOTTOM( DARK COLOR ) |
742 |
"/ ======================================= |
|
743 |
yB := yTop - 1 + h. |
|
744 |
||
745 |
rowSeparatorSelector isNil ifTrue:[ |
|
746 |
times timesRepeat:[ |
|
747 |
dataSet displayLineFromX:xL y:yB toX:xR y:yB. |
|
748 |
yB := yB + h. |
|
749 |
] |
|
750 |
] ifFalse:[ |
|
751 |
start to:stop do:[:idx| |
|
3240
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
752 |
(self hasRowSeparatorAt:idx) ifTrue:[ |
1132 | 753 |
dataSet displayLineFromX:xL y:yB toX:xR y:yB |
754 |
]. |
|
755 |
yB := yB + h. |
|
3240
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
756 |
]. |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
757 |
]. |
1113 | 758 |
]. |
1132 | 759 |
|
1113 | 760 |
showColSeparator ifTrue:[ |
1132 | 761 |
"/ DRAW SEPARATORS AT RIGHT( DARK COLOR ) |
762 |
"/ ====================================== |
|
763 |
yT := yTop. |
|
764 |
||
765 |
times timesRepeat:[ |
|
766 |
dataSet displayLineFromX:xR y:yT toX:xR y:(yT - 1 + h). |
|
767 |
yT := yT + h. |
|
768 |
] |
|
1113 | 769 |
]. |
1089 | 770 |
|
1113 | 771 |
is3D ifFalse:[ |
772 |
^ self |
|
773 |
]. |
|
1088 | 774 |
|
1113 | 775 |
dataSet paint:(dataSet separatorLightColor). |
1040
c8e6a2ed7928
use the same background color for a selected rowSelector
ca
parents:
1007
diff
changeset
|
776 |
|
1113 | 777 |
( columnNumber == 1 |
3505 | 778 |
or:[(dataSet columnDescriptorAt:(columnNumber - 1)) showColSeparator] |
1113 | 779 |
) ifTrue:[ |
1132 | 780 |
|
781 |
"/ DRAW SEPARATORS AT LEFT( LIGHT COLOR ) |
|
782 |
"/ ====================================== |
|
783 |
yT := yTop. |
|
784 |
||
785 |
times timesRepeat:[ |
|
786 |
dataSet displayLineFromX:xL y:yT toX:xL y:(yT - 1 + h). |
|
787 |
yT := yT + h. |
|
788 |
]. |
|
1113 | 789 |
] ifFalse:[ |
1132 | 790 |
xL := xL - 1 |
1113 | 791 |
]. |
1092 | 792 |
|
1113 | 793 |
showRowSeparator ifTrue:[ |
1132 | 794 |
"/ DRAW SEPARATORS AT TOP( LIGHT COLOR ) |
795 |
"/ ===================================== |
|
796 |
yT := yTop. |
|
797 |
||
798 |
rowSeparatorSelector isNil ifTrue:[ |
|
799 |
times timesRepeat:[ |
|
800 |
dataSet displayLineFromX:xL y:yT toX:xR y:yT. |
|
801 |
yT := yT + h. |
|
802 |
] |
|
803 |
] ifFalse:[ |
|
804 |
"/ CHECK WHETHER PREVIOUS ROW HAS A SEPARATOR AT BOTTOM |
|
805 |
"/ ==================================================== |
|
806 |
start to:stop do:[:idx| |
|
3240
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
807 |
(idx == 1 or:[self hasRowSeparatorAt:(idx - 1)]) ifTrue:[ |
1132 | 808 |
dataSet displayLineFromX:xL y:yT toX:xR y:yT. |
809 |
]. |
|
810 |
yT := yT + h. |
|
811 |
] |
|
1088 | 812 |
] |
542 | 813 |
]. |
607 | 814 |
! |
815 |
||
542 | 816 |
invalidate |
1484 | 817 |
"invalidate width of column; forces a recomputation |
542 | 818 |
" |
1484 | 819 |
width := nil. |
542 | 820 |
|
1088 | 821 |
! |
822 |
||
1132 | 823 |
redrawX:xLeft y:yTop h:h from:start to:stop |
3505 | 824 |
"redraw all rows between start and stop" |
825 |
||
3298
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
826 |
|rH y cashedWidth| |
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
827 |
|
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
828 |
cashedWidth := self width. |
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
829 |
cashedWidth isNil ifTrue:[ ^ self ]. |
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
830 |
|
1132 | 831 |
rH := dataSet rowHeight. |
1088 | 832 |
|
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
833 |
description backgroundSelector isNil ifTrue:[ |
1132 | 834 |
dataSet paint:backgroundColor. |
3298
3408a7138374
Cache width during redraw. Should solve problems by setting width to nil
ab
parents:
3264
diff
changeset
|
835 |
dataSet fillRectangleX:xLeft y:yTop width:cashedWidth height:h |
1115 | 836 |
]. |
837 |
||
3505 | 838 |
"/ DRAW CELLS: BACKGROUND/FOREGROUND/LABEL |
839 |
"/ ======================================= |
|
1132 | 840 |
self drawLabelsAtX:xLeft y:yTop h:rH from:start to:stop. |
1113 | 841 |
|
3505 | 842 |
"/ DRAW RENDERED INDICATORS |
843 |
"/ ======================== |
|
844 |
rendererType notNil ifTrue:[ |
|
1132 | 845 |
y := yTop. |
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
846 |
start to:stop do:[:rowNr| |
3505 | 847 |
|state| |
848 |
||
2542 | 849 |
(self isRowVisible:rowNr) ifTrue:[ |
3505 | 850 |
state := self at:rowNr. |
851 |
self drawRendererInRow:rowNr x:xLeft y:y width:cashedWidth value:state. |
|
1113 | 852 |
]. |
1132 | 853 |
y := y + rH. |
3505 | 854 |
]. |
1088 | 855 |
]. |
856 |
||
3505 | 857 |
"/ DRAW SEPARATORS |
858 |
"/ =============== |
|
1132 | 859 |
self drawSeparatorsAtX:xLeft y:yTop h:rH from:start to:stop |
2693 | 860 |
! |
861 |
||
862 |
shownValueForRow:aRow rowNr:aRowNr |
|
3325
8d2a6394f01a
added/fixed printConverter handling
Claus Gittinger <cg@exept.de>
parents:
3320
diff
changeset
|
863 |
|selector format value type choices translatedChoices idx converter| |
2693 | 864 |
|
865 |
rendererType == #CheckToggle ifTrue:[ |
|
866 |
^ nil |
|
867 |
]. |
|
3505 | 868 |
rendererType == #RadioButton ifTrue:[ |
869 |
^ nil |
|
870 |
]. |
|
2693 | 871 |
|
872 |
rendererType == #rowSelector ifTrue:[ |
|
873 |
^ nil |
|
874 |
]. |
|
875 |
||
876 |
selector := description printSelector. |
|
877 |
selector notNil ifTrue:[ |
|
878 |
^ aRow |
|
879 |
perform:selector |
|
880 |
withOptionalArgument:dataSet and:columnNumber and:aRowNr and:dataSet. |
|
881 |
]. |
|
882 |
||
883 |
value := self extractColFromRow:aRow rowNr:aRowNr. |
|
2865 | 884 |
description translatedChoices notNil ifTrue:[ |
885 |
choices := self choicesFor:aRow at:aRowNr. |
|
886 |
idx := choices indexOf:value. |
|
887 |
idx ~~ 0 ifTrue:[ |
|
888 |
translatedChoices := self translatedChoicesFor:aRow at:aRowNr. |
|
889 |
translatedChoices notNil ifTrue:[ |
|
890 |
value := translatedChoices at:idx. |
|
891 |
]. |
|
892 |
]. |
|
893 |
]. |
|
2693 | 894 |
|
895 |
selector := description formatSelector. |
|
896 |
selector notNil ifTrue:[ |
|
897 |
format := aRow |
|
3674 | 898 |
perform:selector asSymbol |
2693 | 899 |
withOptionalArgument:dataSet and:columnNumber and:aRowNr and:dataSet. |
900 |
] ifFalse:[ |
|
901 |
format := description formatString. |
|
902 |
]. |
|
903 |
format notNil ifTrue:[ |
|
904 |
"/ cannot remember what this was used for ... |
|
905 |
"/ (idx := format indexOf:$.) ~~ 0 ifTrue:[ |
|
906 |
"/ idx := format size - idx |
|
907 |
"/ ]. |
|
908 |
"/ format := '%0.', idx printString, 'f'. |
|
909 |
||
3674 | 910 |
^ value printStringFormat:format |
3325
8d2a6394f01a
added/fixed printConverter handling
Claus Gittinger <cg@exept.de>
parents:
3320
diff
changeset
|
911 |
]. |
8d2a6394f01a
added/fixed printConverter handling
Claus Gittinger <cg@exept.de>
parents:
3320
diff
changeset
|
912 |
|
8d2a6394f01a
added/fixed printConverter handling
Claus Gittinger <cg@exept.de>
parents:
3320
diff
changeset
|
913 |
type := description type. |
8d2a6394f01a
added/fixed printConverter handling
Claus Gittinger <cg@exept.de>
parents:
3320
diff
changeset
|
914 |
type ~~ #string ifTrue:[ |
8d2a6394f01a
added/fixed printConverter handling
Claus Gittinger <cg@exept.de>
parents:
3320
diff
changeset
|
915 |
converter := TypeConverter new perform:type. |
3920
4a1933e73efd
changed: #shownValueForRow:rowNr:
Claus Gittinger <cg@exept.de>
parents:
3869
diff
changeset
|
916 |
^ converter getBlock value:value. |
4a1933e73efd
changed: #shownValueForRow:rowNr:
Claus Gittinger <cg@exept.de>
parents:
3869
diff
changeset
|
917 |
"/ cg: the code below is dangerous (tries to addDependent to Integers) !! |
4a1933e73efd
changed: #shownValueForRow:rowNr:
Claus Gittinger <cg@exept.de>
parents:
3869
diff
changeset
|
918 |
"/ converter model:value. |
4a1933e73efd
changed: #shownValueForRow:rowNr:
Claus Gittinger <cg@exept.de>
parents:
3869
diff
changeset
|
919 |
"/ ^ converter value. |
2693 | 920 |
]. |
921 |
||
922 |
^ value |
|
3920
4a1933e73efd
changed: #shownValueForRow:rowNr:
Claus Gittinger <cg@exept.de>
parents:
3869
diff
changeset
|
923 |
|
4a1933e73efd
changed: #shownValueForRow:rowNr:
Claus Gittinger <cg@exept.de>
parents:
3869
diff
changeset
|
924 |
"Modified: / 28-07-2010 / 20:42:51 / cg" |
542 | 925 |
! ! |
926 |
||
614 | 927 |
!DataSetColumn methodsFor:'editing'! |
928 |
||
3856 | 929 |
editorForRowAt:aRowNr |
930 |
"creates the editor for the row in a view and returns an editorAndModel, or nil" |
|
3771 | 931 |
|
1268 | 932 |
|val row| |
614 | 933 |
|
3264
642d79a1b0d6
care for non-exisiting columns (race condition)
Claus Gittinger <cg@exept.de>
parents:
3240
diff
changeset
|
934 |
row := dataSet at:aRowNr ifAbsent:[^ nil]. |
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
935 |
val := self extractColFromRow:row rowNr:aRowNr. |
614 | 936 |
|
833 | 937 |
val isText ifTrue:[val := val string]. |
3856 | 938 |
^ description editorOn:row at:aRowNr column:self value:val usingAdaptor:columnAdaptor. |
3264
642d79a1b0d6
care for non-exisiting columns (race condition)
Claus Gittinger <cg@exept.de>
parents:
3240
diff
changeset
|
939 |
|
642d79a1b0d6
care for non-exisiting columns (race condition)
Claus Gittinger <cg@exept.de>
parents:
3240
diff
changeset
|
940 |
"Modified: / 27-10-2007 / 10:26:15 / cg" |
2693 | 941 |
! ! |
942 |
||
943 |
!DataSetColumn methodsFor:'event handling'! |
|
944 |
||
945 |
doesNotUnderstand:aMessage |
|
946 |
||
947 |
(description respondsTo:(aMessage selector)) ifTrue:[ |
|
948 |
^ aMessage sendTo:description |
|
949 |
]. |
|
950 |
^ super doesNotUnderstand:aMessage |
|
951 |
||
952 |
! ! |
|
953 |
||
954 |
!DataSetColumn methodsFor:'grow & shrink'! |
|
955 |
||
956 |
growWidth:n |
|
957 |
"grow the width for n pixels |
|
958 |
" |
|
959 |
width := self width + n. |
|
960 |
||
961 |
||
962 |
! ! |
|
963 |
||
964 |
!DataSetColumn methodsFor:'initialization'! |
|
542 | 965 |
|
1147 | 966 |
on:aDSVColumnView description:aDescription columnNumber:aNumber label:aLabel |
542 | 967 |
"instance creation; set attributes dependent on the description |
968 |
" |
|
1089 | 969 |
columnNumber := aNumber. |
970 |
dataSet := aDSVColumnView. |
|
1147 | 971 |
label := aLabel. |
1487 | 972 |
|
1089 | 973 |
description := aDescription. |
974 |
rendererType := description rendererType. |
|
1496 | 975 |
containsText := ( rendererType ~~ #CheckToggle |
3505 | 976 |
and:[rendererType ~~ #RadioButton |
977 |
and:[rendererType ~~ #rowSelector]] |
|
1496 | 978 |
). |
1490 | 979 |
descWidth := description width. |
2424
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
980 |
longStringCompression := description longStringCompression. |
1526 | 981 |
|
982 |
description usePreferredWidth ifTrue:[ |
|
983 |
descWidth := 0 |
|
984 |
]. |
|
985 |
||
1565 | 986 |
width := nil. |
987 |
||
2693 | 988 |
minValue := description minValue. |
989 |
maxValue := description maxValue. |
|
1113 | 990 |
rowSeparatorSelector := description rowSeparatorSelector. |
1565 | 991 |
|
1113 | 992 |
showColSeparator := description showColSeparator. |
993 |
showRowSeparator := description showRowSeparator. |
|
1089 | 994 |
columnAdaptor := dataSet columnAdaptor. |
995 |
buttonExtent := 0 @ 0. |
|
996 |
columnAlignment := #left. |
|
584 | 997 |
|
1132 | 998 |
(backgroundColor := description backgroundColor) isNil ifTrue:[ |
999 |
backgroundColor := dataSet backgroundColor |
|
1000 |
] ifFalse:[ |
|
1480 | 1001 |
backgroundColor := backgroundColor onDevice:dataSet device |
584 | 1002 |
]. |
1113 | 1003 |
|
1004 |
(foregroundColor := description foregroundColor) isNil ifTrue:[ |
|
1005 |
foregroundColor := dataSet foregroundColor |
|
1006 |
] ifFalse:[ |
|
1480 | 1007 |
foregroundColor := foregroundColor onDevice:dataSet device |
584 | 1008 |
]. |
542 | 1009 |
|
1010 |
rendererType == #CheckToggle ifTrue:[ |
|
1113 | 1011 |
buttonExtent := dataSet checkToggleExtent. |
2067
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
1012 |
^ self |
542 | 1013 |
]. |
3505 | 1014 |
rendererType == #RadioButton ifTrue:[ |
1015 |
buttonExtent := dataSet radioButtonExtent. |
|
1016 |
^ self |
|
1017 |
]. |
|
542 | 1018 |
|
1019 |
rendererType == #rowSelector ifTrue:[ |
|
807 | 1020 |
buttonExtent := dataSet rowSelectorExtent. |
2067
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
1021 |
^ self |
542 | 1022 |
]. |
1023 |
||
1024 |
(rendererType == #ComboBox or:[rendererType == #ComboList]) ifTrue:[ |
|
807 | 1025 |
buttonExtent := dataSet comboButtonExtent. |
883 | 1026 |
] ifFalse:[ |
1027 |
columnAlignment := description columnAlignment |
|
542 | 1028 |
]. |
1029 |
||
2444 | 1030 |
"Modified: / 25.2.2000 / 14:25:56 / cg" |
2424
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
1031 |
! ! |
576621beeacb
Care for #longStringCompression
Stefan Vogel <sv@exept.de>
parents:
2420
diff
changeset
|
1032 |
|
621 | 1033 |
!DataSetColumn methodsFor:'private'! |
1034 |
||
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
1035 |
extractColFromRow:aRow rowNr:rowNr |
3320 | 1036 |
|readSelector col numArgs| |
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1037 |
|
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1038 |
readSelector := description readSelector. |
1226 | 1039 |
readSelector isNil ifTrue:[^ nil]. |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
1040 |
|
2862
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1041 |
readSelector isBlock ifTrue:[ |
3737 | 1042 |
"/ I dont use valueWithOptionalArgument:and:and:and: here, to make better use of inline caches... |
3320 | 1043 |
numArgs := readSelector numArgs. |
1044 |
numArgs == 0 ifTrue:[ |
|
2862
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1045 |
^ readSelector value |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1046 |
]. |
3320 | 1047 |
numArgs == 1 ifTrue:[ |
2862
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1048 |
^ readSelector value:aRow |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1049 |
]. |
3320 | 1050 |
numArgs == 2 ifTrue:[ |
2862
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1051 |
^ readSelector value:aRow value:columnNumber |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1052 |
]. |
3320 | 1053 |
numArgs == 3 ifTrue:[ |
2862
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1054 |
^ readSelector value:aRow value:columnNumber value:rowNr |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1055 |
]. |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1056 |
^ readSelector value:aRow value:columnNumber value:rowNr value:dataSet |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1057 |
]. |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1058 |
|
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
1059 |
columnAdaptor notNil ifTrue:[ |
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
1060 |
^ columnAdaptor perform:readSelector withOptionalArgument:aRow and:columnNumber and:rowNr and:dataSet |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
1061 |
]. |
2635
a8add4698dea
care for nil rows when extracting columns
Claus Gittinger <cg@exept.de>
parents:
2613
diff
changeset
|
1062 |
aRow isNil ifTrue:[^ nil]. |
a8add4698dea
care for nil rows when extracting columns
Claus Gittinger <cg@exept.de>
parents:
2613
diff
changeset
|
1063 |
|
4230 | 1064 |
(aRow isDictionary) ifTrue:[ |
3724
f4726b172c16
allow for dictionary to be used as row
Claus Gittinger <cg@exept.de>
parents:
3675
diff
changeset
|
1065 |
col := aRow at:readSelector |
f4726b172c16
allow for dictionary to be used as row
Claus Gittinger <cg@exept.de>
parents:
3675
diff
changeset
|
1066 |
] ifFalse:[ |
f4726b172c16
allow for dictionary to be used as row
Claus Gittinger <cg@exept.de>
parents:
3675
diff
changeset
|
1067 |
col := aRow perform:readSelector withOptionalArgument:columnNumber and:rowNr and:dataSet. |
f4726b172c16
allow for dictionary to be used as row
Claus Gittinger <cg@exept.de>
parents:
3675
diff
changeset
|
1068 |
]. |
2444 | 1069 |
^ col |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
1070 |
! |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
1071 |
|
2693 | 1072 |
storeCol:newValueArg inRow:aRow |
2862
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1073 |
|writeSelector numArgs newValue| |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
1074 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
1075 |
writeSelector := description writeSelector. |
1226 | 1076 |
writeSelector isNil ifTrue:[^ aRow]. |
1077 |
||
2693 | 1078 |
newValue := newValueArg. |
1079 |
(newValue isNumber) ifTrue:[ |
|
2862
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1080 |
minValue notNil ifTrue:[ |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1081 |
newValue < minValue ifTrue:[ |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1082 |
newValue := minValue |
2693 | 1083 |
] |
1084 |
]. |
|
2862
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1085 |
maxValue notNil ifTrue:[ |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1086 |
newValue > maxValue ifTrue:[ |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1087 |
newValue := maxValue |
2693 | 1088 |
] |
1089 |
]. |
|
1090 |
]. |
|
1091 |
||
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
1092 |
numArgs := writeSelector numArgs. |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
1093 |
|
2862
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1094 |
writeSelector isBlock ifTrue:[ |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1095 |
numArgs == 2 ifTrue:[ |
2863
c0585cbcd922
argument order when using write-store-blocks
Claus Gittinger <cg@exept.de>
parents:
2862
diff
changeset
|
1096 |
^ writeSelector value:newValue value:aRow |
2862
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1097 |
]. |
2863
c0585cbcd922
argument order when using write-store-blocks
Claus Gittinger <cg@exept.de>
parents:
2862
diff
changeset
|
1098 |
^ writeSelector value:newValue value:aRow value:columnNumber |
2862
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1099 |
]. |
3279303eabd8
allow for block in readselector/writeSelector
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1100 |
|
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
1101 |
columnAdaptor notNil ifTrue:[ |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
1102 |
numArgs == 2 ifTrue:[ |
2419
e0121908fffe
added longStringCompression flag
Claus Gittinger <cg@exept.de>
parents:
2222
diff
changeset
|
1103 |
columnAdaptor perform:writeSelector with:aRow with:newValue. |
e0121908fffe
added longStringCompression flag
Claus Gittinger <cg@exept.de>
parents:
2222
diff
changeset
|
1104 |
^ self |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
1105 |
]. |
2419
e0121908fffe
added longStringCompression flag
Claus Gittinger <cg@exept.de>
parents:
2222
diff
changeset
|
1106 |
columnAdaptor perform:writeSelector with:aRow with:columnNumber with:newValue. |
e0121908fffe
added longStringCompression flag
Claus Gittinger <cg@exept.de>
parents:
2222
diff
changeset
|
1107 |
^ self |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
1108 |
]. |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
1109 |
|
4230 | 1110 |
(aRow isDictionary) ifTrue:[ |
3724
f4726b172c16
allow for dictionary to be used as row
Claus Gittinger <cg@exept.de>
parents:
3675
diff
changeset
|
1111 |
aRow at:writeSelector put:newValue |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
1112 |
] ifFalse:[ |
3724
f4726b172c16
allow for dictionary to be used as row
Claus Gittinger <cg@exept.de>
parents:
3675
diff
changeset
|
1113 |
numArgs == 1 ifTrue:[ |
f4726b172c16
allow for dictionary to be used as row
Claus Gittinger <cg@exept.de>
parents:
3675
diff
changeset
|
1114 |
aRow perform:writeSelector with:newValue |
f4726b172c16
allow for dictionary to be used as row
Claus Gittinger <cg@exept.de>
parents:
3675
diff
changeset
|
1115 |
] ifFalse:[ |
f4726b172c16
allow for dictionary to be used as row
Claus Gittinger <cg@exept.de>
parents:
3675
diff
changeset
|
1116 |
aRow perform:writeSelector with:columnNumber with:newValue |
f4726b172c16
allow for dictionary to be used as row
Claus Gittinger <cg@exept.de>
parents:
3675
diff
changeset
|
1117 |
] |
1059 | 1118 |
]. |
621 | 1119 |
! ! |
1120 |
||
542 | 1121 |
!DataSetColumn methodsFor:'queries'! |
1122 |
||
1492 | 1123 |
canResize |
4117
b2eb0d2d0008
changed: #canResize - formatting
Stefan Vogel <sv@exept.de>
parents:
3992
diff
changeset
|
1124 |
^ containsText and:[descWidth == 0 or:[self hasRelativeWidth]] |
1492 | 1125 |
! |
1126 |
||
607 | 1127 |
canSelect:aRowNr |
3448
ef7d76d6bcfd
some comments changed into reasonable english
Claus Gittinger <cg@exept.de>
parents:
3364
diff
changeset
|
1128 |
"returns true if the cell in column is selectable. |
ef7d76d6bcfd
some comments changed into reasonable english
Claus Gittinger <cg@exept.de>
parents:
3364
diff
changeset
|
1129 |
(possibly calls the selectSelector, if any)" |
ef7d76d6bcfd
some comments changed into reasonable english
Claus Gittinger <cg@exept.de>
parents:
3364
diff
changeset
|
1130 |
|
2067
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
1131 |
|s row| |
607 | 1132 |
|
2067
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
1133 |
description canSelect ifFalse:[^ false]. |
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
1134 |
s := description selectSelector. |
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
1135 |
s isNil ifTrue:[^ true]. |
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
1136 |
|
3264
642d79a1b0d6
care for non-exisiting columns (race condition)
Claus Gittinger <cg@exept.de>
parents:
3240
diff
changeset
|
1137 |
row := dataSet at:aRowNr ifAbsent:[^ false]. |
2067
cda10b41aa0f
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
1138 |
columnAdaptor notNil ifTrue:[ |
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
1139 |
^ columnAdaptor perform:s withOptionalArgument:row and:columnNumber and:aRowNr and:dataSet |
607 | 1140 |
]. |
1141 |
||
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
1142 |
^ row perform:s withOptionalArgument:columnNumber and:aRowNr and:dataSet |
3264
642d79a1b0d6
care for non-exisiting columns (race condition)
Claus Gittinger <cg@exept.de>
parents:
3240
diff
changeset
|
1143 |
|
642d79a1b0d6
care for non-exisiting columns (race condition)
Claus Gittinger <cg@exept.de>
parents:
3240
diff
changeset
|
1144 |
"Modified: / 27-10-2007 / 10:27:20 / cg" |
607 | 1145 |
! |
1146 |
||
2864
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1147 |
choicesFor:aRow at:aRowNr |
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1148 |
|choicesSelector| |
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1149 |
|
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1150 |
choicesSelector := description choices. |
2897 | 1151 |
choicesSelector isNil ifTrue:[^ nil]. |
2864
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1152 |
|
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1153 |
columnAdaptor notNil ifTrue:[ |
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1154 |
^ columnAdaptor perform:choicesSelector withOptionalArgument:aRow and:columnNumber and:aRowNr and:dataSet |
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1155 |
]. |
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1156 |
^ aRow perform:choicesSelector withOptionalArgument:aRowNr and:columnNumber and:dataSet |
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1157 |
! |
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1158 |
|
647 | 1159 |
containsText |
1160 |
"returns true if text might exist |
|
1161 |
" |
|
1496 | 1162 |
^ containsText |
647 | 1163 |
! |
1164 |
||
2074 | 1165 |
doubleClickOn:aRowNr |
2694 | 1166 |
|sel row| |
2074 | 1167 |
|
1168 |
(sel := self doubleClickedSelector) notNil ifTrue:[ |
|
2694 | 1169 |
row := dataSet at:aRowNr. |
2074 | 1170 |
columnAdaptor notNil ifTrue:[ |
2694 | 1171 |
^ columnAdaptor perform:sel withOptionalArgument:row and:columnNumber and:aRowNr and:dataSet |
2074 | 1172 |
]. |
2694 | 1173 |
^ row perform:sel withOptionalArgument:columnNumber and:aRowNr and:dataSet |
2074 | 1174 |
]. |
1175 |
! |
|
1176 |
||
833 | 1177 |
hasChoices:aRowNr |
2864
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1178 |
|row| |
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1179 |
|
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1180 |
row := dataSet at:aRowNr. |
a2b8598dc659
fix: choices via columnAdaptor
Claus Gittinger <cg@exept.de>
parents:
2863
diff
changeset
|
1181 |
^ (self choicesFor:row at:aRowNr) notNil |
833 | 1182 |
! |
1183 |
||
1950 | 1184 |
hasPotentialNonConstantBackground |
1185 |
(backgroundColor notNil and:[backgroundColor isImageOrForm]) ifTrue:[^ true]. |
|
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1186 |
description backgroundSelector notNil ifTrue:[^ true]. |
1950 | 1187 |
^ false. |
1188 |
! |
|
1189 |
||
1484 | 1190 |
hasRelativeWidth |
1191 |
"returns true if width is relative |
|
1192 |
" |
|
4963 | 1193 |
^ descWidth isInteger not. "/ descWidth isLimitedPrecisionReal |
1484 | 1194 |
! |
1195 |
||
3240
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1196 |
hasRowSeparatorAt:rowNumber |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1197 |
|row bool| |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1198 |
|
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1199 |
rowSeparatorSelector isNil ifTrue:[^ true ]. |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1200 |
row := dataSet at:rowNumber. |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1201 |
|
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1202 |
columnAdaptor isNil ifTrue:[ |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1203 |
bool := row perform:rowSeparatorSelector. |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1204 |
] ifFalse:[ |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1205 |
bool := columnAdaptor perform:rowSeparatorSelector |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1206 |
withOptionalArgument:row and:columnNumber and:rowNumber and:dataSet. |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1207 |
]. |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1208 |
^ bool ~~ false |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1209 |
! |
2afa6e06b634
bugfix: columnAdapter notNil -> invoke rowSeparatorSelector
ca
parents:
3218
diff
changeset
|
1210 |
|
542 | 1211 |
heightOfHighestRow |
1725
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
1212 |
"returns the height of the highest row in pixels. |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
1213 |
Warning: |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
1214 |
only the first numberOfRowsProbedForColumnSize are probed, |
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
1215 |
in case the access is expensive (dataBase apps) |
3992 | 1216 |
If the descriptor defines a height, that is used, and the items are not probed at all. |
4331 | 1217 |
If the descriptor's height is -1 or #fontHeight, that is used. |
4332 | 1218 |
If the descriptor's height is #heightOfFirstRow, only the first columns height is probed. |
542 | 1219 |
" |
4331 | 1220 |
|h end bE editorType row1| |
542 | 1221 |
|
1496 | 1222 |
(h := description height) == 0 ifTrue:[ |
1223 |
containsText ifTrue:[ |
|
542 | 1224 |
"/ search first none empty drawable object |
2154
cb22be939082
split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
1225 |
end := description numberOfRowsProbedForColumnSize min:dataSet size. |
542 | 1226 |
|
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
1227 |
1 to:end do:[:rowNr| |row| |
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
1228 |
row := dataSet at:rowNr. |
2444 | 1229 |
h := h max:(self heightOfLabel:(self shownValueForRow:row rowNr:rowNr)) |
542 | 1230 |
] |
1231 |
] |
|
3992 | 1232 |
] ifFalse:[ |
4332 | 1233 |
((h == #heightOfFirstRow) or:[ h == #askFirst]) ifTrue:[ |
4335 | 1234 |
h := 0. |
1235 |
containsText ifTrue:[ |
|
1236 |
row1 := dataSet at:1. |
|
1237 |
row1 notNil ifTrue:[ |
|
1238 |
h := self heightOfLabel:(self shownValueForRow:row1 rowNr:1) |
|
1239 |
] |
|
1240 |
]. |
|
4331 | 1241 |
] ifFalse:[ |
1242 |
(h == #fontHeight or:[ h isNumber and:[h < 0] ]) ifTrue:[ |
|
1243 |
h := dataSet font heightOn:dataSet device. |
|
4335 | 1244 |
] ifFalse:[ |
1245 |
h := 0 |
|
4331 | 1246 |
]. |
3992 | 1247 |
]. |
542 | 1248 |
]. |
3992 | 1249 |
|
1559
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
1250 |
(bE := buttonExtent y) = 0 ifTrue:[ |
3505 | 1251 |
editorType := description editorType. |
1252 |
(editorType == #ComboList or:[ editorType == #ComboBox]) ifTrue:[ |
|
1559
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
1253 |
bE := dataSet comboButtonExtent y. |
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
1254 |
]. |
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
1255 |
]. |
1e7f30057e22
care for renderer==Text and editor==Comboxxx in
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
1256 |
^ h max:bE |
1725
897453804fa8
made numberOfRowsProbedForSize a variable;
Claus Gittinger <cg@exept.de>
parents:
1712
diff
changeset
|
1257 |
|
3992 | 1258 |
"Modified: / 20-01-2011 / 18:03:45 / cg" |
1113 | 1259 |
! |
1260 |
||
1147 | 1261 |
heightOfLabel:aLabel |
3462
d2df3607bfb5
mass operations: color selected-color
Claus Gittinger <cg@exept.de>
parents:
3460
diff
changeset
|
1262 |
"returns the height of the label" |
1147 | 1263 |
|
4332 | 1264 |
|h font| |
3992 | 1265 |
|
3462
d2df3607bfb5
mass operations: color selected-color
Claus Gittinger <cg@exept.de>
parents:
3460
diff
changeset
|
1266 |
aLabel isNil ifTrue:[ ^ 0 ]. |
4332 | 1267 |
font := dataSet font onDevice:dataSet device. |
3992 | 1268 |
|
4331 | 1269 |
((h := description height) == #fontHeight or:[ h isNumber and:[h < 0] ]) ifTrue:[ |
4332 | 1270 |
^ font height |
3992 | 1271 |
]. |
1272 |
||
3462
d2df3607bfb5
mass operations: color selected-color
Claus Gittinger <cg@exept.de>
parents:
3460
diff
changeset
|
1273 |
(aLabel isString) ifTrue:[ |
d2df3607bfb5
mass operations: color selected-color
Claus Gittinger <cg@exept.de>
parents:
3460
diff
changeset
|
1274 |
"/ if multiple lines - count 'em |
d2df3607bfb5
mass operations: color selected-color
Claus Gittinger <cg@exept.de>
parents:
3460
diff
changeset
|
1275 |
(aLabel includes:Character cr) ifTrue:[ |
d2df3607bfb5
mass operations: color selected-color
Claus Gittinger <cg@exept.de>
parents:
3460
diff
changeset
|
1276 |
^ aLabel asStringCollection inject:0 into:[:sumH :line | sumH + (line heightOn:dataSet)] |
d2df3607bfb5
mass operations: color selected-color
Claus Gittinger <cg@exept.de>
parents:
3460
diff
changeset
|
1277 |
]. |
4332 | 1278 |
^ font heightOf:aLabel |
1496 | 1279 |
]. |
3462
d2df3607bfb5
mass operations: color selected-color
Claus Gittinger <cg@exept.de>
parents:
3460
diff
changeset
|
1280 |
(aLabel isImageOrForm) ifTrue:[ |
4332 | 1281 |
^ font heightOf:aLabel |
3462
d2df3607bfb5
mass operations: color selected-color
Claus Gittinger <cg@exept.de>
parents:
3460
diff
changeset
|
1282 |
]. |
1147 | 1283 |
|
1496 | 1284 |
aLabel isSequenceable ifFalse:[ |
3462
d2df3607bfb5
mass operations: color selected-color
Claus Gittinger <cg@exept.de>
parents:
3460
diff
changeset
|
1285 |
^ aLabel |
d2df3607bfb5
mass operations: color selected-color
Claus Gittinger <cg@exept.de>
parents:
3460
diff
changeset
|
1286 |
perform:#heightOn: |
d2df3607bfb5
mass operations: color selected-color
Claus Gittinger <cg@exept.de>
parents:
3460
diff
changeset
|
1287 |
with:dataSet |
d2df3607bfb5
mass operations: color selected-color
Claus Gittinger <cg@exept.de>
parents:
3460
diff
changeset
|
1288 |
ifNotUnderstood:[ aLabel displayString heightOn:dataSet ] |
1147 | 1289 |
]. |
1290 |
||
3462
d2df3607bfb5
mass operations: color selected-color
Claus Gittinger <cg@exept.de>
parents:
3460
diff
changeset
|
1291 |
^ aLabel inject:0 into:[:sumH :line | sumH + (line heightOn:dataSet)]. |
3992 | 1292 |
|
1293 |
"Modified: / 20-01-2011 / 18:03:38 / cg" |
|
1147 | 1294 |
! |
1295 |
||
1937 | 1296 |
isResizeable |
1297 |
"returns true if the row is resizeable |
|
1298 |
" |
|
1299 |
^ description isResizeable |
|
1300 |
! |
|
1301 |
||
2542 | 1302 |
isRowVisible:rowNr |
1303 |
^ description rowIsVisible:(dataSet at:rowNr) |
|
1304 |
! |
|
1305 |
||
3767 | 1306 |
isSortable |
1307 |
^ description isSortable |
|
1308 |
! |
|
1309 |
||
1113 | 1310 |
showColSeparator |
1311 |
"returns true if column separator is on |
|
1312 |
" |
|
1313 |
^ showColSeparator |
|
1133 | 1314 |
! |
1315 |
||
1316 |
showSelectionHighLighted |
|
1317 |
"returns true if selection is highLighted |
|
1318 |
" |
|
1319 |
^ description showSelectionHighLighted ~~ false |
|
1147 | 1320 |
! |
1321 |
||
2865 | 1322 |
translatedChoicesFor:aRow at:aRowNr |
1323 |
|translatedChoicesSelector| |
|
1324 |
||
1325 |
translatedChoicesSelector := description translatedChoices. |
|
1326 |
||
1327 |
columnAdaptor notNil ifTrue:[ |
|
1328 |
^ columnAdaptor perform:translatedChoicesSelector withOptionalArgument:aRow and:columnNumber and:aRowNr and:dataSet |
|
1329 |
]. |
|
1330 |
^ aRow perform:translatedChoicesSelector withOptionalArgument:aRowNr and:columnNumber and:dataSet |
|
1331 |
! |
|
1332 |
||
1147 | 1333 |
widthOfLabel:aLabel |
1334 |
"returns the width of the label |
|
1335 |
" |
|
1496 | 1336 |
|w| |
1147 | 1337 |
|
1496 | 1338 |
(aLabel isString or:[aLabel isImageOrForm]) ifTrue:[ |
1339 |
^ aLabel widthOn:dataSet |
|
1340 |
]. |
|
1147 | 1341 |
aLabel isNil ifTrue:[ ^ 0 ]. |
1342 |
||
1496 | 1343 |
aLabel isSequenceable ifFalse:[ |
1344 |
^ aLabel perform:#widthOn: with:dataSet ifNotUnderstood:[ |
|
1345 |
aLabel displayString widthOn:dataSet |
|
1346 |
] |
|
1147 | 1347 |
]. |
1348 |
||
1496 | 1349 |
w := 0. |
1350 |
aLabel do:[:el|w := w max:(el widthOn:dataSet)]. |
|
1351 |
^ w |
|
542 | 1352 |
! ! |
1353 |
||
1354 |
!DataSetColumn methodsFor:'searching'! |
|
1355 |
||
1356 |
findRowNrStartingWithChar:aChar start:start stop:stop |
|
1357 |
"find the first row starting at start to stop, which drawable label |
|
1358 |
starts with the character, aChar. The index of the detected row is |
|
1359 |
returned or if no row is found 0. |
|
1360 |
" |
|
1361 |
|char| |
|
1362 |
||
1496 | 1363 |
containsText ifTrue:[ |
542 | 1364 |
char := aChar asLowercase. |
1365 |
||
2211
f14db8e094b9
pass rowNr and dataSet as additional args to
Claus Gittinger <cg@exept.de>
parents:
2154
diff
changeset
|
1366 |
start to:stop do:[:eachNr| |row lbl| |
2636
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1367 |
(dataSet isRowSelectable:eachNr) ifTrue:[ |
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1368 |
row := dataSet at:eachNr. |
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1369 |
lbl := self shownValueForRow:row rowNr:eachNr. |
1147 | 1370 |
|
2636
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1371 |
(lbl isSequenceable and:[lbl isString not]) ifTrue:[ |
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1372 |
lbl := lbl at:1 ifAbsent:nil |
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1373 |
]. |
542 | 1374 |
|
2636
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1375 |
(lbl respondsTo:#string) ifTrue:[ |
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1376 |
lbl := lbl string. |
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1377 |
(lbl size ~~ 0 and:[(lbl at:1) asLowercase == char]) ifTrue:[ |
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1378 |
^ eachNr |
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1379 |
] |
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1380 |
] ifFalse:[ |
4248 | 1381 |
lbl notNil ifTrue:[ ^ 0 ]. |
2636
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1382 |
]. |
103067a67ff9
add selectConditionBlock: to enable the selection of a row
ca
parents:
2635
diff
changeset
|
1383 |
]. |
542 | 1384 |
] |
1385 |
]. |
|
1386 |
^ 0 |
|
1387 |
! ! |
|
1388 |
||
1389 |
!DataSetColumn class methodsFor:'documentation'! |
|
1390 |
||
1391 |
version |
|
4821 | 1392 |
^ '$Header$' |
3767 | 1393 |
! |
1394 |
||
1395 |
version_CVS |
|
4821 | 1396 |
^ '$Header$' |
542 | 1397 |
! ! |
4230 | 1398 |