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