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