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