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