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