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