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