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