author | ca |
Tue, 08 Jul 2008 12:19:06 +0200 | |
changeset 3467 | f2212331f4e5 |
parent 3466 | e35f9173be58 |
child 3489 | f2f5a8273044 |
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 |
" |
|
3467 | 205 |
|desc startOfTabX endOfTabX lastColumn has3Dseparators separatorOneDColor |
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 |
|
3467 | 222 |
has3Dseparators := dataSet has3Dseparators. |
223 |
separatorOneDColor := dataSet separatorOneDColor. |
|
224 |
lastColumn := columns last. |
|
3464 | 225 |
|
2146 | 226 |
columns keysAndValuesDo:[:aKey :aCol| |
227 |
desc := aCol description. |
|
228 |
x0 := x1. |
|
229 |
x1 := x1 + aCol width. |
|
230 |
||
3464 | 231 |
endOfTabX := nil. |
232 |
||
2146 | 233 |
aKey == selection ifTrue:[ |
3464 | 234 |
startOfTabX notNil ifTrue:[ endOfTabX := x0 ]. |
235 |
||
2146 | 236 |
(x1 > x and:[x0 < maxX]) ifTrue:[ |
3464 | 237 |
dataSet drawEdgesAtX:x0 y:y0 width:(x1 - x0) height:h level:-1 on:self. |
2146 | 238 |
]. |
3464 | 239 |
|
2146 | 240 |
] ifFalse:[ |
3464 | 241 |
desc labelHasButtonLayout ifTrue:[ |
3466 | 242 |
startOfTabX isNil ifTrue:[ startOfTabX := x0 ]. |
243 |
||
3464 | 244 |
(desc== lastColumn or:[desc labelIsPartOfGroup not]) ifTrue:[ |
245 |
endOfTabX := x1. |
|
246 |
] |
|
247 |
] ifFalse:[ |
|
248 |
startOfTabX notNil ifTrue:[ |
|
249 |
endOfTabX := x0. |
|
250 |
]. |
|
251 |
]. |
|
2146 | 252 |
]. |
3464 | 253 |
endOfTabX notNil ifTrue:[ |
254 |
startOfTabX isNil ifTrue:[ startOfTabX := x0 ]. |
|
255 |
||
256 |
startOfTabX < endOfTabX ifTrue:[ |
|
257 |
(endOfTabX > x and:[startOfTabX < maxX]) ifTrue:[ |
|
258 |
has3Dseparators ifTrue:[ |
|
259 |
dataSet drawEdgesAtX:startOfTabX y:y0 width:(endOfTabX - startOfTabX) height:h level:absLabelLevel on:self. |
|
260 |
] ifFalse:[ |
|
3467 | 261 |
self paint:separatorOneDColor. |
3464 | 262 |
self displayLineFromX:endOfTabX-1 y:0 toX:endOfTabX-1 y:h. |
263 |
]. |
|
264 |
]. |
|
2146 | 265 |
]. |
3464 | 266 |
startOfTabX := nil. |
267 |
]. |
|
2146 | 268 |
]. |
269 |
||
3464 | 270 |
has3Dseparators ifTrue:[ |
271 |
x1 < (maxX - absLabelLevel - absLabelLevel - 3) ifTrue:[ |
|
272 |
dataSet |
|
273 |
drawEdgesAtX:x1 y:y0 |
|
274 |
width:(width"-margin"-x1"-absLabelLevel") height:h |
|
275 |
level:absLabelLevel on:self |
|
276 |
]. |
|
3467 | 277 |
] ifFalse:[ |
278 |
h := h - 1. |
|
279 |
self paint:separatorOneDColor. |
|
280 |
self displayLineFromX:x y:h toX:(x + aWidth) y:h. |
|
2146 | 281 |
]. |
282 |
! |
|
283 |
||
284 |
redrawX:x y:y width:wArg height:h |
|
285 |
|savClip w| |
|
286 |
||
287 |
(shown) ifFalse:[^ self]. |
|
288 |
||
289 |
w := wArg. |
|
290 |
self redrawColumnsInX:x y:y width:w height:h. |
|
291 |
||
292 |
super redrawX:x y:y width:w height:h. |
|
293 |
||
294 |
"/ (x + w) >= (width-margin) ifTrue:[ |
|
295 |
"/ w := (width-margin) - 1 - x. |
|
296 |
"/ ]. |
|
3324
bdd503be73d1
redraw when there are no columns
Claus Gittinger <cg@exept.de>
parents:
3216
diff
changeset
|
297 |
columns notEmpty ifTrue:[ |
bdd503be73d1
redraw when there are no columns
Claus Gittinger <cg@exept.de>
parents:
3216
diff
changeset
|
298 |
savClip := clipRect. |
bdd503be73d1
redraw when there are no columns
Claus Gittinger <cg@exept.de>
parents:
3216
diff
changeset
|
299 |
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
|
300 |
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
|
301 |
self clippingRectangle:savClip. |
bdd503be73d1
redraw when there are no columns
Claus Gittinger <cg@exept.de>
parents:
3216
diff
changeset
|
302 |
] |
637 | 303 |
! ! |
304 |
||
2820 | 305 |
!DSVLabelView methodsFor:'enumerating columns'! |
306 |
||
307 |
columnsDo:aOneArgBlock |
|
308 |
"evaluate the argument, aOneArgBlock for every column" |
|
309 |
||
310 |
columns do:aOneArgBlock |
|
311 |
! ! |
|
312 |
||
637 | 313 |
!DSVLabelView methodsFor:'event handling'! |
542 | 314 |
|
1491 | 315 |
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
|
316 |
"mouse-button was moved; |
1491 | 317 |
redraw thumb at its new position and, if scroll-mode is asynchronous, |
318 |
the scroll action is performed |
|
319 |
" |
|
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
320 |
|colNr x1 col| |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
321 |
|
1958 | 322 |
state = 0 ifTrue:[ |
323 |
lineDrag := nil. |
|
324 |
]. |
|
325 |
||
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
326 |
lineDrag notNil ifTrue:[ |
1932 | 327 |
(opaqueColumnResize ? (UserPreferences current opaqueTableColumnResizing == true)) ifTrue:[ |
1939 | 328 |
lineDrag moveToX:x. |
329 |
dataSet changeWidthOfColumn:lineDrag column deltaX:lineDrag deltaX. |
|
330 |
lineDrag resetDeltaX. |
|
331 |
] ifFalse:[ |
|
332 |
lineDrag invertLine. "/ off |
|
333 |
lineDrag moveToX:x. |
|
334 |
lineDrag invertLine. "/ on |
|
1931 | 335 |
]. |
336 |
^ self. |
|
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
337 |
]. |
1491 | 338 |
|
1585
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
339 |
"/ in the resize area ? |
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
340 |
colNr := self xVisibleToColNr:(x-tabSpacing). |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
341 |
colNr notNil ifTrue:[ |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
342 |
col := columns at:colNr. |
1937 | 343 |
|
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
344 |
(col notNil and:[col isResizeable]) ifTrue:[ |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
345 |
x1 := self xVisibleOfColNr:(colNr + 1). |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
346 |
(x between:(x1-tabSpacing) and:(x1+tabSpacing)) |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
347 |
"/ x + tabSpacing > x1 |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
348 |
ifTrue:[ |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
349 |
self cursor:handleCursor. |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
350 |
^ self |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
351 |
]. |
1585
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
352 |
]. |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
353 |
]. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
354 |
self cursor:(Cursor normal) |
3212 | 355 |
|
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
356 |
"Modified: / 26-03-2007 / 15:20:27 / cg" |
1491 | 357 |
! |
358 |
||
637 | 359 |
buttonPress:button x:x y:y |
824 | 360 |
"handle a button press event; checks whether the item under the mouse |
361 |
is selectable. If true, the selection is set to the item. |
|
637 | 362 |
" |
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
363 |
|x1 colNr col| |
1491 | 364 |
|
2146 | 365 |
(enabled and:[shown]) ifFalse:[ |
1491 | 366 |
^ self |
367 |
]. |
|
368 |
||
1585
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
369 |
"/ in the resize area ? |
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
370 |
colNr := self xVisibleToColNr:(x-tabSpacing). |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
371 |
colNr notNil ifTrue:[ |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
372 |
col := columns at:colNr. |
1937 | 373 |
col isResizeable ifTrue:[ |
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
374 |
x1 := self xVisibleOfColNr:(colNr + 1). |
3212 | 375 |
(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
|
376 |
col := columns at:colNr ifAbsent:nil. |
1937 | 377 |
self cursor:handleCursor. |
378 |
||
379 |
lineDrag := LineDrag new. |
|
380 |
lineDrag column:col |
|
381 |
x:x |
|
382 |
y:margin |
|
383 |
h:(self height + dataSet height) |
|
384 |
minX:(x1 - col width + col minimumRequiredWidth) |
|
385 |
on:self. |
|
1939 | 386 |
(opaqueColumnResize ? (UserPreferences current opaqueTableColumnResizing == true)) ifFalse:[ |
387 |
lineDrag invertLine. |
|
388 |
]. |
|
3212 | 389 |
^ self |
1937 | 390 |
] |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
391 |
] |
1491 | 392 |
]. |
1585
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
393 |
|
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
394 |
colNr := self xVisibleToColNr:x. |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
395 |
colNr notNil ifTrue:[ |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
396 |
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
|
397 |
col label isSelectable ifTrue:[ |
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
398 |
self invalidateItemAt:(selection := colNr) |
3212 | 399 |
]. |
1585
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
400 |
]. |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
401 |
self cursor:(Cursor normal). |
3212 | 402 |
|
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
403 |
"Modified: / 26-03-2007 / 15:21:00 / cg" |
542 | 404 |
! |
405 |
||
637 | 406 |
buttonRelease:button x:x y:y |
824 | 407 |
"handle a button press event; checks whether the item under the mouse |
408 |
is the selected item. If true, the application is informed. |
|
409 |
" |
|
1491 | 410 |
|selected index column deltaX| |
824 | 411 |
|
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
412 |
self cursor:(Cursor normal). |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
413 |
|
1487 | 414 |
selection isNil ifTrue:[ |
1933 | 415 |
lineDrag notNil ifTrue:[ |
1939 | 416 |
(opaqueColumnResize ? (UserPreferences current opaqueTableColumnResizing == true)) ifFalse:[ |
2150 | 417 |
lineDrag invertLine. |
1932 | 418 |
column := lineDrag column. |
419 |
deltaX := lineDrag deltaX. |
|
1491 | 420 |
|
1932 | 421 |
deltaX abs > 0 "2" ifTrue:[ |
422 |
dataSet changeWidthOfColumn:column deltaX:deltaX |
|
423 |
] |
|
424 |
]. |
|
1933 | 425 |
lineDrag := nil. |
1491 | 426 |
]. |
1085 | 427 |
^ self |
428 |
]. |
|
1487 | 429 |
index := self xVisibleToSelectionIndex:x. |
430 |
selected := index == selection. |
|
1491 | 431 |
index := selection. |
1487 | 432 |
selection := nil. |
1085 | 433 |
|
1487 | 434 |
self invalidateItemAt:index. |
435 |
||
436 |
selected ifTrue:[ |
|
437 |
(columns at:index) label sendClickMsgTo:(self application) |
|
1085 | 438 |
] |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
439 |
! |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
440 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
441 |
pointerLeave:state |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
442 |
"mouse left view - restore cursor. |
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 |
self sensor anyButtonPressed ifFalse:[ |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
445 |
self cursor:(Cursor normal) |
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 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
448 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
449 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
450 |
! |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
451 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
452 |
xVisibleToColNr:x |
3212 | 453 |
"returns the column number for a physical x position. |
454 |
Returns nil if x is behond the last column." |
|
455 |
||
1525
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 |
|
2146 | 458 |
x1 := self xVisibleOfColNr:1. |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
459 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
460 |
columns keysAndValuesDo:[:index :aCol| |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
461 |
x0 := x1. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
462 |
x1 := x0 + aCol width. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
463 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
464 |
(x1 > x and:[x0 < x]) ifTrue:[ |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
465 |
^ index |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
466 |
] |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
467 |
]. |
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
468 |
^ nil |
3212 | 469 |
|
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
470 |
"Modified: / 26-03-2007 / 15:21:37 / cg" |
824 | 471 |
! ! |
472 |
||
3188 | 473 |
!DSVLabelView methodsFor:'focus handling'! |
474 |
||
475 |
canTab |
|
476 |
^ false |
|
477 |
! |
|
478 |
||
479 |
wantsFocusWithButtonPress |
|
480 |
"never wants the focus - view which keeps the labels |
|
481 |
" |
|
482 |
^ false |
|
483 |
! ! |
|
484 |
||
3214 | 485 |
!DSVLabelView methodsFor:'help'! |
486 |
||
487 |
flyByHelpTextAt:aPoint |
|
488 |
"return the helpText for aPoint (i.e. when mouse-pointer is moved over an item)." |
|
489 |
||
490 |
|colNr col| |
|
491 |
||
492 |
columns isEmpty ifTrue:[^ nil]. |
|
493 |
colNr := self xVisibleToColNr:aPoint x. |
|
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
494 |
colNr notNil ifTrue:[ |
3214 | 495 |
col := columns at:colNr. |
496 |
^ col activeHelpText. |
|
497 |
]. |
|
498 |
^ nil |
|
499 |
||
500 |
"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
|
501 |
"Modified: / 26-03-2007 / 15:21:07 / cg" |
3214 | 502 |
! ! |
503 |
||
2146 | 504 |
!DSVLabelView methodsFor:'initialization'! |
505 |
||
506 |
initStyle |
|
2924 | 507 |
<resource: #style (#'dataSet.labelView.level' |
508 |
#'dataSet.labelView.verticalSpace' |
|
509 |
)> |
|
510 |
||
2146 | 511 |
super initStyle. |
512 |
||
513 |
handleCursor := (VariablePanel cursorForOrientation:#horizontal onDevice:device) onDevice:device. |
|
2685 | 514 |
font := (self class defaultFont) onDevice:device. |
2146 | 515 |
"/ self level:0. |
2924 | 516 |
self level:(styleSheet at:#'dataSet.labelView.level' default:-1). |
517 |
verticalLabelSpacing := (styleSheet at:#'dataSet.labelView.verticalSpace' default:2). |
|
2146 | 518 |
! |
519 |
||
520 |
initialize |
|
521 |
super initialize. |
|
522 |
"/ super level:(self defaultLevel). |
|
523 |
||
524 |
enabled := true. |
|
525 |
columns := #(). |
|
526 |
tabSpacing := self class tabSpacing. |
|
527 |
||
528 |
self enableMotionEvents. |
|
529 |
! ! |
|
530 |
||
824 | 531 |
!DSVLabelView methodsFor:'instance creation'! |
532 |
||
533 |
for:aColumnView |
|
534 |
"initialization |
|
535 |
" |
|
1491 | 536 |
dataSet := aColumnView. |
2146 | 537 |
"/ self level:(dataSet level). |
538 |
"/ self borderWidth:(dataSet borderWidth). |
|
1085 | 539 |
! |
540 |
||
1487 | 541 |
realize |
542 |
"recompute contents and fit columns to view |
|
543 |
" |
|
544 |
self bitGravity:#NorthWest. |
|
545 |
super realize. |
|
824 | 546 |
! ! |
547 |
||
1487 | 548 |
!DSVLabelView methodsFor:'queries'! |
824 | 549 |
|
1487 | 550 |
enabled |
551 |
"true, if widget is enabled |
|
552 |
" |
|
553 |
^ enabled |
|
554 |
! |
|
555 |
||
556 |
enabled:aState |
|
557 |
"true, if widget is enabled |
|
542 | 558 |
" |
1487 | 559 |
enabled := aState. |
560 |
! |
|
561 |
||
2146 | 562 |
preferredHeight |
563 |
|h| |
|
564 |
||
565 |
preferredHeight notNil ifTrue:[ |
|
566 |
^ preferredHeight |
|
567 |
]. |
|
1487 | 568 |
|
2146 | 569 |
h := 0. |
570 |
columns do:[:c | h := (c label preferredHeight) max:h ]. |
|
571 |
^ self margin + verticalLabelSpacing + h + verticalLabelSpacing + self margin |
|
572 |
! |
|
573 |
||
574 |
xVisibleOfColNr:colNr |
|
575 |
"/ must adjust, because dataset includes its own margin, which might be different from ours |
|
576 |
||
577 |
^ (dataSet xVisibleOfColNr:colNr) - dataSet margin + margin |
|
824 | 578 |
! |
579 |
||
1487 | 580 |
xVisibleToSelectionIndex:x |
581 |
"returns the column number assigned to a physical x or nil. If |
|
582 |
the column exists but is not selectable nil is returned. |
|
824 | 583 |
" |
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
584 |
|
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
585 |
|colNr column| |
824 | 586 |
|
2146 | 587 |
(shown and:[enabled]) ifTrue:[ |
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
588 |
((colNr := dataSet xVisibleToColNr:x) notNil |
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
589 |
and:[(column := columns at:colNr) notNil |
1487 | 590 |
and:[column label isSelectable]] |
591 |
) ifTrue:[ |
|
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
592 |
^ colNr |
1487 | 593 |
] |
824 | 594 |
]. |
1487 | 595 |
^ nil |
3216
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
596 |
|
18f104700621
xVisibleToSelectionIndex:x different return value confusion
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
597 |
"Modified: / 26-03-2007 / 15:21:27 / cg" |
824 | 598 |
! ! |
599 |
||
1487 | 600 |
!DSVLabelView methodsFor:'scrolling'! |
824 | 601 |
|
1487 | 602 |
copyFromX:x0 y:y0 toX:x1 y:y1 width:w invalidateX:leftX |
824 | 603 |
|
2146 | 604 |
(shown) ifFalse:[^ self]. |
824 | 605 |
|
1487 | 606 |
(self sensor hasDamageFor:self) ifTrue:[ |
607 |
self invalidate |
|
608 |
] ifFalse:[ |
|
609 |
self copyFrom:self x:x0 y:y0 toX:x1 y:y1 width:w height:height async:false. |
|
610 |
self invalidate:(Rectangle left:leftX top:0 width:(width - w) height:height) |
|
611 |
repairNow:true |
|
612 |
] |
|
824 | 613 |
! ! |
614 |
||
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
615 |
!DSVLabelView::LineDrag methodsFor:'accessing'! |
1491 | 616 |
|
617 |
column |
|
618 |
"return the value of the instance variable 'column' (automatically generated)" |
|
619 |
||
1931 | 620 |
^ column |
621 |
! |
|
1491 | 622 |
|
623 |
deltaX |
|
624 |
"returns the distance x between the start and end action |
|
625 |
" |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
626 |
^ topX - startX |
1931 | 627 |
! |
628 |
||
629 |
resetDeltaX |
|
630 |
startX := topX |
|
1491 | 631 |
! ! |
632 |
||
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
633 |
!DSVLabelView::LineDrag methodsFor:'dragging'! |
1491 | 634 |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
635 |
invertLine |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
636 |
"invert for a line |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
637 |
" |
2027
e61da28e7ffc
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1959
diff
changeset
|
638 |
|c rootDevice| |
e61da28e7ffc
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1959
diff
changeset
|
639 |
|
e61da28e7ffc
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1959
diff
changeset
|
640 |
rootDevice := rootView device. |
1939 | 641 |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
642 |
rootView clippedByChildren:false. |
1491 | 643 |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
644 |
rootView xoring:[ |
2027
e61da28e7ffc
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1959
diff
changeset
|
645 |
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
|
646 |
rootView lineWidth:2. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
647 |
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
|
648 |
rootView flush |
2027
e61da28e7ffc
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1959
diff
changeset
|
649 |
] |
e61da28e7ffc
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1959
diff
changeset
|
650 |
|
e61da28e7ffc
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1959
diff
changeset
|
651 |
"Modified: / 10.10.2001 / 15:14:25 / cg" |
1491 | 652 |
! |
653 |
||
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
654 |
moveToX:viewX |
1939 | 655 |
topX := (minX max:viewX) + transX. |
1491 | 656 |
! ! |
657 |
||
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
658 |
!DSVLabelView::LineDrag methodsFor:'setup'! |
1491 | 659 |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
660 |
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
|
661 |
|device point| |
1491 | 662 |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
663 |
column := aColumn. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
664 |
device := aView device. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
665 |
rootView := device rootView. |
2027
e61da28e7ffc
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1959
diff
changeset
|
666 |
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
|
667 |
topX := point x. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
668 |
topY := point y. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
669 |
botY := topY + h. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
670 |
minX := aMinX. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
671 |
startX := topX. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
672 |
transX := topX - x. |
1491 | 673 |
! ! |
674 |
||
542 | 675 |
!DSVLabelView class methodsFor:'documentation'! |
676 |
||
677 |
version |
|
3467 | 678 |
^ '$Header: /cvs/stx/stx/libwidg2/DSVLabelView.st,v 1.59 2008-07-08 10:19:06 ca Exp $' |
542 | 679 |
! ! |