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