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