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