author | Claus Gittinger <cg@exept.de> |
Fri, 27 Jul 2012 11:09:03 +0200 | |
changeset 4439 | df2d2f707795 |
parent 3952 | 35fa38e8cf5b |
child 4625 | ff8daa46e92f |
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 |
||
3889
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
1132 |
self clippedByChildren:false. |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
1133 |
|
733 | 1134 |
self xoring:[ |
1135 |
self lineWidth:0. |
|
743
c2aafc876d49
dashed rectangle drag does not work on some Xservers
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
1136 |
"/ self lineStyle:#dashed. |
733 | 1137 |
self displayRectangle:dragObject. |
743
c2aafc876d49
dashed rectangle drag does not work on some Xservers
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
1138 |
"/ self lineStyle:#solid. |
733 | 1139 |
]. |
1140 |
||
3889
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
1141 |
self clippedByChildren:true. |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
1142 |
|
743
c2aafc876d49
dashed rectangle drag does not work on some Xservers
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
1143 |
"Modified: 3.6.1996 / 10:02:22 / cg" |
216 | 1144 |
! |
1145 |
||
1146 |
setRectangleDragActions |
|
1147 |
"setup to drag a rectangle. Call this (for example) from your buttonPress |
|
1148 |
method, to make the view start the drag. |
|
1149 |
See startRectangleDrag:." |
|
1150 |
||
1151 |
motionAction := [:movePoint | self doRectangleDrag:movePoint]. |
|
1152 |
releaseAction := [self endRectangleDrag] |
|
1153 |
! |
|
1154 |
||
1155 |
startRectangleDrag:startPoint |
|
1156 |
"start a rectangle drag" |
|
1157 |
||
3302 | 1158 |
lastButt := startPoint. |
216 | 1159 |
self setRectangleDragActions. |
1160 |
dragObject := Rectangle origin:startPoint corner:startPoint. |
|
1161 |
self invertDragRectangle. |
|
1162 |
oldCursor := cursor. |
|
1163 |
self cursor:leftHandCursor |
|
71 | 1164 |
! ! |
1165 |
||
1166 |
!ObjectView methodsFor:'drawing'! |
|
1167 |
||
1168 |
redraw |
|
1169 |
"redraw complete View" |
|
1170 |
||
1171 |
shown ifTrue:[ |
|
2924 | 1172 |
self clearView. |
1173 |
self redrawObjects |
|
71 | 1174 |
] |
1175 |
! |
|
1176 |
||
1177 |
redrawObjects |
|
1178 |
"redraw all objects" |
|
1179 |
||
1180 |
self redrawObjectsOn:self |
|
1181 |
! |
|
1182 |
||
1183 |
redrawObjectsAbove:anObject in:aRectangle |
|
1184 |
"redraw all objects which have part of themselfes in aRectangle |
|
1185 |
and are above (in front of) anObject. |
|
1186 |
draw only in (i.e. clip output to) aRectangle" |
|
1187 |
||
700 | 1188 |
|vis oldClip| |
71 | 1189 |
|
1190 |
shown ifTrue:[ |
|
700 | 1191 |
vis := aRectangle. |
1192 |
clipRect notNil ifTrue:[ |
|
1193 |
vis := vis intersect:clipRect |
|
1194 |
]. |
|
1195 |
oldClip := clipRect. |
|
1196 |
self clippingRectangle:vis. |
|
1197 |
||
1198 |
self redrawObjectsAbove:anObject intersecting:vis. |
|
1199 |
||
1200 |
self clippingRectangle:oldClip |
|
71 | 1201 |
] |
700 | 1202 |
|
1203 |
"Modified: 28.5.1996 / 19:57:06 / cg" |
|
71 | 1204 |
! |
1205 |
||
1206 |
redrawObjectsAbove:anObject inVisible:aRectangle |
|
1207 |
"redraw all objects which have part of themselfes in a vis rectangle |
|
1208 |
and are above (in front of) anObject. |
|
1209 |
draw only in (i.e. clip output to) aRectangle" |
|
1210 |
||
700 | 1211 |
|vis oldClip| |
71 | 1212 |
|
1213 |
shown ifTrue:[ |
|
700 | 1214 |
vis := aRectangle. |
1215 |
clipRect notNil ifTrue:[ |
|
1216 |
vis := vis intersect:clipRect |
|
1217 |
]. |
|
1218 |
oldClip := clipRect. |
|
1219 |
self clippingRectangle:vis. |
|
1220 |
||
1221 |
self redrawObjectsAbove:anObject intersectingVisible:vis. |
|
1222 |
||
1223 |
self clippingRectangle:oldClip |
|
71 | 1224 |
] |
700 | 1225 |
|
1226 |
"Modified: 28.5.1996 / 19:56:44 / cg" |
|
0 | 1227 |
! |
1228 |
||
216 | 1229 |
redrawObjectsAbove:anObject intersecting:aRectangle |
1230 |
"redraw all objects which have part of themself in aRectangle |
|
1231 |
and are above (in front of) anObject" |
|
1232 |
||
1233 |
self objectsAbove:anObject intersecting:aRectangle do:[:theObject | |
|
1234 |
self show:theObject |
|
1235 |
] |
|
71 | 1236 |
! |
1237 |
||
216 | 1238 |
redrawObjectsAbove:anObject intersectingVisible:aRectangle |
1239 |
"redraw all objects which have part of themself in a vis rectangle |
|
1240 |
and are above (in front of) anObject" |
|
1241 |
||
1242 |
self objectsAbove:anObject intersectingVisible:aRectangle do:[:theObject | |
|
1243 |
self show:theObject |
|
1244 |
] |
|
71 | 1245 |
! |
1246 |
||
216 | 1247 |
redrawObjectsIn:aRectangle |
1248 |
"redraw all objects which have part of themselfes in aRectangle |
|
1249 |
draw only in (i.e. clip output to) aRectangle" |
|
1250 |
||
700 | 1251 |
|visRect oldClip| |
216 | 1252 |
|
1253 |
shown ifTrue:[ |
|
700 | 1254 |
visRect := Rectangle origin:(aRectangle origin) |
1255 |
extent:(aRectangle extent). |
|
216 | 1256 |
"/ transformation notNil ifTrue:[ |
700 | 1257 |
visRect := visRect origin truncated |
1258 |
corner:(visRect corner + (1@1)) truncated. |
|
216 | 1259 |
"/ ]. |
700 | 1260 |
clipRect notNil ifTrue:[ |
1261 |
visRect := visRect intersect:clipRect |
|
1262 |
]. |
|
1263 |
oldClip := clipRect. |
|
1264 |
self clippingRectangle:visRect. |
|
1265 |
||
1266 |
self clearRectangle:visRect. |
|
1267 |
self redrawObjectsIntersecting:visRect. |
|
1268 |
||
1269 |
self clippingRectangle:oldClip |
|
71 | 1270 |
] |
700 | 1271 |
|
1272 |
"Modified: 28.5.1996 / 19:56:20 / cg" |
|
71 | 1273 |
! |
1274 |
||
216 | 1275 |
redrawObjectsInVisible:visRect |
1276 |
"redraw all objects which have part of themselfes in a vis rectangle |
|
1277 |
draw only in (i.e. clip output to) aRectangle" |
|
1278 |
||
700 | 1279 |
|vis oldClip| |
216 | 1280 |
|
1281 |
shown ifTrue:[ |
|
700 | 1282 |
vis := visRect. |
1283 |
clipRect notNil ifTrue:[ |
|
1284 |
vis := vis intersect:clipRect |
|
1285 |
]. |
|
1286 |
||
1287 |
transformation notNil ifTrue:[ |
|
216 | 1288 |
"/ transformation scale ~~ 1 ifTrue:[ |
700 | 1289 |
vis := vis origin truncated |
1290 |
corner:(vis corner + (1@1)) truncated. |
|
216 | 1291 |
"/ ] |
700 | 1292 |
]. |
1293 |
||
1294 |
oldClip := clipRect. |
|
1295 |
self clippingRectangle:vis. |
|
1296 |
||
2985
22ab9531ab4f
redrawObjectsInVisible: donot clear background; already done in redrawX:y:width:height:
ca
parents:
2924
diff
changeset
|
1297 |
"/ 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
|
1298 |
"/ self clearRectangle:vis. |
22ab9531ab4f
redrawObjectsInVisible: donot clear background; already done in redrawX:y:width:height:
ca
parents:
2924
diff
changeset
|
1299 |
|
700 | 1300 |
self redrawObjectsIntersecting:vis. |
1301 |
||
1302 |
self clippingRectangle:oldClip |
|
0 | 1303 |
] |
700 | 1304 |
|
1305 |
"Modified: 28.5.1996 / 19:55:47 / cg" |
|
0 | 1306 |
! |
1307 |
||
216 | 1308 |
redrawObjectsIntersecting:aRectangle |
1309 |
"redraw all objects which have part of themself in aRectangle" |
|
0 | 1310 |
|
63 | 1311 |
self objectsIntersecting:aRectangle do:[:theObject | |
216 | 1312 |
self show:theObject |
71 | 1313 |
] |
0 | 1314 |
! |
1315 |
||
216 | 1316 |
redrawObjectsIntersectingVisible:aRectangle |
1317 |
"redraw all objects which have part of themself in a vis rectangle |
|
1318 |
This is a leftOver from times when scrolling was not transparent. |
|
1319 |
Please use redrawObjectsIntersecting:, since this will vanish." |
|
1320 |
||
1321 |
self redrawObjectsIntersecting:aRectangle |
|
71 | 1322 |
! |
1323 |
||
216 | 1324 |
redrawObjectsOn:aGC |
1325 |
"redraw all objects on a graphic context" |
|
1326 |
||
1327 |
|vFrame| |
|
1328 |
||
1329 |
(aGC == self) ifTrue:[ |
|
619 | 1330 |
shown ifFalse:[^ self]. |
1331 |
vFrame := Rectangle left:0 top:0 width:width height:height. |
|
1332 |
||
1333 |
transformation notNil ifTrue:[ |
|
1334 |
vFrame := transformation applyInverseTo:vFrame. |
|
1335 |
]. |
|
1336 |
self redrawObjectsIntersecting:vFrame |
|
216 | 1337 |
] ifFalse:[ |
619 | 1338 |
"should loop over pages" |
1339 |
||
1340 |
vFrame := Rectangle left:0 top:0 width:9999 height:9999. |
|
1341 |
||
1342 |
self objectsIntersecting:vFrame do:[:theObject | |
|
1343 |
theObject drawIn:aGC |
|
1344 |
] |
|
63 | 1345 |
] |
619 | 1346 |
|
1347 |
"Modified: 8.5.1996 / 21:01:27 / cg" |
|
63 | 1348 |
! |
1349 |
||
216 | 1350 |
redrawScale |
1351 |
"redraw the scales" |
|
1352 |
||
1353 |
self redrawHorizontalScale. |
|
1354 |
self redrawVerticalScale |
|
1355 |
! |
|
1356 |
||
1357 |
show:anObject |
|
1358 |
"show the object, either selected or not" |
|
1359 |
||
1360 |
(self isSelected:anObject) ifTrue:[ |
|
1361 |
self showSelected:anObject |
|
1362 |
] ifFalse:[ |
|
1363 |
self showUnselected:anObject |
|
63 | 1364 |
] |
1365 |
! |
|
1366 |
||
216 | 1367 |
showDragging:something offset:anOffset |
1368 |
"show an object while dragging" |
|
1369 |
||
1370 |
|drawer| |
|
1371 |
||
1372 |
rootMotion ifTrue:[ |
|
1373 |
"drag in root-window" |
|
1374 |
||
1375 |
drawer := rootView |
|
1376 |
] ifFalse:[ |
|
1377 |
drawer := self |
|
1378 |
]. |
|
71 | 1379 |
self forEach:something do:[:anObject | |
216 | 1380 |
anObject drawDragIn:drawer offset:anOffset |
71 | 1381 |
] |
1382 |
! |
|
1383 |
||
216 | 1384 |
showSelected:anObject |
1385 |
"show an object as selected" |
|
1386 |
||
1387 |
anObject drawSelectedIn:self |
|
71 | 1388 |
! |
1389 |
||
216 | 1390 |
showUnselected:anObject |
1391 |
"show an object as unselected" |
|
1392 |
||
2678
873a631b1f1d
only send drawOn to displayObjects
Michael Beyl <mb@exept.de>
parents:
2658
diff
changeset
|
1393 |
anObject isView ifFalse:[ |
873a631b1f1d
only send drawOn to displayObjects
Michael Beyl <mb@exept.de>
parents:
2658
diff
changeset
|
1394 |
anObject drawIn:self |
873a631b1f1d
only send drawOn to displayObjects
Michael Beyl <mb@exept.de>
parents:
2658
diff
changeset
|
1395 |
] |
0 | 1396 |
! ! |
1397 |
||
3889
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
1398 |
!ObjectView methodsFor:'enumerating'! |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
1399 |
|
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
1400 |
contentsDo:aBlock |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
1401 |
contents do:aBlock |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
1402 |
! ! |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
1403 |
|
216 | 1404 |
!ObjectView methodsFor:'event handling'! |
1405 |
||
3002 | 1406 |
buttonCtrlPress:button x:x y:y |
1407 |
"user pressed left button with ctrl" |
|
1408 |
||
1409 |
ctrlPressAction notNil ifTrue:[ |
|
1410 |
ctrlPressAction value:lastButt. |
|
1411 |
] |
|
1412 |
! |
|
1413 |
||
3039
c346a6cdcf73
buttonState handling sensor bug workaround
Claus Gittinger <cg@exept.de>
parents:
3002
diff
changeset
|
1414 |
buttonMotion:buttonState x:buttX y:buttY |
216 | 1415 |
"user moved mouse while button pressed" |
1416 |
||
3199
893814d511ff
better start-motion behavior
Claus Gittinger <cg@exept.de>
parents:
3162
diff
changeset
|
1417 |
|xpos ypos movePoint limitW limitH minDeltaForMotion| |
216 | 1418 |
|
1419 |
"is it the select or 1-button ?" |
|
3039
c346a6cdcf73
buttonState handling sensor bug workaround
Claus Gittinger <cg@exept.de>
parents:
3002
diff
changeset
|
1420 |
buttonState == 0 ifTrue:[^ self]. |
1622
50dd1ee1604a
use another left-button-down test in #buttonMotion.
Claus Gittinger <cg@exept.de>
parents:
1490
diff
changeset
|
1421 |
self sensor leftButtonPressed ifFalse:[^ self]. |
216 | 1422 |
|
1423 |
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
|
1424 |
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
|
1425 |
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
|
1426 |
|
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 |
"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
|
1428 |
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
|
1429 |
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
|
1430 |
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
|
1431 |
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
|
1432 |
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
|
1433 |
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
|
1434 |
]. |
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 |
(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
|
1437 |
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
|
1438 |
] 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
|
1439 |
(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
|
1440 |
]. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1441 |
(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
|
1442 |
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
|
1443 |
] 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
|
1444 |
(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
|
1445 |
] |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1446 |
]. |
3199
893814d511ff
better start-motion behavior
Claus Gittinger <cg@exept.de>
parents:
3162
diff
changeset
|
1447 |
|
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
|
1448 |
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
|
1449 |
|
3199
893814d511ff
better start-motion behavior
Claus Gittinger <cg@exept.de>
parents:
3162
diff
changeset
|
1450 |
"/ if the motion is more than mouseMotionDeltaForMove |
893814d511ff
better start-motion behavior
Claus Gittinger <cg@exept.de>
parents:
3162
diff
changeset
|
1451 |
"/ or the time-delta is longer than timeDeltaForMove |
3302 | 1452 |
buttonPressTime notNil ifTrue:[ |
1453 |
(Timestamp now millisecondDeltaFrom:buttonPressTime) > self class mouseMotionTimeDeltaForMove ifFalse:[ |
|
1454 |
inMotion == true ifTrue:[ |
|
1455 |
minDeltaForMotion := 1 |
|
1456 |
] ifFalse:[ |
|
1457 |
minDeltaForMotion := self class mouseMotionDeltaForMove |
|
1458 |
]. |
|
1459 |
transformation notNil ifTrue:[ |
|
1460 |
minDeltaForMotion := transformation applyInverseToX:minDeltaForMotion. |
|
1461 |
]. |
|
1462 |
((xpos - (lastButt x)) abs < minDeltaForMotion |
|
1463 |
and:[ (ypos - (lastButt y)) abs < minDeltaForMotion]) ifTrue:[ |
|
1464 |
^ self "no (ignored) move" |
|
1465 |
]. |
|
3199
893814d511ff
better start-motion behavior
Claus Gittinger <cg@exept.de>
parents:
3162
diff
changeset
|
1466 |
]. |
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
|
1467 |
]. |
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 |
|
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1469 |
motionAction notNil ifTrue:[ |
3889
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
1470 |
self sensor motionEventPending ifFalse:[ |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
1471 |
inMotion := true. |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
1472 |
motionAction value:movePoint. |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
1473 |
lastButt := movePoint. |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
1474 |
]. |
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
|
1475 |
^ 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
|
1476 |
]. |
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 |
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
|
1478 |
]. |
3039
c346a6cdcf73
buttonState handling sensor bug workaround
Claus Gittinger <cg@exept.de>
parents:
3002
diff
changeset
|
1479 |
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
|
1480 |
|
1622
50dd1ee1604a
use another left-button-down test in #buttonMotion.
Claus Gittinger <cg@exept.de>
parents:
1490
diff
changeset
|
1481 |
"Modified: / 28.7.1998 / 16:01:31 / cg" |
216 | 1482 |
! |
1483 |
||
1484 |
buttonMultiPress:button x:x y:y |
|
1485 |
"user pressed left button twice (or more)" |
|
1486 |
||
3916
73162fbd69c1
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3889
diff
changeset
|
1487 |
(button == 1) 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
|
1488 |
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
|
1489 |
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
|
1490 |
^ 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
|
1491 |
] |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1492 |
]. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1493 |
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
|
1494 |
|
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1495 |
"Modified: 30.5.1996 / 17:57:36 / cg" |
0 | 1496 |
! |
1497 |
||
216 | 1498 |
buttonPress:button x:x y:y |
1499 |
"user pressed left button" |
|
1500 |
||
3878 | 1501 |
|sensor| |
1502 |
||
3916
73162fbd69c1
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3889
diff
changeset
|
1503 |
(button == 1) ifTrue:[ |
3199
893814d511ff
better start-motion behavior
Claus Gittinger <cg@exept.de>
parents:
3162
diff
changeset
|
1504 |
lastButt := x @ y. |
893814d511ff
better start-motion behavior
Claus Gittinger <cg@exept.de>
parents:
3162
diff
changeset
|
1505 |
buttonPressTime := Timestamp now. |
3878 | 1506 |
sensor := self sensor. |
1507 |
sensor shiftDown ifTrue:[ |
|
815 | 1508 |
^ self buttonShiftPress:button x:x y:y |
1509 |
]. |
|
3878 | 1510 |
sensor ctrlDown ifTrue:[ |
3002 | 1511 |
^ self buttonCtrlPress:button x:x y:y |
1512 |
]. |
|
815 | 1513 |
|
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 |
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
|
1515 |
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
|
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 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
|
1520 |
|
815 | 1521 |
"Modified: 1.8.1996 / 19:13:01 / cg" |
71 | 1522 |
! |
1523 |
||
216 | 1524 |
buttonRelease:button x:x y:y |
3199
893814d511ff
better start-motion behavior
Claus Gittinger <cg@exept.de>
parents:
3162
diff
changeset
|
1525 |
inMotion := false. |
893814d511ff
better start-motion behavior
Claus Gittinger <cg@exept.de>
parents:
3162
diff
changeset
|
1526 |
|
3916
73162fbd69c1
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3889
diff
changeset
|
1527 |
(button == 1) 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
|
1528 |
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
|
1529 |
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
|
1530 |
^ 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
|
1531 |
] |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1532 |
]. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1533 |
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
|
1534 |
|
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1535 |
"Modified: 30.5.1996 / 17:57:13 / cg" |
63 | 1536 |
! |
1537 |
||
216 | 1538 |
buttonShiftPress:button x:x y:y |
1539 |
"user pressed left button with shift" |
|
1540 |
||
815 | 1541 |
shiftPressAction notNil ifTrue:[ |
1542 |
shiftPressAction value:lastButt. |
|
1543 |
] |
|
1544 |
||
1545 |
"Modified: 1.8.1996 / 19:13:19 / cg" |
|
63 | 1546 |
! |
1547 |
||
216 | 1548 |
keyPress:key x:x y:y |
1549 |
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
|
1550 |
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
|
1551 |
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
|
1552 |
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
|
1553 |
] |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1554 |
]. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1555 |
^ 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
|
1556 |
]. |
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1557 |
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
|
1558 |
|
1b1520ba6c56
perform default event actions, if no corresponding action was set (keyPress/release; buttonPress/release)
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1559 |
"Modified: 30.5.1996 / 17:57:54 / cg" |
0 | 1560 |
! |
1561 |
||
216 | 1562 |
redrawX:x y:y width:w height:h |
1563 |
|redrawFrame | |
|
1564 |
||
3878 | 1565 |
"/ self clearRectangle:redrawFrame. |
1566 |
super redrawX:x y:y width:w height:h. |
|
1567 |
||
216 | 1568 |
((contents size ~~ 0) or:[gridShown]) ifTrue:[ |
3878 | 1569 |
redrawFrame := Rectangle left:x top:y width:w height:h. |
619 | 1570 |
self redrawObjectsInVisible:redrawFrame |
0 | 1571 |
] |
619 | 1572 |
|
749
19b1792b9506
clear area before doing a redraw
Claus Gittinger <cg@exept.de>
parents:
747
diff
changeset
|
1573 |
"Modified: 5.6.1996 / 10:42:19 / cg" |
63 | 1574 |
! ! |
1575 |
||
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1826
diff
changeset
|
1576 |
!ObjectView methodsFor:'focus control'! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1826
diff
changeset
|
1577 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1826
diff
changeset
|
1578 |
wantsFocusWithPointerEnter |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1826
diff
changeset
|
1579 |
^ UserPreferences current focusFollowsMouse ~~ false |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1826
diff
changeset
|
1580 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1826
diff
changeset
|
1581 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1826
diff
changeset
|
1582 |
! ! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1826
diff
changeset
|
1583 |
|
63 | 1584 |
!ObjectView methodsFor:'grid manipulation'! |
1585 |
||
216 | 1586 |
alignOff |
1587 |
"do no align point to grid" |
|
1588 |
||
1589 |
aligning := false |
|
71 | 1590 |
! |
1591 |
||
216 | 1592 |
alignOn |
1593 |
"align points to grid" |
|
1594 |
||
1595 |
aligning := true. |
|
1596 |
self getAlignParameters |
|
63 | 1597 |
! |
1598 |
||
1599 |
defineGrid |
|
77 | 1600 |
"define the grid pattern - this creates the gridPixmap, which is |
1601 |
used as viewBackground when a grid is to be shown. |
|
1602 |
The grid is specified by the value returned from gridParameters, |
|
1603 |
which can be redefined in subclasses. See the comment there on how |
|
1604 |
the numbers are interpreted." |
|
63 | 1605 |
|
1606 |
|mmH mmV params showDocumentBoundary gridW gridH |
|
3000 | 1607 |
bigStepH bigStepV littleStepH littleStepV hires |
1608 |
devPixmap colorMap fg bg| |
|
63 | 1609 |
|
1610 |
mmH := self horizontalPixelPerMillimeter. |
|
1611 |
mmV := self verticalPixelPerMillimeter. |
|
1612 |
hires := self horizontalPixelPerInch > 120. |
|
0 | 1613 |
|
63 | 1614 |
params := self gridParameters. |
1615 |
||
1616 |
bigStepH := params at:1. |
|
1617 |
bigStepV := params at:2. |
|
1618 |
littleStepH := params at:3. |
|
1619 |
littleStepV := params at:4. |
|
1620 |
showDocumentBoundary := params at:7. |
|
3000 | 1621 |
fg := Black. |
1622 |
bg := White. |
|
1623 |
params size >= 8 ifTrue:[ |
|
1624 |
bg := params at:8. |
|
1625 |
params size >= 9 ifTrue:[ |
|
1626 |
fg := params at:9. |
|
1627 |
]. |
|
1628 |
]. |
|
0 | 1629 |
|
63 | 1630 |
transformation notNil ifTrue:[ |
256
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1631 |
mmH := mmH * transformation scale x. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1632 |
mmV := mmV * transformation scale y. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1633 |
bigStepH := bigStepH * transformation scale x. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1634 |
bigStepV := bigStepV * transformation scale y. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1635 |
littleStepH notNil ifTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1636 |
littleStepH := littleStepH * transformation scale x. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1637 |
]. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1638 |
littleStepV notNil ifTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1639 |
littleStepV := littleStepV * transformation scale y. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1640 |
]. |
0 | 1641 |
]. |
1642 |
||
63 | 1643 |
bigStepH isNil ifTrue:[^ self]. |
1644 |
||
1490 | 1645 |
gridW := (self widthOfContentsInMM * mmH). |
1646 |
gridH := (self heightOfContentsInMM * mmV). |
|
1647 |
||
256
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1648 |
self withWaitCursorDo:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1649 |
|xp yp y x| |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1650 |
|
1490 | 1651 |
((bigStepH isInteger and:[littleStepH isNil or:[littleStepH isInteger]]) |
1652 |
and:[(bigStepV isInteger and:[littleStepV isNil or:[littleStepV isInteger]])]) ifTrue:[ |
|
1653 |
gridW := bigStepH. |
|
1654 |
littleStepH notNil ifTrue:[gridW := gridW max:littleStepH]. |
|
1655 |
gridH := bigStepV. |
|
1656 |
littleStepV notNil ifTrue:[gridH := gridH max:littleStepV]. |
|
1657 |
] ifFalse:[ |
|
1658 |
||
1659 |
" |
|
1660 |
up to next full unit |
|
1661 |
" |
|
1662 |
gridW := ((gridW // bigStepH) + 1 * bigStepH) asInteger. |
|
1663 |
gridH := ((gridH // bigStepV) + 1 * bigStepV) asInteger. |
|
1664 |
]. |
|
256
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1665 |
|
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1666 |
gridPixmap := Form width:gridW height:gridH depth:1. |
3000 | 1667 |
gridPixmap colorMap:(Array with:bg with:fg). |
256
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1668 |
gridPixmap clear. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1669 |
gridPixmap paint:(Color colorId:1). |
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 |
"draw first row point-by-point" |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1672 |
yp := 0.0. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1673 |
xp := 0.0. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1674 |
y := yp asInteger. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1675 |
[xp <= gridW] whileTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1676 |
x := xp 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 displayPointX:(x + 1) y:y. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1679 |
gridPixmap displayPointX:(x + 2) y:y |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1680 |
]. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1681 |
gridPixmap displayPointX:x y:y. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1682 |
littleStepH notNil ifTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1683 |
xp := xp + littleStepH |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1684 |
] ifFalse:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1685 |
xp := xp + bigStepH |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1686 |
] |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1687 |
]. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1688 |
|
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1689 |
"copy rest from what has been drawn already" |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1690 |
yp := yp + bigStepV. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1691 |
[yp <= gridH] whileTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1692 |
y := yp rounded. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1693 |
hires ifTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1694 |
gridPixmap copyFrom:gridPixmap x:0 y:0 |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1695 |
toX:0 y:(y + 1) |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1696 |
width:gridW height:1. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1697 |
gridPixmap copyFrom:gridPixmap x:0 y:0 |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1698 |
toX:0 y:(y + 2) |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1699 |
width:gridW height:1 |
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 copyFrom:gridPixmap x:0 y:0 |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1702 |
toX:0 y:y |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1703 |
width:gridW height:1. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1704 |
yp := yp + bigStepV |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1705 |
]. |
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 |
"draw first col point-by-point" |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1708 |
xp := 0.0. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1709 |
yp := 0.0. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1710 |
x := xp asInteger. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1711 |
[yp <= gridH] whileTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1712 |
y := yp 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 displayPointX:x y:(y + 1). |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1715 |
gridPixmap displayPointX:x y:(y + 2) |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1716 |
]. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1717 |
gridPixmap displayPointX:x y:y. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1718 |
littleStepV notNil ifTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1719 |
yp := yp + littleStepV |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1720 |
] ifFalse:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1721 |
yp := yp + bigStepV |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1722 |
] |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1723 |
]. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1724 |
|
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1725 |
"copy rest from what has been drawn already" |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1726 |
xp := xp + bigStepH. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1727 |
[xp <= gridW] whileTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1728 |
x := xp rounded. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1729 |
hires ifTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1730 |
gridPixmap copyFrom:gridPixmap x:0 y:0 |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1731 |
toX:(x + 1) y:0 |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1732 |
width:1 height:gridH. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1733 |
gridPixmap copyFrom:gridPixmap x:0 y:0 |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1734 |
toX:(x + 2) y:0 |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1735 |
width:1 height:gridH |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1736 |
]. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1737 |
gridPixmap copyFrom:gridPixmap x:0 y:0 |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1738 |
toX:x y:0 |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1739 |
width:1 height:gridH. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1740 |
xp := xp + bigStepH |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1741 |
]. |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1742 |
|
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1743 |
showDocumentBoundary ifTrue:[ |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1744 |
" |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1745 |
mark the right-end and bottom of the document |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1746 |
" |
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1747 |
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
|
1748 |
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
|
1749 |
]. |
1920 | 1750 |
|
1751 |
device platformName = 'WIN32' ifTrue:[ |
|
1752 |
"/ kludge - needs a deep form |
|
1753 |
colorMap := gridPixmap colorMap. |
|
3489
2611d54611ee
Change senders of obsolete messages Form>>...on: to ...onDevice:
Stefan Vogel <sv@exept.de>
parents:
3421
diff
changeset
|
1754 |
devPixmap := Form width:gridW height:gridH depth:device depth onDevice:device. |
1920 | 1755 |
devPixmap notNil ifTrue:[ |
1756 |
devPixmap paint:(colorMap at:1). |
|
1757 |
devPixmap fillRectangleX:0 y:0 width:gridW height:gridH. |
|
1758 |
devPixmap foreground:(colorMap at:2) background:(colorMap at:1). |
|
1759 |
devPixmap copyPlaneFrom:gridPixmap x:0 y:0 toX:0 y:0 width:gridW height:gridH. |
|
1760 |
gridPixmap := devPixmap. |
|
1761 |
] |
|
1762 |
]. |
|
63 | 1763 |
] |
256
c55a4f8d8a70
use withWaitCursorDo: / withReadCursorDo:
Claus Gittinger <cg@exept.de>
parents:
216
diff
changeset
|
1764 |
|
1920 | 1765 |
"Modified: / 6.6.1999 / 01:00:16 / cg" |
63 | 1766 |
! |
1767 |
||
216 | 1768 |
getAlignParameters |
1769 |
|params| |
|
1770 |
||
1771 |
params := self gridParameters. |
|
1772 |
gridAlign := (params at:5) @ (params at:6) |
|
1773 |
! |
|
1774 |
||
1775 |
gridParameters |
|
1776 |
"used by defineGrid, and in a separate method for |
|
1777 |
easier redefinition in subclasses. |
|
1778 |
Returns the grid parameters in an array of 7 elements, |
|
1779 |
which control the appearance of the grid-pattern. |
|
1780 |
the elements are: |
|
1781 |
||
3000 | 1782 |
bigStepH number of pixels horizontally between 2 major steps |
1783 |
bigStepV number of pixels vertically between 2 major steps |
|
1784 |
littleStepH number of pixels horizontally between 2 minor steps |
|
1785 |
littleStepV number of pixels vertically between 2 minor steps |
|
1786 |
gridAlignH number of pixels for horizontal grid align (pointer snap) |
|
1787 |
gridAlignV number of pixels for vertical grid align (pointer snap) |
|
1788 |
docBounds true, if document boundary should be shown |
|
1789 |
bgColor grid bg-color [optional] |
|
1790 |
fgColor grid fg-color [optional] |
|
216 | 1791 |
|
1792 |
if littleStepH/V are nil, only bigSteps are drawn. |
|
1793 |
" |
|
1794 |
||
1795 |
|mmH mmV bigStepH bigStepV littleStepH littleStepV arr| |
|
1796 |
||
1797 |
"example: 12grid & 12snapIn" |
|
1798 |
"/ ^ #(12 12 nil nil 12 12 false). |
|
1799 |
||
1800 |
"example: 12grid & 24snapIn" |
|
1801 |
"/ ^ #(12 12 nil nil 24 24 false). |
|
1802 |
||
1803 |
"default: cm/mm grid & mm snapIn for metric, |
|
1804 |
1inch , 1/8inch grid & 1/8 inch snapIn" |
|
1805 |
||
1806 |
mmH := self horizontalPixelPerMillimeter. |
|
1807 |
mmV := self verticalPixelPerMillimeter. |
|
1808 |
||
1809 |
" |
|
1810 |
metric grid: small steps every millimeter, big step every |
|
1811 |
centimeter. If the transformation is shrinking, turn off little |
|
1812 |
steps. |
|
1813 |
" |
|
1814 |
(scaleMetric == #mm) ifTrue:[ |
|
3000 | 1815 |
"dots every mm; lines every cm" |
1816 |
bigStepH := mmH * 10.0. |
|
1817 |
bigStepV := mmV * 10.0. |
|
1818 |
(transformation notNil |
|
1819 |
and:[transformation scale <= 0.5]) ifFalse:[ |
|
1820 |
littleStepH := mmH. |
|
1821 |
littleStepV := mmV |
|
1822 |
] |
|
216 | 1823 |
]. |
1824 |
" |
|
1825 |
inch grid: small steps every 1/8th inch, big step every half inch |
|
1826 |
If the transformation is shrinking, change little steps to 1/th inch |
|
1827 |
or even turn them off completely. |
|
1828 |
" |
|
1829 |
(scaleMetric == #inch) ifTrue:[ |
|
3000 | 1830 |
"dots every eights inch; lines every half inch" |
1831 |
bigStepH := mmH * (25.4 / 2). |
|
1832 |
bigStepV := mmV * (25.4 / 2). |
|
1833 |
(transformation notNil |
|
1834 |
and:[transformation scale <= 0.5]) ifTrue:[ |
|
1835 |
transformation scale > 0.2 ifTrue:[ |
|
1836 |
littleStepH := mmH * (25.4 / 4). |
|
1837 |
littleStepV := mmV * (25.4 / 4) |
|
1838 |
] |
|
1839 |
] ifFalse:[ |
|
1840 |
littleStepH := mmH * (25.4 / 8). |
|
1841 |
littleStepV := mmV * (25.4 / 8) |
|
1842 |
] |
|
216 | 1843 |
]. |
1844 |
||
3000 | 1845 |
arr := Array new:9. |
216 | 1846 |
arr at:1 put:bigStepH. |
1847 |
arr at:2 put:bigStepV. |
|
1848 |
arr at:3 put:littleStepH. |
|
1849 |
arr at:4 put:littleStepV. |
|
1850 |
arr at:5 put:littleStepH. |
|
1851 |
arr at:6 put:littleStepV. |
|
1852 |
arr at:7 put:false. |
|
3000 | 1853 |
arr at:8 put:White. |
1854 |
arr at:9 put:Black. |
|
216 | 1855 |
|
1856 |
^ arr |
|
0 | 1857 |
! |
1858 |
||
1859 |
hideGrid |
|
1860 |
"hide the grid" |
|
1861 |
||
1862 |
gridShown := false. |
|
63 | 1863 |
self newGrid |
1864 |
! |
|
1865 |
||
216 | 1866 |
newGrid |
1867 |
"define a new grid - this is a private helper which has to be |
|
1868 |
called after any change in the grid. It (re)creates the gridPixmap, |
|
1869 |
clears the view and redraws all visible objects." |
|
1870 |
||
3000 | 1871 |
|params bg| |
1872 |
||
216 | 1873 |
gridPixmap := nil. |
1874 |
shown ifTrue:[ |
|
3000 | 1875 |
params := self gridParameters. |
1876 |
bg := White. |
|
1877 |
params size >= 8 ifTrue:[ |
|
1878 |
bg := params at:8. |
|
1879 |
]. |
|
1880 |
||
1881 |
self viewBackground:bg. |
|
2924 | 1882 |
self clearView. |
216 | 1883 |
]. |
1884 |
||
1885 |
gridShown ifTrue:[ |
|
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
1886 |
self defineGrid. |
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
1887 |
self viewBackground:gridPixmap. |
216 | 1888 |
]. |
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
1889 |
|
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
1890 |
self invalidate |
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
1891 |
|
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
1892 |
"Modified: 29.5.1996 / 16:20:11 / cg" |
0 | 1893 |
! |
1894 |
||
216 | 1895 |
showGrid |
1896 |
"show the grid. The grid is defined by the return value of |
|
1897 |
gridParameters, which can be redefined in concrete subclasses." |
|
1898 |
||
1899 |
gridShown := true. |
|
1900 |
self newGrid |
|
1901 |
! ! |
|
1902 |
||
1903 |
!ObjectView methodsFor:'initialization'! |
|
1904 |
||
1905 |
initEvents |
|
1906 |
"/ self backingStore:true. |
|
0 | 1907 |
! |
1908 |
||
216 | 1909 |
initialize |
1910 |
super initialize. |
|
1911 |
||
1912 |
viewBackground := White. |
|
1913 |
||
1914 |
bitGravity := #NorthWest. |
|
1915 |
contents := OrderedCollection new. |
|
1916 |
gridShown := false. |
|
1917 |
||
1918 |
canDragOutOfView := false. |
|
1919 |
rootView := DisplayRootView new. |
|
1220 | 1920 |
rootView clippedByChildren:false. |
216 | 1921 |
rootMotion := false. |
1922 |
self setInitialDocumentFormat. |
|
1923 |
||
1924 |
leftHandCursor := Cursor leftHand. |
|
1925 |
sorted := false. |
|
961 | 1926 |
aligning := false. |
1927 |
aligningMove := false. |
|
3199
893814d511ff
better start-motion behavior
Claus Gittinger <cg@exept.de>
parents:
3162
diff
changeset
|
1928 |
inMotion := false. |
961 | 1929 |
|
1930 |
"Modified: 20.1.1997 / 20:41:10 / cg" |
|
216 | 1931 |
! |
1932 |
||
1933 |
setInitialDocumentFormat |
|
3951
1726c8891c34
changed: #setInitialDocumentFormat
Claus Gittinger <cg@exept.de>
parents:
3916
diff
changeset
|
1934 |
(UserPreferences current languageTerritory == #us) ifTrue:[ |
1726c8891c34
changed: #setInitialDocumentFormat
Claus Gittinger <cg@exept.de>
parents:
3916
diff
changeset
|
1935 |
documentFormat := 'letter'. |
1726c8891c34
changed: #setInitialDocumentFormat
Claus Gittinger <cg@exept.de>
parents:
3916
diff
changeset
|
1936 |
scaleMetric := #inch |
216 | 1937 |
] ifFalse:[ |
3951
1726c8891c34
changed: #setInitialDocumentFormat
Claus Gittinger <cg@exept.de>
parents:
3916
diff
changeset
|
1938 |
documentFormat := 'a4'. |
1726c8891c34
changed: #setInitialDocumentFormat
Claus Gittinger <cg@exept.de>
parents:
3916
diff
changeset
|
1939 |
scaleMetric := #mm |
216 | 1940 |
]. |
0 | 1941 |
! ! |
1942 |
||
216 | 1943 |
!ObjectView methodsFor:'layout manipulation'! |
1944 |
||
1945 |
alignBottom:something |
|
1946 |
|botMost| |
|
1947 |
||
1948 |
botMost := -999999. |
|
1949 |
self forEach:something do:[:anObject | |
|
1950 |
botMost := botMost max:(anObject frame bottom) |
|
1951 |
]. |
|
1952 |
self withSelectionHiddenDo:[ |
|
1953 |
self forEach:something do:[:anObject | |
|
1954 |
self moveObject:anObject to:(anObject frame left) |
|
1955 |
@ |
|
1956 |
(botMost - (anObject frame height)) |
|
1957 |
] |
|
1958 |
] |
|
1959 |
! |
|
1960 |
||
747 | 1961 |
alignHorizontal:something |
1962 |
"align selection along their center horizontally" |
|
1963 |
||
1964 |
|topMost bottomMost h| |
|
1965 |
||
1966 |
topMost := 999999. |
|
1967 |
bottomMost := -999999. |
|
1968 |
self forEach:something do:[:anObject | |
|
1969 |
|f| |
|
1970 |
f := anObject frame. |
|
1971 |
topMost := topMost min:(f top). |
|
1972 |
bottomMost := bottomMost max:(f bottom). |
|
1973 |
]. |
|
1974 |
h := bottomMost - topMost. |
|
1975 |
||
1976 |
self withSelectionHiddenDo:[ |
|
1977 |
self forEach:something do:[:anObject | |
|
1978 |
self moveObject:anObject |
|
1979 |
to:(anObject frame left) |
|
1980 |
@ |
|
1981 |
(topMost + ((h - anObject frame height) // 2)) |
|
1982 |
] |
|
1983 |
] |
|
1984 |
||
1985 |
"Created: 4.6.1996 / 20:01:19 / cg" |
|
1986 |
"Modified: 4.6.1996 / 21:19:48 / cg" |
|
1987 |
! |
|
1988 |
||
216 | 1989 |
alignLeft:something |
1990 |
|leftMost| |
|
1991 |
||
1992 |
leftMost := 999999. |
|
1993 |
self forEach:something do:[:anObject | |
|
1994 |
leftMost := leftMost min:(anObject frame left) |
|
1995 |
]. |
|
1996 |
self withSelectionHiddenDo:[ |
|
1997 |
self forEach:something do:[:anObject | |
|
1998 |
self moveObject:anObject to:(leftMost @ (anObject frame top)) |
|
1999 |
] |
|
2000 |
] |
|
2001 |
! |
|
2002 |
||
2003 |
alignRight:something |
|
2004 |
|rightMost| |
|
2005 |
||
2006 |
rightMost := -999999. |
|
2007 |
self forEach:something do:[:anObject | |
|
2008 |
rightMost := rightMost max:(anObject frame right) |
|
2009 |
]. |
|
2010 |
self withSelectionHiddenDo:[ |
|
2011 |
self forEach:something do:[:anObject | |
|
2012 |
self moveObject:anObject to:(rightMost - (anObject frame width)) |
|
2013 |
@ (anObject frame top) |
|
2014 |
] |
|
2015 |
] |
|
2016 |
! |
|
2017 |
||
2018 |
alignTop:something |
|
2019 |
|topMost| |
|
2020 |
||
2021 |
topMost := 999999. |
|
2022 |
self forEach:something do:[:anObject | |
|
2023 |
topMost := topMost min:(anObject frame top) |
|
2024 |
]. |
|
2025 |
self withSelectionHiddenDo:[ |
|
2026 |
self forEach:something do:[:anObject | |
|
2027 |
self moveObject:anObject to:((anObject frame left) @ topMost) |
|
2028 |
] |
|
2029 |
] |
|
2030 |
! |
|
2031 |
||
747 | 2032 |
alignVertical:something |
2033 |
"align selection along their center vertically" |
|
2034 |
||
2035 |
|leftMost rightMost w| |
|
2036 |
||
2037 |
leftMost := 999999. |
|
2038 |
rightMost := -999999. |
|
2039 |
self forEach:something do:[:anObject | |
|
2040 |
|f| |
|
2041 |
f := anObject frame. |
|
2042 |
rightMost := rightMost max:(f right). |
|
2043 |
leftMost := leftMost min:(f left). |
|
2044 |
]. |
|
2045 |
w := rightMost - leftMost. |
|
2046 |
||
2047 |
self withSelectionHiddenDo:[ |
|
2048 |
self forEach:something do:[:anObject | |
|
2049 |
self moveObject:anObject |
|
2050 |
to:(leftMost + ((w - anObject frame width) // 2)) |
|
2051 |
@ |
|
2052 |
(anObject frame top) |
|
2053 |
] |
|
2054 |
] |
|
2055 |
||
2056 |
"Created: 4.6.1996 / 19:59:16 / cg" |
|
2057 |
"Modified: 4.6.1996 / 21:19:58 / cg" |
|
2058 |
! |
|
2059 |
||
216 | 2060 |
move:something by:delta |
2061 |
"change the position of something, an Object or Collection |
|
2062 |
by delta, aPoint" |
|
2063 |
||
2064 |
(delta x == 0) ifTrue:[ |
|
2065 |
(delta y == 0) ifTrue:[^ self] |
|
2066 |
]. |
|
2067 |
||
2068 |
self forEach:something do:[:anObject | |
|
2069 |
self moveObject:anObject by:delta |
|
2070 |
] |
|
2071 |
! |
|
2072 |
||
2073 |
move:something to:aPoint in:aView |
|
2074 |
"can only happen when dragOutOfView is true |
|
2075 |
- should be redefined in subclasses" |
|
2076 |
||
2077 |
self notify:'cannot move object(s) out of view' |
|
2078 |
! |
|
2079 |
||
2080 |
move:something to:aPoint inAlienViewId:aViewId |
|
2081 |
"can only happen when dragOutOfView is true |
|
2082 |
- should be redefined in subclasses" |
|
2083 |
||
2084 |
self notify:'cannot move object(s) to alien views' |
|
77 | 2085 |
! |
2086 |
||
216 | 2087 |
moveObject:anObject by:delta |
2088 |
"change the position of anObject by delta, aPoint" |
|
2089 |
||
2090 |
self moveObject:anObject to:(anObject origin + delta) |
|
2091 |
! |
|
2092 |
||
2093 |
moveObject:anObject to:newOrigin |
|
2094 |
"move anObject to newOrigin, aPoint" |
|
2095 |
||
2096 |
|oldOrigin oldFrame newFrame |
|
2097 |
objectsIntersectingOldFrame objectsIntersectingNewFrame |
|
2098 |
wasObscured isObscured intersects |
|
701 | 2099 |
oldLeft oldTop w h newLeft newTop griddedNewOrigin clip| |
216 | 2100 |
|
2101 |
anObject isNil ifTrue:[^ self]. |
|
2102 |
anObject canBeMoved ifFalse:[^ self]. |
|
2103 |
||
2104 |
griddedNewOrigin := self alignToGrid:newOrigin. |
|
2105 |
oldOrigin := anObject origin. |
|
2106 |
(oldOrigin = griddedNewOrigin) ifTrue:[^ self]. |
|
2107 |
||
2108 |
oldFrame := self frameOf:anObject. |
|
2109 |
objectsIntersectingOldFrame := self objectsIntersecting:oldFrame. |
|
2110 |
wasObscured := self isObscured:anObject. |
|
2111 |
||
2112 |
anObject moveTo:griddedNewOrigin. |
|
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2113 |
self changed:#objectLayout. |
782 | 2114 |
shown ifFalse:[^ self]. |
216 | 2115 |
|
2116 |
newFrame := self frameOf:anObject. |
|
2117 |
objectsIntersectingNewFrame := self objectsIntersecting:newFrame. |
|
2118 |
||
2119 |
"try to redraw the minimum possible" |
|
2120 |
||
2121 |
"if no other object intersects both frames we can do a copy:" |
|
2122 |
||
2123 |
intersects := oldFrame intersects:newFrame. |
|
2124 |
intersects ifFalse:[ |
|
2045 | 2125 |
self hasSolidBackground ifTrue:[ |
701 | 2126 |
transformation isNil ifTrue:[ |
2127 |
(objectsIntersectingOldFrame size == 1) ifTrue:[ |
|
2128 |
(objectsIntersectingNewFrame size == 1) ifTrue:[ |
|
2129 |
clip := self clippingRectangleOrNil. |
|
2130 |
(clip isNil or:[oldFrame isContainedIn:clip]) ifTrue:[ |
|
2131 |
oldLeft := oldFrame left. |
|
2132 |
oldTop := oldFrame top. |
|
2133 |
newLeft := newFrame left. |
|
2134 |
newTop := newFrame top. |
|
2135 |
w := oldFrame width. |
|
2136 |
h := oldFrame height. |
|
2137 |
((newLeft < width) and:[newTop < height]) ifTrue:[ |
|
2138 |
((newLeft >= 0) and:[newTop >= 0]) ifTrue:[ |
|
2139 |
self catchExpose. |
|
984 | 2140 |
self |
2141 |
copyFrom:self |
|
2142 |
x:oldLeft y:oldTop |
|
2143 |
toX:newLeft y:newTop |
|
2144 |
width:w height:h |
|
2145 |
async:true. |
|
701 | 2146 |
self waitForExpose |
2147 |
] |
|
2148 |
]. |
|
2149 |
((oldLeft < width) and:[oldTop < height]) ifTrue:[ |
|
2150 |
((oldLeft >= 0) and:[oldTop >= 0]) ifTrue:[ |
|
2151 |
self clearRectangleX:oldLeft y:oldTop width:w height:h. |
|
216 | 2152 |
|
2153 |
"/ self fillRectangleX:oldLeft y:oldTop width:w height:h |
|
2154 |
"/ with:viewBackground |
|
701 | 2155 |
] |
2156 |
]. |
|
2157 |
^ self |
|
2158 |
] |
|
2159 |
] |
|
2160 |
] |
|
2161 |
] |
|
2162 |
] |
|
216 | 2163 |
]. |
2164 |
isObscured := self isObscured:anObject. |
|
2165 |
(oldFrame intersects:newFrame) ifTrue:[ |
|
701 | 2166 |
isObscured ifFalse:[ |
2167 |
self redrawObjectsIn:oldFrame. |
|
2168 |
self show: anObject |
|
2169 |
] ifTrue:[ |
|
2170 |
self redrawObjectsIn:(oldFrame merge:newFrame) |
|
2171 |
] |
|
216 | 2172 |
] ifFalse:[ |
701 | 2173 |
self redrawObjectsIn:oldFrame. |
2174 |
isObscured ifFalse:[ |
|
2175 |
self show: anObject |
|
2176 |
] ifTrue:[ |
|
2177 |
self redrawObjectsIn:newFrame |
|
2178 |
] |
|
216 | 2179 |
] |
701 | 2180 |
|
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2181 |
"Modified: / 4.7.1999 / 16:52:17 / cg" |
59 | 2182 |
! |
2183 |
||
216 | 2184 |
objectToBack:anObject |
2185 |
"bring the argument, anObject to back" |
|
2186 |
||
2187 |
anObject notNil ifTrue:[ |
|
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2188 |
contents remove:anObject. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2189 |
contents addFirst:anObject. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2190 |
(self isObscured:anObject) ifTrue:[ |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2191 |
self redrawObjectsIn:(anObject frame) |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2192 |
]. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2193 |
self changed:#objectLayout. |
216 | 2194 |
] |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2195 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2196 |
"Modified: / 4.7.1999 / 16:52:39 / cg" |
216 | 2197 |
! |
2198 |
||
2199 |
objectToFront:anObject |
|
2200 |
"bring the argument, anObject to front" |
|
2201 |
||
2202 |
|wasObscured| |
|
2203 |
||
2204 |
anObject notNil ifTrue:[ |
|
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2205 |
wasObscured := self isObscured:anObject. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2206 |
contents remove:anObject. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2207 |
contents addLast:anObject. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2208 |
wasObscured ifTrue:[ |
216 | 2209 |
"old: |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2210 |
self redrawObjectsIn:(anObject frame) |
216 | 2211 |
" |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2212 |
self hideSelection. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2213 |
self show:anObject. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2214 |
self showSelection |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2215 |
]. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2216 |
self changed:#objectLayout. |
216 | 2217 |
] |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2218 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2219 |
"Modified: / 4.7.1999 / 16:52:49 / cg" |
216 | 2220 |
! |
2221 |
||
2222 |
selectionAlignBottom |
|
2223 |
"align selected objects at bottom" |
|
2224 |
||
2225 |
self alignBottom:selection |
|
2226 |
! |
|
2227 |
||
747 | 2228 |
selectionAlignHorizontal |
2229 |
"align selected objects horizontally" |
|
2230 |
||
2231 |
self alignHorizontal:selection |
|
2232 |
||
2233 |
"Created: 4.6.1996 / 19:58:46 / cg" |
|
2234 |
"Modified: 4.6.1996 / 19:59:10 / cg" |
|
2235 |
! |
|
2236 |
||
216 | 2237 |
selectionAlignLeft |
2238 |
"align selected objects left" |
|
2239 |
||
2240 |
self alignLeft:selection |
|
2241 |
! |
|
2242 |
||
2243 |
selectionAlignRight |
|
2244 |
"align selected objects right" |
|
2245 |
||
2246 |
self alignRight:selection |
|
2247 |
! |
|
2248 |
||
2249 |
selectionAlignTop |
|
2250 |
"align selected objects at top" |
|
2251 |
||
2252 |
self alignTop:selection |
|
59 | 2253 |
! |
2254 |
||
747 | 2255 |
selectionAlignVertical |
2256 |
"align selected objects vertically" |
|
2257 |
||
2258 |
self alignVertical:selection |
|
2259 |
||
2260 |
"Created: 4.6.1996 / 19:59:00 / cg" |
|
2261 |
! |
|
2262 |
||
216 | 2263 |
selectionToBack |
2264 |
"bring the selection to back" |
|
2265 |
||
2266 |
self toBack:selection |
|
2267 |
! |
|
2268 |
||
2269 |
selectionToFront |
|
2270 |
"bring the selection to front" |
|
2271 |
||
2272 |
self toFront:selection |
|
2273 |
! |
|
2274 |
||
2275 |
toBack:something |
|
2276 |
"bring the argument, anObject or a collection of objects to back" |
|
2277 |
||
2278 |
self forEach:something do:[:anObject | |
|
2279 |
self objectToBack:anObject |
|
2280 |
] |
|
2281 |
! |
|
2282 |
||
2283 |
toFront:something |
|
2284 |
"bring the argument, anObject or a collection of objects to front" |
|
2285 |
||
2286 |
self forEach:something do:[:anObject | |
|
2287 |
self objectToFront:anObject |
|
2288 |
] |
|
2289 |
! ! |
|
2290 |
||
2291 |
!ObjectView methodsFor:'misc'! |
|
2292 |
||
2293 |
documentFormat:aFormatString |
|
2294 |
"set the document format (mostly used by scrollbars). |
|
2295 |
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
|
2296 |
or 'letter'. |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2297 |
See the UnitConverter class for supported formats." |
216 | 2298 |
|
2299 |
aFormatString ~= documentFormat ifTrue:[ |
|
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
2300 |
documentFormat := aFormatString. |
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
2301 |
self contentsChanged. |
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
2302 |
self defineGrid. |
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
2303 |
gridShown ifTrue:[ |
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
2304 |
self invalidate "/ clear; redraw |
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
2305 |
] |
216 | 2306 |
] |
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
2307 |
|
736
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2308 |
"Modified: 31.5.1996 / 19:44:08 / cg" |
216 | 2309 |
! |
2310 |
||
2311 |
forEach:aCollection do:aBlock |
|
2312 |
"apply block to every object in a collectioni; |
|
2313 |
(adds a check for non-collection)" |
|
2314 |
||
2315 |
aCollection isNil ifTrue:[^self]. |
|
2316 |
aCollection isCollection ifTrue:[ |
|
2317 |
aCollection do:[:object | |
|
2318 |
object notNil ifTrue:[ |
|
2319 |
aBlock value:object |
|
2320 |
] |
|
2321 |
] |
|
2322 |
] ifFalse: [ |
|
2323 |
aBlock value:aCollection |
|
2324 |
] |
|
59 | 2325 |
! |
2326 |
||
216 | 2327 |
hitDelta |
2328 |
"when clicking an object, allow for hitDelta pixels around object. |
|
2329 |
We compensate for any scaling here, to get a constant physical |
|
2330 |
hitDelta (i.e. the value returned here is inverse scaled)." |
|
2331 |
||
2332 |
|delta| |
|
2333 |
||
2334 |
delta := self class hitDelta. |
|
2335 |
transformation notNil ifTrue:[ |
|
2336 |
delta := delta / transformation scale x |
|
2337 |
]. |
|
2338 |
^ delta |
|
2339 |
! |
|
2340 |
||
2341 |
numberOfObjectsIntersecting:aRectangle |
|
2342 |
"answer the number of objects intersecting the argument, aRectangle" |
|
2343 |
||
2344 |
|tally| |
|
2345 |
||
2346 |
tally := 0. |
|
2347 |
contents do:[:theObject | |
|
2348 |
(theObject frame intersects:aRectangle) ifTrue:[ |
|
2349 |
tally := tally + 1 |
|
2350 |
] |
|
2351 |
]. |
|
2352 |
^ tally |
|
2353 |
! |
|
2354 |
||
2355 |
numberOfObjectsIntersectingVisible:aRectangle |
|
2356 |
"answer the number of objects intersecting the argument, aRectangle. |
|
2357 |
This is a leftOver from times when scrolling was not transparent. |
|
2358 |
Please use numberOfObjectsIntersecting:, since this will vanish." |
|
2359 |
||
2360 |
^ self numberOfObjectsIntersecting:aRectangle |
|
2361 |
! |
|
2362 |
||
3889
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
2363 |
object:anObject isContainedIn:aRectangle |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
2364 |
"true, if anObject is completely inside aRectangle (for rectangle drag)" |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
2365 |
|
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
2366 |
^ anObject isContainedIn:aRectangle |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
2367 |
! |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
2368 |
|
216 | 2369 |
objectsAbove:objectToBeTested do:aBlock |
2370 |
"do something to every object above objectToBeTested |
|
2371 |
(does not mean obscured - simply above in hierarchy)" |
|
2372 |
||
2373 |
|startIndex| |
|
2374 |
||
2375 |
startIndex := contents identityIndexOf:objectToBeTested |
|
2289 | 2376 |
ifAbsent:[self error:'nonexisting object']. |
216 | 2377 |
contents from:startIndex to:(contents size) do:aBlock |
2378 |
! |
|
2379 |
||
2380 |
objectsAbove:anObject intersecting:aRectangle do:aBlock |
|
2381 |
"do something to every object above objectToBeTested |
|
2382 |
and intersecting aRectangle" |
|
2383 |
||
2384 |
self objectsAbove:anObject do:[:theObject | |
|
2385 |
(theObject frame intersects:aRectangle) ifTrue:[ |
|
2386 |
aBlock value:theObject |
|
2387 |
] |
|
2388 |
] |
|
2389 |
! |
|
2390 |
||
2391 |
objectsBelow:objectToBeTested do:aBlock |
|
2392 |
"do something to every object below objectToBeTested |
|
2393 |
(does not mean obscured by - simply below in hierarchy)" |
|
2394 |
||
2395 |
|endIndex| |
|
2396 |
||
2289 | 2397 |
endIndex := contents identityIndexOf:objectToBeTested ifAbsent:[self error:'nonexisting object']. |
216 | 2398 |
contents from:1 to:(endIndex - 1) do:aBlock |
2399 |
! |
|
2400 |
||
2401 |
objectsIn:aRectangle do:aBlock |
|
2402 |
"do something to every object which is completely in a rectangle" |
|
2403 |
||
2404 |
|bot| |
|
2405 |
||
2406 |
sorted ifTrue:[ |
|
3889
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
2407 |
bot := aRectangle bottom. |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
2408 |
self contentsDo:[:theObject | |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
2409 |
(self object:theObject isContainedIn:aRectangle) ifTrue:[ |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
2410 |
aBlock value:theObject |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
2411 |
] ifFalse:[ |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
2412 |
theObject frame top > bot ifTrue:[^ self] |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
2413 |
] |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
2414 |
]. |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
2415 |
^ self |
216 | 2416 |
]. |
2417 |
||
3889
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
2418 |
self contentsDo:[:theObject | |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
2419 |
(self object:theObject isContainedIn:aRectangle) ifTrue:[ |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
2420 |
aBlock value:theObject |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
2421 |
] |
216 | 2422 |
] |
2423 |
! |
|
2424 |
||
2425 |
objectsInVisible:aRectangle do:aBlock |
|
2426 |
"do something to every object which is completely in a |
|
2427 |
visible rectangle. |
|
2428 |
This is a leftOver from times when scrolling was not transparent. |
|
2429 |
Please use objectsIn:do:, since this will vanish." |
|
2430 |
||
2431 |
self objectsIn:aRectangle do:aBlock |
|
2432 |
! |
|
2433 |
||
2434 |
objectsIntersecting:aRectangle |
|
2435 |
"answer a Collection of objects intersecting the argument, aRectangle" |
|
2436 |
||
2437 |
|newCollection| |
|
2438 |
||
2439 |
newCollection := OrderedCollection new. |
|
2440 |
self objectsIntersecting:aRectangle do:[:theObject | |
|
2441 |
newCollection add:theObject |
|
2442 |
]. |
|
2443 |
(newCollection size == 0) ifTrue:[^ nil]. |
|
2444 |
^ newCollection |
|
2445 |
! |
|
2446 |
||
2447 |
objectsIntersecting:aRectangle do:aBlock |
|
2448 |
"do something to every object which intersects a rectangle" |
|
2449 |
||
2450 |
|f top bot |
|
2451 |
firstIndex "{ Class: SmallInteger }" |
|
2452 |
delta "{ Class: SmallInteger }" |
|
2453 |
theObject |
|
2454 |
nObjects "{ Class: SmallInteger }"| |
|
2455 |
||
2456 |
nObjects := contents size. |
|
2457 |
(nObjects == 0) ifTrue:[^ self]. |
|
2458 |
||
2459 |
sorted ifFalse:[ |
|
77 | 2460 |
" |
216 | 2461 |
have to check every object |
2462 |
" |
|
2463 |
contents do:[:theObject | |
|
2464 |
(theObject frame intersects:aRectangle) ifTrue:[ |
|
2465 |
aBlock value:theObject |
|
2466 |
] |
|
60 | 2467 |
]. |
216 | 2468 |
^ self |
2469 |
]. |
|
2470 |
||
2471 |
" |
|
2472 |
contents is sorted by y; can do a fast (binary) search for the first |
|
2473 |
object which intersects aRectangle and |
|
2474 |
break from the draw loop, when the 1st object below aRectangle is reached. |
|
2475 |
" |
|
2476 |
bot := aRectangle bottom. |
|
2477 |
top := aRectangle top. |
|
2478 |
||
2479 |
" |
|
2480 |
binary search for an object in aRectangle ... |
|
2481 |
" |
|
2482 |
delta := nObjects // 2. |
|
2483 |
firstIndex := delta. |
|
2484 |
(firstIndex == 0) ifTrue:[ |
|
2485 |
firstIndex := 1 |
|
2486 |
]. |
|
2487 |
theObject := contents at:firstIndex. |
|
2488 |
(theObject frame bottom < top) ifTrue:[ |
|
2489 |
[theObject frame bottom < top and:[delta > 1]] whileTrue:[ |
|
2490 |
delta := delta // 2. |
|
2491 |
firstIndex := firstIndex + delta. |
|
2492 |
theObject := contents at:firstIndex |
|
2493 |
] |
|
60 | 2494 |
] ifFalse:[ |
216 | 2495 |
[theObject frame top > bot and:[delta > 1]] whileTrue:[ |
2496 |
delta := delta // 2. |
|
2497 |
firstIndex := firstIndex - delta. |
|
2498 |
theObject := contents at:firstIndex |
|
2499 |
] |
|
2500 |
]. |
|
2501 |
||
2502 |
" |
|
2503 |
now, theObject at:firstIndex is in aRectangle; go backward to the object |
|
2504 |
following first non-visible |
|
2505 |
" |
|
2506 |
[theObject frame bottom > top and:[firstIndex > 1]] whileTrue:[ |
|
2507 |
firstIndex := firstIndex - 1. |
|
2508 |
theObject := contents at:firstIndex |
|
60 | 2509 |
]. |
87 | 2510 |
|
216 | 2511 |
firstIndex to:nObjects do:[:index | |
2512 |
theObject := contents at:index. |
|
2513 |
f := theObject frame. |
|
2514 |
(f intersects:aRectangle) ifTrue:[ |
|
2515 |
aBlock value:theObject |
|
60 | 2516 |
] ifFalse:[ |
216 | 2517 |
(f top > bot) ifTrue:[^ self] |
2518 |
] |
|
2519 |
] |
|
2520 |
! |
|
2521 |
||
2522 |
objectsIntersectingVisible:aRectangle |
|
2523 |
"answer a Collection of objects intersecting a visible aRectangle. |
|
2524 |
This is a leftOver from times when scrolling was not transparent. |
|
2525 |
Please use objectsIntersecting:, since this will vanish." |
|
2526 |
||
2527 |
^ self objectsIntersecting:aRectangle |
|
2528 |
! |
|
2529 |
||
2530 |
objectsIntersectingVisible:aRectangle do:aBlock |
|
2531 |
"do something to every object which intersects a visible rectangle. |
|
2532 |
This is a leftOver from times when scrolling was not transparent. |
|
2533 |
Please use objectsIntersecting:do:, since this will vanish." |
|
2534 |
||
2535 |
self objectsIntersecting:aRectangle do:aBlock |
|
2536 |
! |
|
2537 |
||
2538 |
rectangleForScroll |
|
2539 |
"find the area occupied by visible objects" |
|
2540 |
||
2541 |
|left right top bottom frame oLeft oRight oTop oBottom| |
|
2542 |
||
2543 |
left := 9999. |
|
2544 |
right := 0. |
|
2545 |
top := 9999. |
|
2546 |
bottom := 0. |
|
2547 |
self visibleObjectsDo:[:anObject | |
|
2548 |
frame := anObject frame. |
|
2549 |
oLeft := frame left. |
|
2550 |
oRight := frame right. |
|
2551 |
oTop := frame top. |
|
2552 |
oBottom := frame bottom. |
|
2553 |
(oLeft < left) ifTrue:[left := oLeft]. |
|
2554 |
(oRight > right) ifTrue:[right := oRight]. |
|
2555 |
(oTop < top) ifTrue:[top := oTop]. |
|
2556 |
(oBottom > bottom) ifTrue:[bottom := oBottom] |
|
60 | 2557 |
]. |
216 | 2558 |
(left < margin) ifTrue:[left := margin]. |
2559 |
(top < margin) ifTrue:[top := margin]. |
|
2560 |
(right > (width - margin)) ifTrue:[right := width - margin]. |
|
2561 |
(bottom > (height - margin)) ifTrue:[bottom := height - margin]. |
|
2562 |
||
2563 |
((left > right) or:[top > bottom]) ifTrue:[^ nil]. |
|
2564 |
||
2565 |
^ Rectangle left:left right:right top:top bottom:bottom |
|
2566 |
! |
|
2567 |
||
2568 |
visibleObjectsDo:aBlock |
|
2569 |
"do something to every visible object" |
|
2570 |
||
2571 |
|absRect| |
|
2572 |
||
2573 |
absRect := Rectangle left:0 top:0 width:width height:height. |
|
2574 |
self objectsIntersecting:absRect do:aBlock |
|
2575 |
! ! |
|
2576 |
||
2577 |
!ObjectView methodsFor:'queries'! |
|
2578 |
||
2045 | 2579 |
hasSolidBackground |
2580 |
"return true, if I have a solid color background, which can be pixel-copied |
|
2581 |
for optimized redraw in moveObject." |
|
2582 |
||
2583 |
^ gridShown not |
|
2584 |
! |
|
2585 |
||
216 | 2586 |
heightOfContents |
2587 |
"answer the height of the document in pixels" |
|
2588 |
||
2589 |
|h| |
|
2590 |
||
2591 |
h := self heightOfContentsInMM * (self verticalPixelPerMillimeter:1). |
|
2592 |
^ h rounded |
|
0 | 2593 |
! |
2594 |
||
216 | 2595 |
heightOfContentsInMM |
2596 |
"answer the height of the document in millimeters" |
|
2597 |
||
736
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2598 |
|unit value| |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2599 |
|
216 | 2600 |
"landscape" |
736
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2601 |
unit := (documentFormat , 'H') asSymbolIfInterned. |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2602 |
unit isNil ifTrue:[ |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2603 |
"/ certainly unknown |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2604 |
] ifFalse:[ |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2605 |
value := UnitConverter convert:1 from:unit to:#millimeter |
216 | 2606 |
]. |
736
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2607 |
value isNil ifTrue:[ |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2608 |
"/ assuming window size is document size |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2609 |
value := (height / self verticalPixelPerMillimeter:1) asInteger |
216 | 2610 |
]. |
736
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2611 |
^ value |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2612 |
|
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2613 |
"Modified: 31.5.1996 / 19:38:51 / cg" |
216 | 2614 |
! |
2615 |
||
2616 |
widthOfContents |
|
2617 |
"answer the width of the document in pixels" |
|
2618 |
||
2619 |
|w| |
|
2620 |
||
2621 |
w := self widthOfContentsInMM * (self horizontalPixelPerMillimeter:1). |
|
2622 |
^ w rounded |
|
2623 |
! |
|
2624 |
||
2625 |
widthOfContentsInMM |
|
2626 |
"answer the width of the document in millimeters" |
|
2627 |
||
736
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2628 |
|unit value| |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2629 |
|
216 | 2630 |
"landscape" |
736
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2631 |
unit := (documentFormat , 'W') asSymbolIfInterned. |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2632 |
unit isNil ifTrue:[ |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2633 |
"/ certainly unknown |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2634 |
] ifFalse:[ |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2635 |
value := UnitConverter convert:1 from:unit to:#millimeter |
216 | 2636 |
]. |
736
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2637 |
value isNil ifTrue:[ |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2638 |
"/ assuming window size is document size |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2639 |
value := (width / self horizontalPixelPerMillimeter:1) asInteger |
216 | 2640 |
]. |
736
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2641 |
^ value |
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2642 |
|
53d23f1eb6af
use UnitConverter for page sizes
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
2643 |
"Modified: 31.5.1996 / 19:38:22 / cg" |
0 | 2644 |
! ! |
2645 |
||
2747 | 2646 |
!ObjectView methodsFor:'saving & restoring'! |
0 | 2647 |
|
2648 |
fileInContentsFrom:aStream |
|
59 | 2649 |
"remove all objects, load new contents from aStream and redraw" |
2650 |
||
77 | 2651 |
self fileInContentsFrom:aStream redraw:true new:true binary:false |
63 | 2652 |
! |
2653 |
||
2654 |
fileInContentsFrom:aStream redraw:redraw |
|
2655 |
"remove all objects, load new contents from aStream |
|
2656 |
and redraw if the redraw argument is true" |
|
2657 |
||
77 | 2658 |
self fileInContentsFrom:aStream redraw:redraw new:true binary:false |
2659 |
! |
|
2660 |
||
2661 |
fileInContentsFrom:aStream redraw:redraw new:new |
|
2662 |
"remove all objects, load new contents from aStream |
|
2663 |
and redraw if the redraw argument is true" |
|
2664 |
||
2665 |
self fileInContentsFrom:aStream redraw:redraw new:new binary:false |
|
2666 |
! |
|
2667 |
||
3354 | 2668 |
fileInContentsFrom:aStream redraw:redraw new:new binary:binary |
2669 |
"if the new argument is true, remove all objects. |
|
2670 |
Then load objects from aStream. If redraw is false, no redraw |
|
2671 |
is done |
|
2672 |
(allows fileIn of multiple files doing a single redraw at the end)." |
|
2673 |
||
2674 |
binary ifTrue:[ |
|
2675 |
aStream binary |
|
2676 |
]. |
|
2677 |
self topView withReadCursorDo:[ |
|
2678 |
|newObject chunk individualRedraw| |
|
2679 |
||
2680 |
self unselect. |
|
2681 |
individualRedraw := redraw. |
|
2682 |
new ifTrue:[ |
|
2683 |
self removeAll. |
|
2684 |
individualRedraw := false. |
|
2685 |
]. |
|
2686 |
[aStream atEnd] whileFalse:[ |
|
2687 |
binary ifTrue:[ |
|
2688 |
newObject := Object readBinaryFrom:aStream |
|
2689 |
] ifFalse:[ |
|
2690 |
chunk := aStream nextChunk. |
|
2691 |
(chunk size > 0) ifTrue:[ |
|
2692 |
newObject := Compiler evaluate:chunk compile:false. |
|
2693 |
] ifFalse:[ |
|
2694 |
newObject := nil |
|
2695 |
] |
|
2696 |
]. |
|
2697 |
newObject notNil ifTrue:[ |
|
2698 |
self initializeFileInObject:newObject. |
|
2699 |
individualRedraw ifFalse:[ |
|
2700 |
self addObjectWithoutRedraw:newObject |
|
2701 |
] ifTrue:[ |
|
2702 |
self addObject:newObject |
|
2703 |
] |
|
2704 |
] |
|
2705 |
]. |
|
2706 |
(new and:[redraw]) ifTrue:[ |
|
2707 |
self invalidate |
|
2708 |
] |
|
2709 |
] |
|
2710 |
||
2711 |
"Modified: / 30.1.1998 / 01:02:16 / cg" |
|
2712 |
! |
|
2713 |
||
216 | 2714 |
initializeFileInObject:anObject |
2715 |
"each object may be processed here after its being filed-in |
|
2716 |
- subclasses may do whatever they want here ... |
|
2717 |
(see LogicView for example)" |
|
2718 |
||
2719 |
^ self |
|
2720 |
! |
|
2721 |
||
2722 |
storeBinaryContentsOn:aStream |
|
2723 |
"store the contents in binary representation on aStream." |
|
2724 |
||
2725 |
aStream binary. |
|
4439 | 2726 |
self topView withWriteCursorDo:[ |
2727 |
self forEach:contents do:[:theObject | |
|
2728 |
theObject storeBinaryOn:aStream. |
|
2729 |
]. |
|
216 | 2730 |
] |
4439 | 2731 |
|
2732 |
"Modified: / 27-07-2012 / 09:45:31 / cg" |
|
216 | 2733 |
! |
2734 |
||
2735 |
storeContentsOn:aStream |
|
2736 |
"store the contents in textual representation on aStream. |
|
2737 |
Notice, that for huge objects (such as DrawImages) this ascii output |
|
2738 |
can become quite large, and the time to save and reload can become |
|
2739 |
long." |
|
2740 |
||
2741 |
|excla| |
|
2742 |
||
4439 | 2743 |
self topView withWriteCursorDo:[ |
2744 |
excla := aStream class chunkSeparator. |
|
2745 |
self forEach:contents do:[:theObject | |
|
2746 |
theObject storeOn:aStream. |
|
2747 |
aStream nextPut:excla. |
|
2748 |
aStream cr |
|
2749 |
]. |
|
2750 |
aStream nextPut:excla |
|
216 | 2751 |
] |
4439 | 2752 |
|
2753 |
"Modified: / 27-07-2012 / 09:45:23 / cg" |
|
216 | 2754 |
! |
2755 |
||
2756 |
withoutRedrawFileInContentsFrom:aStream |
|
2757 |
"remove all objects, load new contents from aStream without any redraw" |
|
2758 |
||
2759 |
self fileInContentsFrom:aStream redraw:false new:true binary:false |
|
0 | 2760 |
! ! |
216 | 2761 |
|
2762 |
!ObjectView methodsFor:'scrolling'! |
|
2763 |
||
2764 |
horizontalScrollStep |
|
2765 |
"return the amount to scroll when stepping left/right. |
|
2766 |
Redefined to scroll by inches or centimeters." |
|
2767 |
||
2768 |
scaleMetric == #inch ifTrue:[ |
|
2769 |
^ (device horizontalPixelPerInch * (1/2)) asInteger |
|
2770 |
]. |
|
2771 |
^ (device horizontalPixelPerMillimeter * 20) asInteger |
|
2772 |
! |
|
2773 |
||
2774 |
verticalScrollStep |
|
2775 |
"return the amount to scroll when stepping left/right. |
|
2776 |
Redefined to scroll by inches or centimeters." |
|
2777 |
||
2778 |
scaleMetric == #inch ifTrue:[ |
|
2779 |
^ (device verticalPixelPerInch * (1/2)) asInteger |
|
2780 |
]. |
|
2781 |
^ (device verticalPixelPerMillimeter * 20) asInteger |
|
2782 |
! ! |
|
2783 |
||
1752
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2784 |
!ObjectView methodsFor:'selection & handles'! |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2785 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2786 |
drawHandle:aPoint |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2787 |
|hsize halfSize| |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2788 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2789 |
hsize := self handleSize. |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2790 |
halfSize := hsize // 2. |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2791 |
self fillRectangleX:(aPoint x - halfSize) |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2792 |
y:(aPoint y - halfSize) |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2793 |
width:hsize |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2794 |
height:hsize |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2795 |
! |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2796 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2797 |
drawHandlesFor:anObject |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2798 |
|hsize halfSize| |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2799 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2800 |
hsize := self handleSize. |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2801 |
halfSize := hsize // 2. |
2049
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2802 |
self handlesOf:anObject do:[:handlePoint | |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2803 |
self fillRectangleX:(handlePoint x - halfSize) |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2804 |
y:(handlePoint y - halfSize) |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2805 |
width:hsize |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2806 |
height:hsize |
1752
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2807 |
] |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2808 |
! |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2809 |
|
2782 | 2810 |
findAllObjectsHandleAt:aPoint |
2811 |
||
2812 |
^ contents select:[:object| |
|
2813 |
(self object:object hasHandleAt:aPoint) |
|
2814 |
] |
|
2815 |
! |
|
2816 |
||
2817 |
findAllObjectsHandleAt:aPoint suchThat:aBlock |
|
2818 |
||
2819 |
^ contents select:[:object| |
|
2820 |
(aBlock value:object) |
|
2821 |
and:[(self object:object hasHandleAt:aPoint)] |
|
2822 |
] |
|
2823 |
! |
|
2824 |
||
2825 |
findLastObjectHandleAt:aPoint |
|
2826 |
||
2827 |
^ contents detectLast:[:object| |
|
2828 |
(self object:object hasHandleAt:aPoint) |
|
2829 |
] ifNone:nil |
|
2830 |
! |
|
2831 |
||
2832 |
findLastObjectHandleAt:aPoint suchThat:aBlock |
|
2833 |
||
2834 |
contents reverseDo:[:object | |
|
2835 |
(self object:object hasHandleAt:aPoint) ifTrue:[ |
|
2836 |
(aBlock value:object) ifTrue:[ ^ object ] |
|
2837 |
] |
|
2838 |
]. |
|
2839 |
^ nil |
|
2840 |
! |
|
2841 |
||
1752
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2842 |
findObjectHandleAt:aPoint |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2843 |
|objectFound| |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2844 |
contents do:[:object | |
2782 | 2845 |
(self object:object hasHandleAt:aPoint) ifTrue:[ |
2846 |
objectFound := object |
|
2847 |
] |
|
1752
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 |
^ objectFound |
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 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2852 |
handle:handlePoint isHitBy:aPoint |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2853 |
^ (self handleFor:handlePoint) containsPoint:aPoint |
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 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2856 |
handleFor:aPoint |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2857 |
"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
|
2858 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2859 |
|hsize centerX centerY| |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2860 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2861 |
hsize := self handleSize. |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2862 |
centerX := aPoint x. |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2863 |
centerY := aPoint y. |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2864 |
^ Rectangle left:(centerX - hsize) |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2865 |
top:(centerY - hsize) |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2866 |
right:(centerX + hsize) |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2867 |
bottom:(centerY + hsize) |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2868 |
! |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2869 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2870 |
handleSize |
2289 | 2871 |
"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
|
2872 |
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
|
2873 |
what the default is." |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2874 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2875 |
|hs| |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2876 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2877 |
hs := self class handleSize. |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2878 |
transformation notNil ifTrue:[ |
2289 | 2879 |
^ transformation applyInverseScaleX:hs |
1752
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 |
^ hs |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2882 |
! |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2883 |
|
2049
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2884 |
handlesOf:anObject do:aBlock |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2885 |
anObject handlesDo:aBlock |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2886 |
! |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2887 |
|
1752
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2888 |
invertHandle:aHandle |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2889 |
self xoring:[self drawHandle:aHandle] |
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 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2892 |
invertHandlesOf:aSelection |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2893 |
aSelection notNil ifTrue:[ |
2049
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2894 |
self clippedTo:nil do:[ |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2895 |
self xoring:[ |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2896 |
self forEach:aSelection do:[:anObject | |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2897 |
(anObject respondsTo:#handlesDo:) ifTrue:[ |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2898 |
self drawHandlesFor:anObject |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2899 |
] ifFalse:[ |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2900 |
anObject drawOutlineIn:self |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2901 |
] |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2902 |
] |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2903 |
] |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2904 |
] |
1752
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2905 |
] |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2906 |
! |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2907 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2908 |
object:anObject hasHandleAt:aPoint |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2909 |
|found| |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2910 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2911 |
found := false. |
2049
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2912 |
self handlesOf:anObject do:[:handlePoint | |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2913 |
(self handle:handlePoint isHitBy:aPoint) ifTrue:[ |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2914 |
found := true |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2915 |
] |
1752
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2916 |
]. |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2917 |
^ found |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2918 |
! |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2919 |
|
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2920 |
selectionHandlesDo:aBlock |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2921 |
self forEach:selection do:[:theObject | |
2049
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2922 |
(theObject respondsTo:#handlesDo:) ifTrue:[ |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2923 |
self handlesOf:theObject do:[:handlePoint | |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2924 |
aBlock value:theObject value:handlePoint |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2925 |
] |
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
2926 |
] |
1752
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2927 |
] |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2928 |
! ! |
f1e400f163ad
moved some handle stuff from DrawView to here,
Claus Gittinger <cg@exept.de>
parents:
1746
diff
changeset
|
2929 |
|
216 | 2930 |
!ObjectView methodsFor:'selections'! |
2931 |
||
2932 |
addToSelection:anObject |
|
839
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2933 |
"add anObject to the selection; redraw it selected" |
733 | 2934 |
|
216 | 2935 |
selection isCollection ifFalse:[ |
1002 | 2936 |
selection isNil ifTrue:[ |
3420
d1d2631c48a6
clear releaseAction after a motion
Claus Gittinger <cg@exept.de>
parents:
3419
diff
changeset
|
2937 |
selection := OrderedCollection new |
d1d2631c48a6
clear releaseAction after a motion
Claus Gittinger <cg@exept.de>
parents:
3419
diff
changeset
|
2938 |
] ifFalse:[ |
d1d2631c48a6
clear releaseAction after a motion
Claus Gittinger <cg@exept.de>
parents:
3419
diff
changeset
|
2939 |
selection := OrderedCollection with:selection |
d1d2631c48a6
clear releaseAction after a motion
Claus Gittinger <cg@exept.de>
parents:
3419
diff
changeset
|
2940 |
] |
216 | 2941 |
]. |
839
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2942 |
|
733 | 2943 |
(selection includes:anObject) ifFalse:[ |
839
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2944 |
(self frameIncludesSelectionHandlesOn:anObject) ifFalse:[ |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2945 |
self hideSelection. |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2946 |
selection add:anObject. |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
2947 |
self showSelection. |
839
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2948 |
] ifTrue:[ |
3209 | 2949 |
selection add:anObject. |
839
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2950 |
self showSelected:anObject |
3209 | 2951 |
]. |
2952 |
self changed:#selection with:selection. |
|
733 | 2953 |
]. |
839
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2954 |
|
3420
d1d2631c48a6
clear releaseAction after a motion
Claus Gittinger <cg@exept.de>
parents:
3419
diff
changeset
|
2955 |
"Modified: / 27-10-2006 / 14:16:04 / cg" |
216 | 2956 |
! |
2957 |
||
2958 |
hideSelection |
|
2959 |
"hide the selection - undraw hilights - whatever that is" |
|
2960 |
||
3783 | 2961 |
shown ifFalse:[^ self]. |
2962 |
||
216 | 2963 |
self selectionDo:[:object | |
3783 | 2964 |
self showUnselected:object |
216 | 2965 |
] |
2966 |
! |
|
2967 |
||
2968 |
removeFromSelection:anObject |
|
2969 |
"remove anObject from the selection" |
|
2970 |
||
839
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2971 |
|wasSelected didHide| |
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 := false. |
733 | 2974 |
wasSelected := true. |
839
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2975 |
|
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2976 |
(self frameIncludesSelectionHandlesOn:anObject) ifFalse:[ |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2977 |
"/ must hide any selection-handles first |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2978 |
self hideSelection. |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2979 |
didHide := true. |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2980 |
]. |
733 | 2981 |
|
216 | 2982 |
selection isCollection ifTrue:[ |
733 | 2983 |
(selection remove:anObject ifAbsent:[nil]) isNil ifTrue:[ |
2984 |
wasSelected := false |
|
2985 |
]. |
|
2986 |
(selection size == 1) ifTrue:[ |
|
2987 |
selection := selection first |
|
1002 | 2988 |
] ifFalse:[ |
2989 |
selection isEmpty ifTrue:[ |
|
2990 |
selection := nil |
|
2991 |
] |
|
733 | 2992 |
] |
216 | 2993 |
] ifFalse:[ |
733 | 2994 |
(selection == anObject) ifTrue:[ |
2995 |
selection := nil |
|
2996 |
] ifFalse:[ |
|
2997 |
wasSelected := false |
|
2998 |
] |
|
216 | 2999 |
]. |
839
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
3000 |
|
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
3001 |
didHide ifTrue:[ |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
3002 |
self showSelection. |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
3003 |
] ifFalse:[ |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
3004 |
wasSelected ifTrue:[ |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
3005 |
self showUnselected:anObject |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
3006 |
]. |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3007 |
]. |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3008 |
|
3209 | 3009 |
self changed:#selection with:selection. |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3010 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3011 |
"Modified: / 4.7.1999 / 15:22:28 / cg" |
216 | 3012 |
! |
3013 |
||
3014 |
select:something |
|
3952 | 3015 |
"select something - hide previous selection, set to something and hilight" |
216 | 3016 |
|
3775 | 3017 |
|newSelection| |
3018 |
||
3019 |
newSelection := |
|
3020 |
(something isCollection and:[something size == 0]) |
|
3021 |
ifTrue:[ nil ] |
|
3022 |
ifFalse:[ something ]. |
|
3023 |
||
3024 |
(selection = newSelection) ifFalse:[ |
|
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3025 |
self hideSelection. |
3775 | 3026 |
selection := newSelection. |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3027 |
self showSelection. |
2051
56ebae1cfdbe
pass the selection as argument with the selectionChange notification
Claus Gittinger <cg@exept.de>
parents:
2049
diff
changeset
|
3028 |
self changed:#selection with:selection. |
216 | 3029 |
] |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3030 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3031 |
"Modified: / 4.7.1999 / 15:22:39 / cg" |
216 | 3032 |
! |
3033 |
||
3034 |
selectAll |
|
3035 |
"select all objects" |
|
3036 |
||
3162 | 3037 |
self select:contents copy. |
216 | 3038 |
! |
3039 |
||
3040 |
selectAllIn:aRectangle |
|
3162 | 3041 |
"select all objects which are fully contained in aRectangle" |
3042 |
||
3043 |
|newSelection| |
|
3044 |
||
3045 |
newSelection := OrderedCollection new. |
|
3889
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
3046 |
self |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
3047 |
objectsIn:aRectangle |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
3048 |
do:[:theObject | |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
3049 |
newSelection add:theObject |
da959fe6f990
refactored selectAll to allow for rectangle-drag in UIObjectView
Claus Gittinger <cg@exept.de>
parents:
3878
diff
changeset
|
3050 |
]. |
3162 | 3051 |
self select:newSelection. |
216 | 3052 |
! |
3053 |
||
3054 |
selectAllIntersecting:aRectangle |
|
3162 | 3055 |
"select all objects which are touched by aRectangle" |
3056 |
||
3057 |
|newSelection| |
|
3058 |
||
3059 |
newSelection := OrderedCollection new. |
|
216 | 3060 |
self objectsIntersecting:aRectangle do:[:theObject | |
3162 | 3061 |
newSelection add:theObject |
216 | 3062 |
]. |
3162 | 3063 |
self select:newSelection. |
216 | 3064 |
! |
3065 |
||
1940 | 3066 |
selection |
3067 |
"return the selection as a collection or nil" |
|
3068 |
||
3069 |
selection isNil ifTrue:[^ nil]. |
|
3070 |
selection isCollection ifTrue:[^ selection]. |
|
3071 |
^ Array with:selection |
|
3072 |
||
3073 |
"Created: / 4.7.1999 / 14:33:16 / cg" |
|
3074 |
"Modified: / 4.7.1999 / 14:34:20 / cg" |
|
3075 |
! |
|
3076 |
||
216 | 3077 |
selectionDo:aBlock |
3078 |
"apply block to every object in selection" |
|
3079 |
||
3080 |
self forEach:selection do:aBlock |
|
3081 |
! |
|
3082 |
||
3083 |
showSelection |
|
3084 |
"show the selection - draw hilights - whatever that is" |
|
3085 |
||
3783 | 3086 |
shown ifFalse:[^ self]. |
3087 |
||
216 | 3088 |
self selectionDo:[:object | |
3162 | 3089 |
self showSelected:object |
216 | 3090 |
] |
3091 |
! |
|
3092 |
||
3093 |
unselect |
|
3094 |
"unselect - hide selection; clear selection" |
|
3095 |
||
2049
e59deb5f1de8
allow for handle-enumeration to be redefined.
Claus Gittinger <cg@exept.de>
parents:
2047
diff
changeset
|
3096 |
selection notNil ifTrue:[ |
3162 | 3097 |
self select:nil. |
1941
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3098 |
] |
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3099 |
|
928af17c7344
send self changed:#addObject after adding,
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3100 |
"Modified: / 4.7.1999 / 15:30:36 / cg" |
216 | 3101 |
! |
3102 |
||
3103 |
withSelectionHiddenDo:aBlock |
|
3104 |
"evaluate aBlock while selection is hidden" |
|
3105 |
||
3106 |
|sel| |
|
3107 |
||
3108 |
sel := selection. |
|
3109 |
sel notNil ifTrue:[self unselect]. |
|
3110 |
aBlock value. |
|
3111 |
sel notNil ifTrue:[self select:sel] |
|
3112 |
! ! |
|
3113 |
||
3114 |
!ObjectView methodsFor:'testing objects'! |
|
3115 |
||
3421 | 3116 |
allObjectsHitAt:aPoint do:aBlock |
3117 |
"for all objects (by enumerating from back to front) which are hit by |
|
3118 |
the argument, aPoint, evaluate aBlock" |
|
3119 |
||
3530 | 3120 |
self allObjectsHitAt:aPoint withDelta:(self hitDelta / self scale x) do:aBlock |
3121 |
! |
|
3122 |
||
3123 |
allObjectsHitAt:aPoint withDelta:hDelta do:aBlock |
|
3124 |
"for all objects (by enumerating from back to front) which are hit by |
|
3125 |
the argument, aPoint, evaluate aBlock" |
|
3421 | 3126 |
|
3127 |
contents notEmptyOrNil ifTrue:[ |
|
3128 |
contents reverseDo:[:object | |
|
3530 | 3129 |
(object isHitBy:aPoint withDelta:hDelta) ifTrue:[ |
3421 | 3130 |
aBlock value:object |
3131 |
] |
|
3132 |
] |
|
3133 |
]. |
|
3134 |
^ nil |
|
3135 |
||
3136 |
"Created: / 27-10-2006 / 16:58:34 / cg" |
|
3137 |
! |
|
3138 |
||
216 | 3139 |
canMove:something |
3140 |
"return true, if the argument, anObject or a collection can be moved" |
|
3141 |
||
3142 |
something isCollection ifTrue:[ |
|
1947
5b20f4b196da
oops - care for unimplemented #canBeMoved and #canBeSelected
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
3143 |
self forEach:something do:[:theObject | |
5b20f4b196da
oops - care for unimplemented #canBeMoved and #canBeSelected
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
3144 |
(theObject perform:#canBeMoved ifNotUnderstood:true) ifFalse:[^ false] |
5b20f4b196da
oops - care for unimplemented #canBeMoved and #canBeSelected
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
3145 |
]. |
5b20f4b196da
oops - care for unimplemented #canBeMoved and #canBeSelected
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
3146 |
^ true |
216 | 3147 |
]. |
1947
5b20f4b196da
oops - care for unimplemented #canBeMoved and #canBeSelected
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
3148 |
^ something perform:#canBeMoved ifNotUnderstood:true |
216 | 3149 |
! |
3150 |
||
1942 | 3151 |
canSelect:something |
3152 |
"return true, if the argument, anObject or a collection can be selected" |
|
3153 |
||
3154 |
something isCollection ifTrue:[ |
|
3155 |
self forEach:something do:[:theObject | |
|
2635 | 3156 |
theObject isView ifFalse:[ |
3157 |
(theObject perform:#canBeSelected ifNotUnderstood:true) ifFalse:[^ false] |
|
3158 |
] |
|
1942 | 3159 |
]. |
3160 |
^ true |
|
3161 |
]. |
|
2635 | 3162 |
something isView ifTrue:[^ true]. |
1947
5b20f4b196da
oops - care for unimplemented #canBeMoved and #canBeSelected
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
3163 |
^ something perform:#canBeSelected ifNotUnderstood:true |
1942 | 3164 |
|
3165 |
"Created: / 4.7.1999 / 18:51:29 / cg" |
|
3166 |
! |
|
3167 |
||
3530 | 3168 |
findNearestObjectAt:aPoint |
3169 |
"find the nearest object (by looking from back to front) which is hit by |
|
3170 |
the argument, aPoint - this is the topmost object hit" |
|
3171 |
||
3172 |
0 to:(self hitDelta) by:(1 / 2) do:[:hdelta | |
|
3173 |
self allObjectsHitAt:aPoint withDelta:(hdelta " / self scale x") do:[:object | ^ object]. |
|
3174 |
]. |
|
3175 |
^ nil |
|
3176 |
||
3177 |
"Modified: / 27-10-2006 / 16:58:54 / cg" |
|
3178 |
! |
|
3179 |
||
216 | 3180 |
findObjectAt:aPoint |
3181 |
"find the last object (by looking from back to front) which is hit by |
|
3182 |
the argument, aPoint - this is the topmost object hit" |
|
3183 |
||
3421 | 3184 |
self allObjectsHitAt:aPoint do:[:object | ^ object]. |
216 | 3185 |
^ nil |
3421 | 3186 |
|
3187 |
"Modified: / 27-10-2006 / 16:58:54 / cg" |
|
216 | 3188 |
! |
3189 |
||
3300 | 3190 |
findObjectAt:aPoint forWhich:aBlock |
3191 |
"find the last object (by looking from back to front) which is hit by |
|
3192 |
the argument, aPoint - this is the topmost object hit" |
|
3193 |
||
3421 | 3194 |
self allObjectsHitAt:aPoint do:[:object | (aBlock value:object) ifTrue:[^ object]]. |
3300 | 3195 |
^ nil |
3421 | 3196 |
|
3197 |
"Modified: / 27-10-2006 / 16:59:26 / cg" |
|
3300 | 3198 |
! |
3199 |
||
216 | 3200 |
findObjectAt:aPoint suchThat:aBlock |
3845 | 3201 |
<resource: #obsolete> |
216 | 3202 |
"find the last object (back to front ) which is hit by |
3421 | 3203 |
the argument, aPoint and for which the testBlock, aBlock evaluates to true. |
3204 |
This is a leftOver from times when scrolling was not transparent. |
|
3205 |
Please use findObjectAt:forWhich:, since this will vanish." |
|
3206 |
||
3207 |
self obsoleteMethodWarning:'use findObjectAt:forWhich:'. |
|
3208 |
^ self findObjectAt:aPoint forWhich:aBlock |
|
3209 |
||
3210 |
"Modified: / 27-10-2006 / 17:01:42 / cg" |
|
216 | 3211 |
! |
3212 |
||
3213 |
findObjectAtVisible:aPoint |
|
3845 | 3214 |
<resource: #obsolete> |
216 | 3215 |
"find the last object (by looking from back to front) which is hit by |
3216 |
a visible point - this is the topmost object hit. |
|
3217 |
This is a leftOver from times when scrolling was not transparent. |
|
3218 |
Please use findObjectAt:, since this will vanish." |
|
3219 |
||
3421 | 3220 |
self obsoleteMethodWarning:'use findObjectAt:'. |
216 | 3221 |
^ self findObjectAt:aPoint |
3421 | 3222 |
|
3223 |
"Modified: / 27-10-2006 / 17:02:08 / cg" |
|
216 | 3224 |
! |
3225 |
||
3226 |
findObjectAtVisible:aPoint suchThat:aBlock |
|
3845 | 3227 |
<resource: #obsolete> |
216 | 3228 |
"find the last object (back to front ) which is hit by |
3229 |
the argument, aPoint and for which the testBlock, aBlock evaluates to |
|
3230 |
true. |
|
3231 |
This is a leftOver from times when scrolling was not transparent. |
|
3421 | 3232 |
Please use findObjectAt:forWhich:, since this will vanish." |
3233 |
||
3234 |
self obsoleteMethodWarning:'use findObjectAt:forWhich:'. |
|
216 | 3235 |
^ self findObjectAt:aPoint suchThat:aBlock |
3421 | 3236 |
|
3237 |
"Modified: / 27-10-2006 / 17:01:47 / cg" |
|
216 | 3238 |
! |
3239 |
||
3530 | 3240 |
findObjectForSelectAt:aPoint |
3241 |
"find the object for a select" |
|
3242 |
||
3243 |
^ self findObjectAt:aPoint |
|
3244 |
! |
|
3245 |
||
839
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
3246 |
frameIncludesSelectionHandlesOn:anObject |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
3247 |
"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
|
3248 |
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
|
3249 |
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
|
3250 |
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
|
3251 |
|
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
3252 |
^ false "/ i.e. dont know. |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
3253 |
|
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
3254 |
"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
|
3255 |
! |
53a5344288e6
redrawing when removing/adding from/to the selection
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
3256 |
|
216 | 3257 |
frameOf:anObjectOrCollection |
3258 |
"answer the maximum extent defined by the argument, anObject or a |
|
3259 |
collection of objects" |
|
3260 |
||
3261 |
|first frameAll| |
|
3262 |
||
3263 |
anObjectOrCollection isNil ifTrue:[^ nil ]. |
|
3421 | 3264 |
|
216 | 3265 |
first := true. |
3266 |
self forEach:anObjectOrCollection do:[:theObject | |
|
3421 | 3267 |
first ifTrue:[ |
3268 |
frameAll := theObject frame. |
|
3269 |
first := false |
|
3270 |
] ifFalse:[ |
|
3271 |
frameAll := frameAll merge:(theObject frame) |
|
3272 |
] |
|
216 | 3273 |
]. |
3274 |
^ frameAll |
|
3421 | 3275 |
|
3276 |
"Modified: / 27-10-2006 / 17:02:16 / cg" |
|
216 | 3277 |
! |
3278 |
||
3279 |
isObscured:something |
|
3280 |
"return true, if the argument something, anObject or a collection of |
|
3281 |
objects is obscured (partially or whole) by any other object" |
|
3282 |
||
3283 |
self forEach:something do:[:anObject | |
|
3284 |
(self objectIsObscured:anObject) ifTrue:[ |
|
3285 |
^ true |
|
3286 |
] |
|
3287 |
]. |
|
3288 |
^ false |
|
3289 |
! |
|
3290 |
||
3291 |
isSelected:anObject |
|
3292 |
"return true, if the argument, anObject is in the selection" |
|
3293 |
||
3294 |
selection isNil ifTrue:[^ false]. |
|
3295 |
(selection == anObject) ifTrue:[^ true]. |
|
3296 |
selection isCollection ifTrue:[ |
|
3297 |
^ (selection identityIndexOf:anObject startingAt:1) ~~ 0 |
|
3298 |
]. |
|
3299 |
^ false |
|
3300 |
! |
|
3301 |
||
3302 |
objectIsObscured:objectToBeTested |
|
3303 |
"return true, if the argument, anObject is obscured (partially or whole) |
|
3304 |
by any other object" |
|
3305 |
||
3306 |
|frameToBeTested frameleft frameright frametop framebot |
|
3307 |
objectsFrame startIndex| |
|
3308 |
||
3309 |
(objectToBeTested == (contents last)) ifTrue:[ |
|
2289 | 3310 |
"quick return if object is on top" |
3311 |
^ false |
|
216 | 3312 |
]. |
3313 |
||
3314 |
frameToBeTested := self frameOf:objectToBeTested. |
|
3315 |
frameleft := frameToBeTested left. |
|
3316 |
frameright := frameToBeTested right. |
|
3317 |
frametop := frameToBeTested top. |
|
3318 |
framebot := frameToBeTested bottom. |
|
3319 |
||
3320 |
"check objects after the one to check" |
|
3321 |
||
2289 | 3322 |
startIndex := contents identityIndexOf:objectToBeTested ifAbsent:[self error:'nonexisting object']. |
216 | 3323 |
contents from:(startIndex + 1) to:(contents size) do:[:object | |
2289 | 3324 |
objectsFrame := self frameOf:object. |
3325 |
(objectsFrame right < frameleft) ifFalse:[ |
|
3326 |
(objectsFrame left > frameright) ifFalse:[ |
|
3327 |
(objectsFrame bottom < frametop) ifFalse:[ |
|
3328 |
(objectsFrame top > framebot) ifFalse:[ |
|
3329 |
^ true |
|
3330 |
] |
|
3331 |
] |
|
3332 |
] |
|
3333 |
] |
|
216 | 3334 |
]. |
3335 |
^ false |
|
3336 |
! ! |
|
3337 |
||
3338 |
!ObjectView methodsFor:'user interface'! |
|
3339 |
||
3340 |
alignToGrid:aPoint |
|
3341 |
"round aPoint to the next nearest point on the grid" |
|
3342 |
||
3343 |
aligning ifFalse:[ |
|
2782 | 3344 |
^ aPoint |
216 | 3345 |
]. |
3346 |
||
3347 |
^ (aPoint grid:gridAlign) rounded |
|
3348 |
! |
|
3349 |
||
3350 |
selectMore:aPoint |
|
3351 |
"add/remove an object from the selection" |
|
3352 |
||
3353 |
|anObject| |
|
3354 |
||
3355 |
anObject := self findObjectAt:aPoint. |
|
3356 |
anObject notNil ifTrue:[ |
|
1942 | 3357 |
(self isSelected:anObject) ifTrue:[ |
3358 |
"remove from selection" |
|
3359 |
self removeFromSelection:anObject |
|
3360 |
] ifFalse:[ |
|
3361 |
"add to selection" |
|
3362 |
(self canSelect:anObject) ifTrue:[ |
|
3363 |
self addToSelection:anObject |
|
3364 |
] |
|
3365 |
] |
|
216 | 3366 |
]. |
3367 |
^ self |
|
1942 | 3368 |
|
3369 |
"Modified: / 4.7.1999 / 18:52:13 / cg" |
|
216 | 3370 |
! |
3371 |
||
3372 |
startSelectMoreOrMove:aPoint |
|
3373 |
"add/remove object hit by aPoint, then start a rectangleDrag or move |
|
3374 |
- if aPoint hits an object, a move is started, otherwise a rectangleDrag. |
|
3375 |
This is typically the button shiftPressAction." |
|
3376 |
||
3377 |
|anObject| |
|
3378 |
||
3379 |
anObject := self findObjectAt:aPoint. |
|
3380 |
anObject notNil ifTrue:[ |
|
733 | 3381 |
(self isSelected:anObject) ifTrue:[ |
3382 |
"remove from selection" |
|
3383 |
self removeFromSelection:anObject |
|
3384 |
] ifFalse:[ |
|
3385 |
"add to selection" |
|
1942 | 3386 |
(self canSelect:anObject) ifTrue:[ |
3387 |
self addToSelection:anObject |
|
3388 |
] |
|
733 | 3389 |
]. |
3390 |
self startObjectMove:selection at:aPoint. |
|
3391 |
^ self |
|
216 | 3392 |
]. |
733 | 3393 |
"/ self unselect. |
3394 |
"/ self startRectangleDrag:aPoint |
|
3395 |
||
1942 | 3396 |
"Modified: / 4.7.1999 / 18:51:52 / cg" |
216 | 3397 |
! |
3398 |
||
3399 |
startSelectOrMove:aPoint |
|
3400 |
"start a rectangleDrag or objectMove - if aPoint hits an object, |
|
3401 |
an object move is started, otherwise a rectangleDrag. |
|
3402 |
This is typically the button pressAction." |
|
3403 |
||
3404 |
|anObject| |
|
3405 |
||
3530 | 3406 |
anObject := self findObjectForSelectAt:aPoint. |
216 | 3407 |
anObject notNil ifTrue:[ |
3530 | 3408 |
(self isSelected:anObject) ifFalse:[ |
3409 |
self unselect. |
|
3410 |
self startObjectMove:anObject at:aPoint. |
|
3411 |
] ifTrue:[ |
|
3412 |
self startObjectMove:selection at:aPoint. |
|
3413 |
]. |
|
3414 |
^ self |
|
216 | 3415 |
]. |
3416 |
"nothing was hit by this click - this starts a group select" |
|
3417 |
self unselect. |
|
3418 |
self startRectangleDrag:aPoint |
|
3419 |
! ! |
|
3420 |
||
3421 |
!ObjectView methodsFor:'view manipulation'! |
|
3422 |
||
3423 |
inchMetric |
|
3424 |
(scaleMetric ~~ #inch) ifTrue:[ |
|
3425 |
scaleMetric := #inch. |
|
3426 |
self newGrid |
|
3427 |
] |
|
3428 |
! |
|
3429 |
||
3430 |
millimeterMetric |
|
3431 |
(scaleMetric ~~ #mm) ifTrue:[ |
|
3432 |
scaleMetric := #mm. |
|
3433 |
self newGrid |
|
3434 |
] |
|
3435 |
! |
|
3436 |
||
3437 |
zoom:factor |
|
2736 | 3438 |
"set a zoom factor; smaller than 1 is shrink; larger than 1 is magnify. |
3439 |
I.e. 1 is identity; 2 is magnify by 2; 0.5 is shrink by 2" |
|
216 | 3440 |
|
3301
af1a7ca0488c
preserve relative translation, when zoom changes
Claus Gittinger <cg@exept.de>
parents:
3300
diff
changeset
|
3441 |
|currentScale currentTranslation newScale| |
af1a7ca0488c
preserve relative translation, when zoom changes
Claus Gittinger <cg@exept.de>
parents:
3300
diff
changeset
|
3442 |
|
af1a7ca0488c
preserve relative translation, when zoom changes
Claus Gittinger <cg@exept.de>
parents:
3300
diff
changeset
|
3443 |
currentScale := self scale. |
af1a7ca0488c
preserve relative translation, when zoom changes
Claus Gittinger <cg@exept.de>
parents:
3300
diff
changeset
|
3444 |
currentTranslation := self translation. |
af1a7ca0488c
preserve relative translation, when zoom changes
Claus Gittinger <cg@exept.de>
parents:
3300
diff
changeset
|
3445 |
|
af1a7ca0488c
preserve relative translation, when zoom changes
Claus Gittinger <cg@exept.de>
parents:
3300
diff
changeset
|
3446 |
newScale := factor. |
af1a7ca0488c
preserve relative translation, when zoom changes
Claus Gittinger <cg@exept.de>
parents:
3300
diff
changeset
|
3447 |
newScale isNil ifTrue:[ |
af1a7ca0488c
preserve relative translation, when zoom changes
Claus Gittinger <cg@exept.de>
parents:
3300
diff
changeset
|
3448 |
newScale := 1 @ 1 |
216 | 3449 |
]. |
3301
af1a7ca0488c
preserve relative translation, when zoom changes
Claus Gittinger <cg@exept.de>
parents:
3300
diff
changeset
|
3450 |
newScale := newScale asPoint. |
af1a7ca0488c
preserve relative translation, when zoom changes
Claus Gittinger <cg@exept.de>
parents:
3300
diff
changeset
|
3451 |
|
af1a7ca0488c
preserve relative translation, when zoom changes
Claus Gittinger <cg@exept.de>
parents:
3300
diff
changeset
|
3452 |
newScale = currentScale ifTrue:[ |
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
3453 |
^ self |
216 | 3454 |
]. |
3297 | 3455 |
|
3301
af1a7ca0488c
preserve relative translation, when zoom changes
Claus Gittinger <cg@exept.de>
parents:
3300
diff
changeset
|
3456 |
(newScale = 1) ifTrue:[ |
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
3457 |
transformation := nil |
216 | 3458 |
] ifFalse:[ |
3301
af1a7ca0488c
preserve relative translation, when zoom changes
Claus Gittinger <cg@exept.de>
parents:
3300
diff
changeset
|
3459 |
transformation := WindowingTransformation |
af1a7ca0488c
preserve relative translation, when zoom changes
Claus Gittinger <cg@exept.de>
parents:
3300
diff
changeset
|
3460 |
scale:newScale |
af1a7ca0488c
preserve relative translation, when zoom changes
Claus Gittinger <cg@exept.de>
parents:
3300
diff
changeset
|
3461 |
translation:(currentTranslation / currentScale x * newScale x ) rounded. |
216 | 3462 |
]. |
3463 |
self contentsChanged. |
|
3464 |
self setInnerClip. |
|
3465 |
gridShown ifTrue:[ |
|
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
3466 |
self newGrid |
216 | 3467 |
]. |
3297 | 3468 |
self invalidate |
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
3469 |
|
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
3470 |
"Modified: 29.5.1996 / 16:20:41 / cg" |
216 | 3471 |
! |
3472 |
||
3473 |
zoomIn |
|
2736 | 3474 |
"zoom in - multiply the zoom factor by 1.5" |
3475 |
||
2134 | 3476 |
self zoomIn:1.5 |
3477 |
||
3478 |
"Modified: / 10.2.2000 / 21:14:41 / cg" |
|
588 | 3479 |
! |
3480 |
||
3481 |
zoomIn:factor |
|
2736 | 3482 |
"zoom in by multiplying the zoom factor by the argument" |
3483 |
||
216 | 3484 |
transformation isNil ifTrue:[ |
588 | 3485 |
transformation := WindowingTransformation scale:1 translation:0 |
216 | 3486 |
]. |
588 | 3487 |
transformation := WindowingTransformation |
2736 | 3488 |
scale:(transformation scale * factor) |
3489 |
translation:(transformation translation * factor) rounded. |
|
216 | 3490 |
self contentsChanged. |
3491 |
self setInnerClip. |
|
721
4a01084cf643
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
3492 |
self invalidate. |
588 | 3493 |
|
2134 | 3494 |
"Created: / 27.4.1996 / 10:08:39 / cg" |
3495 |
"Modified: / 10.2.2000 / 21:11:11 / cg" |
|
216 | 3496 |
! |
3497 |
||
3498 |
zoomOut |
|
2736 | 3499 |
"zoom in - divide the zoom factor by 1.5" |
3500 |
||
2134 | 3501 |
self zoomOut:1.5 |
3502 |
||
3503 |
"Modified: / 10.2.2000 / 21:14:46 / cg" |
|
588 | 3504 |
! |
3505 |
||
3506 |
zoomOut:factor |
|
2736 | 3507 |
"zoom out by dividing the zoom factor by the argument" |
3508 |
||
3509 |
self zoomIn:(1.0 / factor) |
|
588 | 3510 |
|
2134 | 3511 |
"Created: / 27.4.1996 / 10:09:19 / cg" |
3512 |
"Modified: / 10.2.2000 / 21:10:52 / cg" |
|
216 | 3513 |
! ! |
3514 |
||
961 | 3515 |
!ObjectView class methodsFor:'documentation'! |
216 | 3516 |
|
3517 |
version |
|
4439 | 3518 |
^ '$Header: /cvs/stx/stx/libwidg/ObjectView.st,v 1.135 2012-07-27 09:09:03 cg Exp $' |
3951
1726c8891c34
changed: #setInitialDocumentFormat
Claus Gittinger <cg@exept.de>
parents:
3916
diff
changeset
|
3519 |
! |
1726c8891c34
changed: #setInitialDocumentFormat
Claus Gittinger <cg@exept.de>
parents:
3916
diff
changeset
|
3520 |
|
1726c8891c34
changed: #setInitialDocumentFormat
Claus Gittinger <cg@exept.de>
parents:
3916
diff
changeset
|
3521 |
version_CVS |
4439 | 3522 |
^ '$Header: /cvs/stx/stx/libwidg/ObjectView.st,v 1.135 2012-07-27 09:09:03 cg Exp $' |
216 | 3523 |
! ! |