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