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