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