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