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