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