author | Claus Gittinger <cg@exept.de> |
Fri, 01 Nov 2002 00:25:54 +0100 | |
changeset 2658 | 1d3f90424bcf |
parent 2653 | 441d15cf7fba |
child 2678 | 873a631b1f1d |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
59 | 3 |
All Rights Reserved |
0 | 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 |
||
2227 | 13 |
"{ Package: 'stx:libwidg' }" |
14 |
||
121 | 15 |
View subclass:#ObjectView |
256
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
16 |
instanceVariableNames:'contents sorted lastButt pressAction releaseAction |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
17 |
shiftPressAction doublePressAction motionAction keyPressAction |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
18 |
selection gridShown gridPixmap scaleMetric dragObject |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
19 |
leftHandCursor oldCursor movedObject moveStartPoint moveDelta |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
20 |
documentFormat canDragOutOfView rootMotion rootView aligning |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
21 |
gridAlign aligningMove' |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
22 |
classVariableNames:'' |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
23 |
poolDictionaries:'' |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
24 |
category:'Views-Basic' |
0 | 25 |
! |
26 |
||
961 | 27 |
!ObjectView class methodsFor:'documentation'! |
59 | 28 |
|
29 |
copyright |
|
30 |
" |
|
31 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
32 |
All Rights Reserved |
|
0 | 33 |
|
59 | 34 |
This software is furnished under a license and may be used |
35 |
only in accordance with the terms of that license and with the |
|
36 |
inclusion of the above copyright notice. This software may not |
|
37 |
be provided or otherwise made available to, or used by, any |
|
38 |
other person. No title to or ownership of the software is |
|
39 |
hereby transferred. |
|
40 |
" |
|
41 |
! |
|
0 | 42 |
|
59 | 43 |
documentation |
44 |
" |
|
45 |
a View which can hold DisplayObjects, can make selections, move them around etc. |
|
2653 | 46 |
ObjectView is an abstract class providing common mechanisms (i.e. a blackBox framework, |
47 |
to be used by concrete subclasses). |
|
48 |
Actual instances are DrawView, DirectoryView, LogicView or DocumentView. |
|
49 |
||
50 |
If you want to use this class, have a special look at the pluggable behavior, especially, |
|
51 |
pressAction, releaseAction etc.: |
|
59 | 52 |
|
584 | 53 |
[Instance variables:] |
54 |
||
55 |
contents <Collection> the objects. The order in which |
|
56 |
these are in that collection defines |
|
57 |
their appearance in the z-plane: |
|
58 |
an object located after another one |
|
59 |
here will be drawn ABOVE the other. |
|
60 |
||
61 |
sorted <Boolean> if set, redraw and picking methods |
|
62 |
assume that the objects are sorted by |
|
63 |
>= y-coordinates. These operations are |
|
64 |
a bit faster then, since a binary search |
|
65 |
can be done. (use with care). |
|
66 |
||
67 |
lastButt <Point> last pointer press position |
|
68 |
(internal) |
|
69 |
||
70 |
pressAction <Block> action to perform when mouse pointer |
|
71 |
is pressed. Can be set to something like |
|
72 |
[self startCreate], [self startSelectOrMove] |
|
73 |
etc. |
|
74 |
||
75 |
releaseAction <Block> action to perform when mouse pointer is |
|
76 |
released. Typically set in one of the |
|
77 |
startXXX methods. |
|
78 |
||
79 |
shiftPressAction <Block> like pressAction, if shift key is |
|
80 |
pressed. |
|
81 |
||
82 |
doublePressAction <Block> same for double-clicks |
|
83 |
||
84 |
motionAction <Block> action to perform on mouse-pointer |
|
85 |
motion. |
|
86 |
||
87 |
keyPressAction <Block> action for keyboard events |
|
88 |
||
89 |
selection <any> the current selection; either a single |
|
90 |
object or a collection of objects. |
|
91 |
||
92 |
gridShown <Boolean> internal |
|
93 |
||
94 |
gridPixmap <Form> internal |
|
95 |
||
96 |
scaleMetric <Symbol> either #mm or #inch; used to |
|
97 |
decide how the grid is defined |
|
98 |
||
99 |
dragObject internal |
|
100 |
||
101 |
leftHandCursor cursor shown while dragging a rectangle |
|
102 |
||
103 |
oldCursor saved original cursor while dragging a rectangle |
|
104 |
||
105 |
movedObject internal |
|
106 |
moveStartPoint internal |
|
107 |
moveDelta internal |
|
108 |
||
109 |
documentFormat <Symbol> defines the size and layout of the |
|
110 |
document. Can be any of |
|
111 |
#letter, #a4, #a3 etc. |
|
112 |
||
113 |
canDragOutOfView <Boolean> if true, objects can be dragged out of the |
|
114 |
view. If false, dragging is restricted to within |
|
115 |
this view. |
|
116 |
||
117 |
rootMotion internal |
|
118 |
rootView internal |
|
119 |
||
120 |
aligning <Boolean> if true, pointer positions are |
|
121 |
aligned (snapped) to the point |
|
122 |
specified in gridAlign |
|
123 |
||
124 |
gridAlign <Point> if aligning is true, this point |
|
125 |
defines the snapping. For example, |
|
126 |
12@12 defines snap to the nearest |
|
127 |
12-point grid. |
|
77 | 128 |
|
59 | 129 |
written spring/summer 89 by claus |
584 | 130 |
|
131 |
[author:] |
|
132 |
Claus Gittinger |
|
133 |
||
134 |
[see also:] |
|
135 |
DrawTool LogicTool |
|
136 |
DrawObject |
|
137 |
DisplayObject |
|
59 | 138 |
" |
77 | 139 |
! |
140 |
||
141 |
examples |
|
142 |
" |
|
143 |
typically, ObjectViews are not used on their own, but instead |
|
144 |
subclassed and thereby provide the common functionality for |
|
145 |
views which show (possibly overlapping) objects. |
|
146 |
The methods here provide all mechanisms to handle redraws, picking |
|
147 |
(i.e. finding an object by position), gridding, moving objects with |
|
148 |
minimum redraw etc. |
|
149 |
Also, zooming and scrolling is handled. |
|
150 |
All objects which respond to the DisplayObject protocol can be handled |
|
151 |
by ObjectView - therefore, you can add almost any object and have it |
|
152 |
displayed and handled here. (as an example, try to copy a LogicGate |
|
153 |
from a LogicView and paste it into a DrawTool - it will work). |
|
154 |
||
155 |
Reminder: ObjectViews are not to be used as below, but instead to be |
|
156 |
subclassed. Therefore, the examples below are somewhat untypical. |
|
157 |
||
158 |
simple example: |
|
592 | 159 |
[exBegin] |
531 | 160 |
|v o| |
161 |
||
162 |
v := ObjectView new. |
|
163 |
v extent:200@200. |
|
164 |
||
165 |
o := DrawRectangle new. |
|
166 |
o origin:10@10 corner:100@100. |
|
167 |
v add:o. |
|
168 |
||
169 |
o := DrawText new. |
|
170 |
o text:'hello there'; origin:50@50; foreground:Color red. |
|
171 |
v add:o. |
|
172 |
||
173 |
v open |
|
592 | 174 |
[exEnd] |
77 | 175 |
|
176 |
add scrolling: |
|
592 | 177 |
[exBegin] |
531 | 178 |
|v top o| |
179 |
||
180 |
top := HVScrollableView for:ObjectView. |
|
181 |
top extent:200@200. |
|
182 |
v := top scrolledView. |
|
183 |
||
184 |
o := DrawRectangle new. |
|
185 |
o origin:10@10 corner:100@100. |
|
186 |
v add:o. |
|
187 |
||
188 |
o := DrawText new. |
|
189 |
o text:'hello there'; origin:50@50; foreground:Color red. |
|
190 |
v add:o. |
|
191 |
||
192 |
top open |
|
592 | 193 |
[exEnd] |
77 | 194 |
|
195 |
or, using miniscrollers: |
|
592 | 196 |
[exBegin] |
531 | 197 |
|v top o| |
198 |
||
199 |
top := HVScrollableView for:ObjectView |
|
200 |
miniScrollerH:true miniScrollerV:true. |
|
201 |
top extent:200@200. |
|
202 |
v := top scrolledView. |
|
203 |
||
204 |
o := DrawRectangle new. |
|
205 |
o origin:10@10 corner:100@100. |
|
206 |
v add:o. |
|
207 |
||
208 |
o := DrawText new. |
|
209 |
o text:'hello there'; origin:50@50; foreground:Color red. |
|
210 |
v add:o. |
|
211 |
||
212 |
top open |
|
592 | 213 |
[exEnd] |
77 | 214 |
|
215 |
grid: |
|
592 | 216 |
[exBegin] |
531 | 217 |
|v top o| |
218 |
||
219 |
top := HVScrollableView for:ObjectView |
|
220 |
miniScrollerH:true miniScrollerV:true. |
|
221 |
top extent:200@200. |
|
222 |
v := top scrolledView. |
|
223 |
v showGrid. |
|
224 |
||
225 |
o := DrawRectangle new. |
|
226 |
o origin:10@10 corner:100@100. |
|
227 |
v add:o. |
|
228 |
||
229 |
o := DrawText new. |
|
230 |
o text:'hello there'; origin:50@50; foreground:Color red. |
|
231 |
v add:o. |
|
232 |
||
233 |
top open |
|
592 | 234 |
[exEnd] |
531 | 235 |
|
236 |
zoom: |
|
592 | 237 |
[exBegin] |
531 | 238 |
|v top o| |
239 |
||
240 |
top := HVScrollableView for:ObjectView |
|
241 |
miniScrollerH:true miniScrollerV:true. |
|
242 |
top extent:200@200. |
|
243 |
v := top scrolledView. |
|
244 |
v showGrid. |
|
245 |
||
246 |
o := DrawRectangle new. |
|
247 |
o origin:10@10 corner:100@100. |
|
248 |
v add:o. |
|
249 |
||
250 |
o := DrawText new. |
|
251 |
o text:'hello there'; origin:50@50; foreground:Color red. |
|
252 |
v add:o. |
|
253 |
||
254 |
top open. |
|
255 |
||
256 |
Delay waitForSeconds:5. |
|
257 |
v zoom:2. |
|
258 |
||
259 |
Delay waitForSeconds:5. |
|
260 |
v zoom:0.35. |
|
261 |
||
262 |
Delay waitForSeconds:5. |
|
263 |
v zoom:1. |
|
592 | 264 |
[exEnd] |
531 | 265 |
|
266 |
private benchmark: display 10000 objects ... |
|
592 | 267 |
[exBegin] |
531 | 268 |
|v top o rnd| |
269 |
||
270 |
top := HVScrollableView for:ObjectView |
|
271 |
miniScrollerH:true miniScrollerV:true. |
|
272 |
top extent:200@200. |
|
273 |
v := top scrolledView. |
|
274 |
||
275 |
rnd := Random new. |
|
1164 | 276 |
10000 timesRepeat:[ |
531 | 277 |
o := DrawLine new. |
278 |
o origin:(rnd nextIntegerBetween:0 and:700) @ (rnd nextIntegerBetween:0 and:700) |
|
279 |
corner:(rnd nextIntegerBetween:0 and:700) @ (rnd nextIntegerBetween:0 and:700). |
|
280 |
v add:o. |
|
281 |
]. |
|
282 |
||
283 |
top openAndWait. |
|
284 |
||
655 | 285 |
Transcript showCR:( |
531 | 286 |
Time millisecondsToRun:[ |
287 |
v redraw |
|
288 |
]) |
|
592 | 289 |
[exEnd] |
77 | 290 |
" |
59 | 291 |
! ! |
0 | 292 |
|
961 | 293 |
!ObjectView class methodsFor:'defaults'! |
0 | 294 |
|
1752
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
295 |
handleSize |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
296 |
"size of blob drawn for handles" |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
297 |
|
2289 | 298 |
^ (Screen current horizontalPixelPerMillimeter * 1.2) rounded asInteger |
1752
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
299 |
! |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
300 |
|
0 | 301 |
hitDelta |
302 |
"when clicking an object, allow for hitDelta pixels around object; |
|
303 |
0 is exact; 1*pixelPerMillimeter is good for draw programs" |
|
63 | 304 |
|
0 | 305 |
^ 0 |
306 |
! ! |
|
307 |
||
996 | 308 |
!ObjectView methodsFor:'accessing'! |
309 |
||
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
310 |
contents |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
311 |
^ contents |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
312 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
313 |
"Created: / 4.7.1999 / 15:15:15 / cg" |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
314 |
! |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
315 |
|
996 | 316 |
gridShown |
317 |
^ gridShown |
|
318 |
! ! |
|
319 |
||
2227 | 320 |
!ObjectView methodsFor:'accessing-behavior'! |
1943 | 321 |
|
2381 | 322 |
keyPressAction:aBlock |
323 |
keyPressAction := aBlock |
|
324 |
! |
|
325 |
||
326 |
motionAction:aBlock |
|
327 |
motionAction := aBlock |
|
328 |
! |
|
329 |
||
330 |
pressAction:aBlock |
|
331 |
pressAction := aBlock |
|
332 |
! |
|
333 |
||
334 |
releaseAction:aBlock |
|
335 |
releaseAction := aBlock |
|
336 |
! |
|
337 |
||
1943 | 338 |
setDefaultActions |
339 |
"setup actions for default behavior (do - nothing)" |
|
340 |
||
341 |
motionAction := [:movePoint | nil]. |
|
342 |
releaseAction := [nil] |
|
343 |
||
344 |
"Modified: / 4.7.1999 / 18:55:01 / cg" |
|
345 |
! ! |
|
346 |
||
2144 | 347 |
!ObjectView methodsFor:'adding & removing'! |
216 | 348 |
|
349 |
add:something |
|
350 |
"add something, anObject or a collection of objects to the contents |
|
351 |
with redraw" |
|
352 |
||
353 |
self forEach:something do:[:anObject | |
|
354 |
self addObject:anObject |
|
355 |
] |
|
77 | 356 |
! |
357 |
||
216 | 358 |
addObject:anObject |
359 |
"add the argument, anObject to the contents - with redraw" |
|
360 |
||
361 |
anObject notNil ifTrue:[ |
|
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
362 |
contents addLast:anObject. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
363 |
self changed:#addObject. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
364 |
"its on top - only draw this one" |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
365 |
shown "realized" ifTrue:[ |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
366 |
self showUnselected:anObject |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
367 |
] |
71 | 368 |
] |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
369 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
370 |
"Modified: / 4.7.1999 / 16:50:24 / cg" |
71 | 371 |
! |
372 |
||
1741 | 373 |
addObjectFirst:anObject |
374 |
"add the argument, anObject to the beginning of the contents - with redraw" |
|
375 |
||
376 |
anObject notNil ifTrue:[ |
|
377 |
contents addFirst:anObject. |
|
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
378 |
self changed:#addObject. |
1741 | 379 |
"its on top - only draw this one" |
380 |
shown "realized" ifTrue:[ |
|
381 |
self showUnselected:anObject |
|
382 |
] |
|
383 |
] |
|
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
384 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
385 |
"Modified: / 4.7.1999 / 16:50:22 / cg" |
1741 | 386 |
! |
387 |
||
388 |
addObjectFirstWithoutRedraw:anObject |
|
389 |
"add the argument, anObject to the start of the contents - no redraw" |
|
390 |
||
391 |
anObject notNil ifTrue:[ |
|
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
392 |
contents addFirst:anObject. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
393 |
self changed:#addObject. |
1741 | 394 |
] |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
395 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
396 |
"Modified: / 4.7.1999 / 16:50:19 / cg" |
1741 | 397 |
! |
398 |
||
216 | 399 |
addObjectWithoutRedraw:anObject |
400 |
"add the argument, anObject to the contents - no redraw" |
|
401 |
||
402 |
anObject notNil ifTrue:[ |
|
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
403 |
contents addLast:anObject. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
404 |
self changed:#addObject. |
216 | 405 |
] |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
406 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
407 |
"Modified: / 4.7.1999 / 16:50:16 / cg" |
216 | 408 |
! |
409 |
||
410 |
addSelected:something |
|
411 |
"add something, anObject or a collection of objects to the contents |
|
412 |
and select it" |
|
413 |
||
414 |
self add:something. |
|
415 |
self select:something |
|
416 |
! |
|
417 |
||
418 |
addWithoutRedraw:something |
|
419 |
"add something, anObject or a collection of objects to the contents |
|
420 |
do not redraw" |
|
421 |
||
422 |
self forEach:something do:[:anObject | |
|
423 |
self addObjectWithoutRedraw:anObject |
|
71 | 424 |
] |
425 |
! |
|
426 |
||
216 | 427 |
remove:something |
428 |
"remove something, anObject or a collection of objects from the contents |
|
429 |
do redraw" |
|
430 |
||
431 |
something size > (contents size / 4) ifTrue:[ |
|
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
432 |
" |
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
433 |
better to remove first, then redraw rest |
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
434 |
" |
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
435 |
self forEach:something do:[:anObject | |
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
436 |
self removeFromSelection:anObject. |
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
437 |
contents remove:anObject. |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
438 |
self changed:#removeObject. |
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
439 |
]. |
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
440 |
self invalidate. |
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
441 |
^ self |
71 | 442 |
]. |
443 |
||
216 | 444 |
self forEach:something do:[:anObject | |
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
445 |
self removeObject:anObject |
71 | 446 |
] |
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
447 |
|
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
448 |
"Modified: / 4.7.1999 / 16:50:09 / cg" |
71 | 449 |
! |
450 |
||
216 | 451 |
removeAll |
452 |
"remove all - redraw" |
|
453 |
||
454 |
self removeAllWithoutRedraw. |
|
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
455 |
self invalidate |
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
456 |
|
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
457 |
"Modified: 29.5.1996 / 16:20:28 / cg" |
216 | 458 |
! |
459 |
||
460 |
removeAllWithoutRedraw |
|
461 |
"remove all - no redraw" |
|
462 |
||
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
463 |
contents := OrderedCollection new. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
464 |
self changed:#removeObject. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
465 |
selection notNil ifTrue:[ |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
466 |
selection := nil. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
467 |
self changed:#selection. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
468 |
]. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
469 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
470 |
"Modified: / 4.7.1999 / 16:50:43 / cg" |
216 | 471 |
! |
472 |
||
473 |
removeObject:anObject |
|
474 |
"remove the argument, anObject from the contents - no redraw" |
|
475 |
||
476 |
anObject notNil ifTrue:[ |
|
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
477 |
self removeFromSelection:anObject. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
478 |
contents remove:anObject. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
479 |
shown "realized" ifTrue:[ |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
480 |
self redrawObjectsIn:(anObject frame) |
2053 | 481 |
]. |
482 |
self changed:#removeObject with:anObject. |
|
71 | 483 |
] |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
484 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
485 |
"Modified: / 4.7.1999 / 16:50:49 / cg" |
71 | 486 |
! |
487 |
||
216 | 488 |
removeObjectWithoutRedraw:anObject |
489 |
"remove the argument, anObject from the contents - no redraw" |
|
490 |
||
491 |
anObject notNil ifTrue:[ |
|
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
492 |
self removeFromSelection:anObject. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
493 |
contents remove:anObject. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
494 |
self changed:#removeObject. |
71 | 495 |
] |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
496 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
497 |
"Modified: / 4.7.1999 / 16:50:58 / cg" |
71 | 498 |
! |
499 |
||
216 | 500 |
removeWithoutRedraw:something |
501 |
"remove something, anObject or a collection of objects from the contents |
|
502 |
do not redraw" |
|
503 |
||
504 |
self forEach:something do:[:anObject | |
|
505 |
self removeObjectWithoutRedraw:anObject |
|
506 |
] |
|
71 | 507 |
! ! |
508 |
||
2449 | 509 |
!ObjectView methodsFor:'cut & paste'! |
216 | 510 |
|
511 |
convertForPaste:anObject |
|
512 |
"return a converted version of anObject to be pasted, or nil if |
|
513 |
the object is not compatible with me. |
|
514 |
Return nil here; concrete subclasses should try to convert. |
|
515 |
Notice: anObject may be a collection of to-be-pasted objects." |
|
516 |
||
517 |
"in concrete subclasses, you can use:" |
|
518 |
" |
|
519 |
|s| |
|
520 |
||
521 |
(anObject respondsTo:#asDisplayObject) ifTrue:[ |
|
522 |
^ anObject asDisplayObject |
|
523 |
]. |
|
524 |
(anObject isString or:[anObject isMemberOf:Text]) ifTrue:[ |
|
525 |
]. |
|
526 |
anObject size > 0 ifTrue:[ |
|
527 |
(anObject inject:true into:[:okSoFar :element | |
|
528 |
okSoFar and:[element respondsTo:#asDisplayObject] |
|
529 |
]) ifFalse:[ |
|
530 |
self warn:'selection not convertable to DisplayObject'. |
|
531 |
^ nil |
|
532 |
]. |
|
533 |
^ anObject collect:[:element | element asDisplayObject]. |
|
534 |
]. |
|
535 |
" |
|
536 |
^ nil. |
|
537 |
! |
|
538 |
||
539 |
copySelection |
|
540 |
"copy the selection into the cut&paste-buffer" |
|
541 |
||
542 |
|tmp| |
|
543 |
||
544 |
tmp := OrderedCollection new. |
|
545 |
self selectionDo:[:object | |
|
546 |
tmp add:(object copy) |
|
547 |
]. |
|
548 |
"/ self forEach:tmp do:[:anObject | |
|
549 |
"/ anObject moveTo:(anObject origin + (8 @ 8)) |
|
550 |
"/ ]. |
|
551 |
self setSelection:tmp |
|
0 | 552 |
! |
553 |
||
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
554 |
cutSelection |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
555 |
"cut the selection into the cut&paste buffer" |
216 | 556 |
|
557 |
|tmp| |
|
558 |
||
559 |
tmp := selection. |
|
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
560 |
tmp notNil ifTrue:[ |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
561 |
self unselect. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
562 |
self remove:tmp. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
563 |
self setSelection:tmp |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
564 |
] |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
565 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
566 |
"Created: / 4.7.1999 / 15:07:59 / cg" |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
567 |
"Modified: / 4.7.1999 / 15:29:50 / cg" |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
568 |
! |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
569 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
570 |
deleteSelection |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
571 |
"delete the selection" |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
572 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
573 |
|tmp| |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
574 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
575 |
tmp := selection. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
576 |
tmp notNil ifTrue:[ |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
577 |
self unselect. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
578 |
self remove:tmp. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
579 |
"/ self setSelection:tmp |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
580 |
]. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
581 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
582 |
"Modified: / 4.7.1999 / 15:29:55 / cg" |
216 | 583 |
! |
584 |
||
585 |
paste:something |
|
586 |
"add the objects in the cut&paste-buffer" |
|
587 |
||
588 |
|s| |
|
589 |
||
590 |
s := self convertForPaste:something . |
|
591 |
s isNil ifTrue:[ |
|
1186 | 592 |
self warn:'selection not convertable'. |
593 |
^ self |
|
216 | 594 |
]. |
1186 | 595 |
self unselect. |
216 | 596 |
self addSelected:s |
597 |
! |
|
598 |
||
599 |
pasteBuffer |
|
600 |
"add the objects in the paste-buffer" |
|
601 |
||
602 |
|sel| |
|
603 |
||
604 |
sel := self getSelection. |
|
2289 | 605 |
((Display platformName ~= 'X11') |
606 |
or:[(device getSelectionOwnerOf:#PRIMARY) == drawableId]) |
|
216 | 607 |
ifTrue:[ |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
608 |
" |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
609 |
a local selection - paste with some offset |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
610 |
" |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
611 |
sel size > 0 ifTrue:[ |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
612 |
sel := sel collect:[:element | |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
613 |
element copy moveTo:(element origin + (8 @ 8)) |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
614 |
] |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
615 |
] ifFalse:[ |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
616 |
sel := sel copy moveTo:(sel origin + (8 @ 8)) |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
617 |
] |
63 | 618 |
]. |
216 | 619 |
self paste:sel |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
620 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
621 |
"Modified: / 4.7.1999 / 15:10:46 / cg" |
216 | 622 |
! ! |
623 |
||
2615 | 624 |
!ObjectView methodsFor:'dragging-line'! |
216 | 625 |
|
626 |
doLineDrag:aPoint |
|
627 |
"do drag a line" |
|
628 |
||
629 |
self invertDragLine. |
|
630 |
dragObject corner:aPoint. |
|
631 |
self invertDragLine. |
|
632 |
! |
|
633 |
||
634 |
endLineDrag |
|
635 |
"cleanup after line drag; select them. Find the origin and destination |
|
636 |
views and relative offsets, then dispatch to one of the endLineDrag methods. |
|
637 |
These can be redefined in subclasses to allow connect between views." |
|
638 |
||
2435
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
639 |
|rootPoint viewId offs transformation2 |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
640 |
lastViewId destinationId destinationView destinationPoint |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
641 |
inMySelf dragOrigin| |
216 | 642 |
|
643 |
self invertDragLine. |
|
644 |
||
645 |
self cursor:oldCursor. |
|
646 |
||
647 |
"check if line drag is into another view" |
|
648 |
rootMotion ifTrue:[ |
|
2311
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
649 |
rootPoint := lastButt. |
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
650 |
" |
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
651 |
get device coordinates |
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
652 |
" |
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
653 |
transformation notNil ifTrue:[ |
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
654 |
rootPoint := transformation applyTo:rootPoint. |
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
655 |
]. |
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
656 |
|
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
657 |
" |
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
658 |
translate to screen |
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
659 |
" |
2435
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
660 |
offs := device translatePoint:0@0 fromView:self toView:rootView. |
2311
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
661 |
rootPoint := rootPoint + offs. |
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
662 |
|
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
663 |
"search view the drop is in" |
2435
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
664 |
viewId := rootView id. |
2311
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
665 |
[viewId notNil] whileTrue:[ |
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
666 |
destinationId := device viewIdFromPoint:rootPoint in:viewId. |
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
667 |
lastViewId := viewId. |
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
668 |
viewId := destinationId |
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
669 |
]. |
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
670 |
destinationView := device viewFromId:lastViewId. |
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
671 |
destinationId := lastViewId. |
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
672 |
inMySelf := (destinationView == self). |
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
673 |
rootMotion := false |
216 | 674 |
] ifFalse:[ |
2311
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
675 |
inMySelf := true |
216 | 676 |
]. |
677 |
||
2658 | 678 |
dragObject isNil ifTrue:[^ self]. |
679 |
||
2435
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
680 |
dragOrigin := dragObject origin. |
216 | 681 |
inMySelf ifTrue:[ |
2311
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
682 |
"a simple line within myself" |
2435
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
683 |
self lineDragFrom:dragOrigin to:dragObject corner |
63 | 684 |
] ifFalse:[ |
2311
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
685 |
"into another one" |
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
686 |
destinationView notNil ifTrue:[ |
2435
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
687 |
destinationPoint := device translatePoint:rootPoint fromView:rootView toView:destinationView. |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
688 |
(transformation2 := destinationView transformation) notNil ifTrue:[ |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
689 |
destinationPoint := transformation2 applyInverseTo:destinationPoint |
2311
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
690 |
]. |
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
691 |
" |
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
692 |
move into another smalltalk view |
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
693 |
" |
2435
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
694 |
self lineDragFrom:dragOrigin to:destinationPoint in:destinationView |
2311
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
695 |
] ifFalse:[ |
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
696 |
" |
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
697 |
not one of my views |
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
698 |
" |
2435
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
699 |
self lineDragFrom:dragOrigin to:destinationPoint inAlienViewId:destinationId |
2311
9746fb5dd8e0
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
2289
diff
changeset
|
700 |
] |
216 | 701 |
]. |
702 |
self setDefaultActions. |
|
703 |
dragObject := nil |
|
2435
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
704 |
|
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
705 |
"Modified: / 10.10.2001 / 14:41:52 / cg" |
63 | 706 |
! |
707 |
||
216 | 708 |
invertDragLine |
709 |
"helper for line dragging - invert the dragged line. |
|
710 |
Extracted for easier redefinition in subclasses |
|
711 |
(different line width etc.)" |
|
712 |
||
713 |
|dragger offs p1 p2| |
|
714 |
||
2658 | 715 |
dragObject isNil ifTrue:[^ self]. |
716 |
||
216 | 717 |
p1 := dragObject origin. |
718 |
p2 := dragObject corner. |
|
719 |
rootMotion ifTrue:[ |
|
262 | 720 |
dragger := rootView. |
721 |
" |
|
722 |
get device coordinates |
|
723 |
" |
|
724 |
transformation notNil ifTrue:[ |
|
725 |
p1 := transformation applyTo:p1. |
|
726 |
p2 := transformation applyTo:p2. |
|
727 |
]. |
|
728 |
" |
|
729 |
translate to screen |
|
730 |
" |
|
2435
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
731 |
offs := device translatePoint:0@0 fromView:self toView:rootView. |
262 | 732 |
p1 := p1 + offs. |
733 |
p2 := p2 + offs. |
|
63 | 734 |
] ifFalse:[ |
262 | 735 |
dragger := self. |
216 | 736 |
]. |
737 |
||
738 |
dragger xoring:[ |
|
262 | 739 |
dragger lineWidth:0. |
740 |
dragger displayLineFrom:p1 to:p2. |
|
741 |
dragger flush |
|
216 | 742 |
]. |
262 | 743 |
|
2435
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
744 |
"Modified: / 10.10.2001 / 13:59:05 / cg" |
216 | 745 |
! |
746 |
||
747 |
lineDragFrom:startPoint to:endPoint |
|
748 |
"this is called after a line-drag. Nothing is done here. |
|
749 |
- should be redefined in subclasses" |
|
750 |
||
751 |
^ self |
|
752 |
! |
|
753 |
||
754 |
lineDragFrom:startPoint to:endPoint in:destinationView |
|
755 |
"this is called after a line-drag crossing view boundaries. |
|
756 |
- should be redefined in subclasses" |
|
757 |
||
758 |
^ self notify:'dont know how to connect to external views' |
|
63 | 759 |
! |
760 |
||
216 | 761 |
lineDragFrom:startPoint to:endPoint inAlienViewId:destinationId |
762 |
"this is called after a line-drag with rootmotion set |
|
763 |
to true, IFF the endpoint is in an alien view |
|
764 |
- should be redefined in subclasses" |
|
765 |
||
766 |
self notify:'cannot connect object in alien view' |
|
767 |
! |
|
768 |
||
769 |
setLineDragActions |
|
770 |
"setup to drag a line. Call this (for example) from your buttonPress |
|
771 |
method, to make the view start to drag a line. |
|
772 |
See startLineDrag and startRootLineDrag." |
|
773 |
||
774 |
motionAction := [:movePoint | self doLineDrag:movePoint]. |
|
775 |
releaseAction := [self endLineDrag] |
|
776 |
! |
|
777 |
||
778 |
startLineDrag:startPoint |
|
779 |
"start a line drag within the view" |
|
780 |
||
781 |
self setLineDragActions. |
|
782 |
dragObject := Rectangle origin:startPoint corner:startPoint. |
|
783 |
self invertDragLine. |
|
784 |
oldCursor := cursor. |
|
785 |
self cursor:leftHandCursor |
|
786 |
! |
|
787 |
||
788 |
startRootLineDrag:startPoint |
|
789 |
"start a line drag possibly crossing my view boundaries" |
|
790 |
||
791 |
self setLineDragActions. |
|
792 |
rootMotion := true. |
|
793 |
dragObject := Rectangle origin:startPoint corner:startPoint. |
|
794 |
self invertDragLine. |
|
795 |
oldCursor := cursor. |
|
796 |
self cursor:leftHandCursor |
|
0 | 797 |
! ! |
798 |
||
2615 | 799 |
!ObjectView methodsFor:'dragging-object'! |
71 | 800 |
|
801 |
doObjectMove:aPoint |
|
77 | 802 |
"do an object move - this is called for every motion |
803 |
when moving objects." |
|
804 |
||
102 | 805 |
|d org nOrg| |
77 | 806 |
|
71 | 807 |
movedObject isNil ifTrue:[ |
808 |
movedObject := selection. |
|
809 |
" |
|
810 |
draw first outline |
|
811 |
" |
|
812 |
movedObject notNil ifTrue:[ |
|
813 |
moveDelta := 0@0. |
|
814 |
||
77 | 815 |
"tricky, the moved object may not currently be aligned. |
816 |
if so, simulate a frame move of the delta" |
|
817 |
||
105 | 818 |
aligningMove ifTrue:[ |
102 | 819 |
org := movedObject origin. |
820 |
d := org - (self alignToGrid:(org)). |
|
77 | 821 |
moveDelta := d negated. |
822 |
]. |
|
823 |
self invertDragObject:movedObject delta:moveDelta |
|
71 | 824 |
] |
825 |
]. |
|
826 |
movedObject notNil ifTrue:[ |
|
83 | 827 |
d := aPoint - moveStartPoint. |
105 | 828 |
aligningMove ifTrue:[ |
102 | 829 |
org := movedObject origin. |
830 |
nOrg := org + d. |
|
831 |
d := (self alignToGrid:(nOrg)) - org. |
|
77 | 832 |
]. |
83 | 833 |
d ~= moveDelta ifTrue:[ |
834 |
" |
|
835 |
clear prev outline, |
|
836 |
draw new outline |
|
837 |
" |
|
838 |
self invertDragObject:movedObject delta:moveDelta. |
|
839 |
moveDelta := d. |
|
840 |
self invertDragObject:movedObject delta:moveDelta |
|
841 |
] |
|
71 | 842 |
] |
843 |
! |
|
844 |
||
845 |
endObjectMove |
|
77 | 846 |
"cleanup after object move - called when the object move ends. |
847 |
Find the destination view and position and dispatch to |
|
848 |
one of the moveObjectXXX-methods which should do the real move. |
|
849 |
These can be redefined in subclasses." |
|
850 |
||
2435
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
851 |
|inMySelf rootPoint destinationPoint p transformation2 |
71 | 852 |
viewId destinationView destinationId lastViewId| |
853 |
||
854 |
movedObject notNil ifTrue:[ |
|
2435
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
855 |
self invertDragObject:movedObject delta:moveDelta. |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
856 |
|
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
857 |
"check if object is to be put into another view" |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
858 |
rootMotion ifTrue:[ |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
859 |
p := lastButt. |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
860 |
" |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
861 |
get device coordinates |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
862 |
" |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
863 |
transformation notNil ifTrue:[ |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
864 |
p := transformation applyTo:p. |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
865 |
]. |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
866 |
" |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
867 |
translate to screen |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
868 |
" |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
869 |
rootPoint := p + (device translatePoint:0@0 fromView:self toView:rootView). |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
870 |
|
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
871 |
"search view the drop is in" |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
872 |
viewId := rootView id. |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
873 |
[viewId notNil] whileTrue:[ |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
874 |
destinationId := device viewIdFromPoint:rootPoint in:viewId. |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
875 |
lastViewId := viewId. |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
876 |
viewId := destinationId |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
877 |
]. |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
878 |
destinationView := device viewFromId:lastViewId. |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
879 |
destinationId := lastViewId. |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
880 |
inMySelf := (destinationView == self). |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
881 |
rootMotion := false |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
882 |
] ifFalse:[ |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
883 |
inMySelf := true |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
884 |
]. |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
885 |
|
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
886 |
inMySelf ifTrue:[ |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
887 |
"simple move" |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
888 |
self move:movedObject by:moveDelta |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
889 |
] ifFalse:[ |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
890 |
destinationPoint := device translatePoint:rootPoint "/ use id here - could be alian view |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
891 |
from:(rootView id) |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
892 |
to:destinationId. |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
893 |
destinationView notNil ifTrue:[ |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
894 |
(transformation2 := destinationView transformation) notNil ifTrue:[ |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
895 |
destinationPoint := transformation2 applyInverseTo:destinationPoint |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
896 |
]. |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
897 |
" |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
898 |
move into another smalltalk view |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
899 |
" |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
900 |
self move:movedObject to:destinationPoint in:destinationView |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
901 |
] ifFalse:[ |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
902 |
" |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
903 |
not one of my views |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
904 |
" |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
905 |
self move:movedObject to:destinationPoint inAlienViewId:destinationId |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
906 |
] |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
907 |
]. |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
908 |
self setDefaultActions. |
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
909 |
movedObject := nil |
71 | 910 |
] |
2435
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
911 |
|
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
912 |
"Modified: / 10.10.2001 / 14:43:09 / cg" |
71 | 913 |
! |
914 |
||
77 | 915 |
invertDragObject:movedObject delta:moveDelta |
916 |
"draw inverting for an object move" |
|
917 |
||
918 |
|dragger offs p d scale oldTrans| |
|
919 |
||
920 |
rootMotion ifTrue:[ |
|
262 | 921 |
p := movedObject origin + moveDelta. |
922 |
dragger := rootView. |
|
923 |
" |
|
924 |
get device coordinates |
|
925 |
" |
|
77 | 926 |
"/ 'logical ' print. p printNL. |
262 | 927 |
transformation notNil ifTrue:[ |
928 |
scale := transformation scale. |
|
929 |
p := transformation applyTo:p. |
|
77 | 930 |
"/ 'device ' print. p printNL. |
262 | 931 |
]. |
932 |
" |
|
933 |
translate to screen |
|
934 |
" |
|
2435
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
935 |
offs := device translatePoint:0@0 fromView:self toView:rootView. |
77 | 936 |
"/ 'offs' print. offs printNL. |
262 | 937 |
p := p + offs. |
77 | 938 |
"/ 'screen ' print. p printNL. |
262 | 939 |
" |
940 |
p is where we want it ... |
|
941 |
have to adust slightly, since showDragging shows the object |
|
942 |
at its origin plus some offset; here we want it to be drawn |
|
943 |
at absolute p. |
|
944 |
To do so, we set the draggers translation to p and |
|
945 |
draw the object scaled at 0@0 (by setting offset to its negative org) |
|
946 |
" |
|
947 |
||
948 |
oldTrans := dragger transformation. |
|
949 |
dragger transformation:(WindowingTransformation |
|
950 |
scale:scale |
|
951 |
translation:p). |
|
952 |
d := movedObject origin negated. |
|
953 |
||
954 |
dragger xoring:[ |
|
955 |
self showDragging:movedObject offset:d. |
|
956 |
]. |
|
957 |
||
958 |
dragger transformation:oldTrans. |
|
959 |
dragger flush. |
|
77 | 960 |
] ifFalse:[ |
262 | 961 |
self xoring:[ |
962 |
self showDragging:movedObject offset:moveDelta. |
|
963 |
]. |
|
964 |
self flush |
|
77 | 965 |
]. |
262 | 966 |
|
2435
a47df77ac405
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2381
diff
changeset
|
967 |
"Modified: / 10.10.2001 / 13:59:19 / cg" |
216 | 968 |
! |
969 |
||
970 |
setMoveActions |
|
971 |
"setup to drag an object. Call this (for example) from your buttonPress |
|
972 |
method, to make the view start to drag some object. |
|
973 |
See startObjectMove and startRootObjectMove." |
|
974 |
||
975 |
motionAction := [:movePoint | self doObjectMove:movePoint]. |
|
976 |
releaseAction := [self endObjectMove] |
|
977 |
! |
|
978 |
||
979 |
startObjectMove:something at:aPoint |
|
980 |
"start an object move" |
|
981 |
||
982 |
self startObjectMove:something at:aPoint inRoot:canDragOutOfView |
|
983 |
! |
|
984 |
||
985 |
startObjectMove:something at:aPoint inRoot:inRoot |
|
986 |
"start an object move; if inRoot is true, view |
|
987 |
boundaries may be crossed." |
|
988 |
||
989 |
something notNil ifTrue:[ |
|
1944
378857db4611
care for unselectable objects in startMove
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
990 |
(self canSelect:something) ifTrue:[ |
378857db4611
care for unselectable objects in startMove
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
991 |
self select:something. |
378857db4611
care for unselectable objects in startMove
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
992 |
(self canMove:something) ifTrue:[ |
378857db4611
care for unselectable objects in startMove
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
993 |
self setMoveActions. |
378857db4611
care for unselectable objects in startMove
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
994 |
moveStartPoint := aPoint. |
378857db4611
care for unselectable objects in startMove
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
995 |
rootMotion := inRoot. |
378857db4611
care for unselectable objects in startMove
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
996 |
] ifFalse:[ |
378857db4611
care for unselectable objects in startMove
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
997 |
self setDefaultActions |
378857db4611
care for unselectable objects in startMove
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
998 |
] |
378857db4611
care for unselectable objects in startMove
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
999 |
] ifFalse:[ |
378857db4611
care for unselectable objects in startMove
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
1000 |
self setDefaultActions |
378857db4611
care for unselectable objects in startMove
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
1001 |
] |
216 | 1002 |
] |
1944
378857db4611
care for unselectable objects in startMove
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
1003 |
|
378857db4611
care for unselectable objects in startMove
Claus Gittinger <cg@exept.de>
parents:
1943
diff
changeset
|
1004 |
"Modified: / 4.7.1999 / 18:58:08 / cg" |
216 | 1005 |
! |
1006 |
||
1007 |
startRootObjectMove:something at:aPoint |
|
1008 |
"start an object move, possibly crossing view boundaries" |
|
1009 |
||
1010 |
self startObjectMove:something at:aPoint inRoot:true |
|
1011 |
! ! |
|
1012 |
||
2615 | 1013 |
!ObjectView methodsFor:'dragging-rectangle'! |
216 | 1014 |
|
1015 |
doRectangleDrag:aPoint |
|
1016 |
"do drag a rectangle" |
|
1017 |
||
1018 |
self invertDragRectangle. |
|
1019 |
dragObject corner:aPoint. |
|
1020 |
self invertDragRectangle. |
|
1021 |
! |
|
1022 |
||
1023 |
endRectangleDrag |
|
1024 |
"cleanup after rectangle drag; select them" |
|
1025 |
||
1026 |
self invertDragRectangle. |
|
1027 |
self cursor:oldCursor. |
|
1028 |
self selectAllIn:dragObject |
|
1029 |
! |
|
1030 |
||
1031 |
invertDragRectangle |
|
1032 |
"helper for rectangle drag - invert the dragRectangle. |
|
1033 |
Extracted into a separate method to allow easier redefinition |
|
1034 |
(different lineWidth etc)" |
|
1035 |
||
733 | 1036 |
self xoring:[ |
1037 |
self lineWidth:0. |
|
743
c2aafc876d49
dashed rectangle drag does not work on some Xservers
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
1038 |
"/ self lineStyle:#dashed. |
733 | 1039 |
self displayRectangle:dragObject. |
743
c2aafc876d49
dashed rectangle drag does not work on some Xservers
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
1040 |
"/ self lineStyle:#solid. |
733 | 1041 |
]. |
1042 |
||
743
c2aafc876d49
dashed rectangle drag does not work on some Xservers
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
1043 |
"Modified: 3.6.1996 / 10:02:22 / cg" |
216 | 1044 |
! |
1045 |
||
1046 |
setRectangleDragActions |
|
1047 |
"setup to drag a rectangle. Call this (for example) from your buttonPress |
|
1048 |
method, to make the view start the drag. |
|
1049 |
See startRectangleDrag:." |
|
1050 |
||
1051 |
motionAction := [:movePoint | self doRectangleDrag:movePoint]. |
|
1052 |
releaseAction := [self endRectangleDrag] |
|
1053 |
! |
|
1054 |
||
1055 |
startRectangleDrag:startPoint |
|
1056 |
"start a rectangle drag" |
|
1057 |
||
1058 |
self setRectangleDragActions. |
|
1059 |
dragObject := Rectangle origin:startPoint corner:startPoint. |
|
1060 |
self invertDragRectangle. |
|
1061 |
oldCursor := cursor. |
|
1062 |
self cursor:leftHandCursor |
|
71 | 1063 |
! ! |
1064 |
||
1065 |
!ObjectView methodsFor:'drawing'! |
|
1066 |
||
1067 |
redraw |
|
1068 |
"redraw complete View" |
|
1069 |
||
1070 |
shown ifTrue:[ |
|
1071 |
self clear. |
|
1072 |
self redrawObjects |
|
1073 |
] |
|
1074 |
! |
|
1075 |
||
1076 |
redrawObjects |
|
1077 |
"redraw all objects" |
|
1078 |
||
1079 |
self redrawObjectsOn:self |
|
1080 |
! |
|
1081 |
||
1082 |
redrawObjectsAbove:anObject in:aRectangle |
|
1083 |
"redraw all objects which have part of themselfes in aRectangle |
|
1084 |
and are above (in front of) anObject. |
|
1085 |
draw only in (i.e. clip output to) aRectangle" |
|
1086 |
||
700 | 1087 |
|vis oldClip| |
71 | 1088 |
|
1089 |
shown ifTrue:[ |
|
700 | 1090 |
vis := aRectangle. |
1091 |
clipRect notNil ifTrue:[ |
|
1092 |
vis := vis intersect:clipRect |
|
1093 |
]. |
|
1094 |
oldClip := clipRect. |
|
1095 |
self clippingRectangle:vis. |
|
1096 |
||
1097 |
self redrawObjectsAbove:anObject intersecting:vis. |
|
1098 |
||
1099 |
self clippingRectangle:oldClip |
|
71 | 1100 |
] |
700 | 1101 |
|
1102 |
"Modified: 28.5.1996 / 19:57:06 / cg" |
|
71 | 1103 |
! |
1104 |
||
1105 |
redrawObjectsAbove:anObject inVisible:aRectangle |
|
1106 |
"redraw all objects which have part of themselfes in a vis rectangle |
|
1107 |
and are above (in front of) anObject. |
|
1108 |
draw only in (i.e. clip output to) aRectangle" |
|
1109 |
||
700 | 1110 |
|vis oldClip| |
71 | 1111 |
|
1112 |
shown ifTrue:[ |
|
700 | 1113 |
vis := aRectangle. |
1114 |
clipRect notNil ifTrue:[ |
|
1115 |
vis := vis intersect:clipRect |
|
1116 |
]. |
|
1117 |
oldClip := clipRect. |
|
1118 |
self clippingRectangle:vis. |
|
1119 |
||
1120 |
self redrawObjectsAbove:anObject intersectingVisible:vis. |
|
1121 |
||
1122 |
self clippingRectangle:oldClip |
|
71 | 1123 |
] |
700 | 1124 |
|
1125 |
"Modified: 28.5.1996 / 19:56:44 / cg" |
|
0 | 1126 |
! |
1127 |
||
216 | 1128 |
redrawObjectsAbove:anObject intersecting:aRectangle |
1129 |
"redraw all objects which have part of themself in aRectangle |
|
1130 |
and are above (in front of) anObject" |
|
1131 |
||
1132 |
self objectsAbove:anObject intersecting:aRectangle do:[:theObject | |
|
1133 |
self show:theObject |
|
1134 |
] |
|
71 | 1135 |
! |
1136 |
||
216 | 1137 |
redrawObjectsAbove:anObject intersectingVisible:aRectangle |
1138 |
"redraw all objects which have part of themself in a vis rectangle |
|
1139 |
and are above (in front of) anObject" |
|
1140 |
||
1141 |
self objectsAbove:anObject intersectingVisible:aRectangle do:[:theObject | |
|
1142 |
self show:theObject |
|
1143 |
] |
|
71 | 1144 |
! |
1145 |
||
216 | 1146 |
redrawObjectsIn:aRectangle |
1147 |
"redraw all objects which have part of themselfes in aRectangle |
|
1148 |
draw only in (i.e. clip output to) aRectangle" |
|
1149 |
||
700 | 1150 |
|visRect oldClip| |
216 | 1151 |
|
1152 |
shown ifTrue:[ |
|
700 | 1153 |
visRect := Rectangle origin:(aRectangle origin) |
1154 |
extent:(aRectangle extent). |
|
216 | 1155 |
"/ transformation notNil ifTrue:[ |
700 | 1156 |
visRect := visRect origin truncated |
1157 |
corner:(visRect corner + (1@1)) truncated. |
|
216 | 1158 |
"/ ]. |
700 | 1159 |
clipRect notNil ifTrue:[ |
1160 |
visRect := visRect intersect:clipRect |
|
1161 |
]. |
|
1162 |
oldClip := clipRect. |
|
1163 |
self clippingRectangle:visRect. |
|
1164 |
||
1165 |
self clearRectangle:visRect. |
|
1166 |
self redrawObjectsIntersecting:visRect. |
|
1167 |
||
1168 |
self clippingRectangle:oldClip |
|
71 | 1169 |
] |
700 | 1170 |
|
1171 |
"Modified: 28.5.1996 / 19:56:20 / cg" |
|
71 | 1172 |
! |
1173 |
||
216 | 1174 |
redrawObjectsInVisible:visRect |
1175 |
"redraw all objects which have part of themselfes in a vis rectangle |
|
1176 |
draw only in (i.e. clip output to) aRectangle" |
|
1177 |
||
700 | 1178 |
|vis oldClip| |
216 | 1179 |
|
1180 |
shown ifTrue:[ |
|
700 | 1181 |
vis := visRect. |
1182 |
clipRect notNil ifTrue:[ |
|
1183 |
vis := vis intersect:clipRect |
|
1184 |
]. |
|
1185 |
||
1186 |
transformation notNil ifTrue:[ |
|
216 | 1187 |
"/ transformation scale ~~ 1 ifTrue:[ |
700 | 1188 |
vis := vis origin truncated |
1189 |
corner:(vis corner + (1@1)) truncated. |
|
216 | 1190 |
"/ ] |
700 | 1191 |
]. |
1192 |
||
1193 |
oldClip := clipRect. |
|
1194 |
self clippingRectangle:vis. |
|
1195 |
||
1196 |
self clearRectangle:vis. |
|
1197 |
self redrawObjectsIntersecting:vis. |
|
1198 |
||
1199 |
self clippingRectangle:oldClip |
|
0 | 1200 |
] |
700 | 1201 |
|
1202 |
"Modified: 28.5.1996 / 19:55:47 / cg" |
|
0 | 1203 |
! |
1204 |
||
216 | 1205 |
redrawObjectsIntersecting:aRectangle |
1206 |
"redraw all objects which have part of themself in aRectangle" |
|
0 | 1207 |
|
63 | 1208 |
self objectsIntersecting:aRectangle do:[:theObject | |
216 | 1209 |
self show:theObject |
71 | 1210 |
] |
0 | 1211 |
! |
1212 |
||
216 | 1213 |
redrawObjectsIntersectingVisible:aRectangle |
1214 |
"redraw all objects which have part of themself in a vis rectangle |
|
1215 |
This is a leftOver from times when scrolling was not transparent. |
|
1216 |
Please use redrawObjectsIntersecting:, since this will vanish." |
|
1217 |
||
1218 |
self redrawObjectsIntersecting:aRectangle |
|
71 | 1219 |
! |
1220 |
||
216 | 1221 |
redrawObjectsOn:aGC |
1222 |
"redraw all objects on a graphic context" |
|
1223 |
||
1224 |
|vFrame| |
|
1225 |
||
1226 |
(aGC == self) ifTrue:[ |
|
619 | 1227 |
shown ifFalse:[^ self]. |
1228 |
vFrame := Rectangle left:0 top:0 width:width height:height. |
|
1229 |
||
1230 |
transformation notNil ifTrue:[ |
|
1231 |
vFrame := transformation applyInverseTo:vFrame. |
|
1232 |
]. |
|
1233 |
self redrawObjectsIntersecting:vFrame |
|
216 | 1234 |
] ifFalse:[ |
619 | 1235 |
"should loop over pages" |
1236 |
||
1237 |
vFrame := Rectangle left:0 top:0 width:9999 height:9999. |
|
1238 |
||
1239 |
self objectsIntersecting:vFrame do:[:theObject | |
|
1240 |
theObject drawIn:aGC |
|
1241 |
] |
|
63 | 1242 |
] |
619 | 1243 |
|
1244 |
"Modified: 8.5.1996 / 21:01:27 / cg" |
|
63 | 1245 |
! |
1246 |
||
216 | 1247 |
redrawScale |
1248 |
"redraw the scales" |
|
1249 |
||
1250 |
self redrawHorizontalScale. |
|
1251 |
self redrawVerticalScale |
|
1252 |
! |
|
1253 |
||
1254 |
show:anObject |
|
1255 |
"show the object, either selected or not" |
|
1256 |
||
1257 |
(self isSelected:anObject) ifTrue:[ |
|
1258 |
self showSelected:anObject |
|
1259 |
] ifFalse:[ |
|
1260 |
self showUnselected:anObject |
|
63 | 1261 |
] |
1262 |
! |
|
1263 |
||
216 | 1264 |
showDragging:something offset:anOffset |
1265 |
"show an object while dragging" |
|
1266 |
||
1267 |
|drawer| |
|
1268 |
||
1269 |
rootMotion ifTrue:[ |
|
1270 |
"drag in root-window" |
|
1271 |
||
1272 |
drawer := rootView |
|
1273 |
] ifFalse:[ |
|
1274 |
drawer := self |
|
1275 |
]. |
|
71 | 1276 |
self forEach:something do:[:anObject | |
216 | 1277 |
anObject drawDragIn:drawer offset:anOffset |
71 | 1278 |
] |
1279 |
! |
|
1280 |
||
216 | 1281 |
showSelected:anObject |
1282 |
"show an object as selected" |
|
1283 |
||
1284 |
anObject drawSelectedIn:self |
|
71 | 1285 |
! |
1286 |
||
216 | 1287 |
showUnselected:anObject |
1288 |
"show an object as unselected" |
|
1289 |
||
1290 |
anObject drawIn:self |
|
0 | 1291 |
! ! |
1292 |
||
216 | 1293 |
!ObjectView methodsFor:'event handling'! |
1294 |
||
1295 |
buttonMotion:buttonMask x:buttX y:buttY |
|
1296 |
"user moved mouse while button pressed" |
|
1297 |
||
1298 |
|xpos ypos movePoint limitW limitH| |
|
1299 |
||
1300 |
"is it the select or 1-button ?" |
|
1622
50dd1ee1604a
use another left-button-down test in #buttonMotion.
Claus Gittinger <cg@exept.de>
parents:
1490
diff
changeset
|
1301 |
self sensor leftButtonPressed ifFalse:[^ self]. |
50dd1ee1604a
use another left-button-down test in #buttonMotion.
Claus Gittinger <cg@exept.de>
parents:
1490
diff
changeset
|
1302 |
"/ (device buttonMotionMask:buttonMask includesButton:#select) ifFalse:[ |
50dd1ee1604a
use another left-button-down test in #buttonMotion.
Claus Gittinger <cg@exept.de>
parents:
1490
diff
changeset
|
1303 |
"/ (device buttonMotionMask:buttonMask includesButton:1) ifFalse:[ |
50dd1ee1604a
use another left-button-down test in #buttonMotion.
Claus Gittinger <cg@exept.de>
parents:
1490
diff
changeset
|
1304 |
"/ ^ self |
50dd1ee1604a
use another left-button-down test in #buttonMotion.
Claus Gittinger <cg@exept.de>
parents:
1490
diff
changeset
|
1305 |
"/ ]. |
50dd1ee1604a
use another left-button-down test in #buttonMotion.
Claus Gittinger <cg@exept.de>
parents:
1490
diff
changeset
|
1306 |
"/ ]. |
216 | 1307 |
|
1308 |
lastButt notNil ifTrue:[ |
|
732
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1309 |
xpos := buttX. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1310 |
ypos := buttY. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1311 |
|
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1312 |
"check against visible limits if move outside is not allowed" |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1313 |
rootMotion ifFalse:[ |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1314 |
limitW := width. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1315 |
limitH := height. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1316 |
transformation notNil ifTrue:[ |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1317 |
limitW := transformation applyInverseToX:width. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1318 |
limitH := transformation applyInverseToY:height. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1319 |
]. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1320 |
|
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1321 |
(xpos < 0) ifTrue:[ |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1322 |
xpos := 0 |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1323 |
] ifFalse: [ |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1324 |
(xpos > limitW) ifTrue:[xpos := limitW] |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1325 |
]. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1326 |
(ypos < 0) ifTrue:[ |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1327 |
ypos := 0 |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1328 |
] ifFalse: [ |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1329 |
(ypos > limitH) ifTrue:[ypos := limitH] |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1330 |
] |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1331 |
]. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1332 |
movePoint := xpos @ ypos. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1333 |
|
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1334 |
(xpos == (lastButt x)) ifTrue:[ |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1335 |
(ypos == (lastButt y)) ifTrue:[ |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1336 |
^ self "no move" |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1337 |
] |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1338 |
]. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1339 |
|
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1340 |
motionAction notNil ifTrue:[ |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1341 |
motionAction value:movePoint. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1342 |
lastButt := movePoint. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1343 |
^ self |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1344 |
]. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1345 |
lastButt := movePoint |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1346 |
]. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1347 |
super buttonMotion:buttonMask x:buttX y:buttY |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1348 |
|
1622
50dd1ee1604a
use another left-button-down test in #buttonMotion.
Claus Gittinger <cg@exept.de>
parents:
1490
diff
changeset
|
1349 |
"Modified: / 28.7.1998 / 16:01:31 / cg" |
216 | 1350 |
! |
1351 |
||
1352 |
buttonMultiPress:button x:x y:y |
|
1353 |
"user pressed left button twice (or more)" |
|
1354 |
||
1355 |
((button == 1) or:[button == #select]) ifTrue:[ |
|
732
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1356 |
doublePressAction notNil ifTrue:[ |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1357 |
doublePressAction value:(x @ y). |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1358 |
^ self |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1359 |
] |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1360 |
]. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1361 |
super buttonMultiPress:button x:x y:y |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1362 |
|
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1363 |
"Modified: 30.5.1996 / 17:57:36 / cg" |
0 | 1364 |
! |
1365 |
||
216 | 1366 |
buttonPress:button x:x y:y |
1367 |
"user pressed left button" |
|
1368 |
||
1369 |
((button == 1) or:[button == #select]) ifTrue:[ |
|
815 | 1370 |
self sensor shiftDown ifTrue:[ |
1371 |
^ self buttonShiftPress:button x:x y:y |
|
1372 |
]. |
|
1373 |
||
732
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1374 |
pressAction notNil ifTrue:[ |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1375 |
lastButt := x @ y. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1376 |
pressAction value:lastButt. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1377 |
^ self |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1378 |
] |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1379 |
]. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1380 |
super buttonPress:button x:x y:y |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1381 |
|
815 | 1382 |
"Modified: 1.8.1996 / 19:13:01 / cg" |
71 | 1383 |
! |
1384 |
||
216 | 1385 |
buttonRelease:button x:x y:y |
1386 |
((button == 1) or:[button == #select]) ifTrue:[ |
|
732
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1387 |
releaseAction notNil ifTrue:[ |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1388 |
releaseAction value. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1389 |
^ self |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1390 |
] |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1391 |
]. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1392 |
super buttonRelease:button x:x y:y |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1393 |
|
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1394 |
"Modified: 30.5.1996 / 17:57:13 / cg" |
63 | 1395 |
! |
1396 |
||
216 | 1397 |
buttonShiftPress:button x:x y:y |
1398 |
"user pressed left button with shift" |
|
1399 |
||
815 | 1400 |
shiftPressAction notNil ifTrue:[ |
1401 |
lastButt := x @ y. |
|
1402 |
shiftPressAction value:lastButt. |
|
1403 |
^ self |
|
1404 |
] |
|
1405 |
||
1406 |
"Modified: 1.8.1996 / 19:13:19 / cg" |
|
63 | 1407 |
! |
1408 |
||
216 | 1409 |
keyPress:key x:x y:y |
1410 |
keyPressAction notNil ifTrue:[ |
|
732
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1411 |
selection notNil ifTrue:[ |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1412 |
self selectionDo: [:obj | |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1413 |
obj keyInput:key . |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1414 |
] |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1415 |
]. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1416 |
^ self. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1417 |
]. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1418 |
super keyPress:key x:x y:y |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1419 |
|
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1420 |
"Modified: 30.5.1996 / 17:57:54 / cg" |
0 | 1421 |
! |
1422 |
||
216 | 1423 |
redrawX:x y:y width:w height:h |
1424 |
|redrawFrame | |
|
1425 |
||
749
19b1792b9506
clear area before doing a redraw
Claus Gittinger <cg@exept.de>
parents:
747
diff
changeset
|
1426 |
redrawFrame := Rectangle left:x top:y width:w height:h. |
19b1792b9506
clear area before doing a redraw
Claus Gittinger <cg@exept.de>
parents:
747
diff
changeset
|
1427 |
self clearRectangle:redrawFrame. |
216 | 1428 |
((contents size ~~ 0) or:[gridShown]) ifTrue:[ |
619 | 1429 |
self redrawObjectsInVisible:redrawFrame |
0 | 1430 |
] |
619 | 1431 |
|
749
19b1792b9506
clear area before doing a redraw
Claus Gittinger <cg@exept.de>
parents:
747
diff
changeset
|
1432 |
"Modified: 5.6.1996 / 10:42:19 / cg" |
63 | 1433 |
! ! |
1434 |
||
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1826
diff
changeset
|
1435 |
!ObjectView methodsFor:'focus control'! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1826
diff
changeset
|
1436 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1826
diff
changeset
|
1437 |
wantsFocusWithPointerEnter |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1826
diff
changeset
|
1438 |
^ UserPreferences current focusFollowsMouse ~~ false |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1826
diff
changeset
|
1439 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1826
diff
changeset
|
1440 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1826
diff
changeset
|
1441 |
! ! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1826
diff
changeset
|
1442 |
|
63 | 1443 |
!ObjectView methodsFor:'grid manipulation'! |
1444 |
||
216 | 1445 |
alignOff |
1446 |
"do no align point to grid" |
|
1447 |
||
1448 |
aligning := false |
|
71 | 1449 |
! |
1450 |
||
216 | 1451 |
alignOn |
1452 |
"align points to grid" |
|
1453 |
||
1454 |
aligning := true. |
|
1455 |
self getAlignParameters |
|
63 | 1456 |
! |
1457 |
||
1458 |
defineGrid |
|
77 | 1459 |
"define the grid pattern - this creates the gridPixmap, which is |
1460 |
used as viewBackground when a grid is to be shown. |
|
1461 |
The grid is specified by the value returned from gridParameters, |
|
1462 |
which can be redefined in subclasses. See the comment there on how |
|
1463 |
the numbers are interpreted." |
|
63 | 1464 |
|
1465 |
|mmH mmV params showDocumentBoundary gridW gridH |
|
1920 | 1466 |
bigStepH bigStepV littleStepH littleStepV hires devPixmap colorMap| |
63 | 1467 |
|
1468 |
mmH := self horizontalPixelPerMillimeter. |
|
1469 |
mmV := self verticalPixelPerMillimeter. |
|
1470 |
hires := self horizontalPixelPerInch > 120. |
|
0 | 1471 |
|
63 | 1472 |
params := self gridParameters. |
1473 |
||
1474 |
bigStepH := params at:1. |
|
1475 |
bigStepV := params at:2. |
|
1476 |
littleStepH := params at:3. |
|
1477 |
littleStepV := params at:4. |
|
1478 |
showDocumentBoundary := params at:7. |
|
0 | 1479 |
|
63 | 1480 |
transformation notNil ifTrue:[ |
256
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1481 |
mmH := mmH * transformation scale x. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1482 |
mmV := mmV * transformation scale y. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1483 |
bigStepH := bigStepH * transformation scale x. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1484 |
bigStepV := bigStepV * transformation scale y. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1485 |
littleStepH notNil ifTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1486 |
littleStepH := littleStepH * transformation scale x. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1487 |
]. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1488 |
littleStepV notNil ifTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1489 |
littleStepV := littleStepV * transformation scale y. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1490 |
]. |
0 | 1491 |
]. |
1492 |
||
63 | 1493 |
bigStepH isNil ifTrue:[^ self]. |
1494 |
||
1490 | 1495 |
gridW := (self widthOfContentsInMM * mmH). |
1496 |
gridH := (self heightOfContentsInMM * mmV). |
|
1497 |
||
256
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1498 |
self withWaitCursorDo:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1499 |
|xp yp y x| |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1500 |
|
1490 | 1501 |
((bigStepH isInteger and:[littleStepH isNil or:[littleStepH isInteger]]) |
1502 |
and:[(bigStepV isInteger and:[littleStepV isNil or:[littleStepV isInteger]])]) ifTrue:[ |
|
1503 |
gridW := bigStepH. |
|
1504 |
littleStepH notNil ifTrue:[gridW := gridW max:littleStepH]. |
|
1505 |
gridH := bigStepV. |
|
1506 |
littleStepV notNil ifTrue:[gridH := gridH max:littleStepV]. |
|
1507 |
] ifFalse:[ |
|
1508 |
||
1509 |
" |
|
1510 |
up to next full unit |
|
1511 |
" |
|
1512 |
gridW := ((gridW // bigStepH) + 1 * bigStepH) asInteger. |
|
1513 |
gridH := ((gridH // bigStepV) + 1 * bigStepV) asInteger. |
|
1514 |
]. |
|
256
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1515 |
|
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1516 |
gridPixmap := Form width:gridW height:gridH depth:1. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1517 |
gridPixmap colorMap:(Array with:White with:Black). |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1518 |
gridPixmap clear. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1519 |
gridPixmap paint:(Color colorId:1). |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1520 |
|
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1521 |
"draw first row point-by-point" |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1522 |
yp := 0.0. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1523 |
xp := 0.0. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1524 |
y := yp asInteger. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1525 |
[xp <= gridW] whileTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1526 |
x := xp rounded. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1527 |
hires ifTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1528 |
gridPixmap displayPointX:(x + 1) y:y. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1529 |
gridPixmap displayPointX:(x + 2) y:y |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1530 |
]. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1531 |
gridPixmap displayPointX:x y:y. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1532 |
littleStepH notNil ifTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1533 |
xp := xp + littleStepH |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1534 |
] ifFalse:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1535 |
xp := xp + bigStepH |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1536 |
] |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1537 |
]. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1538 |
|
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1539 |
"copy rest from what has been drawn already" |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1540 |
yp := yp + bigStepV. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1541 |
[yp <= gridH] whileTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1542 |
y := yp rounded. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1543 |
hires ifTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1544 |
gridPixmap copyFrom:gridPixmap x:0 y:0 |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1545 |
toX:0 y:(y + 1) |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1546 |
width:gridW height:1. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1547 |
gridPixmap copyFrom:gridPixmap x:0 y:0 |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1548 |
toX:0 y:(y + 2) |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1549 |
width:gridW height:1 |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1550 |
]. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1551 |
gridPixmap copyFrom:gridPixmap x:0 y:0 |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1552 |
toX:0 y:y |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1553 |
width:gridW height:1. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1554 |
yp := yp + bigStepV |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1555 |
]. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1556 |
|
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1557 |
"draw first col point-by-point" |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1558 |
xp := 0.0. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1559 |
yp := 0.0. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1560 |
x := xp asInteger. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1561 |
[yp <= gridH] whileTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1562 |
y := yp rounded. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1563 |
hires ifTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1564 |
gridPixmap displayPointX:x y:(y + 1). |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1565 |
gridPixmap displayPointX:x y:(y + 2) |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1566 |
]. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1567 |
gridPixmap displayPointX:x y:y. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1568 |
littleStepV notNil ifTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1569 |
yp := yp + littleStepV |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1570 |
] ifFalse:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1571 |
yp := yp + bigStepV |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1572 |
] |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1573 |
]. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1574 |
|
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1575 |
"copy rest from what has been drawn already" |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1576 |
xp := xp + bigStepH. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1577 |
[xp <= gridW] whileTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1578 |
x := xp rounded. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1579 |
hires ifTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1580 |
gridPixmap copyFrom:gridPixmap x:0 y:0 |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1581 |
toX:(x + 1) y:0 |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1582 |
width:1 height:gridH. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1583 |
gridPixmap copyFrom:gridPixmap x:0 y:0 |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1584 |
toX:(x + 2) y:0 |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1585 |
width:1 height:gridH |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1586 |
]. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1587 |
gridPixmap copyFrom:gridPixmap x:0 y:0 |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1588 |
toX:x y:0 |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1589 |
width:1 height:gridH. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1590 |
xp := xp + bigStepH |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1591 |
]. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1592 |
|
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1593 |
showDocumentBoundary ifTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1594 |
" |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1595 |
mark the right-end and bottom of the document |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1596 |
" |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1597 |
gridPixmap displayLineFromX:gridW-1 y:0 toX:gridW-1 y:gridH-1. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1598 |
gridPixmap displayLineFromX:0 y:gridH-1 toX:gridW-1 y:gridH-1. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1599 |
]. |
1920 | 1600 |
|
1601 |
device platformName = 'WIN32' ifTrue:[ |
|
1602 |
"/ kludge - needs a deep form |
|
1603 |
colorMap := gridPixmap colorMap. |
|
1604 |
devPixmap := Form width:gridW height:gridH depth:device depth on:device. |
|
1605 |
devPixmap notNil ifTrue:[ |
|
1606 |
devPixmap paint:(colorMap at:1). |
|
1607 |
devPixmap fillRectangleX:0 y:0 width:gridW height:gridH. |
|
1608 |
devPixmap foreground:(colorMap at:2) background:(colorMap at:1). |
|
1609 |
devPixmap copyPlaneFrom:gridPixmap x:0 y:0 toX:0 y:0 width:gridW height:gridH. |
|
1610 |
gridPixmap := devPixmap. |
|
1611 |
] |
|
1612 |
]. |
|
63 | 1613 |
] |
256
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1614 |
|
1920 | 1615 |
"Modified: / 6.6.1999 / 01:00:16 / cg" |
63 | 1616 |
! |
1617 |
||
216 | 1618 |
getAlignParameters |
1619 |
|params| |
|
1620 |
||
1621 |
params := self gridParameters. |
|
1622 |
gridAlign := (params at:5) @ (params at:6) |
|
1623 |
! |
|
1624 |
||
1625 |
gridParameters |
|
1626 |
"used by defineGrid, and in a separate method for |
|
1627 |
easier redefinition in subclasses. |
|
1628 |
Returns the grid parameters in an array of 7 elements, |
|
1629 |
which control the appearance of the grid-pattern. |
|
1630 |
the elements are: |
|
1631 |
||
1632 |
bigStepH number of pixels horizontally between 2 major steps |
|
1633 |
bigStepV number of pixels vertically between 2 major steps |
|
1634 |
littleStepH number of pixels horizontally between 2 minor steps |
|
1635 |
littleStepV number of pixels vertically between 2 minor steps |
|
1636 |
gridAlignH number of pixels for horizontal grid align (pointer snap) |
|
1637 |
gridAlignV number of pixels for vertical grid align (pointer snap) |
|
1638 |
docBounds true, if document boundary should be shown |
|
1639 |
||
1640 |
if littleStepH/V are nil, only bigSteps are drawn. |
|
1641 |
" |
|
1642 |
||
1643 |
|mmH mmV bigStepH bigStepV littleStepH littleStepV arr| |
|
1644 |
||
1645 |
"example: 12grid & 12snapIn" |
|
1646 |
"/ ^ #(12 12 nil nil 12 12 false). |
|
1647 |
||
1648 |
"example: 12grid & 24snapIn" |
|
1649 |
"/ ^ #(12 12 nil nil 24 24 false). |
|
1650 |
||
1651 |
"default: cm/mm grid & mm snapIn for metric, |
|
1652 |
1inch , 1/8inch grid & 1/8 inch snapIn" |
|
1653 |
||
1654 |
mmH := self horizontalPixelPerMillimeter. |
|
1655 |
mmV := self verticalPixelPerMillimeter. |
|
1656 |
||
1657 |
" |
|
1658 |
metric grid: small steps every millimeter, big step every |
|
1659 |
centimeter. If the transformation is shrinking, turn off little |
|
1660 |
steps. |
|
1661 |
" |
|
1662 |
(scaleMetric == #mm) ifTrue:[ |
|
1663 |
"dots every mm; lines every cm" |
|
1664 |
bigStepH := mmH * 10.0. |
|
1665 |
bigStepV := mmV * 10.0. |
|
1666 |
(transformation notNil |
|
1667 |
and:[transformation scale <= 0.5]) ifFalse:[ |
|
1668 |
littleStepH := mmH. |
|
1669 |
littleStepV := mmV |
|
1670 |
] |
|
1671 |
]. |
|
1672 |
" |
|
1673 |
inch grid: small steps every 1/8th inch, big step every half inch |
|
1674 |
If the transformation is shrinking, change little steps to 1/th inch |
|
1675 |
or even turn them off completely. |
|
1676 |
" |
|
1677 |
(scaleMetric == #inch) ifTrue:[ |
|
1678 |
"dots every eights inch; lines every half inch" |
|
1679 |
bigStepH := mmH * (25.4 / 2). |
|
1680 |
bigStepV := mmV * (25.4 / 2). |
|
1681 |
(transformation notNil |
|
1682 |
and:[transformation scale <= 0.5]) ifTrue:[ |
|
1683 |
transformation scale > 0.2 ifTrue:[ |
|
1684 |
littleStepH := mmH * (25.4 / 4). |
|
1685 |
littleStepV := mmV * (25.4 / 4) |
|
1686 |
] |
|
1687 |
] ifFalse:[ |
|
1688 |
littleStepH := mmH * (25.4 / 8). |
|
1689 |
littleStepV := mmV * (25.4 / 8) |
|
1690 |
] |
|
1691 |
]. |
|
1692 |
||
1693 |
arr := Array new:8. |
|
1694 |
arr at:1 put:bigStepH. |
|
1695 |
arr at:2 put:bigStepV. |
|
1696 |
arr at:3 put:littleStepH. |
|
1697 |
arr at:4 put:littleStepV. |
|
1698 |
arr at:5 put:littleStepH. |
|
1699 |
arr at:6 put:littleStepV. |
|
1700 |
arr at:7 put:false. |
|
1701 |
||
1702 |
^ arr |
|
0 | 1703 |
! |
1704 |
||
1705 |
hideGrid |
|
1706 |
"hide the grid" |
|
1707 |
||
1708 |
gridShown := false. |
|
63 | 1709 |
self newGrid |
1710 |
! |
|
1711 |
||
216 | 1712 |
newGrid |
1713 |
"define a new grid - this is a private helper which has to be |
|
1714 |
called after any change in the grid. It (re)creates the gridPixmap, |
|
1715 |
clears the view and redraws all visible objects." |
|
1716 |
||
1717 |
gridPixmap := nil. |
|
1718 |
shown ifTrue:[ |
|
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
1719 |
self viewBackground:White. |
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
1720 |
self clear. |
216 | 1721 |
]. |
1722 |
||
1723 |
gridShown ifTrue:[ |
|
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
1724 |
self defineGrid. |
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
1725 |
self viewBackground:gridPixmap. |
216 | 1726 |
]. |
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
1727 |
|
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
1728 |
self invalidate |
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
1729 |
|
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
1730 |
"Modified: 29.5.1996 / 16:20:11 / cg" |
0 | 1731 |
! |
1732 |
||
216 | 1733 |
showGrid |
1734 |
"show the grid. The grid is defined by the return value of |
|
1735 |
gridParameters, which can be redefined in concrete subclasses." |
|
1736 |
||
1737 |
gridShown := true. |
|
1738 |
self newGrid |
|
1739 |
! ! |
|
1740 |
||
1741 |
!ObjectView methodsFor:'initialization'! |
|
1742 |
||
1743 |
initEvents |
|
1744 |
"/ self backingStore:true. |
|
0 | 1745 |
! |
1746 |
||
216 | 1747 |
initialize |
1748 |
super initialize. |
|
1749 |
||
1750 |
viewBackground := White. |
|
1751 |
||
1752 |
bitGravity := #NorthWest. |
|
1753 |
contents := OrderedCollection new. |
|
1754 |
gridShown := false. |
|
1755 |
||
1756 |
canDragOutOfView := false. |
|
1757 |
rootView := DisplayRootView new. |
|
1220 | 1758 |
rootView clippedByChildren:false. |
216 | 1759 |
rootMotion := false. |
1760 |
self setInitialDocumentFormat. |
|
1761 |
||
1762 |
leftHandCursor := Cursor leftHand. |
|
1763 |
sorted := false. |
|
961 | 1764 |
aligning := false. |
1765 |
aligningMove := false. |
|
1766 |
||
1767 |
"Modified: 20.1.1997 / 20:41:10 / cg" |
|
216 | 1768 |
! |
1769 |
||
1770 |
setInitialDocumentFormat |
|
1771 |
(Smalltalk language == #english) ifTrue:[ |
|
1772 |
documentFormat := 'letter'. |
|
1773 |
scaleMetric := #inch |
|
1774 |
] ifFalse:[ |
|
1775 |
documentFormat := 'a4'. |
|
1776 |
scaleMetric := #mm |
|
1777 |
]. |
|
0 | 1778 |
! ! |
1779 |
||
216 | 1780 |
!ObjectView methodsFor:'layout manipulation'! |
1781 |
||
1782 |
alignBottom:something |
|
1783 |
|botMost| |
|
1784 |
||
1785 |
botMost := -999999. |
|
1786 |
self forEach:something do:[:anObject | |
|
1787 |
botMost := botMost max:(anObject frame bottom) |
|
1788 |
]. |
|
1789 |
self withSelectionHiddenDo:[ |
|
1790 |
self forEach:something do:[:anObject | |
|
1791 |
self moveObject:anObject to:(anObject frame left) |
|
1792 |
@ |
|
1793 |
(botMost - (anObject frame height)) |
|
1794 |
] |
|
1795 |
] |
|
1796 |
! |
|
1797 |
||
747 | 1798 |
alignHorizontal:something |
1799 |
"align selection along their center horizontally" |
|
1800 |
||
1801 |
|topMost bottomMost h| |
|
1802 |
||
1803 |
topMost := 999999. |
|
1804 |
bottomMost := -999999. |
|
1805 |
self forEach:something do:[:anObject | |
|
1806 |
|f| |
|
1807 |
f := anObject frame. |
|
1808 |
topMost := topMost min:(f top). |
|
1809 |
bottomMost := bottomMost max:(f bottom). |
|
1810 |
]. |
|
1811 |
h := bottomMost - topMost. |
|
1812 |
||
1813 |
self withSelectionHiddenDo:[ |
|
1814 |
self forEach:something do:[:anObject | |
|
1815 |
self moveObject:anObject |
|
1816 |
to:(anObject frame left) |
|
1817 |
@ |
|
1818 |
(topMost + ((h - anObject frame height) // 2)) |
|
1819 |
] |
|
1820 |
] |
|
1821 |
||
1822 |
"Created: 4.6.1996 / 20:01:19 / cg" |
|
1823 |
"Modified: 4.6.1996 / 21:19:48 / cg" |
|
1824 |
! |
|
1825 |
||
216 | 1826 |
alignLeft:something |
1827 |
|leftMost| |
|
1828 |
||
1829 |
leftMost := 999999. |
|
1830 |
self forEach:something do:[:anObject | |
|
1831 |
leftMost := leftMost min:(anObject frame left) |
|
1832 |
]. |
|
1833 |
self withSelectionHiddenDo:[ |
|
1834 |
self forEach:something do:[:anObject | |
|
1835 |
self moveObject:anObject to:(leftMost @ (anObject frame top)) |
|
1836 |
] |
|
1837 |
] |
|
1838 |
! |
|
1839 |
||
1840 |
alignRight:something |
|
1841 |
|rightMost| |
|
1842 |
||
1843 |
rightMost := -999999. |
|
1844 |
self forEach:something do:[:anObject | |
|
1845 |
rightMost := rightMost max:(anObject frame right) |
|
1846 |
]. |
|
1847 |
self withSelectionHiddenDo:[ |
|
1848 |
self forEach:something do:[:anObject | |
|
1849 |
self moveObject:anObject to:(rightMost - (anObject frame width)) |
|
1850 |
@ (anObject frame top) |
|
1851 |
] |
|
1852 |
] |
|
1853 |
! |
|
1854 |
||
1855 |
alignTop:something |
|
1856 |
|topMost| |
|
1857 |
||
1858 |
topMost := 999999. |
|
1859 |
self forEach:something do:[:anObject | |
|
1860 |
topMost := topMost min:(anObject frame top) |
|
1861 |
]. |
|
1862 |
self withSelectionHiddenDo:[ |
|
1863 |
self forEach:something do:[:anObject | |
|
1864 |
self moveObject:anObject to:((anObject frame left) @ topMost) |
|
1865 |
] |
|
1866 |
] |
|
1867 |
! |
|
1868 |
||
747 | 1869 |
alignVertical:something |
1870 |
"align selection along their center vertically" |
|
1871 |
||
1872 |
|leftMost rightMost w| |
|
1873 |
||
1874 |
leftMost := 999999. |
|
1875 |
rightMost := -999999. |
|
1876 |
self forEach:something do:[:anObject | |
|
1877 |
|f| |
|
1878 |
f := anObject frame. |
|
1879 |
rightMost := rightMost max:(f right). |
|
1880 |
leftMost := leftMost min:(f left). |
|
1881 |
]. |
|
1882 |
w := rightMost - leftMost. |
|
1883 |
||
1884 |
self withSelectionHiddenDo:[ |
|
1885 |
self forEach:something do:[:anObject | |
|
1886 |
self moveObject:anObject |
|
1887 |
to:(leftMost + ((w - anObject frame width) // 2)) |
|
1888 |
@ |
|
1889 |
(anObject frame top) |
|
1890 |
] |
|
1891 |
] |
|
1892 |
||
1893 |
"Created: 4.6.1996 / 19:59:16 / cg" |
|
1894 |
"Modified: 4.6.1996 / 21:19:58 / cg" |
|
1895 |
! |
|
1896 |
||
216 | 1897 |
move:something by:delta |
1898 |
"change the position of something, an Object or Collection |
|
1899 |
by delta, aPoint" |
|
1900 |
||
1901 |
(delta x == 0) ifTrue:[ |
|
1902 |
(delta y == 0) ifTrue:[^ self] |
|
1903 |
]. |
|
1904 |
||
1905 |
self forEach:something do:[:anObject | |
|
1906 |
self moveObject:anObject by:delta |
|
1907 |
] |
|
1908 |
! |
|
1909 |
||
1910 |
move:something to:aPoint in:aView |
|
1911 |
"can only happen when dragOutOfView is true |
|
1912 |
- should be redefined in subclasses" |
|
1913 |
||
1914 |
self notify:'cannot move object(s) out of view' |
|
1915 |
! |
|
1916 |
||
1917 |
move:something to:aPoint inAlienViewId:aViewId |
|
1918 |
"can only happen when dragOutOfView is true |
|
1919 |
- should be redefined in subclasses" |
|
1920 |
||
1921 |
self notify:'cannot move object(s) to alien views' |
|
77 | 1922 |
! |
1923 |
||
216 | 1924 |
moveObject:anObject by:delta |
1925 |
"change the position of anObject by delta, aPoint" |
|
1926 |
||
1927 |
self moveObject:anObject to:(anObject origin + delta) |
|
1928 |
! |
|
1929 |
||
1930 |
moveObject:anObject to:newOrigin |
|
1931 |
"move anObject to newOrigin, aPoint" |
|
1932 |
||
1933 |
|oldOrigin oldFrame newFrame |
|
1934 |
objectsIntersectingOldFrame objectsIntersectingNewFrame |
|
1935 |
wasObscured isObscured intersects |
|
701 | 1936 |
oldLeft oldTop w h newLeft newTop griddedNewOrigin clip| |
216 | 1937 |
|
1938 |
anObject isNil ifTrue:[^ self]. |
|
1939 |
anObject canBeMoved ifFalse:[^ self]. |
|
1940 |
||
1941 |
griddedNewOrigin := self alignToGrid:newOrigin. |
|
1942 |
oldOrigin := anObject origin. |
|
1943 |
(oldOrigin = griddedNewOrigin) ifTrue:[^ self]. |
|
1944 |
||
1945 |
oldFrame := self frameOf:anObject. |
|
1946 |
objectsIntersectingOldFrame := self objectsIntersecting:oldFrame. |
|
1947 |
wasObscured := self isObscured:anObject. |
|
1948 |
||
1949 |
anObject moveTo:griddedNewOrigin. |
|
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
1950 |
self changed:#objectLayout. |
782 | 1951 |
shown ifFalse:[^ self]. |
216 | 1952 |
|
1953 |
newFrame := self frameOf:anObject. |
|
1954 |
objectsIntersectingNewFrame := self objectsIntersecting:newFrame. |
|
1955 |
||
1956 |
"try to redraw the minimum possible" |
|
1957 |
||
1958 |
"if no other object intersects both frames we can do a copy:" |
|
1959 |
||
1960 |
intersects := oldFrame intersects:newFrame. |
|
1961 |
intersects ifFalse:[ |
|
2045 | 1962 |
self hasSolidBackground ifTrue:[ |
701 | 1963 |
transformation isNil ifTrue:[ |
1964 |
(objectsIntersectingOldFrame size == 1) ifTrue:[ |
|
1965 |
(objectsIntersectingNewFrame size == 1) ifTrue:[ |
|
1966 |
clip := self clippingRectangleOrNil. |
|
1967 |
(clip isNil or:[oldFrame isContainedIn:clip]) ifTrue:[ |
|
1968 |
oldLeft := oldFrame left. |
|
1969 |
oldTop := oldFrame top. |
|
1970 |
newLeft := newFrame left. |
|
1971 |
newTop := newFrame top. |
|
1972 |
w := oldFrame width. |
|
1973 |
h := oldFrame height. |
|
1974 |
((newLeft < width) and:[newTop < height]) ifTrue:[ |
|
1975 |
((newLeft >= 0) and:[newTop >= 0]) ifTrue:[ |
|
1976 |
self catchExpose. |
|
984 | 1977 |
self |
1978 |
copyFrom:self |
|
1979 |
x:oldLeft y:oldTop |
|
1980 |
toX:newLeft y:newTop |
|
1981 |
width:w height:h |
|
1982 |
async:true. |
|
701 | 1983 |
self waitForExpose |
1984 |
] |
|
1985 |
]. |
|
1986 |
((oldLeft < width) and:[oldTop < height]) ifTrue:[ |
|
1987 |
((oldLeft >= 0) and:[oldTop >= 0]) ifTrue:[ |
|
1988 |
self clearRectangleX:oldLeft y:oldTop width:w height:h. |
|
216 | 1989 |
|
1990 |
"/ self fillRectangleX:oldLeft y:oldTop width:w height:h |
|
1991 |
"/ with:viewBackground |
|
701 | 1992 |
] |
1993 |
]. |
|
1994 |
^ self |
|
1995 |
] |
|
1996 |
] |
|
1997 |
] |
|
1998 |
] |
|
1999 |
] |
|
216 | 2000 |
]. |
2001 |
isObscured := self isObscured:anObject. |
|
2002 |
(oldFrame intersects:newFrame) ifTrue:[ |
|
701 | 2003 |
isObscured ifFalse:[ |
2004 |
self redrawObjectsIn:oldFrame. |
|
2005 |
self show: anObject |
|
2006 |
] ifTrue:[ |
|
2007 |
self redrawObjectsIn:(oldFrame merge:newFrame) |
|
2008 |
] |
|
216 | 2009 |
] ifFalse:[ |
701 | 2010 |
self redrawObjectsIn:oldFrame. |
2011 |
isObscured ifFalse:[ |
|
2012 |
self show: anObject |
|
2013 |
] ifTrue:[ |
|
2014 |
self redrawObjectsIn:newFrame |
|
2015 |
] |
|
216 | 2016 |
] |
701 | 2017 |
|
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2018 |
"Modified: / 4.7.1999 / 16:52:17 / cg" |
59 | 2019 |
! |
2020 |
||
216 | 2021 |
objectToBack:anObject |
2022 |
"bring the argument, anObject to back" |
|
2023 |
||
2024 |
anObject notNil ifTrue:[ |
|
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2025 |
contents remove:anObject. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2026 |
contents addFirst:anObject. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2027 |
(self isObscured:anObject) ifTrue:[ |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2028 |
self redrawObjectsIn:(anObject frame) |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2029 |
]. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2030 |
self changed:#objectLayout. |
216 | 2031 |
] |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2032 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2033 |
"Modified: / 4.7.1999 / 16:52:39 / cg" |
216 | 2034 |
! |
2035 |
||
2036 |
objectToFront:anObject |
|
2037 |
"bring the argument, anObject to front" |
|
2038 |
||
2039 |
|wasObscured| |
|
2040 |
||
2041 |
anObject notNil ifTrue:[ |
|
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2042 |
wasObscured := self isObscured:anObject. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2043 |
contents remove:anObject. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2044 |
contents addLast:anObject. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2045 |
wasObscured ifTrue:[ |
216 | 2046 |
"old: |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2047 |
self redrawObjectsIn:(anObject frame) |
216 | 2048 |
" |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2049 |
self hideSelection. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2050 |
self show:anObject. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2051 |
self showSelection |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2052 |
]. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2053 |
self changed:#objectLayout. |
216 | 2054 |
] |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2055 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2056 |
"Modified: / 4.7.1999 / 16:52:49 / cg" |
216 | 2057 |
! |
2058 |
||
2059 |
selectionAlignBottom |
|
2060 |
"align selected objects at bottom" |
|
2061 |
||
2062 |
self alignBottom:selection |
|
2063 |
! |
|
2064 |
||
747 | 2065 |
selectionAlignHorizontal |
2066 |
"align selected objects horizontally" |
|
2067 |
||
2068 |
self alignHorizontal:selection |
|
2069 |
||
2070 |
"Created: 4.6.1996 / 19:58:46 / cg" |
|
2071 |
"Modified: 4.6.1996 / 19:59:10 / cg" |
|
2072 |
! |
|
2073 |
||
216 | 2074 |
selectionAlignLeft |
2075 |
"align selected objects left" |
|
2076 |
||
2077 |
self alignLeft:selection |
|
2078 |
! |
|
2079 |
||
2080 |
selectionAlignRight |
|
2081 |
"align selected objects right" |
|
2082 |
||
2083 |
self alignRight:selection |
|
2084 |
! |
|
2085 |
||
2086 |
selectionAlignTop |
|
2087 |
"align selected objects at top" |
|
2088 |
||
2089 |
self alignTop:selection |
|
59 | 2090 |
! |
2091 |
||
747 | 2092 |
selectionAlignVertical |
2093 |
"align selected objects vertically" |
|
2094 |
||
2095 |
self alignVertical:selection |
|
2096 |
||
2097 |
"Created: 4.6.1996 / 19:59:00 / cg" |
|
2098 |
! |
|
2099 |
||
216 | 2100 |
selectionToBack |
2101 |
"bring the selection to back" |
|
2102 |
||
2103 |
self toBack:selection |
|
2104 |
! |
|
2105 |
||
2106 |
selectionToFront |
|
2107 |
"bring the selection to front" |
|
2108 |
||
2109 |
self toFront:selection |
|
2110 |
! |
|
2111 |
||
2112 |
toBack:something |
|
2113 |
"bring the argument, anObject or a collection of objects to back" |
|
2114 |
||
2115 |
self forEach:something do:[:anObject | |
|
2116 |
self objectToBack:anObject |
|
2117 |
] |
|
2118 |
! |
|
2119 |
||
2120 |
toFront:something |
|
2121 |
"bring the argument, anObject or a collection of objects to front" |
|
2122 |
||
2123 |
self forEach:something do:[:anObject | |
|
2124 |
self objectToFront:anObject |
|
2125 |
] |
|
2126 |
! ! |
|
2127 |
||
2128 |
!ObjectView methodsFor:'misc'! |
|
2129 |
||
2130 |
documentFormat:aFormatString |
|
2131 |
"set the document format (mostly used by scrollbars). |
|
2132 |
The argument should be a string such as 'a4', 'a5' |
|
736
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2133 |
or 'letter'. |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2134 |
See the UnitConverter class for supported formats." |
216 | 2135 |
|
2136 |
aFormatString ~= documentFormat ifTrue:[ |
|
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
2137 |
documentFormat := aFormatString. |
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
2138 |
self contentsChanged. |
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
2139 |
self defineGrid. |
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
2140 |
gridShown ifTrue:[ |
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
2141 |
self invalidate "/ clear; redraw |
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
2142 |
] |
216 | 2143 |
] |
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
2144 |
|
736
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2145 |
"Modified: 31.5.1996 / 19:44:08 / cg" |
216 | 2146 |
! |
2147 |
||
2148 |
forEach:aCollection do:aBlock |
|
2149 |
"apply block to every object in a collectioni; |
|
2150 |
(adds a check for non-collection)" |
|
2151 |
||
2152 |
aCollection isNil ifTrue:[^self]. |
|
2153 |
aCollection isCollection ifTrue:[ |
|
2154 |
aCollection do:[:object | |
|
2155 |
object notNil ifTrue:[ |
|
2156 |
aBlock value:object |
|
2157 |
] |
|
2158 |
] |
|
2159 |
] ifFalse: [ |
|
2160 |
aBlock value:aCollection |
|
2161 |
] |
|
59 | 2162 |
! |
2163 |
||
216 | 2164 |
hitDelta |
2165 |
"when clicking an object, allow for hitDelta pixels around object. |
|
2166 |
We compensate for any scaling here, to get a constant physical |
|
2167 |
hitDelta (i.e. the value returned here is inverse scaled)." |
|
2168 |
||
2169 |
|delta| |
|
2170 |
||
2171 |
delta := self class hitDelta. |
|
2172 |
transformation notNil ifTrue:[ |
|
2173 |
delta := delta / transformation scale x |
|
2174 |
]. |
|
2175 |
^ delta |
|
2176 |
! |
|
2177 |
||
2178 |
numberOfObjectsIntersecting:aRectangle |
|
2179 |
"answer the number of objects intersecting the argument, aRectangle" |
|
2180 |
||
2181 |
|tally| |
|
2182 |
||
2183 |
tally := 0. |
|
2184 |
contents do:[:theObject | |
|
2185 |
(theObject frame intersects:aRectangle) ifTrue:[ |
|
2186 |
tally := tally + 1 |
|
2187 |
] |
|
2188 |
]. |
|
2189 |
^ tally |
|
2190 |
! |
|
2191 |
||
2192 |
numberOfObjectsIntersectingVisible:aRectangle |
|
2193 |
"answer the number of objects intersecting the argument, aRectangle. |
|
2194 |
This is a leftOver from times when scrolling was not transparent. |
|
2195 |
Please use numberOfObjectsIntersecting:, since this will vanish." |
|
2196 |
||
2197 |
^ self numberOfObjectsIntersecting:aRectangle |
|
2198 |
! |
|
2199 |
||
2200 |
objectsAbove:objectToBeTested do:aBlock |
|
2201 |
"do something to every object above objectToBeTested |
|
2202 |
(does not mean obscured - simply above in hierarchy)" |
|
2203 |
||
2204 |
|startIndex| |
|
2205 |
||
2206 |
startIndex := contents identityIndexOf:objectToBeTested |
|
2289 | 2207 |
ifAbsent:[self error:'nonexisting object']. |
216 | 2208 |
contents from:startIndex to:(contents size) do:aBlock |
2209 |
! |
|
2210 |
||
2211 |
objectsAbove:anObject intersecting:aRectangle do:aBlock |
|
2212 |
"do something to every object above objectToBeTested |
|
2213 |
and intersecting aRectangle" |
|
2214 |
||
2215 |
self objectsAbove:anObject do:[:theObject | |
|
2216 |
(theObject frame intersects:aRectangle) ifTrue:[ |
|
2217 |
aBlock value:theObject |
|
2218 |
] |
|
2219 |
] |
|
2220 |
! |
|
2221 |
||
2222 |
objectsBelow:objectToBeTested do:aBlock |
|
2223 |
"do something to every object below objectToBeTested |
|
2224 |
(does not mean obscured by - simply below in hierarchy)" |
|
2225 |
||
2226 |
|endIndex| |
|
2227 |
||
2289 | 2228 |
endIndex := contents identityIndexOf:objectToBeTested ifAbsent:[self error:'nonexisting object']. |
216 | 2229 |
contents from:1 to:(endIndex - 1) do:aBlock |
2230 |
! |
|
2231 |
||
2232 |
objectsIn:aRectangle do:aBlock |
|
2233 |
"do something to every object which is completely in a rectangle" |
|
2234 |
||
2235 |
|bot| |
|
2236 |
||
2237 |
sorted ifTrue:[ |
|
2238 |
bot := aRectangle bottom. |
|
2239 |
contents do:[:theObject | |
|
2240 |
(theObject isContainedIn:aRectangle) ifTrue:[ |
|
2241 |
aBlock value:theObject |
|
2242 |
] ifFalse:[ |
|
2243 |
theObject frame top > bot ifTrue:[^ self] |
|
2244 |
] |
|
77 | 2245 |
]. |
216 | 2246 |
^ self |
2247 |
]. |
|
2248 |
||
2249 |
contents do:[:theObject | |
|
2250 |
(theObject isContainedIn:aRectangle) ifTrue:[ |
|
2251 |
aBlock value:theObject |
|
2252 |
] |
|
2253 |
] |
|
2254 |
! |
|
2255 |
||
2256 |
objectsInVisible:aRectangle do:aBlock |
|
2257 |
"do something to every object which is completely in a |
|
2258 |
visible rectangle. |
|
2259 |
This is a leftOver from times when scrolling was not transparent. |
|
2260 |
Please use objectsIn:do:, since this will vanish." |
|
2261 |
||
2262 |
self objectsIn:aRectangle do:aBlock |
|
2263 |
! |
|
2264 |
||
2265 |
objectsIntersecting:aRectangle |
|
2266 |
"answer a Collection of objects intersecting the argument, aRectangle" |
|
2267 |
||
2268 |
|newCollection| |
|
2269 |
||
2270 |
newCollection := OrderedCollection new. |
|
2271 |
self objectsIntersecting:aRectangle do:[:theObject | |
|
2272 |
newCollection add:theObject |
|
2273 |
]. |
|
2274 |
(newCollection size == 0) ifTrue:[^ nil]. |
|
2275 |
^ newCollection |
|
2276 |
! |
|
2277 |
||
2278 |
objectsIntersecting:aRectangle do:aBlock |
|
2279 |
"do something to every object which intersects a rectangle" |
|
2280 |
||
2281 |
|f top bot |
|
2282 |
firstIndex "{ Class: SmallInteger }" |
|
2283 |
delta "{ Class: SmallInteger }" |
|
2284 |
theObject |
|
2285 |
nObjects "{ Class: SmallInteger }"| |
|
2286 |
||
2287 |
nObjects := contents size. |
|
2288 |
(nObjects == 0) ifTrue:[^ self]. |
|
2289 |
||
2290 |
sorted ifFalse:[ |
|
77 | 2291 |
" |
216 | 2292 |
have to check every object |
2293 |
" |
|
2294 |
contents do:[:theObject | |
|
2295 |
(theObject frame intersects:aRectangle) ifTrue:[ |
|
2296 |
aBlock value:theObject |
|
2297 |
] |
|
60 | 2298 |
]. |
216 | 2299 |
^ self |
2300 |
]. |
|
2301 |
||
2302 |
" |
|
2303 |
contents is sorted by y; can do a fast (binary) search for the first |
|
2304 |
object which intersects aRectangle and |
|
2305 |
break from the draw loop, when the 1st object below aRectangle is reached. |
|
2306 |
" |
|
2307 |
bot := aRectangle bottom. |
|
2308 |
top := aRectangle top. |
|
2309 |
||
2310 |
" |
|
2311 |
binary search for an object in aRectangle ... |
|
2312 |
" |
|
2313 |
delta := nObjects // 2. |
|
2314 |
firstIndex := delta. |
|
2315 |
(firstIndex == 0) ifTrue:[ |
|
2316 |
firstIndex := 1 |
|
2317 |
]. |
|
2318 |
theObject := contents at:firstIndex. |
|
2319 |
(theObject frame bottom < top) ifTrue:[ |
|
2320 |
[theObject frame bottom < top and:[delta > 1]] whileTrue:[ |
|
2321 |
delta := delta // 2. |
|
2322 |
firstIndex := firstIndex + delta. |
|
2323 |
theObject := contents at:firstIndex |
|
2324 |
] |
|
60 | 2325 |
] ifFalse:[ |
216 | 2326 |
[theObject frame top > bot and:[delta > 1]] whileTrue:[ |
2327 |
delta := delta // 2. |
|
2328 |
firstIndex := firstIndex - delta. |
|
2329 |
theObject := contents at:firstIndex |
|
2330 |
] |
|
2331 |
]. |
|
2332 |
||
2333 |
" |
|
2334 |
now, theObject at:firstIndex is in aRectangle; go backward to the object |
|
2335 |
following first non-visible |
|
2336 |
" |
|
2337 |
[theObject frame bottom > top and:[firstIndex > 1]] whileTrue:[ |
|
2338 |
firstIndex := firstIndex - 1. |
|
2339 |
theObject := contents at:firstIndex |
|
60 | 2340 |
]. |
87 | 2341 |
|
216 | 2342 |
firstIndex to:nObjects do:[:index | |
2343 |
theObject := contents at:index. |
|
2344 |
f := theObject frame. |
|
2345 |
(f intersects:aRectangle) ifTrue:[ |
|
2346 |
aBlock value:theObject |
|
60 | 2347 |
] ifFalse:[ |
216 | 2348 |
(f top > bot) ifTrue:[^ self] |
2349 |
] |
|
2350 |
] |
|
2351 |
! |
|
2352 |
||
2353 |
objectsIntersectingVisible:aRectangle |
|
2354 |
"answer a Collection of objects intersecting a visible aRectangle. |
|
2355 |
This is a leftOver from times when scrolling was not transparent. |
|
2356 |
Please use objectsIntersecting:, since this will vanish." |
|
2357 |
||
2358 |
^ self objectsIntersecting:aRectangle |
|
2359 |
! |
|
2360 |
||
2361 |
objectsIntersectingVisible:aRectangle do:aBlock |
|
2362 |
"do something to every object which intersects a visible rectangle. |
|
2363 |
This is a leftOver from times when scrolling was not transparent. |
|
2364 |
Please use objectsIntersecting:do:, since this will vanish." |
|
2365 |
||
2366 |
self objectsIntersecting:aRectangle do:aBlock |
|
2367 |
! |
|
2368 |
||
2369 |
rectangleForScroll |
|
2370 |
"find the area occupied by visible objects" |
|
2371 |
||
2372 |
|left right top bottom frame oLeft oRight oTop oBottom| |
|
2373 |
||
2374 |
left := 9999. |
|
2375 |
right := 0. |
|
2376 |
top := 9999. |
|
2377 |
bottom := 0. |
|
2378 |
self visibleObjectsDo:[:anObject | |
|
2379 |
frame := anObject frame. |
|
2380 |
oLeft := frame left. |
|
2381 |
oRight := frame right. |
|
2382 |
oTop := frame top. |
|
2383 |
oBottom := frame bottom. |
|
2384 |
(oLeft < left) ifTrue:[left := oLeft]. |
|
2385 |
(oRight > right) ifTrue:[right := oRight]. |
|
2386 |
(oTop < top) ifTrue:[top := oTop]. |
|
2387 |
(oBottom > bottom) ifTrue:[bottom := oBottom] |
|
60 | 2388 |
]. |
216 | 2389 |
(left < margin) ifTrue:[left := margin]. |
2390 |
(top < margin) ifTrue:[top := margin]. |
|
2391 |
(right > (width - margin)) ifTrue:[right := width - margin]. |
|
2392 |
(bottom > (height - margin)) ifTrue:[bottom := height - margin]. |
|
2393 |
||
2394 |
((left > right) or:[top > bottom]) ifTrue:[^ nil]. |
|
2395 |
||
2396 |
^ Rectangle left:left right:right top:top bottom:bottom |
|
2397 |
! |
|
2398 |
||
2399 |
visibleObjectsDo:aBlock |
|
2400 |
"do something to every visible object" |
|
2401 |
||
2402 |
|absRect| |
|
2403 |
||
2404 |
absRect := Rectangle left:0 top:0 width:width height:height. |
|
2405 |
self objectsIntersecting:absRect do:aBlock |
|
2406 |
! ! |
|
2407 |
||
2408 |
!ObjectView methodsFor:'queries'! |
|
2409 |
||
2045 | 2410 |
hasSolidBackground |
2411 |
"return true, if I have a solid color background, which can be pixel-copied |
|
2412 |
for optimized redraw in moveObject." |
|
2413 |
||
2414 |
^ gridShown not |
|
2415 |
! |
|
2416 |
||
216 | 2417 |
heightOfContents |
2418 |
"answer the height of the document in pixels" |
|
2419 |
||
2420 |
|h| |
|
2421 |
||
2422 |
h := self heightOfContentsInMM * (self verticalPixelPerMillimeter:1). |
|
2423 |
^ h rounded |
|
0 | 2424 |
! |
2425 |
||
216 | 2426 |
heightOfContentsInMM |
2427 |
"answer the height of the document in millimeters" |
|
2428 |
||
736
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2429 |
|unit value| |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2430 |
|
216 | 2431 |
"landscape" |
736
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2432 |
unit := (documentFormat , 'H') asSymbolIfInterned. |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2433 |
unit isNil ifTrue:[ |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2434 |
"/ certainly unknown |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2435 |
] ifFalse:[ |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2436 |
value := UnitConverter convert:1 from:unit to:#millimeter |
216 | 2437 |
]. |
736
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2438 |
value isNil ifTrue:[ |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2439 |
"/ assuming window size is document size |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2440 |
value := (height / self verticalPixelPerMillimeter:1) asInteger |
216 | 2441 |
]. |
736
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2442 |
^ value |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2443 |
|
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2444 |
"Modified: 31.5.1996 / 19:38:51 / cg" |
216 | 2445 |
! |
2446 |
||
2447 |
widthOfContents |
|
2448 |
"answer the width of the document in pixels" |
|
2449 |
||
2450 |
|w| |
|
2451 |
||
2452 |
w := self widthOfContentsInMM * (self horizontalPixelPerMillimeter:1). |
|
2453 |
^ w rounded |
|
2454 |
! |
|
2455 |
||
2456 |
widthOfContentsInMM |
|
2457 |
"answer the width of the document in millimeters" |
|
2458 |
||
736
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2459 |
|unit value| |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2460 |
|
216 | 2461 |
"landscape" |
736
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2462 |
unit := (documentFormat , 'W') asSymbolIfInterned. |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2463 |
unit isNil ifTrue:[ |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2464 |
"/ certainly unknown |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2465 |
] ifFalse:[ |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2466 |
value := UnitConverter convert:1 from:unit to:#millimeter |
216 | 2467 |
]. |
736
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2468 |
value isNil ifTrue:[ |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2469 |
"/ assuming window size is document size |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2470 |
value := (width / self horizontalPixelPerMillimeter:1) asInteger |
216 | 2471 |
]. |
736
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2472 |
^ value |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2473 |
|
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2474 |
"Modified: 31.5.1996 / 19:38:22 / cg" |
0 | 2475 |
! ! |
2476 |
||
2477 |
!ObjectView methodsFor:'saving / restoring'! |
|
2478 |
||
2479 |
fileInContentsFrom:aStream |
|
59 | 2480 |
"remove all objects, load new contents from aStream and redraw" |
2481 |
||
77 | 2482 |
self fileInContentsFrom:aStream redraw:true new:true binary:false |
63 | 2483 |
! |
2484 |
||
2485 |
fileInContentsFrom:aStream redraw:redraw |
|
2486 |
"remove all objects, load new contents from aStream |
|
2487 |
and redraw if the redraw argument is true" |
|
2488 |
||
77 | 2489 |
self fileInContentsFrom:aStream redraw:redraw new:true binary:false |
2490 |
! |
|
2491 |
||
2492 |
fileInContentsFrom:aStream redraw:redraw new:new |
|
2493 |
"remove all objects, load new contents from aStream |
|
2494 |
and redraw if the redraw argument is true" |
|
2495 |
||
2496 |
self fileInContentsFrom:aStream redraw:redraw new:new binary:false |
|
2497 |
! |
|
2498 |
||
2499 |
fileInContentsFrom:aStream redraw:redraw new:new binary:binary |
|
2500 |
"if the new argument is true, remove all objects. |
|
2501 |
Then load objects from aStream. If redraw is false, no redraw |
|
2502 |
is done |
|
2503 |
(allows fileIn of multiple files doing a single redraw at the end)." |
|
2504 |
||
2505 |
binary ifTrue:[ |
|
256
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2506 |
aStream binary |
77 | 2507 |
]. |
256
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2508 |
self topView withReadCursorDo:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2509 |
|newObject chunk individualRedraw| |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2510 |
|
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2511 |
self unselect. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2512 |
individualRedraw := redraw. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2513 |
new ifTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2514 |
self removeAll. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2515 |
individualRedraw := false. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2516 |
]. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2517 |
[aStream atEnd] whileFalse:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2518 |
binary ifTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2519 |
newObject := Object readBinaryFrom:aStream |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2520 |
] ifFalse:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2521 |
chunk := aStream nextChunk. |
1746
bd570389f315
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
1741
diff
changeset
|
2522 |
(chunk size > 0) ifTrue:[ |
1435
56de6db05972
dont compile expressions, when reading an ObjectView tree.
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
2523 |
newObject := Compiler evaluate:chunk compile:false. |
256
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2524 |
] ifFalse:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2525 |
newObject := nil |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2526 |
] |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2527 |
]. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2528 |
newObject notNil ifTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2529 |
self initializeFileInObject:newObject. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2530 |
individualRedraw ifFalse:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2531 |
self addObjectWithoutRedraw:newObject |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2532 |
] ifTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2533 |
self addObject:newObject |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2534 |
] |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2535 |
] |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2536 |
]. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2537 |
(new and:[redraw]) ifTrue:[ |
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
2538 |
self invalidate |
256
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2539 |
] |
77 | 2540 |
] |
256
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
2541 |
|
1435
56de6db05972
dont compile expressions, when reading an ObjectView tree.
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
2542 |
"Modified: / 30.1.1998 / 01:02:16 / cg" |
216 | 2543 |
! |
2544 |
||
2545 |
initializeFileInObject:anObject |
|
2546 |
"each object may be processed here after its being filed-in |
|
2547 |
- subclasses may do whatever they want here ... |
|
2548 |
(see LogicView for example)" |
|
2549 |
||
2550 |
^ self |
|
2551 |
! |
|
2552 |
||
2553 |
storeBinaryContentsOn:aStream |
|
2554 |
"store the contents in binary representation on aStream." |
|
2555 |
||
2556 |
aStream binary. |
|
2557 |
self topView withCursor:Cursor write do:[ |
|
2558 |
self forEach:contents do:[:theObject | |
|
2559 |
theObject storeBinaryOn:aStream. |
|
2560 |
]. |
|
2561 |
] |
|
2562 |
! |
|
2563 |
||
2564 |
storeContentsOn:aStream |
|
2565 |
"store the contents in textual representation on aStream. |
|
2566 |
Notice, that for huge objects (such as DrawImages) this ascii output |
|
2567 |
can become quite large, and the time to save and reload can become |
|
2568 |
long." |
|
2569 |
||
2570 |
|excla| |
|
2571 |
||
2572 |
self topView withCursor:Cursor write do:[ |
|
2573 |
excla := aStream class chunkSeparator. |
|
2574 |
self forEach:contents do:[:theObject | |
|
2575 |
theObject storeOn:aStream. |
|
2576 |
aStream nextPut:excla. |
|
2577 |
aStream cr |
|
2578 |
]. |
|
2579 |
aStream nextPut:excla |
|
2580 |
] |
|
2581 |
! |
|
2582 |
||
2583 |
withoutRedrawFileInContentsFrom:aStream |
|
2584 |
"remove all objects, load new contents from aStream without any redraw" |
|
2585 |
||
2586 |
self fileInContentsFrom:aStream redraw:false new:true binary:false |
|
0 | 2587 |
! ! |
216 | 2588 |
|
2589 |
!ObjectView methodsFor:'scrolling'! |
|
2590 |
||
2591 |
horizontalScrollStep |
|
2592 |
"return the amount to scroll when stepping left/right. |
|
2593 |
Redefined to scroll by inches or centimeters." |
|
2594 |
||
2595 |
scaleMetric == #inch ifTrue:[ |
|
2596 |
^ (device horizontalPixelPerInch * (1/2)) asInteger |
|
2597 |
]. |
|
2598 |
^ (device horizontalPixelPerMillimeter * 20) asInteger |
|
2599 |
! |
|
2600 |
||
2601 |
verticalScrollStep |
|
2602 |
"return the amount to scroll when stepping left/right. |
|
2603 |
Redefined to scroll by inches or centimeters." |
|
2604 |
||
2605 |
scaleMetric == #inch ifTrue:[ |
|
2606 |
^ (device verticalPixelPerInch * (1/2)) asInteger |
|
2607 |
]. |
|
2608 |
^ (device verticalPixelPerMillimeter * 20) asInteger |
|
2609 |
! ! |
|
2610 |
||
1752
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2611 |
!ObjectView methodsFor:'selection & handles'! |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2612 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2613 |
drawHandle:aPoint |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2614 |
|hsize halfSize| |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2615 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2616 |
hsize := self handleSize. |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2617 |
halfSize := hsize // 2. |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2618 |
self fillRectangleX:(aPoint x - halfSize) |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2619 |
y:(aPoint y - halfSize) |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2620 |
width:hsize |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2621 |
height:hsize |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2622 |
! |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2623 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2624 |
drawHandlesFor:anObject |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2625 |
|hsize halfSize| |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2626 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2627 |
hsize := self handleSize. |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2628 |
halfSize := hsize // 2. |
2049
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2629 |
self handlesOf:anObject do:[:handlePoint | |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2630 |
self fillRectangleX:(handlePoint x - halfSize) |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2631 |
y:(handlePoint y - halfSize) |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2632 |
width:hsize |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2633 |
height:hsize |
1752
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2634 |
] |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2635 |
! |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2636 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2637 |
findObjectHandleAt:aPoint |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2638 |
|objectFound| |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2639 |
contents do:[:object | |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2640 |
(self object:object hasHandle:aPoint) ifTrue:[ |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2641 |
objectFound := object |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2642 |
] |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2643 |
]. |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2644 |
^ objectFound |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2645 |
! |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2646 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2647 |
handle:handlePoint isHitBy:aPoint |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2648 |
^ (self handleFor:handlePoint) containsPoint:aPoint |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2649 |
! |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2650 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2651 |
handleFor:aPoint |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2652 |
"return the handle-rectangle for a handle at aPoint" |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2653 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2654 |
|hsize centerX centerY| |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2655 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2656 |
hsize := self handleSize. |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2657 |
centerX := aPoint x. |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2658 |
centerY := aPoint y. |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2659 |
^ Rectangle left:(centerX - hsize) |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2660 |
top:(centerY - hsize) |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2661 |
right:(centerX + hsize) |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2662 |
bottom:(centerY + hsize) |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2663 |
! |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2664 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2665 |
handleSize |
2289 | 2666 |
"return the size of the handles - since handles should be |
1752
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2667 |
the same size regardless of scaling, inverse-scale from |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2668 |
what the default is." |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2669 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2670 |
|hs| |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2671 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2672 |
hs := self class handleSize. |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2673 |
transformation notNil ifTrue:[ |
2289 | 2674 |
^ transformation applyInverseScaleX:hs |
1752
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2675 |
]. |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2676 |
^ hs |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2677 |
! |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2678 |
|
2049
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2679 |
handlesOf:anObject do:aBlock |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2680 |
anObject handlesDo:aBlock |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2681 |
! |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2682 |
|
1752
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2683 |
invertHandle:aHandle |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2684 |
self xoring:[self drawHandle:aHandle] |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2685 |
! |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2686 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2687 |
invertHandlesOf:aSelection |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2688 |
aSelection notNil ifTrue:[ |
2049
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2689 |
self clippedTo:nil do:[ |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2690 |
self xoring:[ |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2691 |
self forEach:aSelection do:[:anObject | |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2692 |
(anObject respondsTo:#handlesDo:) ifTrue:[ |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2693 |
self drawHandlesFor:anObject |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2694 |
] ifFalse:[ |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2695 |
anObject drawOutlineIn:self |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2696 |
] |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2697 |
] |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2698 |
] |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2699 |
] |
1752
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2700 |
] |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2701 |
! |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2702 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2703 |
object:anObject hasHandleAt:aPoint |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2704 |
|found| |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2705 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2706 |
found := false. |
2049
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2707 |
self handlesOf:anObject do:[:handlePoint | |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2708 |
(self handle:handlePoint isHitBy:aPoint) ifTrue:[ |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2709 |
found := true |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2710 |
] |
1752
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2711 |
]. |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2712 |
^ found |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2713 |
! |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2714 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2715 |
selectionHandlesDo:aBlock |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2716 |
self forEach:selection do:[:theObject | |
2049
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2717 |
(theObject respondsTo:#handlesDo:) ifTrue:[ |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2718 |
self handlesOf:theObject do:[:handlePoint | |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2719 |
aBlock value:theObject value:handlePoint |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2720 |
] |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2721 |
] |
1752
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2722 |
] |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2723 |
! ! |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2724 |
|
216 | 2725 |
!ObjectView methodsFor:'selections'! |
2726 |
||
2727 |
addToSelection:anObject |
|
839
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2728 |
"add anObject to the selection; redraw it selected" |
733 | 2729 |
|
216 | 2730 |
selection isCollection ifFalse:[ |
1002 | 2731 |
selection isNil ifTrue:[ |
2732 |
^ self select:anObject |
|
2733 |
]. |
|
733 | 2734 |
selection := OrderedCollection with:selection |
216 | 2735 |
]. |
839
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2736 |
|
733 | 2737 |
(selection includes:anObject) ifFalse:[ |
839
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2738 |
(self frameIncludesSelectionHandlesOn:anObject) ifFalse:[ |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2739 |
self hideSelection. |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2740 |
selection add:anObject. |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2741 |
self showSelection. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2742 |
self changed:#selection. |
839
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2743 |
] ifTrue:[ |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2744 |
self showSelected:anObject |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2745 |
] |
733 | 2746 |
]. |
839
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2747 |
|
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2748 |
"Modified: / 4.7.1999 / 15:22:13 / cg" |
216 | 2749 |
! |
2750 |
||
2751 |
hideSelection |
|
2752 |
"hide the selection - undraw hilights - whatever that is" |
|
2753 |
||
2754 |
self selectionDo:[:object | |
|
2755 |
self showUnselected:object |
|
2756 |
] |
|
2757 |
! |
|
2758 |
||
2759 |
removeFromSelection:anObject |
|
2760 |
"remove anObject from the selection" |
|
2761 |
||
839
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2762 |
|wasSelected didHide| |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2763 |
|
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2764 |
didHide := false. |
733 | 2765 |
wasSelected := true. |
839
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2766 |
|
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2767 |
(self frameIncludesSelectionHandlesOn:anObject) ifFalse:[ |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2768 |
"/ must hide any selection-handles first |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2769 |
self hideSelection. |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2770 |
didHide := true. |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2771 |
]. |
733 | 2772 |
|
216 | 2773 |
selection isCollection ifTrue:[ |
733 | 2774 |
(selection remove:anObject ifAbsent:[nil]) isNil ifTrue:[ |
2775 |
wasSelected := false |
|
2776 |
]. |
|
2777 |
(selection size == 1) ifTrue:[ |
|
2778 |
selection := selection first |
|
1002 | 2779 |
] ifFalse:[ |
2780 |
selection isEmpty ifTrue:[ |
|
2781 |
selection := nil |
|
2782 |
] |
|
733 | 2783 |
] |
216 | 2784 |
] ifFalse:[ |
733 | 2785 |
(selection == anObject) ifTrue:[ |
2786 |
selection := nil |
|
2787 |
] ifFalse:[ |
|
2788 |
wasSelected := false |
|
2789 |
] |
|
216 | 2790 |
]. |
839
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2791 |
|
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2792 |
didHide ifTrue:[ |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2793 |
self showSelection. |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2794 |
] ifFalse:[ |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2795 |
wasSelected ifTrue:[ |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2796 |
self showUnselected:anObject |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2797 |
]. |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2798 |
]. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2799 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2800 |
self changed:#selection. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2801 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2802 |
"Modified: / 4.7.1999 / 15:22:28 / cg" |
216 | 2803 |
! |
2804 |
||
2805 |
select:something |
|
2806 |
"select something - hide previouse selection, set to something and hilight" |
|
2807 |
||
2808 |
(selection == something) ifFalse:[ |
|
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2809 |
self hideSelection. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2810 |
selection := something. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2811 |
self showSelection. |
2051
56ebae1cfdbe
pass the selection as argument with the selectionChange notification
Claus Gittinger <cg@exept.de>
parents:
2049
diff
changeset
|
2812 |
self changed:#selection with:selection. |
216 | 2813 |
] |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2814 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2815 |
"Modified: / 4.7.1999 / 15:22:39 / cg" |
216 | 2816 |
! |
2817 |
||
2818 |
selectAll |
|
2819 |
"select all objects" |
|
2820 |
||
2821 |
self hideSelection. |
|
2822 |
selection := contents copy. |
|
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2823 |
self showSelection. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2824 |
self changed:#selection. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2825 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2826 |
"Modified: / 4.7.1999 / 15:22:56 / cg" |
216 | 2827 |
! |
2828 |
||
2829 |
selectAllIn:aRectangle |
|
2830 |
"select all objects fully in aRectangle" |
|
2831 |
||
2832 |
self hideSelection. |
|
2833 |
selection := OrderedCollection new. |
|
2834 |
self objectsIn:aRectangle do:[:theObject | |
|
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2835 |
selection add:theObject |
216 | 2836 |
]. |
2837 |
(selection size == 0) ifTrue:[ |
|
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2838 |
selection := nil |
216 | 2839 |
] ifFalse:[ |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2840 |
(selection size == 1) ifTrue:[selection := selection first] |
216 | 2841 |
]. |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2842 |
self showSelection. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2843 |
self changed:#selection. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2844 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2845 |
"Modified: / 4.7.1999 / 15:23:08 / cg" |
216 | 2846 |
! |
2847 |
||
2848 |
selectAllIntersecting:aRectangle |
|
2849 |
"select all objects touched by aRectangle" |
|
2850 |
||
2851 |
self hideSelection. |
|
2852 |
selection := OrderedCollection new. |
|
2853 |
||
2854 |
self objectsIntersecting:aRectangle do:[:theObject | |
|
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2855 |
selection add:theObject |
216 | 2856 |
]. |
2857 |
(selection size == 0) ifTrue:[ |
|
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2858 |
selection := nil |
216 | 2859 |
] ifFalse:[ |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2860 |
(selection size == 1) ifTrue:[selection := selection first] |
216 | 2861 |
]. |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2862 |
self showSelection. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2863 |
self changed:#selection. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2864 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2865 |
"Modified: / 4.7.1999 / 15:23:15 / cg" |
216 | 2866 |
! |
2867 |
||
1940 | 2868 |
selection |
2869 |
"return the selection as a collection or nil" |
|
2870 |
||
2871 |
selection isNil ifTrue:[^ nil]. |
|
2872 |
selection isCollection ifTrue:[^ selection]. |
|
2873 |
^ Array with:selection |
|
2874 |
||
2875 |
"Created: / 4.7.1999 / 14:33:16 / cg" |
|
2876 |
"Modified: / 4.7.1999 / 14:34:20 / cg" |
|
2877 |
! |
|
2878 |
||
216 | 2879 |
selectionDo:aBlock |
2880 |
"apply block to every object in selection" |
|
2881 |
||
2882 |
self forEach:selection do:aBlock |
|
2883 |
! |
|
2884 |
||
2885 |
showSelection |
|
2886 |
"show the selection - draw hilights - whatever that is" |
|
2887 |
||
2888 |
self selectionDo:[:object | |
|
2889 |
self showSelected:object |
|
2890 |
] |
|
2891 |
! |
|
2892 |
||
2893 |
unselect |
|
2894 |
"unselect - hide selection; clear selection" |
|
2895 |
||
2049
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2896 |
selection notNil ifTrue:[ |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2897 |
self hideSelection. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2898 |
selection := nil. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2899 |
self changed:#selection. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2900 |
] |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2901 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2902 |
"Modified: / 4.7.1999 / 15:30:36 / cg" |
216 | 2903 |
! |
2904 |
||
2905 |
withSelectionHiddenDo:aBlock |
|
2906 |
"evaluate aBlock while selection is hidden" |
|
2907 |
||
2908 |
|sel| |
|
2909 |
||
2910 |
sel := selection. |
|
2911 |
sel notNil ifTrue:[self unselect]. |
|
2912 |
aBlock value. |
|
2913 |
sel notNil ifTrue:[self select:sel] |
|
2914 |
! ! |
|
2915 |
||
2916 |
!ObjectView methodsFor:'testing objects'! |
|
2917 |
||
2918 |
canMove:something |
|
2919 |
"return true, if the argument, anObject or a collection can be moved" |
|
2920 |
||
2921 |
something isCollection ifTrue:[ |
|
1947
5b20f4b196da
oops - care for unimplemented #canBeMoved and #canBeSelected
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
2922 |
self forEach:something do:[:theObject | |
5b20f4b196da
oops - care for unimplemented #canBeMoved and #canBeSelected
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
2923 |
(theObject perform:#canBeMoved ifNotUnderstood:true) ifFalse:[^ false] |
5b20f4b196da
oops - care for unimplemented #canBeMoved and #canBeSelected
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
2924 |
]. |
5b20f4b196da
oops - care for unimplemented #canBeMoved and #canBeSelected
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
2925 |
^ true |
216 | 2926 |
]. |
1947
5b20f4b196da
oops - care for unimplemented #canBeMoved and #canBeSelected
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
2927 |
^ something perform:#canBeMoved ifNotUnderstood:true |
216 | 2928 |
! |
2929 |
||
1942 | 2930 |
canSelect:something |
2931 |
"return true, if the argument, anObject or a collection can be selected" |
|
2932 |
||
2933 |
something isCollection ifTrue:[ |
|
2934 |
self forEach:something do:[:theObject | |
|
2635 | 2935 |
theObject isView ifFalse:[ |
2936 |
(theObject perform:#canBeSelected ifNotUnderstood:true) ifFalse:[^ false] |
|
2937 |
] |
|
1942 | 2938 |
]. |
2939 |
^ true |
|
2940 |
]. |
|
2635 | 2941 |
something isView ifTrue:[^ true]. |
1947
5b20f4b196da
oops - care for unimplemented #canBeMoved and #canBeSelected
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
2942 |
^ something perform:#canBeSelected ifNotUnderstood:true |
1942 | 2943 |
|
2944 |
"Created: / 4.7.1999 / 18:51:29 / cg" |
|
2945 |
! |
|
2946 |
||
216 | 2947 |
findObjectAt:aPoint |
2948 |
"find the last object (by looking from back to front) which is hit by |
|
2949 |
the argument, aPoint - this is the topmost object hit" |
|
2950 |
||
2951 |
|hdelta| |
|
2952 |
||
2953 |
hdelta := self hitDelta. |
|
2954 |
contents reverseDo:[:object | |
|
2955 |
(object isHitBy:aPoint withDelta:hdelta) ifTrue:[^ object] |
|
2956 |
]. |
|
2957 |
^ nil |
|
2958 |
! |
|
2959 |
||
2960 |
findObjectAt:aPoint suchThat:aBlock |
|
2961 |
"find the last object (back to front ) which is hit by |
|
2962 |
the argument, aPoint and for which the testBlock, aBlock evaluates to |
|
2963 |
true" |
|
2964 |
||
2965 |
|hdelta| |
|
2966 |
||
2967 |
hdelta := self hitDelta. |
|
2968 |
contents reverseDo:[:object | |
|
2969 |
(object isHitBy:aPoint withDelta:hdelta) ifTrue:[ |
|
2970 |
(aBlock value:object) ifTrue:[^ object] |
|
2971 |
] |
|
2972 |
]. |
|
2973 |
^ nil |
|
2974 |
! |
|
2975 |
||
2976 |
findObjectAtVisible:aPoint |
|
2977 |
"find the last object (by looking from back to front) which is hit by |
|
2978 |
a visible point - this is the topmost object hit. |
|
2979 |
This is a leftOver from times when scrolling was not transparent. |
|
2980 |
Please use findObjectAt:, since this will vanish." |
|
2981 |
||
2982 |
^ self findObjectAt:aPoint |
|
2983 |
! |
|
2984 |
||
2985 |
findObjectAtVisible:aPoint suchThat:aBlock |
|
2986 |
"find the last object (back to front ) which is hit by |
|
2987 |
the argument, aPoint and for which the testBlock, aBlock evaluates to |
|
2988 |
true. |
|
2989 |
This is a leftOver from times when scrolling was not transparent. |
|
2990 |
Please use findObjectAt:suchThat:, since this will vanish." |
|
2991 |
||
2992 |
^ self findObjectAt:aPoint suchThat:aBlock |
|
2993 |
! |
|
2994 |
||
839
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2995 |
frameIncludesSelectionHandlesOn:anObject |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2996 |
"return true, if anObjects frame includes any selection |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2997 |
handles, false if not or if we do not know. |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2998 |
This can be used to optimize the redraw, in removeObjectFromSelection. |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2999 |
Subclasses which know how selections are highlighted may redefine this." |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
3000 |
|
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
3001 |
^ false "/ i.e. dont know. |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
3002 |
|
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
3003 |
"Created: 1.10.1996 / 12:06:51 / cg" |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
3004 |
! |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
3005 |
|
216 | 3006 |
frameOf:anObjectOrCollection |
3007 |
"answer the maximum extent defined by the argument, anObject or a |
|
3008 |
collection of objects" |
|
3009 |
||
3010 |
|first frameAll| |
|
3011 |
||
3012 |
anObjectOrCollection isNil ifTrue:[^ nil ]. |
|
3013 |
first := true. |
|
3014 |
self forEach:anObjectOrCollection do:[:theObject | |
|
3015 |
first ifTrue:[ |
|
3016 |
frameAll := theObject frame. |
|
3017 |
first := false |
|
3018 |
] ifFalse:[ |
|
3019 |
frameAll := frameAll merge:(theObject frame) |
|
3020 |
] |
|
3021 |
]. |
|
3022 |
^ frameAll |
|
3023 |
! |
|
3024 |
||
3025 |
isObscured:something |
|
3026 |
"return true, if the argument something, anObject or a collection of |
|
3027 |
objects is obscured (partially or whole) by any other object" |
|
3028 |
||
3029 |
self forEach:something do:[:anObject | |
|
3030 |
(self objectIsObscured:anObject) ifTrue:[ |
|
3031 |
^ true |
|
3032 |
] |
|
3033 |
]. |
|
3034 |
^ false |
|
3035 |
! |
|
3036 |
||
3037 |
isSelected:anObject |
|
3038 |
"return true, if the argument, anObject is in the selection" |
|
3039 |
||
3040 |
selection isNil ifTrue:[^ false]. |
|
3041 |
(selection == anObject) ifTrue:[^ true]. |
|
3042 |
selection isCollection ifTrue:[ |
|
3043 |
^ (selection identityIndexOf:anObject startingAt:1) ~~ 0 |
|
3044 |
]. |
|
3045 |
^ false |
|
3046 |
! |
|
3047 |
||
3048 |
objectIsObscured:objectToBeTested |
|
3049 |
"return true, if the argument, anObject is obscured (partially or whole) |
|
3050 |
by any other object" |
|
3051 |
||
3052 |
|frameToBeTested frameleft frameright frametop framebot |
|
3053 |
objectsFrame startIndex| |
|
3054 |
||
3055 |
(objectToBeTested == (contents last)) ifTrue:[ |
|
2289 | 3056 |
"quick return if object is on top" |
3057 |
^ false |
|
216 | 3058 |
]. |
3059 |
||
3060 |
frameToBeTested := self frameOf:objectToBeTested. |
|
3061 |
frameleft := frameToBeTested left. |
|
3062 |
frameright := frameToBeTested right. |
|
3063 |
frametop := frameToBeTested top. |
|
3064 |
framebot := frameToBeTested bottom. |
|
3065 |
||
3066 |
"check objects after the one to check" |
|
3067 |
||
2289 | 3068 |
startIndex := contents identityIndexOf:objectToBeTested ifAbsent:[self error:'nonexisting object']. |
216 | 3069 |
contents from:(startIndex + 1) to:(contents size) do:[:object | |
2289 | 3070 |
objectsFrame := self frameOf:object. |
3071 |
(objectsFrame right < frameleft) ifFalse:[ |
|
3072 |
(objectsFrame left > frameright) ifFalse:[ |
|
3073 |
(objectsFrame bottom < frametop) ifFalse:[ |
|
3074 |
(objectsFrame top > framebot) ifFalse:[ |
|
3075 |
^ true |
|
3076 |
] |
|
3077 |
] |
|
3078 |
] |
|
3079 |
] |
|
216 | 3080 |
]. |
3081 |
^ false |
|
3082 |
! ! |
|
3083 |
||
3084 |
!ObjectView methodsFor:'user interface'! |
|
3085 |
||
3086 |
alignToGrid:aPoint |
|
3087 |
"round aPoint to the next nearest point on the grid" |
|
3088 |
||
3089 |
aligning ifFalse:[ |
|
3090 |
^ aPoint |
|
3091 |
]. |
|
3092 |
||
3093 |
^ (aPoint grid:gridAlign) rounded |
|
3094 |
! |
|
3095 |
||
3096 |
selectMore:aPoint |
|
3097 |
"add/remove an object from the selection" |
|
3098 |
||
3099 |
|anObject| |
|
3100 |
||
3101 |
anObject := self findObjectAt:aPoint. |
|
3102 |
anObject notNil ifTrue:[ |
|
1942 | 3103 |
(self isSelected:anObject) ifTrue:[ |
3104 |
"remove from selection" |
|
3105 |
self removeFromSelection:anObject |
|
3106 |
] ifFalse:[ |
|
3107 |
"add to selection" |
|
3108 |
(self canSelect:anObject) ifTrue:[ |
|
3109 |
self addToSelection:anObject |
|
3110 |
] |
|
3111 |
] |
|
216 | 3112 |
]. |
3113 |
^ self |
|
1942 | 3114 |
|
3115 |
"Modified: / 4.7.1999 / 18:52:13 / cg" |
|
216 | 3116 |
! |
3117 |
||
3118 |
startSelectMoreOrMove:aPoint |
|
3119 |
"add/remove object hit by aPoint, then start a rectangleDrag or move |
|
3120 |
- if aPoint hits an object, a move is started, otherwise a rectangleDrag. |
|
3121 |
This is typically the button shiftPressAction." |
|
3122 |
||
3123 |
|anObject| |
|
3124 |
||
3125 |
anObject := self findObjectAt:aPoint. |
|
3126 |
anObject notNil ifTrue:[ |
|
733 | 3127 |
(self isSelected:anObject) ifTrue:[ |
3128 |
"remove from selection" |
|
3129 |
self removeFromSelection:anObject |
|
3130 |
] ifFalse:[ |
|
3131 |
"add to selection" |
|
1942 | 3132 |
(self canSelect:anObject) ifTrue:[ |
3133 |
self addToSelection:anObject |
|
3134 |
] |
|
733 | 3135 |
]. |
3136 |
self startObjectMove:selection at:aPoint. |
|
3137 |
^ self |
|
216 | 3138 |
]. |
733 | 3139 |
"/ self unselect. |
3140 |
"/ self startRectangleDrag:aPoint |
|
3141 |
||
1942 | 3142 |
"Modified: / 4.7.1999 / 18:51:52 / cg" |
216 | 3143 |
! |
3144 |
||
3145 |
startSelectOrMove:aPoint |
|
3146 |
"start a rectangleDrag or objectMove - if aPoint hits an object, |
|
3147 |
an object move is started, otherwise a rectangleDrag. |
|
3148 |
This is typically the button pressAction." |
|
3149 |
||
3150 |
|anObject| |
|
3151 |
||
3152 |
anObject := self findObjectAt:aPoint. |
|
3153 |
anObject notNil ifTrue:[ |
|
3154 |
(self isSelected:anObject) ifFalse:[self unselect]. |
|
3155 |
self startObjectMove:anObject at:aPoint. |
|
3156 |
^ self |
|
3157 |
]. |
|
3158 |
"nothing was hit by this click - this starts a group select" |
|
3159 |
self unselect. |
|
3160 |
self startRectangleDrag:aPoint |
|
3161 |
! ! |
|
3162 |
||
3163 |
!ObjectView methodsFor:'view manipulation'! |
|
3164 |
||
3165 |
inchMetric |
|
3166 |
(scaleMetric ~~ #inch) ifTrue:[ |
|
3167 |
scaleMetric := #inch. |
|
3168 |
self newGrid |
|
3169 |
] |
|
3170 |
! |
|
3171 |
||
3172 |
millimeterMetric |
|
3173 |
(scaleMetric ~~ #mm) ifTrue:[ |
|
3174 |
scaleMetric := #mm. |
|
3175 |
self newGrid |
|
3176 |
] |
|
3177 |
! |
|
3178 |
||
3179 |
zoom:factor |
|
3180 |
"set a zoom factor; nil or 1 is identity; 2 is magnify by 2; |
|
3181 |
0.5 is shrink by 2" |
|
3182 |
||
3183 |
|current| |
|
3184 |
||
3185 |
transformation isNil ifTrue:[ |
|
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
3186 |
current := 1@1 |
216 | 3187 |
] ifFalse:[ |
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
3188 |
current := transformation scale |
216 | 3189 |
]. |
3190 |
factor asPoint = current asPoint ifTrue:[ |
|
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
3191 |
^ self |
216 | 3192 |
]. |
3193 |
current := factor. |
|
3194 |
current isNil ifTrue:[ |
|
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
3195 |
current := 1 |
216 | 3196 |
]. |
3197 |
||
3198 |
(current = 1) ifTrue:[ |
|
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
3199 |
transformation := nil |
216 | 3200 |
] ifFalse:[ |
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
3201 |
transformation := WindowingTransformation scale:current translation:0. |
216 | 3202 |
]. |
3203 |
self contentsChanged. |
|
3204 |
self setInnerClip. |
|
3205 |
gridShown ifTrue:[ |
|
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
3206 |
self newGrid |
216 | 3207 |
]. |
3208 |
shown ifTrue:[ |
|
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
3209 |
self invalidate "/ clear; redraw |
216 | 3210 |
]. |
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
3211 |
|
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
3212 |
"Modified: 29.5.1996 / 16:20:41 / cg" |
216 | 3213 |
! |
3214 |
||
3215 |
zoomIn |
|
2134 | 3216 |
self zoomIn:1.5 |
3217 |
||
3218 |
"Modified: / 10.2.2000 / 21:14:41 / cg" |
|
588 | 3219 |
! |
3220 |
||
3221 |
zoomIn:factor |
|
216 | 3222 |
transformation isNil ifTrue:[ |
588 | 3223 |
transformation := WindowingTransformation scale:1 translation:0 |
216 | 3224 |
]. |
588 | 3225 |
transformation := WindowingTransformation |
2134 | 3226 |
scale:(transformation scale * factor) |
3227 |
translation:(transformation translation * factor) rounded. |
|
216 | 3228 |
self contentsChanged. |
3229 |
self setInnerClip. |
|
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
3230 |
self invalidate. |
588 | 3231 |
|
2134 | 3232 |
"Created: / 27.4.1996 / 10:08:39 / cg" |
3233 |
"Modified: / 10.2.2000 / 21:11:11 / cg" |
|
216 | 3234 |
! |
3235 |
||
3236 |
zoomOut |
|
2134 | 3237 |
self zoomOut:1.5 |
3238 |
||
3239 |
"Modified: / 10.2.2000 / 21:14:46 / cg" |
|
588 | 3240 |
! |
3241 |
||
3242 |
zoomOut:factor |
|
216 | 3243 |
transformation isNil ifTrue:[ |
588 | 3244 |
transformation := WindowingTransformation scale:1 translation:0 |
216 | 3245 |
]. |
588 | 3246 |
transformation := WindowingTransformation |
2134 | 3247 |
scale:(transformation scale / factor) |
3248 |
translation:(transformation translation / factor) rounded. |
|
216 | 3249 |
self contentsChanged. |
3250 |
self setInnerClip. |
|
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
3251 |
self invalidate |
588 | 3252 |
|
2134 | 3253 |
"Created: / 27.4.1996 / 10:09:19 / cg" |
3254 |
"Modified: / 10.2.2000 / 21:10:52 / cg" |
|
216 | 3255 |
! ! |
3256 |
||
961 | 3257 |
!ObjectView class methodsFor:'documentation'! |
216 | 3258 |
|
3259 |
version |
|
2658 | 3260 |
^ '$Header: /cvs/stx/stx/libwidg/ObjectView.st,v 1.93 2002-10-31 23:25:54 cg Exp $' |
216 | 3261 |
! ! |