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