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