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