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