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