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