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