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