author | Claus Gittinger <cg@exept.de> |
Mon, 28 Feb 2005 15:29:56 +0100 | |
changeset 2789 | e7c8596999e7 |
parent 2685 | e3b9d046915d |
child 2820 | 990d1d3eaffc |
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 |
||
284 |
!DSVLabelView methodsFor:'event handling'! |
|
542 | 285 |
|
1491 | 286 |
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
|
287 |
"mouse-button was moved; |
1491 | 288 |
redraw thumb at its new position and, if scroll-mode is asynchronous, |
289 |
the scroll action is performed |
|
290 |
" |
|
1937 | 291 |
|idx x1 col| |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
292 |
|
1958 | 293 |
state = 0 ifTrue:[ |
294 |
lineDrag := nil. |
|
295 |
]. |
|
296 |
||
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
297 |
lineDrag notNil ifTrue:[ |
1932 | 298 |
(opaqueColumnResize ? (UserPreferences current opaqueTableColumnResizing == true)) ifTrue:[ |
1939 | 299 |
lineDrag moveToX:x. |
300 |
dataSet changeWidthOfColumn:lineDrag column deltaX:lineDrag deltaX. |
|
301 |
lineDrag resetDeltaX. |
|
302 |
] ifFalse:[ |
|
303 |
lineDrag invertLine. "/ off |
|
304 |
lineDrag moveToX:x. |
|
305 |
lineDrag invertLine. "/ on |
|
1931 | 306 |
]. |
307 |
^ self. |
|
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
308 |
]. |
1491 | 309 |
|
1585
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
310 |
"/ in the resize area ? |
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
311 |
idx := self xVisibleToColNr:(x-tabSpacing). |
1937 | 312 |
col := columns at:idx ifAbsent:nil. |
313 |
||
314 |
(col notNil and:[col isResizeable]) ifTrue:[ |
|
2146 | 315 |
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
|
316 |
(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
|
317 |
"/ x + tabSpacing > x1 |
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
318 |
ifTrue:[ |
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
319 |
^ self cursor:handleCursor |
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
320 |
]. |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
321 |
]. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
322 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
323 |
self cursor:(Cursor normal) |
1491 | 324 |
! |
325 |
||
637 | 326 |
buttonPress:button x:x y:y |
824 | 327 |
"handle a button press event; checks whether the item under the mouse |
328 |
is selectable. If true, the selection is set to the item. |
|
637 | 329 |
" |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
330 |
|x1 idx col| |
1491 | 331 |
|
2146 | 332 |
(enabled and:[shown]) ifFalse:[ |
1491 | 333 |
^ self |
334 |
]. |
|
335 |
||
1585
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
336 |
"/ in the resize area ? |
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
337 |
idx := self xVisibleToColNr:(x-tabSpacing). |
1937 | 338 |
|
1585
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
339 |
idx ~~ 0 ifTrue:[ |
1937 | 340 |
col := columns at:idx ifAbsent:nil. |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
341 |
|
1937 | 342 |
col isResizeable ifTrue:[ |
2146 | 343 |
x1 := self xVisibleOfColNr:(idx + 1). |
1937 | 344 |
(x between:(x1-tabSpacing) and:(x1+tabSpacing)) |
345 |
ifTrue:[ |
|
346 |
col := columns at:idx ifAbsent:nil. |
|
347 |
self cursor:handleCursor. |
|
348 |
||
349 |
lineDrag := LineDrag new. |
|
350 |
lineDrag column:col |
|
351 |
x:x |
|
352 |
y:margin |
|
353 |
h:(self height + dataSet height) |
|
354 |
minX:(x1 - col width + col minimumRequiredWidth) |
|
355 |
on:self. |
|
1939 | 356 |
(opaqueColumnResize ? (UserPreferences current opaqueTableColumnResizing == true)) ifFalse:[ |
357 |
lineDrag invertLine. |
|
358 |
]. |
|
1937 | 359 |
^ self |
360 |
] |
|
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
361 |
] |
1491 | 362 |
]. |
1585
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
363 |
|
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
364 |
idx := self xVisibleToColNr:x. |
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
365 |
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
|
366 |
|
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
367 |
col notNil ifTrue:[ |
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
368 |
col label isSelectable ifTrue:[ |
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
369 |
self invalidateItemAt:(selection := idx) |
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
370 |
] |
b4f60b1a025b
fixed handle-fetch detection (handle is now easier to catch)
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
371 |
]. |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
372 |
self cursor:(Cursor normal). |
542 | 373 |
! |
374 |
||
637 | 375 |
buttonRelease:button x:x y:y |
824 | 376 |
"handle a button press event; checks whether the item under the mouse |
377 |
is the selected item. If true, the application is informed. |
|
378 |
" |
|
1491 | 379 |
|selected index column deltaX| |
824 | 380 |
|
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
381 |
self cursor:(Cursor normal). |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
382 |
|
1487 | 383 |
selection isNil ifTrue:[ |
1933 | 384 |
lineDrag notNil ifTrue:[ |
1939 | 385 |
(opaqueColumnResize ? (UserPreferences current opaqueTableColumnResizing == true)) ifFalse:[ |
2150 | 386 |
lineDrag invertLine. |
1932 | 387 |
column := lineDrag column. |
388 |
deltaX := lineDrag deltaX. |
|
1491 | 389 |
|
1932 | 390 |
deltaX abs > 0 "2" ifTrue:[ |
391 |
dataSet changeWidthOfColumn:column deltaX:deltaX |
|
392 |
] |
|
393 |
]. |
|
1933 | 394 |
lineDrag := nil. |
1491 | 395 |
]. |
1085 | 396 |
^ self |
397 |
]. |
|
1487 | 398 |
index := self xVisibleToSelectionIndex:x. |
399 |
selected := index == selection. |
|
1491 | 400 |
index := selection. |
1487 | 401 |
selection := nil. |
1085 | 402 |
|
1487 | 403 |
self invalidateItemAt:index. |
404 |
||
405 |
selected ifTrue:[ |
|
406 |
(columns at:index) label sendClickMsgTo:(self application) |
|
1085 | 407 |
] |
1525
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
408 |
! |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
409 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
410 |
pointerLeave:state |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
411 |
"mouse left view - restore cursor. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
412 |
" |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
413 |
self sensor anyButtonPressed ifFalse:[ |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
414 |
self cursor:(Cursor normal) |
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 |
|
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 |
|
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
419 |
! |
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 |
xVisibleToColNr:x |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
422 |
"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
|
423 |
" |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
424 |
|x0 x1| |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
425 |
|
2146 | 426 |
x1 := self xVisibleOfColNr:1. |
1525
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 |
columns keysAndValuesDo:[:index :aCol| |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
429 |
x0 := x1. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
430 |
x1 := x0 + aCol width. |
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 |
(x1 > x and:[x0 < x]) ifTrue:[ |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
433 |
^ index |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
434 |
] |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
435 |
]. |
1ab7703b29a9
change cursor if lineDrag is enabled
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
436 |
^ 0 |
824 | 437 |
! ! |
438 |
||
2146 | 439 |
!DSVLabelView methodsFor:'initialization'! |
440 |
||
441 |
initStyle |
|
442 |
super initStyle. |
|
443 |
||
444 |
handleCursor := (VariablePanel cursorForOrientation:#horizontal onDevice:device) onDevice:device. |
|
2685 | 445 |
font := (self class defaultFont) onDevice:device. |
2146 | 446 |
"/ self level:0. |
447 |
self level:(StyleSheet at:#'dataSet.labelView.level' default:-1). |
|
448 |
verticalLabelSpacing := (StyleSheet at:#'dataSet.labelView.verticalSpace' default:2). |
|
449 |
! |
|
450 |
||
451 |
initialize |
|
452 |
super initialize. |
|
453 |
"/ super level:(self defaultLevel). |
|
454 |
||
455 |
enabled := true. |
|
456 |
columns := #(). |
|
457 |
tabSpacing := self class tabSpacing. |
|
458 |
||
459 |
self enableMotionEvents. |
|
460 |
! ! |
|
461 |
||
824 | 462 |
!DSVLabelView methodsFor:'instance creation'! |
463 |
||
464 |
for:aColumnView |
|
465 |
"initialization |
|
466 |
" |
|
1491 | 467 |
dataSet := aColumnView. |
2146 | 468 |
"/ self level:(dataSet level). |
469 |
"/ self borderWidth:(dataSet borderWidth). |
|
1085 | 470 |
! |
471 |
||
1487 | 472 |
realize |
473 |
"recompute contents and fit columns to view |
|
474 |
" |
|
475 |
self bitGravity:#NorthWest. |
|
476 |
super realize. |
|
824 | 477 |
! ! |
478 |
||
1487 | 479 |
!DSVLabelView methodsFor:'queries'! |
824 | 480 |
|
1487 | 481 |
enabled |
482 |
"true, if widget is enabled |
|
483 |
" |
|
484 |
^ enabled |
|
485 |
! |
|
486 |
||
487 |
enabled:aState |
|
488 |
"true, if widget is enabled |
|
542 | 489 |
" |
1487 | 490 |
enabled := aState. |
491 |
! |
|
492 |
||
2146 | 493 |
preferredHeight |
494 |
|h| |
|
495 |
||
496 |
preferredHeight notNil ifTrue:[ |
|
497 |
^ preferredHeight |
|
498 |
]. |
|
1487 | 499 |
|
2146 | 500 |
h := 0. |
501 |
columns do:[:c | h := (c label preferredHeight) max:h ]. |
|
502 |
^ self margin + verticalLabelSpacing + h + verticalLabelSpacing + self margin |
|
503 |
! |
|
504 |
||
505 |
xVisibleOfColNr:colNr |
|
506 |
"/ must adjust, because dataset includes its own margin, which might be different from ours |
|
507 |
||
508 |
^ (dataSet xVisibleOfColNr:colNr) - dataSet margin + margin |
|
824 | 509 |
! |
510 |
||
1487 | 511 |
xVisibleToSelectionIndex:x |
512 |
"returns the column number assigned to a physical x or nil. If |
|
513 |
the column exists but is not selectable nil is returned. |
|
824 | 514 |
" |
1487 | 515 |
|index column| |
824 | 516 |
|
2146 | 517 |
(shown and:[enabled]) ifTrue:[ |
1487 | 518 |
( (index := dataSet xVisibleToColNr:x) notNil |
519 |
and:[(column := columns at:index ifAbsent:nil) notNil |
|
520 |
and:[column label isSelectable]] |
|
521 |
) ifTrue:[ |
|
522 |
^ index |
|
523 |
] |
|
824 | 524 |
]. |
1487 | 525 |
^ nil |
824 | 526 |
! ! |
527 |
||
1487 | 528 |
!DSVLabelView methodsFor:'scrolling'! |
824 | 529 |
|
1487 | 530 |
copyFromX:x0 y:y0 toX:x1 y:y1 width:w invalidateX:leftX |
824 | 531 |
|
2146 | 532 |
(shown) ifFalse:[^ self]. |
824 | 533 |
|
1487 | 534 |
(self sensor hasDamageFor:self) ifTrue:[ |
535 |
self invalidate |
|
536 |
] ifFalse:[ |
|
537 |
self copyFrom:self x:x0 y:y0 toX:x1 y:y1 width:w height:height async:false. |
|
538 |
self invalidate:(Rectangle left:leftX top:0 width:(width - w) height:height) |
|
539 |
repairNow:true |
|
540 |
] |
|
824 | 541 |
! ! |
542 |
||
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
543 |
!DSVLabelView::LineDrag methodsFor:'accessing'! |
1491 | 544 |
|
545 |
column |
|
546 |
"return the value of the instance variable 'column' (automatically generated)" |
|
547 |
||
1931 | 548 |
^ column |
549 |
! |
|
1491 | 550 |
|
551 |
deltaX |
|
552 |
"returns the distance x between the start and end action |
|
553 |
" |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
554 |
^ topX - startX |
1931 | 555 |
! |
556 |
||
557 |
resetDeltaX |
|
558 |
startX := topX |
|
1491 | 559 |
! ! |
560 |
||
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
561 |
!DSVLabelView::LineDrag methodsFor:'dragging'! |
1491 | 562 |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
563 |
invertLine |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
564 |
"invert for a line |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
565 |
" |
2027
e61da28e7ffc
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1959
diff
changeset
|
566 |
|c rootDevice| |
e61da28e7ffc
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1959
diff
changeset
|
567 |
|
e61da28e7ffc
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1959
diff
changeset
|
568 |
rootDevice := rootView device. |
1939 | 569 |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
570 |
rootView clippedByChildren:false. |
1491 | 571 |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
572 |
rootView xoring:[ |
2027
e61da28e7ffc
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1959
diff
changeset
|
573 |
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
|
574 |
rootView lineWidth:2. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
575 |
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
|
576 |
rootView flush |
2027
e61da28e7ffc
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1959
diff
changeset
|
577 |
] |
e61da28e7ffc
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1959
diff
changeset
|
578 |
|
e61da28e7ffc
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1959
diff
changeset
|
579 |
"Modified: / 10.10.2001 / 15:14:25 / cg" |
1491 | 580 |
! |
581 |
||
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
582 |
moveToX:viewX |
1939 | 583 |
topX := (minX max:viewX) + transX. |
1491 | 584 |
! ! |
585 |
||
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
586 |
!DSVLabelView::LineDrag methodsFor:'setup'! |
1491 | 587 |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
588 |
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
|
589 |
|device point| |
1491 | 590 |
|
1494
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
591 |
column := aColumn. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
592 |
device := aView device. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
593 |
rootView := device rootView. |
2027
e61da28e7ffc
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1959
diff
changeset
|
594 |
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
|
595 |
topX := point x. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
596 |
topY := point y. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
597 |
botY := topY + h. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
598 |
minX := aMinX. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
599 |
startX := topX. |
096845be5d75
draw tabulatorLine on the tootView; do not use a SimpleView
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
600 |
transX := topX - x. |
1491 | 601 |
! ! |
602 |
||
542 | 603 |
!DSVLabelView class methodsFor:'documentation'! |
604 |
||
605 |
version |
|
2789 | 606 |
^ '$Header: /cvs/stx/stx/libwidg2/DSVLabelView.st,v 1.48 2005-02-28 14:29:56 cg Exp $' |
542 | 607 |
! ! |