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