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