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