author | ca |
Tue, 08 Jul 2008 11:40:49 +0200 | |
changeset 3466 | e35f9173be58 |
parent 3465 | b7dd0aa96e3a |
child 3467 | f2212331f4e5 |
permissions | -rw-r--r-- |
542 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by Claus Gittinger / eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
1844 | 12 |
"{ Package: 'stx:libwidg2' }" |
13 |
||
824 | 14 |
SimpleView subclass:#DSVLabelView |
2146 | 15 |
instanceVariableNames:'dataSet lineDrag columns selection enabled preferredHeight |
16 |
handleCursor tabSpacing opaqueColumnResize verticalLabelSpacing' |
|
542 | 17 |
classVariableNames:'' |
18 |
poolDictionaries:'' |
|
19 |
category:'Views-DataSet' |
|
20 |
! |
|
21 |
||
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
22 |
Object subclass:#LineDrag |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
23 |
instanceVariableNames:'rootView topX topY botY column minX startX transX' |
1491 | 24 |
classVariableNames:'' |
25 |
poolDictionaries:'' |
|
26 |
privateIn:DSVLabelView |
|
27 |
! |
|
28 |
||
542 | 29 |
!DSVLabelView class methodsFor:'documentation'! |
30 |
||
31 |
copyright |
|
32 |
" |
|
33 |
COPYRIGHT (c) 1997 by Claus Gittinger / eXept Software AG |
|
34 |
All Rights Reserved |
|
35 |
||
36 |
This software is furnished under a license and may be used |
|
37 |
only in accordance with the terms of that license and with the |
|
38 |
inclusion of the above copyright notice. This software may not |
|
39 |
be provided or otherwise made available to, or used by, any |
|
40 |
other person. No title to or ownership of the software is |
|
41 |
hereby transferred. |
|
42 |
" |
|
43 |
||
44 |
||
45 |
||
46 |
||
47 |
! |
|
48 |
||
49 |
documentation |
|
50 |
" |
|
2789 | 51 |
shows the labels assigned to the column descriptions. |
52 |
Used as the title-part of a DataSetView. |
|
542 | 53 |
|
54 |
[Instance variables:] |
|
55 |
||
1487 | 56 |
dataSet <DSVColumnView> column view which shows the columns |
824 | 57 |
|
1487 | 58 |
selection <Integer or nil> current selected index or nil. |
824 | 59 |
|
1086 | 60 |
enabled <Boolean> if a press action exists on a column |
61 |
entry, this action could be enabled or |
|
62 |
disabled. |
|
63 |
||
1487 | 64 |
preferredHeight <Integer> the preferred height of the labelView |
1086 | 65 |
|
542 | 66 |
|
67 |
[author:] |
|
68 |
Claus Atzkern |
|
69 |
||
70 |
[see also:] |
|
71 |
DSVColumnView |
|
72 |
DataSetColumnSpec |
|
73 |
DataSetColumn |
|
74 |
DataSetView |
|
75 |
" |
|
76 |
! ! |
|
77 |
||
1940 | 78 |
!DSVLabelView class methodsFor:'accessing'! |
79 |
||
80 |
tabSpacing |
|
81 |
"returns the tab spacing |
|
82 |
" |
|
83 |
^ 2 |
|
84 |
! ! |
|
85 |
||
1844 | 86 |
!DSVLabelView class methodsFor:'defaults'! |
87 |
||
88 |
defaultFont |
|
89 |
^ DSVColumnView defaultFont |
|
90 |
! ! |
|
91 |
||
1487 | 92 |
!DSVLabelView methodsFor:'accessing'! |
824 | 93 |
|
1487 | 94 |
columns:aListOfColumns |
95 |
"the list of columns changed |
|
824 | 96 |
" |
2152
6c52408279f9
halts and unused methods removed
Claus Gittinger <cg@exept.de>
parents:
2151
diff
changeset
|
97 |
aListOfColumns = columns ifTrue:[^ self]. |
2150 | 98 |
|
1487 | 99 |
columns := aListOfColumns. |
100 |
preferredHeight := nil. |
|
101 |
selection := nil. |
|
102 |
||
2146 | 103 |
self changed:#columnLayout. |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
104 |
! |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
105 |
|
1931 | 106 |
opaqueColumnResize |
107 |
^ opaqueColumnResize |
|
108 |
! |
|
109 |
||
110 |
opaqueColumnResize:aBoolean |
|
111 |
opaqueColumnResize := aBoolean |
|
884 | 112 |
! ! |
113 |
||
824 | 114 |
!DSVLabelView methodsFor:'drawing'! |
115 |
||
1487 | 116 |
invalidate |
2146 | 117 |
(shown) ifTrue:[ |
1487 | 118 |
super invalidate |
1408
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
119 |
] |
824 | 120 |
! |
121 |
||
1487 | 122 |
invalidateItemAt:anIndex |
123 |
"invalidate rectangle assigned to an item at an index |
|
824 | 124 |
" |
1487 | 125 |
|cL xL xR hg| |
126 |
||
2146 | 127 |
(shown) ifTrue:[ |
1487 | 128 |
cL := columns at:anIndex ifAbsent:[^ nil]. |
2146 | 129 |
xL := self xVisibleOfColNr:anIndex. |
1487 | 130 |
xR := xL + cL width. |
131 |
||
132 |
(xL < width and:[xR > 0]) ifTrue:[ |
|
133 |
xL := xL max:0. |
|
134 |
xR := xR min:width. |
|
135 |
hg := height - margin - margin. |
|
136 |
||
137 |
self invalidate:(Rectangle left:xL top:margin width:(xR - xL) height:hg) |
|
138 |
] |
|
139 |
] |
|
1408
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
140 |
! |
562 | 141 |
|
2146 | 142 |
redrawColumnsInX:x y:y width:w height:h |
824 | 143 |
"redraw a rectangle |
637 | 144 |
" |
1605 | 145 |
|savClip bg fg fgColor bgColor |
1487 | 146 |
inset "{ Class:SmallInteger }" |
147 |
maxX "{ Class:SmallInteger }" |
|
1524
b7f986aa45f4
visibility of label; show as button (yes/no)
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
148 |
lblH "{ Class:SmallInteger }" |
1487 | 149 |
wt "{ Class:SmallInteger }" |
150 |
x1 "{ Class:SmallInteger }" |
|
151 |
x0 "{ Class:SmallInteger }" |
|
152 |
| |
|
2146 | 153 |
(shown) ifFalse:[^ self]. |
824 | 154 |
|
1487 | 155 |
bgColor := dataSet backgroundColor. |
824 | 156 |
self paint:bgColor. |
157 |
self fillRectangleX:x y:y width:w height:h. |
|
158 |
||
1487 | 159 |
columns isEmpty ifTrue:[^ self]. |
160 |
||
161 |
fgColor := dataSet foregroundColor. |
|
162 |
inset := dataSet horizontalSpacing + 1. |
|
163 |
maxX := (x + w) min:(width - margin). |
|
1524
b7f986aa45f4
visibility of label; show as button (yes/no)
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
164 |
lblH := height - margin - margin. |
824 | 165 |
savClip := clipRect. |
859 | 166 |
|
2146 | 167 |
x1 := self xVisibleOfColNr:1. |
824 | 168 |
|
1487 | 169 |
columns keysAndValuesDo:[:aKey :aCol| |anItem| |
170 |
anItem := aCol label. |
|
171 |
wt := aCol width. |
|
172 |
x0 := x1. |
|
173 |
x1 := x1 + wt. |
|
824 | 174 |
|
1487 | 175 |
(x1 > x and:[x0 < maxX]) ifTrue:[ |
1940 | 176 |
|left right rect| |
177 |
||
178 |
left := x0 max:x. |
|
179 |
right := x1 min:maxX. |
|
180 |
rect := Rectangle left:left top:y width:(right - left) height:h. |
|
181 |
||
182 |
clipRect := nil. |
|
183 |
self clippingRectangle:rect. |
|
184 |
||
1487 | 185 |
fg := (anItem foregroundColor) ? fgColor. |
186 |
||
907 | 187 |
(bg := anItem backgroundColor) notNil ifTrue:[ |
188 |
bg ~= bgColor ifTrue:[ |
|
189 |
self paint:bg. |
|
1524
b7f986aa45f4
visibility of label; show as button (yes/no)
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
190 |
self fillRectangleX:x0 y:margin width:wt height:lblH. |
907 | 191 |
] |
192 |
] ifFalse:[ |
|
193 |
bg := bgColor |
|
194 |
]. |
|
824 | 195 |
|
2146 | 196 |
self paint:fg on:bg. |
1487 | 197 |
anItem redrawX:x0 w:wt h:height inset:inset on:self. |
1524
b7f986aa45f4
visibility of label; show as button (yes/no)
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
198 |
] |
824 | 199 |
]. |
2146 | 200 |
! |
201 |
||
202 |
redrawEdgesX:x y:yTop width:aWidth height:aHeight |
|
203 |
"redraw the edges in the range |
|
204 |
" |
|
3464 | 205 |
|desc startOfTabX endOfTabX lastColumn has3Dseparators |
2146 | 206 |
maxX "{ Class:SmallInteger }" |
207 |
h "{ Class:SmallInteger }" |
|
208 |
x1 "{ Class:SmallInteger }" |
|
209 |
x0 "{ Class:SmallInteger }" |
|
210 |
y0 "{ Class:SmallInteger }" |
|
211 |
absLabelLevel |
|
212 |
| |
|
213 |
||
3464 | 214 |
|
2146 | 215 |
maxX := (x + aWidth) min:(width - margin). |
216 |
absLabelLevel := 1. |
|
217 |
x1 := self xVisibleOfColNr:1. |
|
218 |
||
219 |
y0 := margin. |
|
220 |
h := height - margin - margin. |
|
3464 | 221 |
|
222 |
has3Dseparators := dataSet has3Dseparators. |
|
223 |
lastColumn := columns last. |
|
224 |
||
2146 | 225 |
columns keysAndValuesDo:[:aKey :aCol| |
226 |
desc := aCol description. |
|
227 |
x0 := x1. |
|
228 |
x1 := x1 + aCol width. |
|
229 |
||
3464 | 230 |
endOfTabX := nil. |
231 |
||
2146 | 232 |
aKey == selection ifTrue:[ |
3464 | 233 |
startOfTabX notNil ifTrue:[ endOfTabX := x0 ]. |
234 |
||
2146 | 235 |
(x1 > x and:[x0 < maxX]) ifTrue:[ |
3464 | 236 |
dataSet drawEdgesAtX:x0 y:y0 width:(x1 - x0) height:h level:-1 on:self. |
2146 | 237 |
]. |
3464 | 238 |
|
2146 | 239 |
] ifFalse:[ |
3464 | 240 |
desc labelHasButtonLayout ifTrue:[ |
3466 | 241 |
startOfTabX isNil ifTrue:[ startOfTabX := x0 ]. |
242 |
||
3464 | 243 |
(desc== lastColumn or:[desc labelIsPartOfGroup not]) ifTrue:[ |
244 |
endOfTabX := x1. |
|
245 |
] |
|
246 |
] ifFalse:[ |
|
247 |
startOfTabX notNil ifTrue:[ |
|
248 |
endOfTabX := x0. |
|
249 |
]. |
|
250 |
]. |
|
2146 | 251 |
]. |
3464 | 252 |
endOfTabX notNil ifTrue:[ |
253 |
startOfTabX isNil ifTrue:[ startOfTabX := x0 ]. |
|
254 |
||
255 |
startOfTabX < endOfTabX ifTrue:[ |
|
256 |
(endOfTabX > x and:[startOfTabX < maxX]) ifTrue:[ |
|
257 |
has3Dseparators ifTrue:[ |
|
258 |
dataSet drawEdgesAtX:startOfTabX y:y0 width:(endOfTabX - startOfTabX) height:h level:absLabelLevel on:self. |
|
259 |
] ifFalse:[ |
|
260 |
self paint:(dataSet separatorOneDColor). |
|
261 |
self displayLineFromX:endOfTabX-1 y:0 toX:endOfTabX-1 y:h. |
|
262 |
]. |
|
263 |
]. |
|
2146 | 264 |
]. |
3464 | 265 |
startOfTabX := nil. |
266 |
]. |
|
2146 | 267 |
]. |
268 |
||
3464 | 269 |
has3Dseparators ifTrue:[ |
270 |
x1 < (maxX - absLabelLevel - absLabelLevel - 3) ifTrue:[ |
|
271 |
dataSet |
|
272 |
drawEdgesAtX:x1 y:y0 |
|
273 |
width:(width"-margin"-x1"-absLabelLevel") height:h |
|
274 |
level:absLabelLevel on:self |
|
275 |
]. |
|
2146 | 276 |
]. |
277 |
! |
|
278 |
||
279 |
redrawX:x y:y width:wArg height:h |
|
280 |
|savClip w| |
|
281 |
||
282 |
(shown) ifFalse:[^ self]. |
|
283 |
||
284 |
w := wArg. |
|
285 |
self redrawColumnsInX:x y:y width:w height:h. |
|
286 |
||
287 |
super redrawX:x y:y width:w height:h. |
|
288 |
||
289 |
"/ (x + w) >= (width-margin) ifTrue:[ |
|
290 |
"/ w := (width-margin) - 1 - x. |
|
291 |
"/ ]. |
|
3324
bdd503be73d1
redraw when there are no columns
Claus Gittinger <cg@exept.de>
parents:
3216
diff
changeset
|
292 |
columns notEmpty ifTrue:[ |
bdd503be73d1
redraw when there are no columns
Claus Gittinger <cg@exept.de>
parents:
3216
diff
changeset
|
293 |
savClip := clipRect. |
bdd503be73d1
redraw when there are no columns
Claus Gittinger <cg@exept.de>
parents:
3216
diff
changeset
|
294 |
self clippingRectangle:(Rectangle left:x top:margin width:w height:height-margin-margin). |
bdd503be73d1
redraw when there are no columns
Claus Gittinger <cg@exept.de>
parents:
3216
diff
changeset
|
295 |
self redrawEdgesX:x y:y width:w height:h. |
bdd503be73d1
redraw when there are no columns
Claus Gittinger <cg@exept.de>
parents:
3216
diff
changeset
|
296 |
self clippingRectangle:savClip. |
bdd503be73d1
redraw when there are no columns
Claus Gittinger <cg@exept.de>
parents:
3216
diff
changeset
|
297 |
] |
637 | 298 |
! ! |
299 |
||
2820 | 300 |
!DSVLabelView methodsFor:'enumerating columns'! |
301 |
||
302 |
columnsDo:aOneArgBlock |
|
303 |
"evaluate the argument, aOneArgBlock for every column" |
|
304 |
||
305 |
columns do:aOneArgBlock |
|
306 |
! ! |
|
307 |
||
637 | 308 |
!DSVLabelView methodsFor:'event handling'! |
542 | 309 |
|
1491 | 310 |
buttonMotion:state x:x y:y |
1585
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
311 |
"mouse-button was moved; |
1491 | 312 |
redraw thumb at its new position and, if scroll-mode is asynchronous, |
313 |
the scroll action is performed |
|
314 |
" |
|
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
315 |
|colNr x1 col| |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
316 |
|
1958 | 317 |
state = 0 ifTrue:[ |
318 |
lineDrag := nil. |
|
319 |
]. |
|
320 |
||
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
321 |
lineDrag notNil ifTrue:[ |
1932 | 322 |
(opaqueColumnResize ? (UserPreferences current opaqueTableColumnResizing == true)) ifTrue:[ |
1939 | 323 |
lineDrag moveToX:x. |
324 |
dataSet changeWidthOfColumn:lineDrag column deltaX:lineDrag deltaX. |
|
325 |
lineDrag resetDeltaX. |
|
326 |
] ifFalse:[ |
|
327 |
lineDrag invertLine. "/ off |
|
328 |
lineDrag moveToX:x. |
|
329 |
lineDrag invertLine. "/ on |
|
1931 | 330 |
]. |
331 |
^ self. |
|
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
332 |
]. |
1491 | 333 |
|
1585
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
334 |
"/ in the resize area ? |
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
335 |
colNr := self xVisibleToColNr:(x-tabSpacing). |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
336 |
colNr notNil ifTrue:[ |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
337 |
col := columns at:colNr. |
1937 | 338 |
|
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
339 |
(col notNil and:[col isResizeable]) ifTrue:[ |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
340 |
x1 := self xVisibleOfColNr:(colNr + 1). |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
341 |
(x between:(x1-tabSpacing) and:(x1+tabSpacing)) |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
342 |
"/ x + tabSpacing > x1 |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
343 |
ifTrue:[ |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
344 |
self cursor:handleCursor. |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
345 |
^ self |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
346 |
]. |
1585
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
347 |
]. |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
348 |
]. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
349 |
self cursor:(Cursor normal) |
3212 | 350 |
|
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
351 |
"Modified: / 26-03-2007 / 15:20:27 / cg" |
1491 | 352 |
! |
353 |
||
637 | 354 |
buttonPress:button x:x y:y |
824 | 355 |
"handle a button press event; checks whether the item under the mouse |
356 |
is selectable. If true, the selection is set to the item. |
|
637 | 357 |
" |
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
358 |
|x1 colNr col| |
1491 | 359 |
|
2146 | 360 |
(enabled and:[shown]) ifFalse:[ |
1491 | 361 |
^ self |
362 |
]. |
|
363 |
||
1585
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
364 |
"/ in the resize area ? |
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
365 |
colNr := self xVisibleToColNr:(x-tabSpacing). |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
366 |
colNr notNil ifTrue:[ |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
367 |
col := columns at:colNr. |
1937 | 368 |
col isResizeable ifTrue:[ |
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
369 |
x1 := self xVisibleOfColNr:(colNr + 1). |
3212 | 370 |
(x between:(x1-tabSpacing) and:(x1+tabSpacing)) ifTrue:[ |
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
371 |
col := columns at:colNr ifAbsent:nil. |
1937 | 372 |
self cursor:handleCursor. |
373 |
||
374 |
lineDrag := LineDrag new. |
|
375 |
lineDrag column:col |
|
376 |
x:x |
|
377 |
y:margin |
|
378 |
h:(self height + dataSet height) |
|
379 |
minX:(x1 - col width + col minimumRequiredWidth) |
|
380 |
on:self. |
|
1939 | 381 |
(opaqueColumnResize ? (UserPreferences current opaqueTableColumnResizing == true)) ifFalse:[ |
382 |
lineDrag invertLine. |
|
383 |
]. |
|
3212 | 384 |
^ self |
1937 | 385 |
] |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
386 |
] |
1491 | 387 |
]. |
1585
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
388 |
|
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
389 |
colNr := self xVisibleToColNr:x. |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
390 |
colNr notNil ifTrue:[ |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
391 |
col := columns at:colNr. |
1585
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
392 |
col label isSelectable ifTrue:[ |
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
393 |
self invalidateItemAt:(selection := colNr) |
3212 | 394 |
]. |
1585
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
395 |
]. |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
396 |
self cursor:(Cursor normal). |
3212 | 397 |
|
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
398 |
"Modified: / 26-03-2007 / 15:21:00 / cg" |
542 | 399 |
! |
400 |
||
637 | 401 |
buttonRelease:button x:x y:y |
824 | 402 |
"handle a button press event; checks whether the item under the mouse |
403 |
is the selected item. If true, the application is informed. |
|
404 |
" |
|
1491 | 405 |
|selected index column deltaX| |
824 | 406 |
|
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
407 |
self cursor:(Cursor normal). |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
408 |
|
1487 | 409 |
selection isNil ifTrue:[ |
1933 | 410 |
lineDrag notNil ifTrue:[ |
1939 | 411 |
(opaqueColumnResize ? (UserPreferences current opaqueTableColumnResizing == true)) ifFalse:[ |
2150 | 412 |
lineDrag invertLine. |
1932 | 413 |
column := lineDrag column. |
414 |
deltaX := lineDrag deltaX. |
|
1491 | 415 |
|
1932 | 416 |
deltaX abs > 0 "2" ifTrue:[ |
417 |
dataSet changeWidthOfColumn:column deltaX:deltaX |
|
418 |
] |
|
419 |
]. |
|
1933 | 420 |
lineDrag := nil. |
1491 | 421 |
]. |
1085 | 422 |
^ self |
423 |
]. |
|
1487 | 424 |
index := self xVisibleToSelectionIndex:x. |
425 |
selected := index == selection. |
|
1491 | 426 |
index := selection. |
1487 | 427 |
selection := nil. |
1085 | 428 |
|
1487 | 429 |
self invalidateItemAt:index. |
430 |
||
431 |
selected ifTrue:[ |
|
432 |
(columns at:index) label sendClickMsgTo:(self application) |
|
1085 | 433 |
] |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
434 |
! |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
435 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
436 |
pointerLeave:state |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
437 |
"mouse left view - restore cursor. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
438 |
" |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
439 |
self sensor anyButtonPressed ifFalse:[ |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
440 |
self cursor:(Cursor normal) |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
441 |
]. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
442 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
443 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
444 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
445 |
! |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
446 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
447 |
xVisibleToColNr:x |
3212 | 448 |
"returns the column number for a physical x position. |
449 |
Returns nil if x is behond the last column." |
|
450 |
||
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
451 |
|x0 x1| |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
452 |
|
2146 | 453 |
x1 := self xVisibleOfColNr:1. |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
454 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
455 |
columns keysAndValuesDo:[:index :aCol| |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
456 |
x0 := x1. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
457 |
x1 := x0 + aCol width. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
458 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
459 |
(x1 > x and:[x0 < x]) ifTrue:[ |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
460 |
^ index |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
461 |
] |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
462 |
]. |
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
463 |
^ nil |
3212 | 464 |
|
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
465 |
"Modified: / 26-03-2007 / 15:21:37 / cg" |
824 | 466 |
! ! |
467 |
||
3188 | 468 |
!DSVLabelView methodsFor:'focus handling'! |
469 |
||
470 |
canTab |
|
471 |
^ false |
|
472 |
! |
|
473 |
||
474 |
wantsFocusWithButtonPress |
|
475 |
"never wants the focus - view which keeps the labels |
|
476 |
" |
|
477 |
^ false |
|
478 |
! ! |
|
479 |
||
3214 | 480 |
!DSVLabelView methodsFor:'help'! |
481 |
||
482 |
flyByHelpTextAt:aPoint |
|
483 |
"return the helpText for aPoint (i.e. when mouse-pointer is moved over an item)." |
|
484 |
||
485 |
|colNr col| |
|
486 |
||
487 |
columns isEmpty ifTrue:[^ nil]. |
|
488 |
colNr := self xVisibleToColNr:aPoint x. |
|
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
489 |
colNr notNil ifTrue:[ |
3214 | 490 |
col := columns at:colNr. |
491 |
^ col activeHelpText. |
|
492 |
]. |
|
493 |
^ nil |
|
494 |
||
495 |
"Created: / 26-03-2007 / 13:43:20 / cg" |
|
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
496 |
"Modified: / 26-03-2007 / 15:21:07 / cg" |
3214 | 497 |
! ! |
498 |
||
2146 | 499 |
!DSVLabelView methodsFor:'initialization'! |
500 |
||
501 |
initStyle |
|
2924 | 502 |
<resource: #style (#'dataSet.labelView.level' |
503 |
#'dataSet.labelView.verticalSpace' |
|
504 |
)> |
|
505 |
||
2146 | 506 |
super initStyle. |
507 |
||
508 |
handleCursor := (VariablePanel cursorForOrientation:#horizontal onDevice:device) onDevice:device. |
|
2685 | 509 |
font := (self class defaultFont) onDevice:device. |
2146 | 510 |
"/ self level:0. |
2924 | 511 |
self level:(styleSheet at:#'dataSet.labelView.level' default:-1). |
512 |
verticalLabelSpacing := (styleSheet at:#'dataSet.labelView.verticalSpace' default:2). |
|
2146 | 513 |
! |
514 |
||
515 |
initialize |
|
516 |
super initialize. |
|
517 |
"/ super level:(self defaultLevel). |
|
518 |
||
519 |
enabled := true. |
|
520 |
columns := #(). |
|
521 |
tabSpacing := self class tabSpacing. |
|
522 |
||
523 |
self enableMotionEvents. |
|
524 |
! ! |
|
525 |
||
824 | 526 |
!DSVLabelView methodsFor:'instance creation'! |
527 |
||
528 |
for:aColumnView |
|
529 |
"initialization |
|
530 |
" |
|
1491 | 531 |
dataSet := aColumnView. |
2146 | 532 |
"/ self level:(dataSet level). |
533 |
"/ self borderWidth:(dataSet borderWidth). |
|
1085 | 534 |
! |
535 |
||
1487 | 536 |
realize |
537 |
"recompute contents and fit columns to view |
|
538 |
" |
|
539 |
self bitGravity:#NorthWest. |
|
540 |
super realize. |
|
824 | 541 |
! ! |
542 |
||
1487 | 543 |
!DSVLabelView methodsFor:'queries'! |
824 | 544 |
|
1487 | 545 |
enabled |
546 |
"true, if widget is enabled |
|
547 |
" |
|
548 |
^ enabled |
|
549 |
! |
|
550 |
||
551 |
enabled:aState |
|
552 |
"true, if widget is enabled |
|
542 | 553 |
" |
1487 | 554 |
enabled := aState. |
555 |
! |
|
556 |
||
2146 | 557 |
preferredHeight |
558 |
|h| |
|
559 |
||
560 |
preferredHeight notNil ifTrue:[ |
|
561 |
^ preferredHeight |
|
562 |
]. |
|
1487 | 563 |
|
2146 | 564 |
h := 0. |
565 |
columns do:[:c | h := (c label preferredHeight) max:h ]. |
|
566 |
^ self margin + verticalLabelSpacing + h + verticalLabelSpacing + self margin |
|
567 |
! |
|
568 |
||
569 |
xVisibleOfColNr:colNr |
|
570 |
"/ must adjust, because dataset includes its own margin, which might be different from ours |
|
571 |
||
572 |
^ (dataSet xVisibleOfColNr:colNr) - dataSet margin + margin |
|
824 | 573 |
! |
574 |
||
1487 | 575 |
xVisibleToSelectionIndex:x |
576 |
"returns the column number assigned to a physical x or nil. If |
|
577 |
the column exists but is not selectable nil is returned. |
|
824 | 578 |
" |
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
579 |
|
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
580 |
|colNr column| |
824 | 581 |
|
2146 | 582 |
(shown and:[enabled]) ifTrue:[ |
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
583 |
((colNr := dataSet xVisibleToColNr:x) notNil |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
584 |
and:[(column := columns at:colNr) notNil |
1487 | 585 |
and:[column label isSelectable]] |
586 |
) ifTrue:[ |
|
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
587 |
^ colNr |
1487 | 588 |
] |
824 | 589 |
]. |
1487 | 590 |
^ nil |
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
591 |
|
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
592 |
"Modified: / 26-03-2007 / 15:21:27 / cg" |
824 | 593 |
! ! |
594 |
||
1487 | 595 |
!DSVLabelView methodsFor:'scrolling'! |
824 | 596 |
|
1487 | 597 |
copyFromX:x0 y:y0 toX:x1 y:y1 width:w invalidateX:leftX |
824 | 598 |
|
2146 | 599 |
(shown) ifFalse:[^ self]. |
824 | 600 |
|
1487 | 601 |
(self sensor hasDamageFor:self) ifTrue:[ |
602 |
self invalidate |
|
603 |
] ifFalse:[ |
|
604 |
self copyFrom:self x:x0 y:y0 toX:x1 y:y1 width:w height:height async:false. |
|
605 |
self invalidate:(Rectangle left:leftX top:0 width:(width - w) height:height) |
|
606 |
repairNow:true |
|
607 |
] |
|
824 | 608 |
! ! |
609 |
||
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
610 |
!DSVLabelView::LineDrag methodsFor:'accessing'! |
1491 | 611 |
|
612 |
column |
|
613 |
"return the value of the instance variable 'column' (automatically generated)" |
|
614 |
||
1931 | 615 |
^ column |
616 |
! |
|
1491 | 617 |
|
618 |
deltaX |
|
619 |
"returns the distance x between the start and end action |
|
620 |
" |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
621 |
^ topX - startX |
1931 | 622 |
! |
623 |
||
624 |
resetDeltaX |
|
625 |
startX := topX |
|
1491 | 626 |
! ! |
627 |
||
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
628 |
!DSVLabelView::LineDrag methodsFor:'dragging'! |
1491 | 629 |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
630 |
invertLine |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
631 |
"invert for a line |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
632 |
" |
2027
e61da28e7ffc
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1959
diff
changeset
|
633 |
|c rootDevice| |
e61da28e7ffc
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1959
diff
changeset
|
634 |
|
e61da28e7ffc
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1959
diff
changeset
|
635 |
rootDevice := rootView device. |
1939 | 636 |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
637 |
rootView clippedByChildren:false. |
1491 | 638 |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
639 |
rootView xoring:[ |
2027
e61da28e7ffc
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1959
diff
changeset
|
640 |
rootView paint:(Color colorId:(rootDevice blackpixel bitXor:rootDevice whitepixel)). |
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
641 |
rootView lineWidth:2. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
642 |
rootView displayLineFromX:topX y:topY toX:topX y:botY. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
643 |
rootView flush |
2027
e61da28e7ffc
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1959
diff
changeset
|
644 |
] |
e61da28e7ffc
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1959
diff
changeset
|
645 |
|
e61da28e7ffc
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1959
diff
changeset
|
646 |
"Modified: / 10.10.2001 / 15:14:25 / cg" |
1491 | 647 |
! |
648 |
||
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
649 |
moveToX:viewX |
1939 | 650 |
topX := (minX max:viewX) + transX. |
1491 | 651 |
! ! |
652 |
||
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
653 |
!DSVLabelView::LineDrag methodsFor:'setup'! |
1491 | 654 |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
655 |
column:aColumn x:x y:y h:h minX:aMinX on:aView |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
656 |
|device point| |
1491 | 657 |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
658 |
column := aColumn. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
659 |
device := aView device. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
660 |
rootView := device rootView. |
2027
e61da28e7ffc
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1959
diff
changeset
|
661 |
point := device translatePoint:(x@y) fromView:aView toView:rootView. |
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
662 |
topX := point x. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
663 |
topY := point y. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
664 |
botY := topY + h. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
665 |
minX := aMinX. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
666 |
startX := topX. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
667 |
transX := topX - x. |
1491 | 668 |
! ! |
669 |
||
542 | 670 |
!DSVLabelView class methodsFor:'documentation'! |
671 |
||
672 |
version |
|
3466 | 673 |
^ '$Header: /cvs/stx/stx/libwidg2/DSVLabelView.st,v 1.58 2008-07-08 09:40:49 ca Exp $' |
542 | 674 |
! ! |