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