author | tz |
Tue, 21 Jul 1998 19:04:09 +0200 | |
changeset 902 | f510032000ad |
parent 897 | 43f9bdc12ae4 |
child 967 | c3f483120cd7 |
permissions | -rw-r--r-- |
156 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by eXept Software AG |
|
3 |
All Rights Reserved |
|
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 |
||
13 |
||
14 |
||
60 | 15 |
ObjectView subclass:#UIObjectView |
123 | 16 |
instanceVariableNames:'saveSelection inputView enableChannel undoHistory copiedExtent |
175 | 17 |
copiedLayout resizeData clipChildren selectionHiddenLevel |
360 | 18 |
gridParameters setOfSuperViewsSizeChanged' |
60 | 19 |
classVariableNames:'' |
20 |
poolDictionaries:'' |
|
21 |
category:'Interface-UIPainter' |
|
22 |
! |
|
23 |
||
543
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
24 |
Object subclass:#ResizeData |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
25 |
instanceVariableNames:'object selector delta' |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
26 |
classVariableNames:'' |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
27 |
poolDictionaries:'' |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
28 |
privateIn:UIObjectView |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
29 |
! |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
30 |
|
60 | 31 |
Object subclass:#UndoHistory |
134 | 32 |
instanceVariableNames:'startIdentifier identifier painter history transaction enabled' |
60 | 33 |
classVariableNames:'' |
34 |
poolDictionaries:'' |
|
35 |
privateIn:UIObjectView |
|
36 |
! |
|
37 |
||
54 | 38 |
Object subclass:#Transaction |
134 | 39 |
instanceVariableNames:'identifier type text actions' |
54 | 40 |
classVariableNames:'' |
41 |
poolDictionaries:'' |
|
42 |
privateIn:UIObjectView::UndoHistory |
|
43 |
! |
|
44 |
||
128 | 45 |
!UIObjectView class methodsFor:'documentation'! |
46 |
||
156 | 47 |
copyright |
48 |
" |
|
49 |
COPYRIGHT (c) 1995 by eXept Software AG |
|
50 |
All Rights Reserved |
|
51 |
||
52 |
This software is furnished under a license and may be used |
|
53 |
only in accordance with the terms of that license and with the |
|
54 |
inclusion of the above copyright notice. This software may not |
|
55 |
be provided or otherwise made available to, or used by, any |
|
56 |
other person. No title to or ownership of the software is |
|
57 |
hereby transferred. |
|
58 |
" |
|
59 |
||
60 |
||
61 |
! |
|
62 |
||
128 | 63 |
documentation |
64 |
" |
|
131 | 65 |
buildIn view used by the UIPainter; it provides all services for creating, deleting |
66 |
moving and changing layouts of painted components on a canvas. |
|
128 | 67 |
|
68 |
[see also:] |
|
69 |
UIBuilder |
|
70 |
UIPainterView |
|
156 | 71 |
|
72 |
[author:] |
|
73 |
Claus Atzkern |
|
128 | 74 |
" |
75 |
||
76 |
! ! |
|
60 | 77 |
|
63 | 78 |
!UIObjectView class methodsFor:'conversion'! |
79 |
||
80 |
asLayoutFrameFromView:aView |
|
81 |
"convert layout from aView to a frameLayout. On success the frameLayout is |
|
82 |
returned otherwise nil |
|
83 |
" |
|
68 | 84 |
|lF lO rF rO tF tO bF bO type layout newLyt| |
85 |
||
86 |
type := self layoutType:aView. |
|
87 |
layout := aView geometryLayout. |
|
88 |
||
91 | 89 |
layout isNil ifTrue:[ |
90 |
type == #Extent ifTrue:[ |
|
91 |
layout := aView bounds asLayout |
|
92 |
] |
|
93 |
]. |
|
94 |
||
68 | 95 |
(type isNil or:[layout isNil]) ifTrue:[ |
63 | 96 |
^ nil |
97 |
]. |
|
98 |
||
68 | 99 |
type == #LayoutFrame ifTrue:[ |
100 |
^ layout copy |
|
101 |
]. |
|
102 |
||
103 |
layout isLayout ifFalse:[ |
|
104 |
type == #Rectangle ifTrue:[ |
|
63 | 105 |
lO := layout left. |
106 |
tO := layout top. |
|
107 |
rO := layout right. |
|
108 |
bO := layout bottom. |
|
109 |
] ifFalse:[ |
|
110 |
lO := layout x. |
|
111 |
tO := layout y. |
|
112 |
rO := lO + aView extent x. |
|
113 |
bO := tO + aView extent y. |
|
114 |
]. |
|
68 | 115 |
|
116 |
^ LayoutFrame leftFraction:0 offset:lO rightFraction:0 offset:rO |
|
117 |
topFraction:0 offset:tO bottomFraction:0 offset:bO |
|
63 | 118 |
]. |
119 |
||
68 | 120 |
lF := layout leftFraction. |
121 |
lO := layout leftOffset. |
|
122 |
tF := layout topFraction. |
|
123 |
tO := layout topOffset. |
|
124 |
bF := tF. |
|
125 |
bO := tO + aView extent y. |
|
126 |
rF := lF. |
|
127 |
rO := lO + aView extent x. |
|
128 |
||
129 |
newLyt := LayoutFrame leftFraction:lF offset:lO rightFraction:rF offset:rO |
|
130 |
topFraction:tF offset:tO bottomFraction:bF offset:bO. |
|
131 |
||
132 |
( (type == #AlignmentOrigin) |
|
133 |
and:[layout leftAlignmentFraction ~~ 0 |
|
134 |
or:[layout topAlignmentFraction ~~ 0]] |
|
135 |
) ifTrue:[ |
|
136 |
|svRc prBd dlta| |
|
137 |
||
138 |
svRc := aView superView viewRectangle. |
|
139 |
prBd := aView preferredBounds. |
|
140 |
dlta := ( ((layout rectangleRelativeTo:svRc preferred:prBd) corner) |
|
141 |
- ((newLyt rectangleRelativeTo:svRc preferred:prBd) corner) |
|
142 |
) rounded. |
|
143 |
||
144 |
newLyt leftOffset:(lO + dlta x). |
|
145 |
newLyt rightOffset:(rO + dlta x). |
|
146 |
newLyt topOffset:(tO + dlta y). |
|
147 |
newLyt bottomOffset:(bO + dlta y). |
|
148 |
]. |
|
149 |
^ newLyt. |
|
91 | 150 |
|
151 |
"Modified: 28.3.1997 / 19:52:48 / cg" |
|
63 | 152 |
! ! |
153 |
||
60 | 154 |
!UIObjectView class methodsFor:'defaults'! |
155 |
||
156 |
defaultGrid |
|
157 |
^ 4 @ 4 |
|
158 |
||
159 |
! |
|
160 |
||
161 |
gridShown |
|
162 |
^ false |
|
163 |
||
164 |
! |
|
165 |
||
166 |
handleSize |
|
167 |
"size of blob drawn for handles" |
|
168 |
^ 4 |
|
169 |
||
170 |
! |
|
171 |
||
172 |
hitDelta |
|
173 |
^ 4 |
|
174 |
||
175 |
! ! |
|
176 |
||
175 | 177 |
!UIObjectView class methodsFor:'handles'! |
178 |
||
179 |
handlesOf:aView do:aBlock |
|
180 |
|type v h| |
|
181 |
||
182 |
type := self layoutType:aView. |
|
183 |
||
184 |
(type == #LayoutFrame or:[type == #Rectangle]) ifTrue:[ |
|
185 |
v := self isVerticalResizable:aView. |
|
186 |
h := self isHorizontalResizable:aView. |
|
187 |
||
188 |
h ifTrue:[ aBlock value:(aView leftCenter ) value:#left. |
|
189 |
aBlock value:(aView rightCenter) value:#right. |
|
190 |
]. |
|
191 |
v ifTrue:[ aBlock value:(aView topCenter ) value:#top. |
|
192 |
aBlock value:(aView bottomCenter) value:#bottom. |
|
193 |
]. |
|
194 |
||
195 |
(h and:[v]) ifTrue:[ |
|
196 |
aBlock value:(aView origin ) value:#origin. |
|
197 |
aBlock value:(aView topRight ) value:#topRight. |
|
198 |
aBlock value:(aView bottomLeft) value:#bottomLeft. |
|
199 |
aBlock value:(aView corner ) value:#corner. |
|
200 |
^ self |
|
201 |
] |
|
202 |
]. |
|
203 |
||
204 |
aBlock value:(aView origin ) value:#view. |
|
205 |
aBlock value:(aView topRight ) value:#view. |
|
206 |
aBlock value:(aView bottomLeft) value:#view. |
|
207 |
||
208 |
type == #Extent ifTrue:[ |
|
209 |
v := self isVerticalResizable:aView. |
|
210 |
h := self isHorizontalResizable:aView. |
|
211 |
||
212 |
v ifTrue:[aBlock value:(aView bottomCenter) value:#bottom]. |
|
213 |
h ifTrue:[aBlock value:(aView rightCenter ) value:#right ]. |
|
214 |
||
215 |
(h and:[v]) ifTrue:[ |
|
216 |
aBlock value:(aView corner) value:#corner. |
|
217 |
^ self |
|
218 |
] |
|
219 |
]. |
|
220 |
aBlock value:(aView corner) value:#view. |
|
221 |
||
222 |
||
223 |
! ! |
|
224 |
||
61 | 225 |
!UIObjectView class methodsFor:'queries'! |
226 |
||
175 | 227 |
isHorizontalResizable:aComponent |
228 |
"returns true if instance is horizontal resizeable |
|
229 |
" |
|
230 |
(aComponent isKindOf:ScrollBar) ifTrue:[ |
|
231 |
^ aComponent orientation == #horizontal |
|
232 |
]. |
|
233 |
(aComponent isKindOf:Scroller) ifTrue:[ |
|
234 |
^ aComponent orientation == #horizontal |
|
235 |
]. |
|
236 |
(aComponent isKindOf:Slider) ifTrue:[ |
|
237 |
^ aComponent orientation == #horizontal |
|
238 |
]. |
|
239 |
^ true |
|
240 |
||
241 |
! |
|
242 |
||
243 |
isVerticalResizable:aComponent |
|
244 |
"returns true if instance is vertical resizeable |
|
245 |
" |
|
246 |
(aComponent isKindOf:EditField) ifTrue:[ |
|
247 |
^ false |
|
248 |
]. |
|
249 |
(aComponent isKindOf:ComboBoxView) ifTrue:[ |
|
250 |
^ false |
|
251 |
]. |
|
252 |
(aComponent isKindOf:CheckBox) ifTrue:[ |
|
253 |
^ false |
|
254 |
]. |
|
255 |
(aComponent isKindOf:ScrollBar) ifTrue:[ |
|
256 |
^ aComponent orientation == #vertical |
|
257 |
]. |
|
258 |
(aComponent isKindOf:Scroller) ifTrue:[ |
|
259 |
^ aComponent orientation == #vertical |
|
260 |
]. |
|
261 |
(aComponent isKindOf:Slider) ifTrue:[ |
|
262 |
^ aComponent orientation == #vertical |
|
263 |
]. |
|
264 |
^ true |
|
265 |
||
266 |
! |
|
267 |
||
61 | 268 |
layoutType:aView |
269 |
"returns layout type of aView or nil |
|
270 |
" |
|
113 | 271 |
|layout spec superView| |
272 |
||
273 |
aView notNil ifTrue:[ |
|
274 |
layout := aView geometryLayout. |
|
275 |
layout notNil ifTrue:[ |
|
276 |
layout isLayout ifTrue:[ |
|
277 |
layout isLayoutFrame ifTrue:[ ^ #LayoutFrame ]. |
|
278 |
layout isAlignmentOrigin ifTrue:[ ^ #AlignmentOrigin ]. |
|
279 |
layout isLayoutOrigin ifTrue:[ ^ #LayoutOrigin ]. |
|
280 |
] ifFalse:[ |
|
281 |
layout isRectangle ifTrue:[ ^ #Rectangle ]. |
|
282 |
layout isPoint ifTrue:[ ^ #Point ]. |
|
283 |
] |
|
61 | 284 |
] ifFalse:[ |
113 | 285 |
(superView := aView superView) notNil ifTrue:[ |
286 |
spec := superView specClass. |
|
287 |
spec canResizeSubComponents ifTrue:[ |
|
288 |
^ #Extent |
|
289 |
] |
|
290 |
] |
|
61 | 291 |
] |
292 |
]. |
|
293 |
^ nil |
|
294 |
||
67 | 295 |
"Modified: 28.2.1997 / 13:02:16 / cg" |
61 | 296 |
! ! |
297 |
||
60 | 298 |
!UIObjectView methodsFor:'accessing'! |
299 |
||
119 | 300 |
enableChannel |
301 |
"returns the channel which keeps false if running test otherwise true |
|
302 |
" |
|
303 |
^ enableChannel |
|
113 | 304 |
! |
305 |
||
60 | 306 |
gridAlign |
61 | 307 |
"returns state of aligning to grid |
308 |
" |
|
60 | 309 |
^ aligning |
310 |
||
311 |
! |
|
312 |
||
313 |
gridAlign:aBool |
|
61 | 314 |
"change state of aligning to grid |
315 |
" |
|
60 | 316 |
aBool ifTrue:[self alignOn] |
317 |
ifFalse:[self alignOff] |
|
318 |
||
319 |
! |
|
320 |
||
321 |
gridParameters |
|
322 |
"used by defineGrid, and in a separate method for |
|
323 |
easier redefinition in subclasses. |
|
324 |
Returns the grid parameters in an array of 7 elements, |
|
325 |
which control the appearance of the grid-pattern. |
|
326 |
the elements are: |
|
327 |
||
328 |
bigStepH number of pixels horizontally between 2 major steps |
|
329 |
bigStepV number of pixels vertically between 2 major steps |
|
330 |
littleStepH number of pixels horizontally between 2 minor steps |
|
331 |
littleStepV number of pixels vertically between 2 minor steps |
|
332 |
gridAlignH number of pixels for horizontal grid align (pointer snap) |
|
333 |
gridAlignV number of pixels for vertical grid align (pointer snap) |
|
334 |
docBounds true, if document boundary should be shown |
|
335 |
||
336 |
if littleStepH/V are nil, only bigSteps are drawn. |
|
337 |
" |
|
360 | 338 |
gridParameters isNil ifTrue:[ |
339 |
gridParameters := #(10 10 nil nil 10 10 false) |
|
340 |
]. |
|
341 |
^ gridParameters |
|
342 |
||
343 |
||
344 |
! |
|
345 |
||
346 |
gridParameters:newGridParameters |
|
347 |
"used by defineGrid, and in a separate method for |
|
348 |
easier redefinition in subclasses. |
|
349 |
Returns the grid parameters in an array of 7 elements, |
|
350 |
which control the appearance of the grid-pattern. |
|
351 |
the elements are: |
|
352 |
||
353 |
bigStepH number of pixels horizontally between 2 major steps |
|
354 |
bigStepV number of pixels vertically between 2 major steps |
|
355 |
littleStepH number of pixels horizontally between 2 minor steps |
|
356 |
littleStepV number of pixels vertically between 2 minor steps |
|
357 |
gridAlignH number of pixels for horizontal grid align (pointer snap) |
|
358 |
gridAlignV number of pixels for vertical grid align (pointer snap) |
|
359 |
docBounds true, if document boundary should be shown |
|
360 |
||
361 |
if littleStepH/V are nil, only bigSteps are drawn. |
|
362 |
" |
|
363 |
newGridParameters size == 7 ifTrue:[ |
|
364 |
gridParameters := newGridParameters |
|
365 |
]. |
|
60 | 366 |
|
367 |
||
368 |
! |
|
369 |
||
370 |
gridShown:aBool |
|
61 | 371 |
"change visibility of grid |
372 |
" |
|
60 | 373 |
aBool ifTrue:[self showGrid] |
374 |
ifFalse:[self hideGrid] |
|
375 |
! |
|
376 |
||
377 |
hideGrid |
|
61 | 378 |
"hide grid |
379 |
" |
|
60 | 380 |
gridShown ifTrue:[ |
61 | 381 |
self withSelectionHiddenDo:[super hideGrid] |
60 | 382 |
] |
383 |
||
384 |
||
385 |
! |
|
386 |
||
387 |
showGrid |
|
61 | 388 |
"show grid |
389 |
" |
|
390 |
self withSelectionHiddenDo:[super showGrid] |
|
119 | 391 |
! ! |
392 |
||
393 |
!UIObjectView methodsFor:'accessing behavior'! |
|
394 |
||
395 |
enabled |
|
396 |
^ enableChannel value |
|
397 |
! |
|
398 |
||
399 |
enabled:aState |
|
400 |
"set the modification / test mode |
|
401 |
" |
|
402 |
(aState == enableChannel value) ifFalse:[ |
|
123 | 403 |
aState ifFalse:[ |
131 | 404 |
saveSelection := self selection. |
405 |
self select:nil. |
|
128 | 406 |
enableChannel value:aState. |
140 | 407 |
inputView unmap. |
119 | 408 |
] ifTrue:[ |
409 |
inputView raise. |
|
123 | 410 |
inputView realize. |
128 | 411 |
enableChannel value:aState. |
123 | 412 |
self select:saveSelection. |
413 |
] |
|
119 | 414 |
] |
415 |
||
416 |
||
417 |
||
60 | 418 |
! |
419 |
||
134 | 420 |
resetModification |
421 |
"set modification state to false |
|
422 |
" |
|
423 |
undoHistory resetModification |
|
424 |
! |
|
425 |
||
60 | 426 |
testMode |
61 | 427 |
"returns true if running test |
60 | 428 |
" |
119 | 429 |
^ enableChannel value not |
60 | 430 |
|
431 |
||
432 |
! |
|
433 |
||
434 |
testMode:aBoolean |
|
61 | 435 |
"change test mode |
60 | 436 |
" |
119 | 437 |
self enabled:(aBoolean not) |
60 | 438 |
! ! |
439 |
||
440 |
!UIObjectView methodsFor:'blocked'! |
|
441 |
||
442 |
addObject:anObject |
|
61 | 443 |
"add the argument, anObject to the contents - with redraw |
444 |
" |
|
60 | 445 |
self halt |
446 |
||
447 |
! |
|
448 |
||
449 |
addObjectWithoutRedraw:anObject |
|
61 | 450 |
"add the argument, anObject to the contents - with redraw |
451 |
" |
|
60 | 452 |
self halt |
453 |
||
175 | 454 |
! |
455 |
||
456 |
startCreate:aPoint |
|
457 |
self setDefaultActions. |
|
458 |
self halt |
|
60 | 459 |
! ! |
460 |
||
461 |
!UIObjectView methodsFor:'event handling'! |
|
462 |
||
61 | 463 |
elementChangedSize:aView |
464 |
"some element has changed its size; collect them during selectionHiddenLevel |
|
465 |
is on |
|
466 |
" |
|
284 | 467 |
|spv| |
468 |
||
469 |
spv := self findContainerOfView:aView. |
|
470 |
||
471 |
selectionHiddenLevel ~~ 0 ifTrue:[setOfSuperViewsSizeChanged add:spv] |
|
472 |
ifFalse:[spv sizeChanged:nil] |
|
60 | 473 |
! |
474 |
||
475 |
exposeX:x y:y width:w height:h |
|
476 |
"handle an expose event from device; redraw selection |
|
477 |
" |
|
175 | 478 |
resizeData isNil ifTrue:[ |
479 |
super exposeX:x y:y width:w height:h. |
|
480 |
||
481 |
"/ handle any expose events (for subcomponents) before |
|
482 |
"/ redrawing the handles. |
|
483 |
(self sensor hasExposeEventFor:nil) ifTrue:[^ self]. |
|
484 |
||
485 |
self selectionDo:[:aComponent | |
|
486 |
aComponent withAllSubViewsDo:[:v | |
|
487 |
self sensor flushExposeEventsFor:v. |
|
488 |
v exposeX:0 y:0 width:9999 height:9999. |
|
489 |
]. |
|
490 |
self showSelected:aComponent |
|
491 |
] |
|
132 | 492 |
] |
60 | 493 |
|
494 |
! |
|
495 |
||
496 |
keyPress:key x:x y:y |
|
61 | 497 |
"any key pressed |
498 |
" |
|
360 | 499 |
<resource: #keyboard ( #Delete #BackSpace #Cut #Copy #Paste #Cmdu ) > |
60 | 500 |
|
501 |
(key == #Cut or:[key == #Delete or:[key == #BackSpace]]) ifTrue: [ |
|
502 |
^ self deleteSelection |
|
503 |
]. |
|
78 | 504 |
key == #Copy ifTrue:[ ^ self copySelection]. |
505 |
key == #Paste ifTrue:[ ^ self pasteBuffer]. |
|
360 | 506 |
key == #Cmdu ifTrue:[ ^ self undoLast ]. "/ #Undo |
507 |
||
374 | 508 |
super keyPress:key x:x y:y |
509 |
||
510 |
"Modified: / 31.10.1997 / 20:28:00 / cg" |
|
60 | 511 |
! |
512 |
||
513 |
processEvent:anEvent |
|
514 |
"catch expose events for components, and redraw its handles after |
|
515 |
the redraw when this happens |
|
516 |
" |
|
128 | 517 |
(anEvent type == #damage and:[self isSelected:(anEvent view)]) ifTrue:[ |
518 |
self showSelected:(anEvent view) |
|
60 | 519 |
]. |
520 |
^ false. |
|
521 |
||
522 |
||
523 |
! |
|
524 |
||
624
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
525 |
redrawX:nx y:ny width:nw height:nh |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
526 |
"ignore redraws - my components redraw themself |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
527 |
" |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
528 |
! |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
529 |
|
60 | 530 |
sizeChanged:how |
61 | 531 |
"size of a view(s) changed |
532 |
" |
|
60 | 533 |
self withSelectionHiddenDo:[ |
534 |
super sizeChanged:how |
|
535 |
] |
|
536 |
||
537 |
||
538 |
! ! |
|
539 |
||
540 |
!UIObjectView methodsFor:'initialization'! |
|
541 |
||
542 |
initialize |
|
61 | 543 |
"setup attributes |
544 |
" |
|
60 | 545 |
super initialize. |
546 |
||
547 |
"funny: since I do not want the created widgets to get pointer |
|
548 |
events, I put an InputView on top of them, which catches those events |
|
549 |
and passes them back to me - have to take care, that this inputView |
|
550 |
is always on top |
|
551 |
" |
|
552 |
inputView := InputView origin:0.0@0.0 extent:1.0@1.0 in:self. |
|
61 | 553 |
setOfSuperViewsSizeChanged := IdentitySet new. |
60 | 554 |
|
555 |
inputView eventReceiver:self. |
|
556 |
inputView enableButtonEvents. |
|
557 |
inputView enableButtonMotionEvents. |
|
558 |
||
559 |
self setDefaultActions. |
|
560 |
||
134 | 561 |
undoHistory := UndoHistory on:self. |
119 | 562 |
enableChannel := true asValue. |
563 |
clipChildren := true. |
|
61 | 564 |
selectionHiddenLevel := 0. |
60 | 565 |
|
566 |
(self class gridShown) ifTrue:[ |
|
567 |
super showGrid |
|
568 |
]. |
|
569 |
||
897
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
570 |
"Modified: / 20.7.1998 / 18:14:51 / cg" |
60 | 571 |
! |
572 |
||
284 | 573 |
map |
574 |
"make the view visible on the screen and in case of a none empty |
|
575 |
selection the selection will be shown. |
|
576 |
" |
|
577 |
super map. |
|
578 |
self showSelection. |
|
579 |
! |
|
580 |
||
897
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
581 |
mapped |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
582 |
"make certain that the input view is on top. |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
583 |
" |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
584 |
super mapped. |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
585 |
inputView raise. |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
586 |
|
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
587 |
"Created: / 20.7.1998 / 18:10:20 / cg" |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
588 |
"Modified: / 20.7.1998 / 18:11:32 / cg" |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
589 |
! |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
590 |
|
60 | 591 |
realize |
592 |
super realize. |
|
593 |
self windowGroup postEventHook:self |
|
594 |
||
897
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
595 |
! |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
596 |
|
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
597 |
remap |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
598 |
"make the view visible on the screen and in case of a none empty |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
599 |
selection the selection will be shown. |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
600 |
" |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
601 |
super remap. |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
602 |
self halt. |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
603 |
|
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
604 |
"Created: / 20.7.1998 / 18:08:48 / cg" |
60 | 605 |
! ! |
606 |
||
607 |
!UIObjectView methodsFor:'misc'! |
|
608 |
||
609 |
cursor:aCursor |
|
61 | 610 |
"set cursor |
611 |
" |
|
60 | 612 |
inputView realized ifTrue:[ |
613 |
inputView cursor:aCursor |
|
614 |
]. |
|
615 |
super cursor:aCursor |
|
616 |
||
617 |
||
618 |
! |
|
619 |
||
175 | 620 |
invertOutlineOf:something |
621 |
"invert outline of an object or collection of objects |
|
61 | 622 |
" |
175 | 623 |
|wasClipped p| |
60 | 624 |
|
625 |
(wasClipped := clipChildren) ifTrue:[ |
|
626 |
self clippedByChildren:(clipChildren := false). |
|
627 |
]. |
|
175 | 628 |
|
629 |
something isCollection ifTrue:[ |
|
630 |
something do:[:v| |
|
631 |
p := v originRelativeTo:self. |
|
632 |
self xoring:[self displayRectangle:(p extent:v extent)]. |
|
633 |
] |
|
634 |
] ifFalse:[ |
|
635 |
p := something originRelativeTo:self. |
|
636 |
self xoring:[self displayRectangle:(p extent:something extent)] |
|
60 | 637 |
]. |
638 |
||
639 |
wasClipped ifTrue:[ |
|
640 |
self clippedByChildren:(clipChildren := true). |
|
641 |
]. |
|
642 |
||
643 |
! |
|
644 |
||
78 | 645 |
minSetOfSuperViews:setOfViews |
646 |
||
647 |
setOfViews isCollection ifFalse:[ |
|
648 |
setOfViews notNil ifTrue:[^ Array with:setOfViews] |
|
649 |
ifFalse:[^ nil] |
|
72 | 650 |
]. |
78 | 651 |
^ setOfViews select:[:aView| |
652 |
(setOfViews detect:[:v|aView isComponentOf:v] ifNone:nil) isNil |
|
653 |
] |
|
72 | 654 |
! |
655 |
||
624
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
656 |
redrawObjectsInVisible:redrawFrame |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
657 |
"my objects are views - they redraw themself" |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
658 |
|
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
659 |
^ self |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
660 |
|
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
661 |
! |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
662 |
|
60 | 663 |
setDefaultActions |
61 | 664 |
"set default actions |
665 |
" |
|
60 | 666 |
pressAction := [:pressPoint | self startSelectOrMove:pressPoint]. |
667 |
shiftPressAction := [:pressPoint | self startSelectMoreOrMove:pressPoint]. |
|
668 |
motionAction := [:movePoint | nil]. |
|
669 |
releaseAction := [nil]. |
|
670 |
keyPressAction := nil. |
|
671 |
||
672 |
self cursor:Cursor normal. |
|
673 |
||
674 |
! ! |
|
675 |
||
676 |
!UIObjectView methodsFor:'object moving'! |
|
677 |
||
678 |
doObjectMove:aPoint |
|
679 |
"move selection |
|
680 |
" |
|
681 |
movedObject notNil ifTrue:[ |
|
175 | 682 |
self invertOutlineOf:movedObject. |
683 |
||
684 |
movedObject keysAndValuesDo:[:i :v| |
|
685 |
self moveObject:v to:(aPoint - (moveDelta at:i)). |
|
686 |
]. |
|
687 |
self invertOutlineOf:movedObject. |
|
60 | 688 |
] |
689 |
||
690 |
! |
|
691 |
||
692 |
endObjectMove |
|
61 | 693 |
"cleanup after object(s) move |
694 |
" |
|
60 | 695 |
movedObject notNil ifTrue:[ |
175 | 696 |
self invertOutlineOf:movedObject. |
128 | 697 |
|
698 |
movedObject size == 1 ifTrue:[ |
|
699 |
movedObject := movedObject first |
|
60 | 700 |
]. |
128 | 701 |
self setSelection:movedObject withRedraw:true. |
60 | 702 |
movedObject := nil. |
703 |
self setDefaultActions. |
|
225 | 704 |
self layoutChanged. |
60 | 705 |
]. |
706 |
! |
|
707 |
||
708 |
moveObject:anObject to:aPoint |
|
709 |
"move anObject to newOrigin, aPoint |
|
710 |
" |
|
711 |
|dX dY org delta| |
|
712 |
||
713 |
anObject notNil ifTrue:[ |
|
714 |
org := anObject computeOrigin. |
|
715 |
||
716 |
delta := aPoint - org. |
|
717 |
delta := (self alignToGrid:aPoint) - org. |
|
718 |
dX := delta x. |
|
719 |
dY := delta y. |
|
720 |
||
134 | 721 |
undoHistory withoutTransactionDo:[ |
60 | 722 |
self shiftLayout:anObject top:dY bottom:dY left:dX right:dX |
723 |
] |
|
724 |
] |
|
725 |
||
726 |
! |
|
727 |
||
728 |
startObjectMoveAt:aPoint |
|
61 | 729 |
"start object(s) move at a point |
730 |
" |
|
128 | 731 |
self startObjectMove:(self selection) at:aPoint. |
732 |
movedObject := self selection. |
|
733 |
||
734 |
movedObject isCollection ifFalse:[ |
|
735 |
movedObject := Array with:movedObject |
|
60 | 736 |
]. |
128 | 737 |
self setSelection:nil withRedraw:true. |
60 | 738 |
|
739 |
moveDelta := movedObject collect:[:aView| |
|
740 |
aPoint - aView computeOrigin |
|
741 |
]. |
|
175 | 742 |
self transaction:#move objects:movedObject do:[:v|self createUndoLayout:v]. |
743 |
self invertOutlineOf:movedObject. |
|
60 | 744 |
! |
745 |
||
746 |
startSelectMoreOrMove:aPoint |
|
747 |
"add/remove to/from selection" |
|
748 |
||
749 |
|anObject| |
|
750 |
||
119 | 751 |
self enabled ifFalse:[^ self]. |
60 | 752 |
|
753 |
anObject := self findObjectAt:aPoint. |
|
754 |
anObject notNil ifTrue:[ |
|
755 |
(self isSelected:anObject) ifTrue:[ |
|
756 |
self removeFromSelection:anObject |
|
757 |
] ifFalse:[ |
|
758 |
self addToSelection:anObject |
|
759 |
] |
|
760 |
] |
|
761 |
! |
|
762 |
||
763 |
startSelectOrMove:aPoint |
|
61 | 764 |
"a button is pressed at a point; start moving or selection |
60 | 765 |
" |
284 | 766 |
|aView b v| |
60 | 767 |
|
119 | 768 |
self enabled ifFalse:[^ self]. |
60 | 769 |
|
61 | 770 |
aView := self singleSelection. |
771 |
||
772 |
aView notNil ifTrue:[ |
|
284 | 773 |
v := self findContainerOfView:aView. |
774 |
||
775 |
v specClass canResizeSubComponents ifTrue:[ |
|
61 | 776 |
b := self whichHandleOf:aView isHitBy:aPoint. |
777 |
||
778 |
(b notNil and:[b ~~ #view]) ifTrue:[ |
|
779 |
^ self startResizeBorder:b of:aView. |
|
780 |
] |
|
100 | 781 |
]. |
782 |
||
284 | 783 |
(self sensor ctrlDown and:[self canChangeLayoutOfView:aView]) ifFalse:[ |
100 | 784 |
aView := nil |
60 | 785 |
] |
786 |
]. |
|
787 |
||
100 | 788 |
aView isNil ifTrue:[ |
789 |
(aView := self findObjectAt:aPoint) isNil ifTrue:[ |
|
131 | 790 |
^ self select:nil |
100 | 791 |
]. |
792 |
||
284 | 793 |
(self canChangeLayoutOfView:aView) ifFalse:[ |
128 | 794 |
^ self select:aView |
100 | 795 |
] |
61 | 796 |
]. |
797 |
||
798 |
(self isSelected:aView) ifFalse:[ |
|
799 |
self select:aView. |
|
60 | 800 |
]. |
801 |
||
802 |
(self numberOfSelections ~~ 1) ifTrue:[ |
|
803 |
releaseAction := [ |
|
804 |
self setDefaultActions. |
|
61 | 805 |
self select:aView |
60 | 806 |
] |
807 |
] ifFalse:[ |
|
808 |
releaseAction := [self setDefaultActions] |
|
809 |
]. |
|
810 |
||
811 |
"prepare move operation for an object |
|
812 |
" |
|
61 | 813 |
|
60 | 814 |
motionAction := [:movePoint| |
72 | 815 |
(aPoint dist:movePoint) > 8.0 ifTrue:[ |
60 | 816 |
self startObjectMoveAt:aPoint |
817 |
] |
|
818 |
]. |
|
819 |
! ! |
|
820 |
||
821 |
!UIObjectView methodsFor:'object resize'! |
|
822 |
||
823 |
actionResize:anObject selector:aSelector |
|
824 |
"create and initialize action for resize |
|
825 |
" |
|
826 |
|selector delta| |
|
827 |
||
828 |
delta := anObject container originRelativeTo:self. |
|
829 |
selector := ('resize:', aSelector, ':') asSymbol. |
|
830 |
||
543
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
831 |
resizeData := ResizeData new |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
832 |
object:anObject selector:selector delta:delta. |
60 | 833 |
|
834 |
"can change cursor dependent on vertical/horizontal resizing |
|
835 |
" |
|
836 |
oldCursor := cursor. |
|
837 |
self cursor:(Cursor leftHand). |
|
838 |
||
543
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
839 |
"Modified: / 2.2.1998 / 13:40:55 / cg" |
60 | 840 |
! |
841 |
||
842 |
doDragResize:aPoint |
|
61 | 843 |
"do a widget resize drag |
844 |
" |
|
60 | 845 |
|p object| |
846 |
||
175 | 847 |
object := resizeData object. |
60 | 848 |
|
849 |
self invertOutlineOf:object. |
|
175 | 850 |
p := (self alignToGrid:aPoint) - (resizeData delta). |
851 |
||
852 |
self perform:(resizeData selector) with:object with:p. |
|
79 | 853 |
"/ object geometryLayout:(object geometryLayout). |
60 | 854 |
self invertOutlineOf:object |
855 |
||
856 |
! |
|
857 |
||
858 |
endResize |
|
61 | 859 |
"cleanup after object resize |
860 |
" |
|
861 |
|object| |
|
862 |
||
175 | 863 |
object := resizeData object. |
864 |
resizeData := nil. |
|
61 | 865 |
|
866 |
self invertOutlineOf:object. |
|
60 | 867 |
self setDefaultActions. |
61 | 868 |
self elementChangedSize:object. |
138 | 869 |
|
870 |
"/ handle any expose events (for subcomponents) before |
|
871 |
"/ redrawing the handles. |
|
872 |
Delay waitForSeconds:0.05. |
|
873 |
[self sensor hasExposeEventFor:nil] whileTrue:[ |
|
874 |
self windowGroup processExposeEvents |
|
875 |
]. |
|
876 |
||
128 | 877 |
self setSelection:object withRedraw:true. |
225 | 878 |
self layoutChanged. |
60 | 879 |
! |
880 |
||
881 |
startResizeBorder:b of:selection |
|
882 |
"resize selected view |
|
883 |
" |
|
884 |
|object| |
|
885 |
||
886 |
object := self singleSelection. |
|
887 |
self actionResize:object selector:b. |
|
888 |
||
72 | 889 |
self transaction:#resize selectionDo:[:aView| |
134 | 890 |
self createUndoLayout:aView |
60 | 891 |
]. |
128 | 892 |
self setSelection:nil withRedraw:true. |
60 | 893 |
|
894 |
motionAction := [:movePoint | self doDragResize:movePoint]. |
|
895 |
releaseAction := [self endResize]. |
|
896 |
self invertOutlineOf:object |
|
897 |
! ! |
|
898 |
||
899 |
!UIObjectView methodsFor:'private handles'! |
|
900 |
||
768 | 901 |
handleAffectedViews:aViewOrSeqOfViews |
902 |
"update affected views |
|
903 |
" |
|
777 | 904 |
|c| |
768 | 905 |
|
906 |
self forEach:aViewOrSeqOfViews do:[:v| |
|
907 |
v shown ifTrue:[ |
|
908 |
v fill:v viewBackground. |
|
777 | 909 |
v borderWidth ~~ 0 ifTrue:[ |
910 |
c := v borderColor. |
|
911 |
v borderColor:(Color colorId:1). |
|
912 |
v borderColor:c. |
|
768 | 913 |
]. |
914 |
v exposeX:0 y:0 width:9999 height:9999 |
|
915 |
] |
|
916 |
] |
|
917 |
! |
|
918 |
||
175 | 919 |
handlesOf:aComponent do:aTwoArgAction |
920 |
"perform action on each handle of a component |
|
921 |
" |
|
922 |
|dlt ext| |
|
923 |
||
924 |
dlt := (aComponent originRelativeTo:self) - aComponent origin. |
|
925 |
dlt := dlt - (3@3). |
|
926 |
ext := 6@6. |
|
927 |
||
928 |
self class handlesOf:aComponent do:[:pnt :wht | |
|
929 |
aTwoArgAction value:(pnt + dlt extent:ext) value:wht |
|
930 |
] |
|
60 | 931 |
! |
932 |
||
933 |
showUnselected:aComponent |
|
61 | 934 |
"show object unselected |
935 |
" |
|
768 | 936 |
self showUnselected:aComponent addAffectedViewsTo:nil |
937 |
! |
|
938 |
||
939 |
showUnselected:aComponent addAffectedViewsTo:aSet |
|
940 |
"show object unselected. If the set, an IdentitySet, is not nil, the |
|
941 |
affected subviews are added into the set, otherwise an expose event |
|
942 |
to each affected cpomponent is raised. |
|
943 |
" |
|
251 | 944 |
|wasClipped r| |
60 | 945 |
|
138 | 946 |
selectionHiddenLevel ~~ 0 ifTrue:[^ self]. |
947 |
||
60 | 948 |
(wasClipped := clipChildren) ifTrue:[ |
949 |
self clippedByChildren:(clipChildren := false). |
|
950 |
]. |
|
951 |
||
175 | 952 |
self handlesOf:aComponent do:[:rec :wht| self clearRectangle:rec ]. |
60 | 953 |
|
954 |
wasClipped ifTrue:[ |
|
955 |
self clippedByChildren:(clipChildren := true). |
|
956 |
]. |
|
957 |
||
958 |
"/ must redraw all components which are affected b the handles |
|
175 | 959 |
r := (aComponent originRelativeTo:self) - (3@3) extent:(aComponent extent + (6@6)). |
60 | 960 |
|
961 |
subViews do:[:anotherComponent | |
|
962 |
|absOrg absFrame| |
|
963 |
||
964 |
anotherComponent ~~ inputView ifTrue:[ |
|
965 |
absOrg := anotherComponent originRelativeTo:self. |
|
966 |
absFrame := absOrg extent:(anotherComponent extent). |
|
967 |
(absFrame intersects:r) ifTrue:[ |
|
968 |
anotherComponent withAllSubViewsDo:[:v | |
|
95 | 969 |
v shown ifTrue:[ |
768 | 970 |
aSet notNil ifTrue:[ |
971 |
aSet add:v |
|
972 |
] ifFalse:[ |
|
973 |
self handleAffectedViews:v |
|
974 |
] |
|
95 | 975 |
] |
60 | 976 |
] |
977 |
] |
|
978 |
] |
|
768 | 979 |
]. |
980 |
||
60 | 981 |
! |
982 |
||
175 | 983 |
whichHandleOf:aComponent isHitBy:aPoint |
61 | 984 |
"returns kind of handle or nil |
985 |
" |
|
175 | 986 |
self handlesOf:aComponent do:[:rectangle :what| |
987 |
(rectangle containsPoint:aPoint) ifTrue:[^ what] |
|
60 | 988 |
]. |
175 | 989 |
^ nil |
60 | 990 |
! ! |
991 |
||
992 |
!UIObjectView methodsFor:'private resizing-subviews'! |
|
993 |
||
994 |
resize:aView bottom:aPoint |
|
61 | 995 |
"resize a views bottom |
996 |
" |
|
134 | 997 |
undoHistory withoutTransactionDo:[ |
60 | 998 |
self shiftLayout:aView top:0 bottom:((aPoint y) - (aView computeCorner y)) |
999 |
] |
|
1000 |
! |
|
1001 |
||
1002 |
resize:aView bottomLeft:aPoint |
|
61 | 1003 |
"resize a views bottom and left |
1004 |
" |
|
134 | 1005 |
undoHistory withoutTransactionDo:[ |
60 | 1006 |
self shiftLayout:aView top:0 |
1007 |
bottom:((aPoint y) - (aView computeCorner y)) |
|
1008 |
left:((aPoint x) - (aView computeOrigin x)) |
|
1009 |
right:0 |
|
1010 |
||
1011 |
] |
|
1012 |
||
1013 |
||
1014 |
! |
|
1015 |
||
1016 |
resize:aView corner:aPoint |
|
61 | 1017 |
"resize a views corner |
1018 |
" |
|
60 | 1019 |
|delta| |
1020 |
||
1021 |
delta := aPoint - aView computeCorner. |
|
1022 |
||
134 | 1023 |
undoHistory withoutTransactionDo:[ |
60 | 1024 |
self shiftLayout:aView top:0 bottom:(delta y) left:0 right:(delta x) |
1025 |
] |
|
1026 |
! |
|
1027 |
||
1028 |
resize:aView left:aPoint |
|
61 | 1029 |
"resize a views left |
1030 |
" |
|
134 | 1031 |
undoHistory withoutTransactionDo:[ |
60 | 1032 |
self shiftLayout:aView left:((aPoint x) - (aView computeOrigin x)) right:0 |
1033 |
] |
|
1034 |
||
1035 |
! |
|
1036 |
||
1037 |
resize:aView origin:aPoint |
|
61 | 1038 |
"resize a views origin |
1039 |
" |
|
60 | 1040 |
|delta| |
1041 |
||
1042 |
delta := aPoint - aView computeOrigin. |
|
1043 |
||
134 | 1044 |
undoHistory withoutTransactionDo:[ |
60 | 1045 |
self shiftLayout:aView top:(delta y) bottom:0 left:(delta x) right:0 |
1046 |
] |
|
1047 |
||
1048 |
! |
|
1049 |
||
1050 |
resize:aView right:aPoint |
|
61 | 1051 |
"resize a views right |
1052 |
" |
|
134 | 1053 |
undoHistory withoutTransactionDo:[ |
60 | 1054 |
self shiftLayout:aView left:0 right:((aPoint x) - (aView computeCorner x)) |
1055 |
] |
|
1056 |
! |
|
1057 |
||
1058 |
resize:aView top:aPoint |
|
61 | 1059 |
"resize a views top |
1060 |
" |
|
134 | 1061 |
undoHistory withoutTransactionDo:[ |
60 | 1062 |
self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y)) bottom:0 |
1063 |
] |
|
1064 |
! |
|
1065 |
||
1066 |
resize:aView topRight:aPoint |
|
61 | 1067 |
"resize a views top and right |
1068 |
" |
|
134 | 1069 |
undoHistory withoutTransactionDo:[ |
60 | 1070 |
self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y)) |
1071 |
bottom:0 |
|
1072 |
left:0 |
|
1073 |
right:((aPoint x) - (aView computeCorner x)) |
|
1074 |
||
1075 |
] |
|
1076 |
||
1077 |
! ! |
|
1078 |
||
1079 |
!UIObjectView methodsFor:'private shift-layout'! |
|
1080 |
||
1081 |
shiftLayout:aView left:l right:r |
|
1082 |
"shift layout for a view; in case of an open transaction, the undo |
|
1083 |
action is registered |
|
1084 |
" |
|
1085 |
self shiftLayout:aView top:0 bottom:0 left:l right:r |
|
1086 |
||
1087 |
! |
|
1088 |
||
1089 |
shiftLayout:aView top:t bottom:b |
|
1090 |
"shift layout for a view; in case of an open transaction, the undo |
|
1091 |
action is registered |
|
1092 |
" |
|
1093 |
self shiftLayout:aView top:t bottom:b left:0 right:0 |
|
1094 |
||
1095 |
||
1096 |
! |
|
1097 |
||
1098 |
shiftLayout:aView top:t bottom:b left:l right:r |
|
1099 |
"shift layout for a view; in case of an open transaction, the undo |
|
1100 |
action is registered |
|
1101 |
" |
|
79 | 1102 |
|type layout oldExt| |
61 | 1103 |
|
1104 |
type := self class layoutType:aView. |
|
1105 |
||
1106 |
type notNil ifTrue:[ |
|
134 | 1107 |
self createUndoLayout:aView. |
61 | 1108 |
|
1109 |
type == #Extent ifTrue:[ |
|
79 | 1110 |
oldExt := aView extent. |
1111 |
aView extent:(oldExt + ((r-l) @ (b-t))). |
|
1112 |
^ self |
|
60 | 1113 |
]. |
61 | 1114 |
|
78 | 1115 |
layout := aView geometryLayout copy. |
61 | 1116 |
|
1117 |
layout isLayout ifTrue:[ |
|
1118 |
layout leftOffset:(layout leftOffset + l) |
|
1119 |
topOffset:(layout topOffset + t). |
|
1120 |
||
1121 |
type == #LayoutFrame ifTrue:[ |
|
1122 |
layout bottomOffset:(layout bottomOffset + b). |
|
1123 |
layout rightOffset:(layout rightOffset + r). |
|
1124 |
] |
|
1125 |
] ifFalse:[ |
|
1126 |
type == #Rectangle ifTrue:[ |
|
1127 |
layout left:(layout left + l) |
|
1128 |
right:(layout right + r) |
|
1129 |
top:(layout top + t) |
|
1130 |
bottom:(layout bottom + b). |
|
1131 |
] ifFalse:[ "POINT" |
|
1132 |
layout x:(layout x + l) y:(layout y + t). |
|
1133 |
] |
|
1134 |
]. |
|
1135 |
aView geometryLayout:layout |
|
60 | 1136 |
] |
1137 |
! ! |
|
1138 |
||
1139 |
!UIObjectView methodsFor:'searching'! |
|
1140 |
||
1141 |
findObjectAt:aPoint |
|
1142 |
"find the origin/corner of the currentWidget |
|
1143 |
" |
|
1144 |
|view viewId lastId point listOfViews| |
|
1145 |
||
1146 |
viewId := rootView id. |
|
1147 |
point := aPoint + (device translatePoint:0@0 from:(self id) to:viewId). |
|
1148 |
||
1149 |
inputView lower. |
|
1150 |
||
1151 |
[viewId notNil] whileTrue:[ |
|
1152 |
lastId := viewId. |
|
1153 |
viewId := device viewIdFromPoint:point in:lastId |
|
1154 |
]. |
|
1155 |
||
1156 |
inputView raise. |
|
1157 |
||
1158 |
view := device viewFromId:lastId. |
|
1159 |
||
1160 |
view ~~ inputView ifTrue:[^ view]. |
|
1161 |
||
1162 |
"/ look for 'hidden' views ... |
|
1163 |
||
1164 |
listOfViews := OrderedCollection new. |
|
1165 |
self allSubViewsDo:[:aView | |
|
1166 |
|org| |
|
1167 |
||
1168 |
aView ~~ inputView ifTrue:[ |
|
1169 |
org := device translatePoint:0@0 from:(aView id) to:self id. |
|
1170 |
((org extent:aView extent) containsPoint:aPoint) ifTrue:[ |
|
1171 |
listOfViews add:aView. |
|
1172 |
] |
|
1173 |
] |
|
1174 |
]. |
|
1175 |
||
1176 |
listOfViews size > 0 ifTrue:[ |
|
1177 |
^ listOfViews last |
|
1178 |
]. |
|
1179 |
^ nil |
|
1180 |
||
1181 |
||
1182 |
! ! |
|
1183 |
||
1184 |
!UIObjectView methodsFor:'selections'! |
|
1185 |
||
768 | 1186 |
hideSelection |
1187 |
"hide the selection - undraw hilights - whatever that is" |
|
1188 |
||
1189 |
|aSet| |
|
1190 |
||
1191 |
self selectionDo:[:object| |
|
1192 |
aSet isNil ifTrue:[ |
|
1193 |
aSet := IdentitySet new |
|
1194 |
]. |
|
1195 |
self showUnselected:object addAffectedViewsTo:aSet. |
|
1196 |
]. |
|
1197 |
self handleAffectedViews:aSet. |
|
1198 |
||
1199 |
||
1200 |
! |
|
1201 |
||
128 | 1202 |
moveableSelection |
131 | 1203 |
"checks whether the selection is not empty and all selected instances |
1204 |
can be moved. If true the selection is returned otherwise nil |
|
128 | 1205 |
" |
1206 |
|coll| |
|
1207 |
||
1208 |
self hasSelection ifTrue:[ |
|
1209 |
(self canMove:(coll := self selection)) ifTrue:[ |
|
1210 |
^ coll |
|
1211 |
] |
|
1212 |
]. |
|
1213 |
^ nil |
|
1214 |
! |
|
1215 |
||
60 | 1216 |
numberOfSelections |
131 | 1217 |
"return the number of selected instances |
61 | 1218 |
" |
128 | 1219 |
|coll size| |
1220 |
||
1221 |
coll := self selection. |
|
1222 |
size := coll size. |
|
1223 |
||
1224 |
(size ~~ 0 or:[coll isNil]) ifTrue:[^ size]. |
|
1225 |
^ 1 |
|
60 | 1226 |
! |
1227 |
||
149 | 1228 |
selection:something |
1229 |
"change selection to something |
|
1230 |
" |
|
1231 |
self select:something |
|
1232 |
! |
|
1233 |
||
128 | 1234 |
selectionDo:aBlock |
1235 |
"apply block to every selected object |
|
1236 |
" |
|
1237 |
self forEach:(self selection) do:aBlock |
|
1238 |
||
1239 |
||
1240 |
! |
|
1241 |
||
61 | 1242 |
showSelection |
128 | 1243 |
"show the selection - draw handles |
1244 |
" |
|
61 | 1245 |
selectionHiddenLevel == 0 ifTrue:[ |
128 | 1246 |
self selectionDo:[:el| self showSelected:el ] |
60 | 1247 |
]. |
1248 |
! |
|
1249 |
||
1250 |
singleSelection |
|
131 | 1251 |
"checks whether one element is selected; in this case the element is |
1252 |
returned otherwise nil |
|
60 | 1253 |
" |
128 | 1254 |
|coll| |
1255 |
||
1256 |
(coll := self selection) isCollection ifFalse:[ |
|
1257 |
^ coll |
|
60 | 1258 |
]. |
128 | 1259 |
|
1260 |
coll size == 1 ifTrue:[ ^ coll first]. |
|
1261 |
^ nil |
|
60 | 1262 |
! |
1263 |
||
1264 |
singleSelectionDo:aBlock |
|
131 | 1265 |
"checks whether one element is selected; in this case the block |
1266 |
with argument the selected instance will be processed |
|
61 | 1267 |
" |
60 | 1268 |
|view| |
1269 |
||
1270 |
(view := self singleSelection) notNil ifTrue:[ |
|
1271 |
aBlock value:view |
|
1272 |
] |
|
1273 |
! |
|
1274 |
||
1275 |
unselect |
|
61 | 1276 |
"clear selection |
1277 |
" |
|
128 | 1278 |
self select:nil |
60 | 1279 |
! |
1280 |
||
1281 |
withSelectionHiddenDo:aBlock |
|
61 | 1282 |
"apply block with selection hidden (no handles) |
1283 |
" |
|
78 | 1284 |
|coll| |
1285 |
||
138 | 1286 |
selectionHiddenLevel == 0 ifTrue:[ |
768 | 1287 |
self hideSelection. |
61 | 1288 |
device flush. |
1289 |
]. |
|
138 | 1290 |
selectionHiddenLevel := selectionHiddenLevel + 1. |
61 | 1291 |
|
1292 |
aBlock valueNowOrOnUnwindDo:[ |
|
1293 |
selectionHiddenLevel == 1 ifTrue:[ |
|
1294 |
setOfSuperViewsSizeChanged notEmpty ifTrue:[ |
|
78 | 1295 |
coll := self minSetOfSuperViews:setOfSuperViewsSizeChanged. |
1296 |
coll do:[:aView| aView sizeChanged:nil]. |
|
61 | 1297 |
setOfSuperViewsSizeChanged := IdentitySet new |
1298 |
]. |
|
138 | 1299 |
selectionHiddenLevel := 0. |
61 | 1300 |
self selectionDo:[:aView| self showSelected:aView]. |
138 | 1301 |
] ifFalse:[ |
1302 |
selectionHiddenLevel := selectionHiddenLevel - 1. |
|
1303 |
] |
|
61 | 1304 |
] |
1305 |
||
1306 |
! |
|
1307 |
||
1308 |
withoutSelectionDo:aBlock |
|
1309 |
"evaluate aBlock while selection is nilled |
|
1310 |
" |
|
60 | 1311 |
|sel| |
1312 |
||
128 | 1313 |
self hasSelection ifFalse:[ |
60 | 1314 |
aBlock value |
128 | 1315 |
] ifTrue:[ |
1316 |
sel := self selection. |
|
1317 |
self setSelection:nil withRedraw:true. |
|
60 | 1318 |
aBlock value. |
128 | 1319 |
self setSelection:sel withRedraw:true. |
60 | 1320 |
] |
1321 |
||
1322 |
||
1323 |
! ! |
|
1324 |
||
131 | 1325 |
!UIObjectView methodsFor:'selections basic'! |
1326 |
||
1327 |
selection |
|
1328 |
"returns the current selection |
|
1329 |
" |
|
1330 |
^ selection |
|
1331 |
||
1332 |
||
1333 |
! |
|
1334 |
||
1335 |
setSelection:aNewSelection withRedraw:doRedraw |
|
1336 |
"set a new selection without change notifications |
|
1337 |
" |
|
225 | 1338 |
|sel| |
1339 |
||
1340 |
(sel := aNewSelection) == self ifTrue:[ |
|
1341 |
sel := nil |
|
1342 |
]. |
|
1343 |
||
131 | 1344 |
doRedraw ifTrue:[ |
1345 |
self hideSelection. |
|
225 | 1346 |
selection := sel. |
131 | 1347 |
self showSelection |
1348 |
] ifFalse:[ |
|
225 | 1349 |
selection := sel |
131 | 1350 |
] |
1351 |
! ! |
|
1352 |
||
60 | 1353 |
!UIObjectView methodsFor:'testing'! |
1354 |
||
284 | 1355 |
hasSelection |
1356 |
"returns true if any widget is selected |
|
61 | 1357 |
" |
284 | 1358 |
^ self numberOfSelections ~~ 0 |
60 | 1359 |
|
1360 |
! |
|
1361 |
||
284 | 1362 |
hasSingleSelection |
1363 |
"returns true if one widget is selected |
|
61 | 1364 |
" |
284 | 1365 |
^ self numberOfSelections == 1 |
1366 |
||
1367 |
! |
|
1368 |
||
1369 |
hasUndoHistory |
|
1370 |
"returns true if undos exists |
|
1371 |
" |
|
1372 |
^ undoHistory isEmpty not |
|
60 | 1373 |
! |
1374 |
||
134 | 1375 |
isModified |
1376 |
"returns true if painter is modified |
|
1377 |
" |
|
1378 |
^ undoHistory isModified |
|
1379 |
! |
|
1380 |
||
128 | 1381 |
isSelected:anObject |
1382 |
"return true, if the argument, anObject is selected |
|
1383 |
" |
|
1384 |
anObject notNil ifTrue:[ |
|
1385 |
self selectionDo:[:el| el == anObject ifTrue:[^ true]] |
|
1386 |
]. |
|
1387 |
^ false |
|
1388 |
||
60 | 1389 |
! ! |
1390 |
||
1391 |
!UIObjectView methodsFor:'transaction'! |
|
1392 |
||
134 | 1393 |
createUndoLayout:aView |
1394 |
"prepare undo action for a view changing its layout |
|
1395 |
" |
|
1396 |
self subclassResponsibility |
|
1397 |
||
1398 |
! |
|
1399 |
||
60 | 1400 |
transaction:aType objects:something do:aOneArgBlock |
1401 |
"opens a transaction and evaluates a block within the transaction; the |
|
1402 |
argument to the block is a view from derived from something |
|
1403 |
" |
|
1404 |
self subclassResponsibility |
|
1405 |
||
1406 |
||
1407 |
! |
|
1408 |
||
1409 |
transaction:aType selectionDo:aOneArgBlock |
|
1410 |
"opens a transaction and evaluates a block within the transaction; the |
|
1411 |
argument to the block is a view from the selection |
|
1412 |
" |
|
128 | 1413 |
self transaction:aType objects:(self selection) do:aOneArgBlock |
60 | 1414 |
|
1415 |
||
1416 |
! ! |
|
1417 |
||
1418 |
!UIObjectView methodsFor:'user actions - dimension'! |
|
1419 |
||
1420 |
copyExtent |
|
61 | 1421 |
"copy the extent from the selected object |
1422 |
" |
|
60 | 1423 |
|object| |
1424 |
||
1425 |
object := self singleSelection. |
|
1426 |
||
1427 |
object notNil ifTrue:[ |
|
1428 |
copiedExtent := object computeExtent |
|
1429 |
] ifFalse:[ |
|
1430 |
self warn:'exactly one element must be selected'. |
|
1431 |
] |
|
1432 |
||
1433 |
||
1434 |
||
1435 |
! |
|
1436 |
||
89 | 1437 |
copyLayout |
1438 |
"copy the layout from the selected object |
|
1439 |
" |
|
1440 |
|object| |
|
1441 |
||
1442 |
object := self singleSelection. |
|
1443 |
||
1444 |
object notNil ifTrue:[ |
|
1445 |
copiedLayout := object geometryLayout copy |
|
1446 |
] ifFalse:[ |
|
1447 |
self warn:'exactly one element must be selected'. |
|
1448 |
] |
|
1449 |
||
1450 |
||
1451 |
||
1452 |
! |
|
1453 |
||
60 | 1454 |
pasteExtent |
61 | 1455 |
"paste the copied extent to all objects in the selection |
1456 |
" |
|
60 | 1457 |
copiedExtent notNil ifTrue:[ |
134 | 1458 |
self transaction:#pasteExtent dimensionDo:[:v| |
60 | 1459 |
self resize:v corner:(v computeOrigin + copiedExtent) |
1460 |
] |
|
1461 |
] |
|
1462 |
! |
|
1463 |
||
1464 |
pasteHeight |
|
61 | 1465 |
"paste the copied extent height to all objects in the selection |
1466 |
" |
|
60 | 1467 |
copiedExtent notNil ifTrue:[ |
134 | 1468 |
self transaction:#pasteHeight dimensionDo:[:v| |
60 | 1469 |
self resize:v bottom:(v computeOrigin + copiedExtent) |
1470 |
] |
|
1471 |
] |
|
1472 |
||
1473 |
! |
|
1474 |
||
89 | 1475 |
pasteLayout |
1476 |
"paste layout to all objects in the selection |
|
1477 |
" |
|
1478 |
copiedLayout notNil ifTrue:[ |
|
134 | 1479 |
self transaction:#pasteLayout dimensionDo:[:v| |
89 | 1480 |
v geometryLayout:(copiedLayout copy) |
1481 |
] |
|
1482 |
] |
|
1483 |
! |
|
1484 |
||
60 | 1485 |
pasteWidth |
61 | 1486 |
"paste the copied extent width to all objects in the selection |
1487 |
" |
|
60 | 1488 |
copiedExtent notNil ifTrue:[ |
134 | 1489 |
self transaction:#pasteWidth dimensionDo:[:v| |
60 | 1490 |
self resize:v right:(v computeOrigin + copiedExtent) |
1491 |
] |
|
1492 |
] |
|
1493 |
||
1494 |
! |
|
1495 |
||
61 | 1496 |
setExtent:anExtent |
1497 |
"change extent for all selected objects |
|
1498 |
" |
|
134 | 1499 |
self transaction:#extent dimensionDo:[:v| |
67 | 1500 |
v geometryLayout:nil. |
61 | 1501 |
v extent:anExtent. |
67 | 1502 |
]. |
1503 |
||
1504 |
"Modified: 28.2.1997 / 12:49:00 / cg" |
|
60 | 1505 |
! |
1506 |
||
149 | 1507 |
setLayout:aLayout |
1508 |
"change layout for all selected objects |
|
1509 |
" |
|
1510 |
self transaction:#layout dimensionDo:[:v| |
|
1511 |
v geometryLayout:(aLayout copy) |
|
1512 |
]. |
|
1513 |
||
1514 |
! |
|
1515 |
||
353 | 1516 |
setMaxExtent |
1517 |
"set the topViews maxExtent to its current extent |
|
1518 |
" |
|
1519 |
self halt |
|
1520 |
||
1521 |
"Modified: / 27.10.1997 / 03:26:16 / cg" |
|
1522 |
! |
|
1523 |
||
1524 |
setMinExtent |
|
1525 |
"set the topViews minExtent to its current extent |
|
1526 |
" |
|
1527 |
self halt |
|
1528 |
||
1529 |
"Created: / 27.10.1997 / 03:24:02 / cg" |
|
1530 |
"Modified: / 27.10.1997 / 03:26:34 / cg" |
|
1531 |
! |
|
1532 |
||
60 | 1533 |
setToDefaultExtent |
61 | 1534 |
"change extent of all selected views to their default extent |
1535 |
" |
|
134 | 1536 |
self transaction:#defaultExtent dimensionDo:[:v| |
149 | 1537 |
self resize:v corner:(v computeOrigin + (v preferredExtent)). |
60 | 1538 |
] |
1539 |
||
1540 |
! |
|
1541 |
||
1542 |
setToDefaultHeight |
|
61 | 1543 |
"change height of all selected views to their default height |
1544 |
" |
|
134 | 1545 |
self transaction:#defaultHeight dimensionDo:[:v| |
60 | 1546 |
self resize:v bottom:(v computeOrigin + (v preferredExtent)) |
1547 |
] |
|
1548 |
||
1549 |
! |
|
1550 |
||
1551 |
setToDefaultWidth |
|
61 | 1552 |
"change width of all selected views to their default width |
1553 |
" |
|
134 | 1554 |
self transaction:#defaultWidth dimensionDo:[:v| |
60 | 1555 |
self resize:v right:(v computeOrigin + (v preferredExtent)) |
1556 |
] |
|
1557 |
||
1558 |
! |
|
1559 |
||
134 | 1560 |
transaction:aType dimensionDo:aOneArgBlock |
60 | 1561 |
"change dimension within a transaction for the selected elements by evaluating |
1562 |
the block with the argument a view. |
|
1563 |
" |
|
61 | 1564 |
self withSelectionHiddenDo:[ |
60 | 1565 |
self transaction:aType selectionDo:[:aView| |
61 | 1566 |
(self class layoutType:aView) notNil ifTrue:[ |
134 | 1567 |
self createUndoLayout:aView. |
61 | 1568 |
aOneArgBlock value:aView. |
1569 |
self elementChangedSize:aView. |
|
1570 |
] |
|
1571 |
] |
|
1572 |
]. |
|
225 | 1573 |
self layoutChanged |
61 | 1574 |
|
60 | 1575 |
! ! |
1576 |
||
1577 |
!UIObjectView methodsFor:'user actions - move'! |
|
1578 |
||
138 | 1579 |
moveDo:aOneArgBlock |
1580 |
"perform a move operation |
|
1581 |
" |
|
1582 |
|sensor tm| |
|
1583 |
||
1584 |
self moveableSelection isNil ifTrue:[ |
|
1585 |
^ self |
|
1586 |
]. |
|
1587 |
sensor := self sensor. |
|
1588 |
||
1589 |
tm := 0.15. |
|
1590 |
||
1591 |
self withSelectionHiddenDo:[ |
|
1592 |
self transaction:#move selectionDo:[:aView|self createUndoLayout:aView]. |
|
1593 |
||
1594 |
[ |
|
1595 |
self selectionDo:[:aView| aOneArgBlock value:aView ]. |
|
1596 |
Delay waitForSeconds:tm. |
|
1597 |
tm := 0.02. |
|
225 | 1598 |
self layoutChanged. |
138 | 1599 |
sensor leftButtonPressed. |
1600 |
] whileTrue. |
|
1601 |
||
1602 |
"/ handle any expose events (for subcomponents) before |
|
1603 |
"/ redrawing the handles. |
|
1604 |
Delay waitForSeconds:0.05. |
|
1605 |
[self sensor hasExposeEventFor:nil] whileTrue:[ |
|
1606 |
self windowGroup processExposeEvents |
|
1607 |
] |
|
1608 |
]. |
|
1609 |
! |
|
1610 |
||
113 | 1611 |
moveSelectionDown |
61 | 1612 |
"move selection down |
1613 |
" |
|
138 | 1614 |
|gridY n| |
1615 |
||
1616 |
gridAlign notNil ifTrue:[gridY := gridAlign y] |
|
1617 |
ifFalse:[gridY := 1]. |
|
1618 |
||
1619 |
self moveDo:[:aView| |
|
1620 |
aligning ifTrue:[ |
|
1621 |
n := ((aView computeCorner y) \\ gridY). |
|
1622 |
||
1623 |
n ~~ 0 ifTrue:[ |
|
1624 |
n := gridY - n + 1. |
|
1625 |
] ifFalse:[ |
|
1626 |
n := gridY |
|
61 | 1627 |
] |
138 | 1628 |
] ifFalse:[ |
1629 |
n := 1 |
|
60 | 1630 |
]. |
138 | 1631 |
self shiftLayout:aView top:n bottom:n |
60 | 1632 |
] |
1633 |
! |
|
1634 |
||
113 | 1635 |
moveSelectionLeft |
60 | 1636 |
"move selection left |
1637 |
" |
|
113 | 1638 |
|gridX n| |
60 | 1639 |
|
138 | 1640 |
gridAlign notNil ifTrue:[gridX := gridAlign x] |
1641 |
ifFalse:[gridX := 1]. |
|
1642 |
||
1643 |
self moveDo:[:aView| |
|
1644 |
aligning ifTrue:[ |
|
1645 |
n := ((aView computeOrigin x) \\ gridX). |
|
1646 |
n == 0 ifTrue:[n := gridX]. |
|
1647 |
n := n negated. |
|
1648 |
] ifFalse:[ |
|
1649 |
n := -1 |
|
60 | 1650 |
]. |
138 | 1651 |
self shiftLayout:aView left:n right:n |
60 | 1652 |
] |
1653 |
! |
|
1654 |
||
113 | 1655 |
moveSelectionRight |
1656 |
"move selection right |
|
1657 |
" |
|
1658 |
|gridX n| |
|
1659 |
||
138 | 1660 |
gridAlign notNil ifTrue:[gridX := gridAlign x] |
1661 |
ifFalse:[gridX := 1]. |
|
1662 |
||
1663 |
self moveDo:[:aView| |
|
1664 |
aligning ifTrue:[ |
|
1665 |
n := ((aView computeCorner x) \\ gridX). |
|
1666 |
||
1667 |
n ~~ 0 ifTrue:[n := n negated] |
|
1668 |
ifFalse:[n := gridX] |
|
1669 |
] ifFalse:[ |
|
1670 |
n := 1 |
|
113 | 1671 |
]. |
138 | 1672 |
self shiftLayout:aView left:n right:n |
113 | 1673 |
] |
1674 |
! |
|
1675 |
||
1676 |
moveSelectionUp |
|
60 | 1677 |
"move selection up |
1678 |
" |
|
113 | 1679 |
|gridY n| |
60 | 1680 |
|
138 | 1681 |
gridAlign notNil ifTrue:[gridY := gridAlign y] |
1682 |
ifFalse:[gridY := 1]. |
|
1683 |
||
1684 |
self moveDo:[:aView| |
|
1685 |
aligning ifTrue:[ |
|
1686 |
n := ((aView computeOrigin x) \\ gridY). |
|
1687 |
n == 0 ifTrue:[n := gridY]. |
|
1688 |
n := n negated. |
|
1689 |
] ifFalse:[ |
|
1690 |
n := -1 |
|
60 | 1691 |
]. |
138 | 1692 |
self shiftLayout:aView top:n bottom:n |
60 | 1693 |
] |
1694 |
||
1695 |
! ! |
|
1696 |
||
1697 |
!UIObjectView methodsFor:'user actions - position'! |
|
1698 |
||
1699 |
alignSelectionBottom |
|
61 | 1700 |
"align selection to the bottom of the first object in the selection; in case |
1701 |
of one selection the object is aligned to the bottom of its superview |
|
1702 |
" |
|
128 | 1703 |
|bmost delta sel| |
1704 |
||
1705 |
(sel := self moveableSelection) notNil ifTrue:[ |
|
61 | 1706 |
self withSelectionHiddenDo:[ |
60 | 1707 |
self numberOfSelections > 1 ifTrue:[ |
128 | 1708 |
bmost := (sel first) computeCorner y. |
60 | 1709 |
|
72 | 1710 |
self transaction:#alignBottom selectionDo:[:v| |
60 | 1711 |
(delta := bmost - (v computeCorner y)) ~~ 0 ifTrue:[ |
1712 |
self shiftLayout:v top:delta bottom:delta. |
|
1713 |
] |
|
1714 |
] |
|
1715 |
] ifFalse:[ |
|
72 | 1716 |
self extentToFrame:#Bottom do:[:aLayout| |
63 | 1717 |
aLayout bottomOffset:0. |
1718 |
aLayout bottomFraction:1.0 |
|
60 | 1719 |
] |
1720 |
] |
|
1721 |
]. |
|
225 | 1722 |
self layoutChanged |
60 | 1723 |
] |
1724 |
||
1725 |
||
1726 |
||
1727 |
! |
|
1728 |
||
1729 |
alignSelectionCenterHor |
|
61 | 1730 |
"align selection to the center/horizontal of the first object in the selection; in case |
1731 |
of one selection the object is aligned to the center/horizontal of its superview |
|
1732 |
" |
|
128 | 1733 |
|view center sel| |
1734 |
||
1735 |
(sel := self moveableSelection) notNil ifTrue:[ |
|
61 | 1736 |
self withSelectionHiddenDo:[ |
60 | 1737 |
view := self singleSelection. |
1738 |
||
1739 |
view notNil ifTrue:[ |
|
284 | 1740 |
|
1741 |
view := self findContainerOfView:view. |
|
60 | 1742 |
center := view computeExtent |
1743 |
] ifFalse:[ |
|
128 | 1744 |
view := sel first. |
60 | 1745 |
center := view computeCorner + view computeOrigin. |
1746 |
]. |
|
1747 |
center := center x // 2. |
|
1748 |
||
72 | 1749 |
self transaction:#alignCenterHorizontal selectionDo:[:v| |
60 | 1750 |
|newX oldX delta| |
1751 |
||
1752 |
oldX := v computeOrigin x. |
|
1753 |
newX := center - ((v computeCorner x - oldX) // 2). |
|
1754 |
delta := newX - oldX. |
|
1755 |
||
1756 |
self shiftLayout:v left:delta right:delta |
|
61 | 1757 |
] |
1758 |
]. |
|
225 | 1759 |
self layoutChanged |
60 | 1760 |
] |
1761 |
||
1762 |
||
1763 |
||
1764 |
! |
|
1765 |
||
1766 |
alignSelectionCenterVer |
|
61 | 1767 |
"align selection to the center/vertical of the first object in the selection; in case |
1768 |
of one selection the object is aligned to the center/vertical of its superview |
|
1769 |
" |
|
128 | 1770 |
|view center sel| |
1771 |
||
1772 |
(sel := self moveableSelection) notNil ifTrue:[ |
|
61 | 1773 |
self withSelectionHiddenDo:[ |
60 | 1774 |
view := self singleSelection. |
1775 |
||
1776 |
view notNil ifTrue:[ |
|
284 | 1777 |
view := self findContainerOfView:view. |
60 | 1778 |
center := view computeExtent |
1779 |
] ifFalse:[ |
|
128 | 1780 |
view := sel first. |
60 | 1781 |
center := view computeCorner + view computeOrigin. |
1782 |
]. |
|
1783 |
center := center y // 2. |
|
1784 |
||
72 | 1785 |
self transaction:#alignCenterVertical selectionDo:[:v| |
60 | 1786 |
|newY oldY delta| |
1787 |
||
1788 |
oldY := v computeOrigin y. |
|
1789 |
newY := center - ((v computeCorner y - oldY) // 2). |
|
1790 |
delta := newY - oldY. |
|
1791 |
||
1792 |
self shiftLayout:v top:delta bottom:delta |
|
61 | 1793 |
] |
1794 |
]. |
|
225 | 1795 |
self layoutChanged |
60 | 1796 |
] |
1797 |
! |
|
1798 |
||
1799 |
alignSelectionLeft |
|
61 | 1800 |
"align selection to the left of the first object in the selection; in case |
1801 |
of one selection the object is aligned to the left of its superview |
|
1802 |
" |
|
128 | 1803 |
|lmost delta sel| |
1804 |
||
1805 |
(sel := self moveableSelection) notNil ifTrue:[ |
|
61 | 1806 |
self withSelectionHiddenDo:[ |
60 | 1807 |
self numberOfSelections > 1 ifTrue:[ |
128 | 1808 |
lmost := (sel first) computeOrigin x. |
60 | 1809 |
|
72 | 1810 |
self transaction:#alignLeft selectionDo:[:v| |
60 | 1811 |
(delta := lmost - (v computeOrigin x)) ~~ 0 ifTrue:[ |
1812 |
self shiftLayout:v left:delta right:delta |
|
1813 |
] |
|
1814 |
] |
|
1815 |
] ifFalse:[ |
|
72 | 1816 |
self extentToFrame:#Left do:[:aLayout| |
63 | 1817 |
aLayout leftOffset:0. |
1818 |
aLayout leftFraction:0.0. |
|
60 | 1819 |
] |
1820 |
] |
|
1821 |
]. |
|
225 | 1822 |
self layoutChanged |
60 | 1823 |
] |
1824 |
! |
|
1825 |
||
1826 |
alignSelectionLeftAndRight |
|
61 | 1827 |
"align selection to the left/right of the first object in the selection; in case |
1828 |
of one selection the object is aligned to the left/right of its superview |
|
1829 |
" |
|
128 | 1830 |
|lmost rmost sel| |
1831 |
||
1832 |
(sel := self moveableSelection) notNil ifTrue:[ |
|
61 | 1833 |
self withSelectionHiddenDo:[ |
60 | 1834 |
self numberOfSelections > 1 ifTrue:[ |
128 | 1835 |
lmost := (sel first) computeOrigin x. |
1836 |
rmost := (sel first) computeCorner x. |
|
60 | 1837 |
|
72 | 1838 |
self transaction:#alignLeftRight selectionDo:[:aView| |
1839 |
|layout| |
|
1840 |
layout := self class asLayoutFrameFromView:aView. |
|
1841 |
||
1842 |
layout notNil ifTrue:[ |
|
134 | 1843 |
self createUndoLayout:aView. |
72 | 1844 |
aView geometryLayout:layout. |
1845 |
||
134 | 1846 |
undoHistory withoutTransactionDo:[ |
72 | 1847 |
self shiftLayout:aView left:(lmost - (aView computeOrigin x)) |
1848 |
right:(rmost - (aView computeCorner x)). |
|
1849 |
]. |
|
1850 |
self elementChangedSize:aView |
|
1851 |
] |
|
60 | 1852 |
] |
1853 |
] ifFalse:[ |
|
72 | 1854 |
self extentToFrame:#LeftRight do:[:aLayout| |
63 | 1855 |
aLayout leftOffset:0. |
1856 |
aLayout leftFraction:0.0. |
|
1857 |
aLayout rightOffset:0. |
|
1858 |
aLayout rightFraction:1.0. |
|
60 | 1859 |
] |
1860 |
] |
|
1861 |
]. |
|
225 | 1862 |
self layoutChanged |
61 | 1863 |
]. |
1864 |
||
60 | 1865 |
! |
1866 |
||
1867 |
alignSelectionRight |
|
61 | 1868 |
"align selection to the right of the first object in the selection; in case |
1869 |
of one selection the object is aligned to the right of its superview |
|
1870 |
" |
|
128 | 1871 |
|rmost delta sel| |
1872 |
||
1873 |
(sel := self moveableSelection) notNil ifTrue:[ |
|
61 | 1874 |
self withSelectionHiddenDo:[ |
60 | 1875 |
self numberOfSelections > 1 ifTrue:[ |
128 | 1876 |
rmost := (sel first) computeCorner x. |
60 | 1877 |
|
72 | 1878 |
self transaction:#alignRight selectionDo:[:v| |
60 | 1879 |
(delta := rmost - (v computeCorner x)) ~~ 0 ifTrue:[ |
1880 |
self shiftLayout:v left:delta right:delta |
|
1881 |
] |
|
1882 |
] |
|
1883 |
] ifFalse:[ |
|
72 | 1884 |
self extentToFrame:#Right do:[:aLayout| |
63 | 1885 |
aLayout rightOffset:0. |
1886 |
aLayout rightFraction:1.0. |
|
60 | 1887 |
] |
1888 |
] |
|
1889 |
]. |
|
225 | 1890 |
self layoutChanged |
60 | 1891 |
] |
1892 |
! |
|
1893 |
||
1894 |
alignSelectionTop |
|
61 | 1895 |
"align selection to the top of the first object in the selection; in case |
1896 |
of one selection the object is aligned to the top of its superview |
|
1897 |
" |
|
128 | 1898 |
|tmost delta sel| |
1899 |
||
1900 |
(sel := self moveableSelection) notNil ifTrue:[ |
|
61 | 1901 |
self withSelectionHiddenDo:[ |
60 | 1902 |
self numberOfSelections > 1 ifTrue:[ |
128 | 1903 |
tmost := (sel first) computeOrigin y. |
60 | 1904 |
|
72 | 1905 |
self transaction:#alignTop selectionDo:[:v| |
60 | 1906 |
(delta := tmost - (v computeOrigin y)) ~~ 0 ifTrue:[ |
1907 |
self shiftLayout:v top:delta bottom:delta |
|
1908 |
] |
|
1909 |
] |
|
1910 |
] ifFalse:[ |
|
72 | 1911 |
self extentToFrame:#Top do:[:aLayout| |
63 | 1912 |
aLayout topOffset:0. |
1913 |
aLayout topFraction:0.0. |
|
60 | 1914 |
] |
1915 |
] |
|
1916 |
]. |
|
225 | 1917 |
self layoutChanged |
60 | 1918 |
] |
1919 |
||
1920 |
! |
|
1921 |
||
1922 |
alignSelectionTopAndBottom |
|
61 | 1923 |
"align selection to the top/bottom of the first object in the selection; in case |
1924 |
of one selection the object is aligned to the top/bottom of its superview |
|
1925 |
" |
|
128 | 1926 |
|tmost bmost sel| |
1927 |
||
1928 |
(sel := self moveableSelection) notNil ifTrue:[ |
|
61 | 1929 |
self withSelectionHiddenDo:[ |
60 | 1930 |
self numberOfSelections > 1 ifTrue:[ |
128 | 1931 |
tmost := (sel first) computeOrigin y. |
1932 |
bmost := (sel first) computeCorner y. |
|
60 | 1933 |
|
72 | 1934 |
self transaction:#alignTopBottom selectionDo:[:aView| |
1935 |
|layout| |
|
1936 |
layout := self class asLayoutFrameFromView:aView. |
|
1937 |
||
1938 |
layout notNil ifTrue:[ |
|
134 | 1939 |
self createUndoLayout:aView. |
72 | 1940 |
aView geometryLayout:layout. |
1941 |
||
134 | 1942 |
undoHistory withoutTransactionDo:[ |
72 | 1943 |
self shiftLayout:aView top:(tmost - (aView computeOrigin y)) |
1944 |
bottom:(bmost - (aView computeCorner y)). |
|
1945 |
]. |
|
1946 |
self elementChangedSize:aView |
|
1947 |
] |
|
60 | 1948 |
] |
1949 |
] ifFalse:[ |
|
72 | 1950 |
self extentToFrame:#TopBottom do:[:aLayout| |
63 | 1951 |
aLayout topOffset:0. |
1952 |
aLayout topFraction:0.0. |
|
1953 |
aLayout bottomOffset:0. |
|
1954 |
aLayout bottomFraction:1.0. |
|
60 | 1955 |
] |
1956 |
] |
|
1957 |
]. |
|
225 | 1958 |
self layoutChanged |
60 | 1959 |
] |
1960 |
! |
|
1961 |
||
1962 |
centerSelection:aOneArgBlockXorY orientation:orientation |
|
1963 |
"center selection horizontal or vertical dependant on the block result( x or y). |
|
1964 |
The argument to the block is the point. |
|
1965 |
" |
|
1966 |
|superview min max delta val| |
|
1967 |
||
128 | 1968 |
(self moveableSelection) isNil ifTrue:[ |
61 | 1969 |
^ self |
1970 |
]. |
|
1971 |
||
1972 |
self withSelectionHiddenDo:[ |
|
60 | 1973 |
max := 0. |
1974 |
||
1975 |
self selectionDo:[:aView | |
|
1976 |
superview isNil ifTrue:[ |
|
284 | 1977 |
superview := self findContainerOfView:aView |
60 | 1978 |
] ifFalse:[ |
284 | 1979 |
(self findContainerOfView:aView) == superview ifFalse:[ |
60 | 1980 |
^ self notify:'views must have same superview'. |
1981 |
] |
|
1982 |
]. |
|
1983 |
val := aOneArgBlockXorY value:(aView computeOrigin). |
|
1984 |
||
1985 |
min isNil ifTrue:[min := val] |
|
1986 |
ifFalse:[min := min min:val]. |
|
1987 |
||
1988 |
val := aOneArgBlockXorY value:(aView computeCorner). |
|
1989 |
max := max max:val. |
|
1990 |
]. |
|
1991 |
||
1992 |
val := aOneArgBlockXorY value:(superview computeExtent). |
|
1993 |
max := (min + val - max) // 2. |
|
1994 |
||
1995 |
max == min ifFalse:[ |
|
72 | 1996 |
|type| |
1997 |
(orientation == #y) ifTrue:[type := #centerVertical] |
|
1998 |
ifFalse:[type := #centerHorizontal]. |
|
60 | 1999 |
delta := max - min. |
2000 |
||
72 | 2001 |
self transaction:type selectionDo:[:v| |
60 | 2002 |
orientation == #y ifTrue:[ |
2003 |
self shiftLayout:v top:delta bottom:delta |
|
2004 |
] ifFalse:[ |
|
2005 |
self shiftLayout:v left:delta right:delta |
|
2006 |
] |
|
61 | 2007 |
] |
2008 |
]. |
|
225 | 2009 |
self layoutChanged |
60 | 2010 |
] |
2011 |
||
2012 |
||
2013 |
! |
|
2014 |
||
2015 |
centerSelectionHor |
|
2016 |
"center selection horizontal |
|
2017 |
" |
|
2018 |
self centerSelection:[:aPoint| aPoint x] orientation:#x |
|
2019 |
||
2020 |
||
2021 |
! |
|
2022 |
||
2023 |
centerSelectionVer |
|
2024 |
"center selection vertical |
|
2025 |
" |
|
2026 |
self centerSelection:[:aPoint| aPoint y] orientation:#y |
|
2027 |
! |
|
2028 |
||
72 | 2029 |
extentToFrame:toWhat do:aBlock |
2030 |
"align to frame (Left Right ...) and perform the block on a frameLayout |
|
2031 |
" |
|
2032 |
|layout type| |
|
2033 |
||
2034 |
type := ('extent', toWhat asString) asSymbol. |
|
2035 |
||
2036 |
self transaction:type selectionDo:[:aView| |
|
2037 |
layout := self class asLayoutFrameFromView:aView. |
|
2038 |
||
2039 |
layout notNil ifTrue:[ |
|
134 | 2040 |
self createUndoLayout:aView. |
72 | 2041 |
aBlock value:layout. |
2042 |
aView geometryLayout:layout. |
|
2043 |
self elementChangedSize:aView. |
|
2044 |
] |
|
2045 |
] |
|
2046 |
! |
|
2047 |
||
60 | 2048 |
spreadSelectionHor |
61 | 2049 |
"spread multiple selection horizontal |
2050 |
" |
|
128 | 2051 |
|sumWidths min max viewsInOrder topsInOrder count space sel| |
2052 |
||
2053 |
sel := self moveableSelection. |
|
2054 |
||
2055 |
(sel notNil and:[self numberOfSelections > 1]) ifFalse:[ |
|
60 | 2056 |
^ self |
2057 |
]. |
|
2058 |
||
61 | 2059 |
self withSelectionHiddenDo:[ |
60 | 2060 |
count := 0. |
2061 |
sumWidths := 0. |
|
2062 |
max := 0. |
|
2063 |
||
2064 |
self selectionDo:[:aView | |
|
2065 |
sumWidths := sumWidths + aView width. |
|
2066 |
||
2067 |
min isNil ifTrue:[min := aView left] |
|
2068 |
ifFalse:[min := min min:(aView left)]. |
|
2069 |
||
2070 |
max := max max:(aView right). |
|
2071 |
count := count + 1 |
|
2072 |
]. |
|
128 | 2073 |
viewsInOrder := Array withAll:sel. |
60 | 2074 |
topsInOrder := viewsInOrder collect:[:aView | aView left]. |
2075 |
topsInOrder sortWith:viewsInOrder. |
|
2076 |
||
2077 |
space := (((max - min) - sumWidths) / (count - 1)) rounded asInteger. |
|
2078 |
||
72 | 2079 |
self transaction:#spreadHorizontal objects:viewsInOrder do:[:aView| |
60 | 2080 |
|delta| |
2081 |
||
2082 |
delta := min - aView computeOrigin x. |
|
2083 |
self shiftLayout:aView left:delta right:delta. |
|
2084 |
min := min + aView computeExtent x + space |
|
61 | 2085 |
] |
2086 |
]. |
|
225 | 2087 |
self layoutChanged |
60 | 2088 |
|
2089 |
! |
|
2090 |
||
2091 |
spreadSelectionVer |
|
61 | 2092 |
"spread multiple selection vertical |
2093 |
" |
|
128 | 2094 |
|sumHeights min max viewsInOrder topsInOrder count space sel| |
2095 |
||
2096 |
sel := self moveableSelection. |
|
2097 |
||
2098 |
(sel notNil and:[self numberOfSelections > 1]) ifFalse:[ |
|
60 | 2099 |
^ self |
2100 |
]. |
|
2101 |
||
61 | 2102 |
self withSelectionHiddenDo:[ |
60 | 2103 |
count := 0. |
2104 |
sumHeights := 0. |
|
2105 |
max := 0. |
|
2106 |
||
2107 |
self selectionDo:[:aView | |
|
2108 |
sumHeights := sumHeights + aView height. |
|
2109 |
||
2110 |
min isNil ifTrue:[min := aView top] |
|
2111 |
ifFalse:[min := min min:(aView top)]. |
|
2112 |
||
2113 |
max := max max:(aView bottom). |
|
2114 |
count := count + 1 |
|
2115 |
]. |
|
128 | 2116 |
viewsInOrder := Array withAll:sel. |
60 | 2117 |
topsInOrder := viewsInOrder collect:[:aView|aView top]. |
2118 |
topsInOrder sortWith:viewsInOrder. |
|
2119 |
||
2120 |
space := (((max - min) - sumHeights) / (count - 1)) rounded asInteger. |
|
2121 |
||
72 | 2122 |
self transaction:#spreadVertical objects:viewsInOrder do:[:aView| |
60 | 2123 |
|delta| |
2124 |
||
2125 |
delta := min - aView computeOrigin y. |
|
2126 |
self shiftLayout:aView top:delta bottom:delta. |
|
2127 |
min := min + aView height + space |
|
61 | 2128 |
] |
2129 |
]. |
|
225 | 2130 |
self layoutChanged |
60 | 2131 |
! ! |
2132 |
||
2133 |
!UIObjectView methodsFor:'user actions - undo history'! |
|
2134 |
||
72 | 2135 |
enableUndoHistory:aState |
2136 |
"enable or disable undo history |
|
2137 |
" |
|
2138 |
undoHistory enabled:aState |
|
2139 |
! |
|
2140 |
||
60 | 2141 |
openUndoMenu |
61 | 2142 |
"open undo menu |
2143 |
" |
|
149 | 2144 |
self select:nil. |
138 | 2145 |
undoHistory openUndoMenu |
60 | 2146 |
! |
2147 |
||
2148 |
removeUndoHistory |
|
2149 |
"delete total undo history |
|
2150 |
" |
|
134 | 2151 |
undoHistory on:self |
60 | 2152 |
! |
2153 |
||
2154 |
undoLast |
|
61 | 2155 |
"undo last action |
2156 |
" |
|
138 | 2157 |
|newSel oldSel| |
2158 |
||
134 | 2159 |
undoHistory isEmpty ifFalse:[ |
138 | 2160 |
self hasSelection ifTrue:[ |
2161 |
oldSel := OrderedCollection new. |
|
2162 |
newSel := OrderedCollection new. |
|
2163 |
||
2164 |
self selectionDo:[:aView||p| |
|
2165 |
(p := self propertyOfView:aView) notNil ifTrue:[ |
|
2166 |
oldSel add:(p identifier) |
|
2167 |
] |
|
2168 |
]. |
|
2169 |
self setSelection:nil withRedraw:true. |
|
2170 |
]. |
|
2171 |
||
2172 |
self withSelectionHiddenDo:[undoHistory undoLast:1]. |
|
2173 |
||
2174 |
oldSel notNil ifTrue:[ |
|
2175 |
oldSel do:[:id||v| |
|
145 | 2176 |
(v := self findViewWithId:id) notNil ifTrue:[newSel add:v] |
138 | 2177 |
]. |
2178 |
self select:newSel. |
|
134 | 2179 |
] |
61 | 2180 |
]. |
60 | 2181 |
! ! |
2182 |
||
543
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2183 |
!UIObjectView::ResizeData methodsFor:'accessing'! |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2184 |
|
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2185 |
delta |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2186 |
^ delta |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2187 |
|
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2188 |
"Created: / 2.2.1998 / 13:40:32 / cg" |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2189 |
! |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2190 |
|
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2191 |
object |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2192 |
^ object |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2193 |
|
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2194 |
"Created: / 2.2.1998 / 13:40:24 / cg" |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2195 |
! |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2196 |
|
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2197 |
object:anObject selector:aSymbol delta:anInteger |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2198 |
object := anObject. |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2199 |
selector := aSymbol. |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2200 |
delta := anInteger. |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2201 |
|
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2202 |
"Created: / 2.2.1998 / 13:39:22 / cg" |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2203 |
! |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2204 |
|
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2205 |
selector |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2206 |
^ selector |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2207 |
|
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2208 |
"Created: / 2.2.1998 / 13:40:42 / cg" |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2209 |
! ! |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2210 |
|
60 | 2211 |
!UIObjectView::UndoHistory class methodsFor:'constants'! |
2212 |
||
2213 |
maxHistorySize |
|
2214 |
"returns maximum size of history before removing oldest |
|
2215 |
record |
|
2216 |
" |
|
134 | 2217 |
^ 100 |
60 | 2218 |
|
2219 |
||
2220 |
! ! |
|
2221 |
||
131 | 2222 |
!UIObjectView::UndoHistory class methodsFor:'documentation'! |
2223 |
||
2224 |
documentation |
|
2225 |
" |
|
2226 |
undo history used by the UIPainter-Tool; to each operation, an undo block |
|
2227 |
and some text is stored. In case of a required undo, the corresponding |
|
2228 |
undo block will be performed. |
|
2229 |
||
2230 |
[see also:] |
|
2231 |
UIObjectView |
|
2232 |
UIPainterView |
|
156 | 2233 |
|
2234 |
[author:] |
|
2235 |
Claus Atzkern |
|
131 | 2236 |
" |
2237 |
||
2238 |
||
2239 |
! ! |
|
2240 |
||
60 | 2241 |
!UIObjectView::UndoHistory class methodsFor:'instance creation'! |
2242 |
||
134 | 2243 |
on:aPainter |
2244 |
|history| |
|
2245 |
||
2246 |
history := self new. |
|
2247 |
history on:aPainter. |
|
2248 |
^ history |
|
60 | 2249 |
|
2250 |
||
2251 |
! ! |
|
2252 |
||
2253 |
!UIObjectView::UndoHistory methodsFor:'accessing'! |
|
2254 |
||
134 | 2255 |
addUndoSelector:aSelector withArgs:anArray |
2256 |
"add a selector with arguments to the current opened transaction; in case that no |
|
2257 |
transaction is opened or disabled the block will not be kept in the history. |
|
2258 |
" |
|
2259 |
self isTransactionOpen ifTrue:[ |
|
2260 |
transaction add:(Association key:aSelector value:anArray) |
|
2261 |
] |
|
2262 |
||
2263 |
||
2264 |
! ! |
|
2265 |
||
2266 |
!UIObjectView::UndoHistory methodsFor:'accessing behavior'! |
|
2267 |
||
72 | 2268 |
enabled |
2269 |
^ enabled |
|
2270 |
! |
|
2271 |
||
2272 |
enabled:aState |
|
2273 |
enabled := aState |
|
2274 |
! |
|
2275 |
||
134 | 2276 |
resetModification |
2277 |
"set modification state to false |
|
2278 |
" |
|
2279 |
startIdentifier := identifier |
|
2280 |
! ! |
|
2281 |
||
2282 |
!UIObjectView::UndoHistory methodsFor:'activation'! |
|
2283 |
||
2284 |
withinTransaction:aType text:aTextOrNil do:aBlock |
|
2285 |
"open a transaction; perform the block; at least close the transaction |
|
72 | 2286 |
" |
134 | 2287 |
(enabled and:[transaction isNil]) ifTrue:[ |
2288 |
transaction := Transaction type:aType text:aTextOrNil. |
|
2289 |
||
2290 |
aBlock value. |
|
2291 |
||
2292 |
transaction isEmpty ifFalse:[ |
|
2293 |
identifier := identifier + 1. |
|
2294 |
transaction identifier:identifier. |
|
2295 |
history addLast:transaction. |
|
2296 |
history size > (self class maxHistorySize) ifTrue:[history removeFirst] |
|
2297 |
]. |
|
2298 |
transaction := nil |
|
2299 |
||
2300 |
] ifFalse:[ |
|
2301 |
aBlock value |
|
2302 |
] |
|
2303 |
! |
|
2304 |
||
2305 |
withoutTransactionDo:aNoneArgBlock |
|
2306 |
"evaluate the block without opening a transaction or keeping changes |
|
2307 |
within a still opened transaction |
|
2308 |
" |
|
2309 |
|oldState| |
|
2310 |
||
2311 |
oldState := enabled. |
|
2312 |
enabled := false. |
|
2313 |
aNoneArgBlock value. |
|
2314 |
enabled := oldState. |
|
60 | 2315 |
! ! |
2316 |
||
2317 |
!UIObjectView::UndoHistory methodsFor:'initialization'! |
|
2318 |
||
134 | 2319 |
on:aPainter |
2320 |
"setup for a painter and delete all existing history records |
|
60 | 2321 |
" |
134 | 2322 |
identifier := 0. |
2323 |
startIdentifier := 0. |
|
2324 |
||
2325 |
painter := aPainter. |
|
60 | 2326 |
history := OrderedCollection new. |
2327 |
transaction := nil. |
|
2328 |
enabled := true. |
|
2329 |
||
2330 |
||
2331 |
! ! |
|
2332 |
||
2333 |
!UIObjectView::UndoHistory methodsFor:'menu'! |
|
2334 |
||
2335 |
openUndoMenu |
|
72 | 2336 |
|list tabs top slv hzp inset selection okButton| |
60 | 2337 |
|
2338 |
history isEmpty ifTrue:[ |
|
2339 |
^ self |
|
2340 |
]. |
|
2341 |
||
2342 |
top := StandardSystemView new label:'undo history'; extent:250@350. |
|
2343 |
slv := ScrollableView for:SelectionInListView origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
2344 |
hzp := HorizontalPanelView origin:0.0@1.0 corner:1.0@1.0 in:top. |
|
2345 |
hzp horizontalLayout:#fitSpace. |
|
2346 |
||
2347 |
(Button abortButtonIn:hzp) action:[ selection := nil. top destroy ]. |
|
2348 |
okButton := Button okButtonIn:hzp. |
|
2349 |
okButton label:'undo to end'. |
|
2350 |
okButton action:[ top destroy ]. |
|
2351 |
||
2352 |
inset := hzp preferredExtent y. |
|
2353 |
hzp topInset:(inset negated). |
|
2354 |
slv bottomInset:inset. |
|
2355 |
slv := slv scrolledView. |
|
2356 |
||
72 | 2357 |
tabs := TabulatorSpecification new. |
2358 |
tabs unit:#cm. |
|
2359 |
tabs positions:#(0 5). |
|
208 | 2360 |
tabs align:#(#left #left). |
72 | 2361 |
|
60 | 2362 |
list := history collect:[:aTrans||e| |
2363 |
e := MultiColListEntry new. |
|
72 | 2364 |
e colAt:1 put:(aTrans typeAsString). |
60 | 2365 |
e colAt:2 put:(aTrans text ? ''). |
72 | 2366 |
e tabulatorSpecification:tabs. |
60 | 2367 |
e |
2368 |
]. |
|
2369 |
||
2370 |
slv list:list. |
|
2371 |
slv action:[:index | selection := index ]. |
|
2372 |
top openModal. |
|
2373 |
||
2374 |
selection notNil ifTrue:[ |
|
2375 |
self undoLast:(history size - selection + 1). |
|
2376 |
] |
|
2377 |
! ! |
|
2378 |
||
2379 |
!UIObjectView::UndoHistory methodsFor:'testing'! |
|
2380 |
||
2381 |
isEmpty |
|
2382 |
"returns true if undo history is empty |
|
2383 |
" |
|
2384 |
^ history isEmpty |
|
2385 |
||
2386 |
||
2387 |
! |
|
2388 |
||
134 | 2389 |
isModified |
2390 |
"returns true if history is modified |
|
2391 |
" |
|
2392 |
self isEmpty ifTrue:[ |
|
2393 |
^ false |
|
2394 |
]. |
|
2395 |
^ history last identifier ~~ startIdentifier |
|
2396 |
! |
|
2397 |
||
60 | 2398 |
isTransactionOpen |
2399 |
^ (enabled and:[transaction notNil]) |
|
2400 |
! ! |
|
2401 |
||
2402 |
!UIObjectView::UndoHistory methodsFor:'undo'! |
|
2403 |
||
2404 |
undoLast:nTransactions |
|
2405 |
"undo last n transactions; an open transaction will be closed; |
|
2406 |
transactions during undo are disabled |
|
2407 |
" |
|
134 | 2408 |
|repeatTimes transaction actions| |
60 | 2409 |
|
2410 |
transaction := nil. |
|
134 | 2411 |
enabled := false. |
2412 |
repeatTimes := nTransactions min:(history size). |
|
2413 |
||
2414 |
repeatTimes timesRepeat:[ |
|
2415 |
transaction := history removeLast. |
|
2416 |
actions := transaction actions. |
|
2417 |
||
2418 |
actions isCollection ifTrue:[ |
|
2419 |
actions reverseDo:[:aBlock| |
|
2420 |
painter perform:(aBlock key) with:(aBlock value) |
|
2421 |
] |
|
2422 |
] ifFalse:[ |
|
2423 |
painter perform:(actions key) with:(actions value) |
|
2424 |
] |
|
2425 |
]. |
|
2426 |
enabled := true. |
|
60 | 2427 |
! ! |
2428 |
||
2429 |
!UIObjectView::UndoHistory::Transaction class methodsFor:'documentation'! |
|
2430 |
||
131 | 2431 |
documentation |
2432 |
" |
|
2433 |
represents one undo record, keeping the associated type and printable text |
|
2434 |
and the undo action performed on an undo request |
|
2435 |
||
2436 |
[see also:] |
|
2437 |
UndoHistory |
|
156 | 2438 |
|
2439 |
[author:] |
|
2440 |
Claus Atzkern |
|
131 | 2441 |
" |
2442 |
||
60 | 2443 |
! ! |
2444 |
||
54 | 2445 |
!UIObjectView::UndoHistory::Transaction class methodsFor:'instance creation'! |
2446 |
||
2447 |
type:aType text:aTextOrNil |
|
2448 |
^ self new type:aType text:aTextOrNil |
|
2449 |
||
2450 |
||
2451 |
! ! |
|
2452 |
||
2453 |
!UIObjectView::UndoHistory::Transaction methodsFor:'accessing'! |
|
2454 |
||
134 | 2455 |
actions |
2456 |
"returns actions associated with transaction |
|
2457 |
" |
|
2458 |
^ actions |
|
2459 |
! |
|
2460 |
||
2461 |
identifier |
|
2462 |
"gets my identifier |
|
2463 |
" |
|
2464 |
^ identifier |
|
2465 |
! |
|
2466 |
||
2467 |
identifier:anIdentifier |
|
2468 |
"sets my identifier |
|
2469 |
" |
|
2470 |
identifier := anIdentifier |
|
2471 |
! |
|
2472 |
||
54 | 2473 |
text |
134 | 2474 |
"returns text or nil assigned to transaction |
54 | 2475 |
" |
2476 |
^ text |
|
2477 |
! |
|
2478 |
||
2479 |
type |
|
134 | 2480 |
"returns type assigned to transaction |
54 | 2481 |
" |
2482 |
^ type |
|
2483 |
! |
|
2484 |
||
2485 |
type:aType |
|
134 | 2486 |
"change type assigned to transaction |
54 | 2487 |
" |
2488 |
type := aType |
|
72 | 2489 |
! |
2490 |
||
2491 |
typeAsString |
|
2492 |
"returns type as printable string |
|
2493 |
" |
|
2494 |
|line name size sep| |
|
2495 |
||
2496 |
line := type asString. |
|
2497 |
size := 0. |
|
2498 |
line do:[:c| (c isUppercase) ifTrue:[size := size+1] ]. |
|
2499 |
name := String new:(line size + size). |
|
2500 |
size := 1. |
|
2501 |
sep := Character space. |
|
2502 |
||
2503 |
line do:[:c| |
|
2504 |
(c isUppercase) ifFalse:[ |
|
2505 |
name at:size put:c |
|
2506 |
] ifTrue:[ |
|
2507 |
name at:size put:sep. |
|
2508 |
sep := $&. |
|
2509 |
size := size + 1. |
|
2510 |
name at:size put:(c asLowercase) |
|
2511 |
]. |
|
2512 |
size := size + 1 |
|
2513 |
]. |
|
2514 |
^ name |
|
54 | 2515 |
! ! |
2516 |
||
134 | 2517 |
!UIObjectView::UndoHistory::Transaction methodsFor:'adding'! |
54 | 2518 |
|
2519 |
add:anUndoBlock |
|
134 | 2520 |
"add an undo action to the current transaction |
54 | 2521 |
" |
2522 |
actions isNil ifTrue:[ |
|
2523 |
actions := anUndoBlock |
|
2524 |
] ifFalse:[ |
|
2525 |
actions isCollection ifFalse:[ |
|
134 | 2526 |
actions := OrderedCollection with:actions |
47 | 2527 |
]. |
54 | 2528 |
actions add:anUndoBlock. |
2529 |
] |
|
2530 |
! ! |
|
2531 |
||
2532 |
!UIObjectView::UndoHistory::Transaction methodsFor:'initialization'! |
|
2533 |
||
2534 |
type:aType text:aTextOrNil |
|
134 | 2535 |
"initialize transaction |
54 | 2536 |
" |
2537 |
type := aType. |
|
2538 |
text := aTextOrNil. |
|
2539 |
! ! |
|
2540 |
||
2541 |
!UIObjectView::UndoHistory::Transaction methodsFor:'testing'! |
|
2542 |
||
2543 |
isEmpty |
|
2544 |
"returns true if no undo action is registered |
|
2545 |
" |
|
2546 |
^ actions isNil |
|
47 | 2547 |
! ! |
2548 |
||
60 | 2549 |
!UIObjectView class methodsFor:'documentation'! |
2550 |
||
2551 |
version |
|
2552 |
^ '$Header$' |
|
2553 |
! ! |