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