author | Claus Gittinger <cg@exept.de> |
Wed, 13 Oct 1999 23:27:11 +0200 | |
changeset 1585 | b4f60b1a025b |
parent 1525 | 1ab7703b29a9 |
child 1605 | 3eb7d3e78e08 |
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 |
||
824 | 17 |
SimpleView subclass:#DSVLabelView |
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
18 |
instanceVariableNames:'isVisible dataSet lineDrag columns selection enabled |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
19 |
preferredHeight handleCursor tabSpacing' |
542 | 20 |
classVariableNames:'' |
21 |
poolDictionaries:'' |
|
22 |
category:'Views-DataSet' |
|
23 |
! |
|
24 |
||
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
25 |
Object subclass:#LineDrag |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
26 |
instanceVariableNames:'rootView topX topY botY column minX startX transX' |
1491 | 27 |
classVariableNames:'' |
28 |
poolDictionaries:'' |
|
29 |
privateIn:DSVLabelView |
|
30 |
! |
|
31 |
||
542 | 32 |
!DSVLabelView class methodsFor:'documentation'! |
33 |
||
34 |
copyright |
|
35 |
" |
|
36 |
COPYRIGHT (c) 1997 by Claus Gittinger / eXept Software AG |
|
37 |
All Rights Reserved |
|
38 |
||
39 |
This software is furnished under a license and may be used |
|
40 |
only in accordance with the terms of that license and with the |
|
41 |
inclusion of the above copyright notice. This software may not |
|
42 |
be provided or otherwise made available to, or used by, any |
|
43 |
other person. No title to or ownership of the software is |
|
44 |
hereby transferred. |
|
45 |
" |
|
46 |
||
47 |
||
48 |
||
49 |
||
50 |
! |
|
51 |
||
52 |
documentation |
|
53 |
" |
|
54 |
shows the labels assigned to the column descriptions. Used by the |
|
55 |
DataSetView |
|
56 |
||
57 |
[Instance variables:] |
|
58 |
||
1487 | 59 |
dataSet <DSVColumnView> column view which shows the columns |
824 | 60 |
|
1487 | 61 |
selection <Integer or nil> current selected index or nil. |
824 | 62 |
|
1086 | 63 |
enabled <Boolean> if a press action exists on a column |
64 |
entry, this action could be enabled or |
|
65 |
disabled. |
|
66 |
||
1487 | 67 |
isVisible <Boolean> true if the labelView is shown |
68 |
||
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 |
||
83 |
||
84 |
! ! |
|
85 |
||
1487 | 86 |
!DSVLabelView methodsFor:'accessing'! |
824 | 87 |
|
1487 | 88 |
columns:aListOfColumns |
89 |
"the list of columns changed |
|
824 | 90 |
" |
1487 | 91 |
|layout| |
542 | 92 |
|
1487 | 93 |
columns := aListOfColumns. |
94 |
preferredHeight := nil. |
|
95 |
selection := nil. |
|
96 |
||
97 |
isVisible ifTrue:[ |
|
98 |
dataSet layout:layout. |
|
99 |
]. |
|
824 | 100 |
! |
101 |
||
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
102 |
level:aLevel |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
103 |
"ignorre; alway 0 relative to superView |
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 |
! |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
106 |
|
1487 | 107 |
preferredHeight |
824 | 108 |
|
1487 | 109 |
preferredHeight isNil ifTrue:[ |
110 |
preferredHeight := 0. |
|
884 | 111 |
|
1487 | 112 |
columns do:[:c|preferredHeight := (c label preferredHeight) max:preferredHeight ]. |
884 | 113 |
|
1487 | 114 |
|
115 |
preferredHeight := preferredHeight |
|
116 |
+ (margin + margin + dataSet horizontalSpacing * 2) |
|
117 |
]. |
|
118 |
^ preferredHeight |
|
884 | 119 |
! ! |
120 |
||
824 | 121 |
!DSVLabelView methodsFor:'drawing'! |
122 |
||
1487 | 123 |
invalidate |
124 |
(shown and:[isVisible]) ifTrue:[ |
|
125 |
super invalidate |
|
1408
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
126 |
] |
824 | 127 |
! |
128 |
||
1487 | 129 |
invalidateItemAt:anIndex |
130 |
"invalidate rectangle assigned to an item at an index |
|
824 | 131 |
" |
1487 | 132 |
|cL xL xR hg| |
133 |
||
134 |
(isVisible and:[shown]) ifTrue:[ |
|
135 |
cL := columns at:anIndex ifAbsent:[^ nil]. |
|
136 |
xL := dataSet xVisibleOfColNr:anIndex. |
|
137 |
xR := xL + cL width. |
|
138 |
||
139 |
(xL < width and:[xR > 0]) ifTrue:[ |
|
140 |
xL := xL max:0. |
|
141 |
xR := xR min:width. |
|
142 |
hg := height - margin - margin. |
|
143 |
||
144 |
self invalidate:(Rectangle left:xL top:margin width:(xR - xL) height:hg) |
|
145 |
] |
|
146 |
] |
|
147 |
||
1408
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
148 |
! |
562 | 149 |
|
824 | 150 |
redrawX:x y:y width:w height:h |
151 |
"redraw a rectangle |
|
637 | 152 |
" |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
153 |
|items savClip bg fg fgColor bgColor |
1487 | 154 |
inset "{ Class:SmallInteger }" |
155 |
maxX "{ Class:SmallInteger }" |
|
1524
b7f986aa45f4
visibility of label; show as button (yes/no)
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
156 |
lblH "{ Class:SmallInteger }" |
1487 | 157 |
wt "{ Class:SmallInteger }" |
158 |
x1 "{ Class:SmallInteger }" |
|
159 |
x0 "{ Class:SmallInteger }" |
|
160 |
| |
|
161 |
(isVisible and:[shown]) ifFalse:[^ self]. |
|
824 | 162 |
|
1487 | 163 |
bgColor := dataSet backgroundColor. |
824 | 164 |
self paint:bgColor. |
165 |
self fillRectangleX:x y:y width:w height:h. |
|
166 |
||
1487 | 167 |
columns isEmpty ifTrue:[^ self]. |
168 |
||
169 |
fgColor := dataSet foregroundColor. |
|
170 |
inset := dataSet horizontalSpacing + 1. |
|
171 |
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
|
172 |
lblH := height - margin - margin. |
824 | 173 |
savClip := clipRect. |
859 | 174 |
|
824 | 175 |
self clippingRectangle:(Rectangle left:x top:y width:w height:h). |
1487 | 176 |
x1 := dataSet xVisibleOfColNr:1. |
824 | 177 |
|
1487 | 178 |
columns keysAndValuesDo:[:aKey :aCol| |anItem| |
179 |
anItem := aCol label. |
|
180 |
wt := aCol width. |
|
181 |
x0 := x1. |
|
182 |
x1 := x1 + wt. |
|
824 | 183 |
|
1487 | 184 |
(x1 > x and:[x0 < maxX]) ifTrue:[ |
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 |
|
907 | 196 |
self paint:fg on:bg. |
1487 | 197 |
anItem redrawX:x0 w:wt h:height inset:inset on:self. |
198 |
||
1524
b7f986aa45f4
visibility of label; show as button (yes/no)
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
199 |
selection == aKey ifTrue:[ |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
200 |
dataSet drawEdgesAtX:x0 y:margin width:wt height:lblH level:-1 on:self |
1524
b7f986aa45f4
visibility of label; show as button (yes/no)
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
201 |
] ifFalse:[ |
b7f986aa45f4
visibility of label; show as button (yes/no)
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
202 |
anItem labelIsButton ifTrue:[ |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
203 |
dataSet drawEdgesAtX:x0 y:margin width:wt height:lblH level:1 on:self |
1524
b7f986aa45f4
visibility of label; show as button (yes/no)
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
204 |
] |
b7f986aa45f4
visibility of label; show as button (yes/no)
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
205 |
] |
b7f986aa45f4
visibility of label; show as button (yes/no)
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
206 |
] |
824 | 207 |
]. |
1487 | 208 |
|
859 | 209 |
self clippingRectangle:savClip. |
824 | 210 |
|
637 | 211 |
|
562 | 212 |
|
637 | 213 |
! ! |
214 |
||
215 |
!DSVLabelView methodsFor:'event handling'! |
|
542 | 216 |
|
1491 | 217 |
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
|
218 |
"mouse-button was moved; |
1491 | 219 |
redraw thumb at its new position and, if scroll-mode is asynchronous, |
220 |
the scroll action is performed |
|
221 |
" |
|
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
222 |
|idx x1| |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
223 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
224 |
lineDrag notNil ifTrue:[ |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
225 |
^ lineDrag moveToX:x |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
226 |
]. |
1491 | 227 |
|
1585
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
228 |
"/ in the resize area ? |
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
229 |
idx := self xVisibleToColNr:(x-tabSpacing). |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
230 |
idx ~~ 0 ifTrue:[ |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
231 |
x1 := dataSet xVisibleOfColNr:(idx + 1). |
1585
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
232 |
(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
|
233 |
"/ x + tabSpacing > x1 |
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
234 |
ifTrue:[ |
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
235 |
^ self cursor:handleCursor |
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
236 |
]. |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
237 |
]. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
238 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
239 |
self cursor:(Cursor normal) |
1491 | 240 |
|
241 |
! |
|
242 |
||
637 | 243 |
buttonPress:button x:x y:y |
824 | 244 |
"handle a button press event; checks whether the item under the mouse |
245 |
is selectable. If true, the selection is set to the item. |
|
637 | 246 |
" |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
247 |
|x1 idx col| |
1491 | 248 |
|
249 |
(isVisible and:[enabled and:[shown]]) ifFalse:[ |
|
250 |
^ self |
|
251 |
]. |
|
252 |
||
1585
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
253 |
"/ in the resize area ? |
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
254 |
idx := self xVisibleToColNr:(x-tabSpacing). |
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
255 |
idx ~~ 0 ifTrue:[ |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
256 |
x1 := dataSet xVisibleOfColNr:(idx + 1). |
1585
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
257 |
(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
|
258 |
ifTrue:[ |
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
259 |
col := columns at:idx ifAbsent:nil. |
1491 | 260 |
|
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
261 |
self cursor:handleCursor. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
262 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
263 |
lineDrag := LineDrag new. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
264 |
lineDrag column:col |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
265 |
x:x |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
266 |
y:margin |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
267 |
h:(self height + dataSet height) |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
268 |
minX:(x1 - col width + col minimumRequiredWidth) |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
269 |
on:self. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
270 |
^ self |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
271 |
] |
1491 | 272 |
]. |
1585
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
273 |
|
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
274 |
idx := self xVisibleToColNr:x. |
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
275 |
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
|
276 |
|
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
277 |
col notNil ifTrue:[ |
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
278 |
col label isSelectable ifTrue:[ |
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
279 |
self invalidateItemAt:(selection := idx) |
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
280 |
] |
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
281 |
]. |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
282 |
self cursor:(Cursor normal). |
542 | 283 |
! |
284 |
||
637 | 285 |
buttonRelease:button x:x y:y |
824 | 286 |
"handle a button press event; checks whether the item under the mouse |
287 |
is the selected item. If true, the application is informed. |
|
288 |
" |
|
1491 | 289 |
|selected index column deltaX| |
824 | 290 |
|
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
291 |
self cursor:(Cursor normal). |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
292 |
|
1487 | 293 |
selection isNil ifTrue:[ |
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
294 |
lineDrag notNil ifTrue:[ |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
295 |
lineDrag invertLine. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
296 |
column := lineDrag column. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
297 |
deltaX := lineDrag deltaX. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
298 |
lineDrag := nil. |
1491 | 299 |
|
300 |
deltaX abs > 2 ifTrue:[ |
|
301 |
dataSet changeWidthOfColumn:column deltaX:deltaX |
|
302 |
] |
|
303 |
]. |
|
1085 | 304 |
^ self |
305 |
]. |
|
1487 | 306 |
index := self xVisibleToSelectionIndex:x. |
307 |
selected := index == selection. |
|
1491 | 308 |
index := selection. |
1487 | 309 |
selection := nil. |
1085 | 310 |
|
1487 | 311 |
self invalidateItemAt:index. |
312 |
||
313 |
selected ifTrue:[ |
|
314 |
(columns at:index) label sendClickMsgTo:(self application) |
|
1085 | 315 |
] |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
316 |
! |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
317 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
318 |
pointerLeave:state |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
319 |
"mouse left view - restore cursor. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
320 |
" |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
321 |
self sensor anyButtonPressed ifFalse:[ |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
322 |
self cursor:(Cursor normal) |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
323 |
]. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
324 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
325 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
326 |
|
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 |
xVisibleToColNr:x |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
330 |
"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
|
331 |
" |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
332 |
|x0 x1| |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
333 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
334 |
x1 := dataSet xVisibleOfColNr:1. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
335 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
336 |
columns keysAndValuesDo:[:index :aCol| |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
337 |
x0 := x1. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
338 |
x1 := x0 + aCol width. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
339 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
340 |
(x1 > x and:[x0 < x]) ifTrue:[ |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
341 |
^ index |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
342 |
] |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
343 |
]. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
344 |
^ 0 |
824 | 345 |
! ! |
346 |
||
347 |
!DSVLabelView methodsFor:'instance creation'! |
|
348 |
||
349 |
for:aColumnView |
|
350 |
"initialization |
|
351 |
" |
|
1491 | 352 |
dataSet := aColumnView. |
353 |
self level:(dataSet level). |
|
354 |
self borderWidth:(dataSet borderWidth). |
|
355 |
! |
|
356 |
||
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
357 |
initStyle |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
358 |
super initStyle. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
359 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
360 |
handleCursor := (VariablePanel cursorForOrientation:#horizontal onDevice:device) onDevice:device. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
361 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
362 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
363 |
! |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
364 |
|
1491 | 365 |
initialize |
366 |
super initialize. |
|
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
367 |
super level:0. |
1491 | 368 |
|
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
369 |
enabled := true. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
370 |
isVisible := true. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
371 |
columns := #(). |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
372 |
tabSpacing := 6. |
1491 | 373 |
|
374 |
self enableMotionEvents. |
|
375 |
||
376 |
||
1085 | 377 |
! |
378 |
||
1487 | 379 |
realize |
380 |
"recompute contents and fit columns to view |
|
381 |
" |
|
382 |
self bitGravity:#NorthWest. |
|
383 |
super realize. |
|
1085 | 384 |
|
824 | 385 |
! ! |
386 |
||
1487 | 387 |
!DSVLabelView methodsFor:'queries'! |
824 | 388 |
|
1487 | 389 |
enabled |
390 |
"true, if widget is enabled |
|
391 |
" |
|
392 |
^ enabled |
|
393 |
! |
|
394 |
||
395 |
enabled:aState |
|
396 |
"true, if widget is enabled |
|
542 | 397 |
" |
1487 | 398 |
enabled := aState. |
399 |
! |
|
400 |
||
401 |
isVisible |
|
402 |
^ isVisible |
|
403 |
! |
|
404 |
||
405 |
isVisible:aBool |
|
406 |
||
407 |
aBool ~~ isVisible ifTrue:[ |
|
408 |
isVisible := aBool. |
|
409 |
dataSet layout:nil. |
|
824 | 410 |
]. |
411 |
! |
|
412 |
||
1487 | 413 |
xVisibleToSelectionIndex:x |
414 |
"returns the column number assigned to a physical x or nil. If |
|
415 |
the column exists but is not selectable nil is returned. |
|
824 | 416 |
" |
1487 | 417 |
|index column| |
824 | 418 |
|
1487 | 419 |
(isVisible and:[enabled]) ifTrue:[ |
420 |
( (index := dataSet xVisibleToColNr:x) notNil |
|
421 |
and:[(column := columns at:index ifAbsent:nil) notNil |
|
422 |
and:[column label isSelectable]] |
|
423 |
) ifTrue:[ |
|
424 |
^ index |
|
425 |
] |
|
824 | 426 |
]. |
1487 | 427 |
^ nil |
824 | 428 |
! ! |
429 |
||
1487 | 430 |
!DSVLabelView methodsFor:'scrolling'! |
824 | 431 |
|
1487 | 432 |
copyFromX:x0 y:y0 toX:x1 y:y1 width:w invalidateX:leftX |
824 | 433 |
|
1487 | 434 |
(shown and:[isVisible]) ifFalse:[^ self]. |
824 | 435 |
|
1487 | 436 |
(self sensor hasDamageFor:self) ifTrue:[ |
437 |
self invalidate |
|
438 |
] ifFalse:[ |
|
439 |
self copyFrom:self x:x0 y:y0 toX:x1 y:y1 width:w height:height async:false. |
|
440 |
self invalidate:(Rectangle left:leftX top:0 width:(width - w) height:height) |
|
441 |
repairNow:true |
|
442 |
] |
|
824 | 443 |
! ! |
444 |
||
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
445 |
!DSVLabelView::LineDrag methodsFor:'accessing'! |
1491 | 446 |
|
447 |
column |
|
448 |
"return the value of the instance variable 'column' (automatically generated)" |
|
449 |
||
450 |
^ column! |
|
451 |
||
452 |
deltaX |
|
453 |
"returns the distance x between the start and end action |
|
454 |
" |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
455 |
^ topX - startX |
1491 | 456 |
! ! |
457 |
||
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
458 |
!DSVLabelView::LineDrag methodsFor:'dragging'! |
1491 | 459 |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
460 |
invertLine |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
461 |
"invert for a line |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
462 |
" |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
463 |
rootView clippedByChildren:false. |
1491 | 464 |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
465 |
rootView xoring:[ |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
466 |
rootView lineWidth:2. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
467 |
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
|
468 |
rootView flush |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
469 |
] |
1491 | 470 |
! |
471 |
||
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
472 |
moveToX:viewX |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
473 |
|x| |
1491 | 474 |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
475 |
x := (minX max:viewX) + transX. |
1491 | 476 |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
477 |
x == topX ifFalse:[ |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
478 |
self invertLine. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
479 |
topX := x. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
480 |
self invertLine. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
481 |
] |
1491 | 482 |
! ! |
483 |
||
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
484 |
!DSVLabelView::LineDrag methodsFor:'setup'! |
1491 | 485 |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
486 |
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
|
487 |
|device point| |
1491 | 488 |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
489 |
column := aColumn. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
490 |
device := aView device. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
491 |
rootView := device rootView. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
492 |
point := device translatePoint:(x@y) from:(aView id) to:(rootView id). |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
493 |
topX := point x. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
494 |
topY := point y. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
495 |
botY := topY + h. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
496 |
minX := aMinX. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
497 |
startX := topX. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
498 |
transX := topX - x. |
1491 | 499 |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
500 |
self invertLine. |
1491 | 501 |
! ! |
502 |
||
542 | 503 |
!DSVLabelView class methodsFor:'documentation'! |
504 |
||
505 |
version |
|
1585
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
506 |
^ '$Header: /cvs/stx/stx/libwidg2/DSVLabelView.st,v 1.30 1999-10-13 21:27:11 cg Exp $' |
542 | 507 |
! ! |