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