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