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