author | Claus Gittinger <cg@exept.de> |
Mon, 02 Feb 1998 13:44:17 +0100 | |
changeset 543 | e3f2bf2dfb59 |
parent 374 | 421f8a3723f1 |
child 624 | 26e7978936fc |
permissions | -rw-r--r-- |
156 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by eXept Software AG |
|
3 |
All Rights Reserved |
|
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 |
" |
|
12 |
||
13 |
||
14 |
||
60 | 15 |
ObjectView subclass:#UIObjectView |
123 | 16 |
instanceVariableNames:'saveSelection inputView enableChannel undoHistory copiedExtent |
175 | 17 |
copiedLayout resizeData clipChildren selectionHiddenLevel |
360 | 18 |
gridParameters setOfSuperViewsSizeChanged' |
60 | 19 |
classVariableNames:'' |
20 |
poolDictionaries:'' |
|
21 |
category:'Interface-UIPainter' |
|
22 |
! |
|
23 |
||
543
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
24 |
Object subclass:#ResizeData |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
25 |
instanceVariableNames:'object selector delta' |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
26 |
classVariableNames:'' |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
27 |
poolDictionaries:'' |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
28 |
privateIn:UIObjectView |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
29 |
! |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
30 |
|
60 | 31 |
Object subclass:#UndoHistory |
134 | 32 |
instanceVariableNames:'startIdentifier identifier painter history transaction enabled' |
60 | 33 |
classVariableNames:'' |
34 |
poolDictionaries:'' |
|
35 |
privateIn:UIObjectView |
|
36 |
! |
|
37 |
||
54 | 38 |
Object subclass:#Transaction |
134 | 39 |
instanceVariableNames:'identifier type text actions' |
54 | 40 |
classVariableNames:'' |
41 |
poolDictionaries:'' |
|
42 |
privateIn:UIObjectView::UndoHistory |
|
43 |
! |
|
44 |
||
128 | 45 |
!UIObjectView class methodsFor:'documentation'! |
46 |
||
156 | 47 |
copyright |
48 |
" |
|
49 |
COPYRIGHT (c) 1995 by eXept Software AG |
|
50 |
All Rights Reserved |
|
51 |
||
52 |
This software is furnished under a license and may be used |
|
53 |
only in accordance with the terms of that license and with the |
|
54 |
inclusion of the above copyright notice. This software may not |
|
55 |
be provided or otherwise made available to, or used by, any |
|
56 |
other person. No title to or ownership of the software is |
|
57 |
hereby transferred. |
|
58 |
" |
|
59 |
||
60 |
||
61 |
! |
|
62 |
||
128 | 63 |
documentation |
64 |
" |
|
131 | 65 |
buildIn view used by the UIPainter; it provides all services for creating, deleting |
66 |
moving and changing layouts of painted components on a canvas. |
|
128 | 67 |
|
68 |
[see also:] |
|
69 |
UIBuilder |
|
70 |
UIPainterView |
|
156 | 71 |
|
72 |
[author:] |
|
73 |
Claus Atzkern |
|
128 | 74 |
" |
75 |
||
76 |
! ! |
|
60 | 77 |
|
63 | 78 |
!UIObjectView class methodsFor:'conversion'! |
79 |
||
80 |
asLayoutFrameFromView:aView |
|
81 |
"convert layout from aView to a frameLayout. On success the frameLayout is |
|
82 |
returned otherwise nil |
|
83 |
" |
|
68 | 84 |
|lF lO rF rO tF tO bF bO type layout newLyt| |
85 |
||
86 |
type := self layoutType:aView. |
|
87 |
layout := aView geometryLayout. |
|
88 |
||
91 | 89 |
layout isNil ifTrue:[ |
90 |
type == #Extent ifTrue:[ |
|
91 |
layout := aView bounds asLayout |
|
92 |
] |
|
93 |
]. |
|
94 |
||
68 | 95 |
(type isNil or:[layout isNil]) ifTrue:[ |
63 | 96 |
^ nil |
97 |
]. |
|
98 |
||
68 | 99 |
type == #LayoutFrame ifTrue:[ |
100 |
^ layout copy |
|
101 |
]. |
|
102 |
||
103 |
layout isLayout ifFalse:[ |
|
104 |
type == #Rectangle ifTrue:[ |
|
63 | 105 |
lO := layout left. |
106 |
tO := layout top. |
|
107 |
rO := layout right. |
|
108 |
bO := layout bottom. |
|
109 |
] ifFalse:[ |
|
110 |
lO := layout x. |
|
111 |
tO := layout y. |
|
112 |
rO := lO + aView extent x. |
|
113 |
bO := tO + aView extent y. |
|
114 |
]. |
|
68 | 115 |
|
116 |
^ LayoutFrame leftFraction:0 offset:lO rightFraction:0 offset:rO |
|
117 |
topFraction:0 offset:tO bottomFraction:0 offset:bO |
|
63 | 118 |
]. |
119 |
||
68 | 120 |
lF := layout leftFraction. |
121 |
lO := layout leftOffset. |
|
122 |
tF := layout topFraction. |
|
123 |
tO := layout topOffset. |
|
124 |
bF := tF. |
|
125 |
bO := tO + aView extent y. |
|
126 |
rF := lF. |
|
127 |
rO := lO + aView extent x. |
|
128 |
||
129 |
newLyt := LayoutFrame leftFraction:lF offset:lO rightFraction:rF offset:rO |
|
130 |
topFraction:tF offset:tO bottomFraction:bF offset:bO. |
|
131 |
||
132 |
( (type == #AlignmentOrigin) |
|
133 |
and:[layout leftAlignmentFraction ~~ 0 |
|
134 |
or:[layout topAlignmentFraction ~~ 0]] |
|
135 |
) ifTrue:[ |
|
136 |
|svRc prBd dlta| |
|
137 |
||
138 |
svRc := aView superView viewRectangle. |
|
139 |
prBd := aView preferredBounds. |
|
140 |
dlta := ( ((layout rectangleRelativeTo:svRc preferred:prBd) corner) |
|
141 |
- ((newLyt rectangleRelativeTo:svRc preferred:prBd) corner) |
|
142 |
) rounded. |
|
143 |
||
144 |
newLyt leftOffset:(lO + dlta x). |
|
145 |
newLyt rightOffset:(rO + dlta x). |
|
146 |
newLyt topOffset:(tO + dlta y). |
|
147 |
newLyt bottomOffset:(bO + dlta y). |
|
148 |
]. |
|
149 |
^ newLyt. |
|
91 | 150 |
|
151 |
"Modified: 28.3.1997 / 19:52:48 / cg" |
|
63 | 152 |
! ! |
153 |
||
60 | 154 |
!UIObjectView class methodsFor:'defaults'! |
155 |
||
156 |
defaultGrid |
|
157 |
^ 4 @ 4 |
|
158 |
||
159 |
! |
|
160 |
||
161 |
gridShown |
|
162 |
^ false |
|
163 |
||
164 |
! |
|
165 |
||
166 |
handleSize |
|
167 |
"size of blob drawn for handles" |
|
168 |
^ 4 |
|
169 |
||
170 |
! |
|
171 |
||
172 |
hitDelta |
|
173 |
^ 4 |
|
174 |
||
175 |
! ! |
|
176 |
||
175 | 177 |
!UIObjectView class methodsFor:'handles'! |
178 |
||
179 |
handlesOf:aView do:aBlock |
|
180 |
|type v h| |
|
181 |
||
182 |
type := self layoutType:aView. |
|
183 |
||
184 |
(type == #LayoutFrame or:[type == #Rectangle]) ifTrue:[ |
|
185 |
v := self isVerticalResizable:aView. |
|
186 |
h := self isHorizontalResizable:aView. |
|
187 |
||
188 |
h ifTrue:[ aBlock value:(aView leftCenter ) value:#left. |
|
189 |
aBlock value:(aView rightCenter) value:#right. |
|
190 |
]. |
|
191 |
v ifTrue:[ aBlock value:(aView topCenter ) value:#top. |
|
192 |
aBlock value:(aView bottomCenter) value:#bottom. |
|
193 |
]. |
|
194 |
||
195 |
(h and:[v]) ifTrue:[ |
|
196 |
aBlock value:(aView origin ) value:#origin. |
|
197 |
aBlock value:(aView topRight ) value:#topRight. |
|
198 |
aBlock value:(aView bottomLeft) value:#bottomLeft. |
|
199 |
aBlock value:(aView corner ) value:#corner. |
|
200 |
^ self |
|
201 |
] |
|
202 |
]. |
|
203 |
||
204 |
aBlock value:(aView origin ) value:#view. |
|
205 |
aBlock value:(aView topRight ) value:#view. |
|
206 |
aBlock value:(aView bottomLeft) value:#view. |
|
207 |
||
208 |
type == #Extent ifTrue:[ |
|
209 |
v := self isVerticalResizable:aView. |
|
210 |
h := self isHorizontalResizable:aView. |
|
211 |
||
212 |
v ifTrue:[aBlock value:(aView bottomCenter) value:#bottom]. |
|
213 |
h ifTrue:[aBlock value:(aView rightCenter ) value:#right ]. |
|
214 |
||
215 |
(h and:[v]) ifTrue:[ |
|
216 |
aBlock value:(aView corner) value:#corner. |
|
217 |
^ self |
|
218 |
] |
|
219 |
]. |
|
220 |
aBlock value:(aView corner) value:#view. |
|
221 |
||
222 |
||
223 |
! ! |
|
224 |
||
61 | 225 |
!UIObjectView class methodsFor:'queries'! |
226 |
||
175 | 227 |
isHorizontalResizable:aComponent |
228 |
"returns true if instance is horizontal resizeable |
|
229 |
" |
|
230 |
(aComponent isKindOf:ScrollBar) ifTrue:[ |
|
231 |
^ aComponent orientation == #horizontal |
|
232 |
]. |
|
233 |
(aComponent isKindOf:Scroller) ifTrue:[ |
|
234 |
^ aComponent orientation == #horizontal |
|
235 |
]. |
|
236 |
(aComponent isKindOf:Slider) ifTrue:[ |
|
237 |
^ aComponent orientation == #horizontal |
|
238 |
]. |
|
239 |
^ true |
|
240 |
||
241 |
! |
|
242 |
||
243 |
isVerticalResizable:aComponent |
|
244 |
"returns true if instance is vertical resizeable |
|
245 |
" |
|
246 |
(aComponent isKindOf:EditField) ifTrue:[ |
|
247 |
^ false |
|
248 |
]. |
|
249 |
(aComponent isKindOf:ComboBoxView) ifTrue:[ |
|
250 |
^ false |
|
251 |
]. |
|
252 |
(aComponent isKindOf:CheckBox) ifTrue:[ |
|
253 |
^ false |
|
254 |
]. |
|
255 |
(aComponent isKindOf:ScrollBar) ifTrue:[ |
|
256 |
^ aComponent orientation == #vertical |
|
257 |
]. |
|
258 |
(aComponent isKindOf:Scroller) ifTrue:[ |
|
259 |
^ aComponent orientation == #vertical |
|
260 |
]. |
|
261 |
(aComponent isKindOf:Slider) ifTrue:[ |
|
262 |
^ aComponent orientation == #vertical |
|
263 |
]. |
|
264 |
^ true |
|
265 |
||
266 |
! |
|
267 |
||
61 | 268 |
layoutType:aView |
269 |
"returns layout type of aView or nil |
|
270 |
" |
|
113 | 271 |
|layout spec superView| |
272 |
||
273 |
aView notNil ifTrue:[ |
|
274 |
layout := aView geometryLayout. |
|
275 |
layout notNil ifTrue:[ |
|
276 |
layout isLayout ifTrue:[ |
|
277 |
layout isLayoutFrame ifTrue:[ ^ #LayoutFrame ]. |
|
278 |
layout isAlignmentOrigin ifTrue:[ ^ #AlignmentOrigin ]. |
|
279 |
layout isLayoutOrigin ifTrue:[ ^ #LayoutOrigin ]. |
|
280 |
] ifFalse:[ |
|
281 |
layout isRectangle ifTrue:[ ^ #Rectangle ]. |
|
282 |
layout isPoint ifTrue:[ ^ #Point ]. |
|
283 |
] |
|
61 | 284 |
] ifFalse:[ |
113 | 285 |
(superView := aView superView) notNil ifTrue:[ |
286 |
spec := superView specClass. |
|
287 |
spec canResizeSubComponents ifTrue:[ |
|
288 |
^ #Extent |
|
289 |
] |
|
290 |
] |
|
61 | 291 |
] |
292 |
]. |
|
293 |
^ nil |
|
294 |
||
67 | 295 |
"Modified: 28.2.1997 / 13:02:16 / cg" |
61 | 296 |
! ! |
297 |
||
60 | 298 |
!UIObjectView methodsFor:'accessing'! |
299 |
||
119 | 300 |
enableChannel |
301 |
"returns the channel which keeps false if running test otherwise true |
|
302 |
" |
|
303 |
^ enableChannel |
|
113 | 304 |
! |
305 |
||
60 | 306 |
gridAlign |
61 | 307 |
"returns state of aligning to grid |
308 |
" |
|
60 | 309 |
^ aligning |
310 |
||
311 |
! |
|
312 |
||
313 |
gridAlign:aBool |
|
61 | 314 |
"change state of aligning to grid |
315 |
" |
|
60 | 316 |
aBool ifTrue:[self alignOn] |
317 |
ifFalse:[self alignOff] |
|
318 |
||
319 |
! |
|
320 |
||
321 |
gridParameters |
|
322 |
"used by defineGrid, and in a separate method for |
|
323 |
easier redefinition in subclasses. |
|
324 |
Returns the grid parameters in an array of 7 elements, |
|
325 |
which control the appearance of the grid-pattern. |
|
326 |
the elements are: |
|
327 |
||
328 |
bigStepH number of pixels horizontally between 2 major steps |
|
329 |
bigStepV number of pixels vertically between 2 major steps |
|
330 |
littleStepH number of pixels horizontally between 2 minor steps |
|
331 |
littleStepV number of pixels vertically between 2 minor steps |
|
332 |
gridAlignH number of pixels for horizontal grid align (pointer snap) |
|
333 |
gridAlignV number of pixels for vertical grid align (pointer snap) |
|
334 |
docBounds true, if document boundary should be shown |
|
335 |
||
336 |
if littleStepH/V are nil, only bigSteps are drawn. |
|
337 |
" |
|
360 | 338 |
gridParameters isNil ifTrue:[ |
339 |
gridParameters := #(10 10 nil nil 10 10 false) |
|
340 |
]. |
|
341 |
^ gridParameters |
|
342 |
||
343 |
||
344 |
! |
|
345 |
||
346 |
gridParameters:newGridParameters |
|
347 |
"used by defineGrid, and in a separate method for |
|
348 |
easier redefinition in subclasses. |
|
349 |
Returns the grid parameters in an array of 7 elements, |
|
350 |
which control the appearance of the grid-pattern. |
|
351 |
the elements are: |
|
352 |
||
353 |
bigStepH number of pixels horizontally between 2 major steps |
|
354 |
bigStepV number of pixels vertically between 2 major steps |
|
355 |
littleStepH number of pixels horizontally between 2 minor steps |
|
356 |
littleStepV number of pixels vertically between 2 minor steps |
|
357 |
gridAlignH number of pixels for horizontal grid align (pointer snap) |
|
358 |
gridAlignV number of pixels for vertical grid align (pointer snap) |
|
359 |
docBounds true, if document boundary should be shown |
|
360 |
||
361 |
if littleStepH/V are nil, only bigSteps are drawn. |
|
362 |
" |
|
363 |
newGridParameters size == 7 ifTrue:[ |
|
364 |
gridParameters := newGridParameters |
|
365 |
]. |
|
60 | 366 |
|
367 |
||
368 |
! |
|
369 |
||
370 |
gridShown:aBool |
|
61 | 371 |
"change visibility of grid |
372 |
" |
|
60 | 373 |
aBool ifTrue:[self showGrid] |
374 |
ifFalse:[self hideGrid] |
|
375 |
! |
|
376 |
||
377 |
hideGrid |
|
61 | 378 |
"hide grid |
379 |
" |
|
60 | 380 |
gridShown ifTrue:[ |
61 | 381 |
self withSelectionHiddenDo:[super hideGrid] |
60 | 382 |
] |
383 |
||
384 |
||
385 |
! |
|
386 |
||
387 |
showGrid |
|
61 | 388 |
"show grid |
389 |
" |
|
390 |
self withSelectionHiddenDo:[super showGrid] |
|
119 | 391 |
! ! |
392 |
||
393 |
!UIObjectView methodsFor:'accessing behavior'! |
|
394 |
||
395 |
enabled |
|
396 |
^ enableChannel value |
|
397 |
! |
|
398 |
||
399 |
enabled:aState |
|
400 |
"set the modification / test mode |
|
401 |
" |
|
402 |
(aState == enableChannel value) ifFalse:[ |
|
123 | 403 |
aState ifFalse:[ |
131 | 404 |
saveSelection := self selection. |
405 |
self select:nil. |
|
128 | 406 |
enableChannel value:aState. |
140 | 407 |
inputView unmap. |
119 | 408 |
] ifTrue:[ |
409 |
inputView raise. |
|
123 | 410 |
inputView realize. |
128 | 411 |
enableChannel value:aState. |
123 | 412 |
self select:saveSelection. |
413 |
] |
|
119 | 414 |
] |
415 |
||
416 |
||
417 |
||
60 | 418 |
! |
419 |
||
134 | 420 |
resetModification |
421 |
"set modification state to false |
|
422 |
" |
|
423 |
undoHistory resetModification |
|
424 |
! |
|
425 |
||
60 | 426 |
testMode |
61 | 427 |
"returns true if running test |
60 | 428 |
" |
119 | 429 |
^ enableChannel value not |
60 | 430 |
|
431 |
||
432 |
! |
|
433 |
||
434 |
testMode:aBoolean |
|
61 | 435 |
"change test mode |
60 | 436 |
" |
119 | 437 |
self enabled:(aBoolean not) |
60 | 438 |
! ! |
439 |
||
440 |
!UIObjectView methodsFor:'blocked'! |
|
441 |
||
442 |
addObject:anObject |
|
61 | 443 |
"add the argument, anObject to the contents - with redraw |
444 |
" |
|
60 | 445 |
self halt |
446 |
||
447 |
! |
|
448 |
||
449 |
addObjectWithoutRedraw:anObject |
|
61 | 450 |
"add the argument, anObject to the contents - with redraw |
451 |
" |
|
60 | 452 |
self halt |
453 |
||
175 | 454 |
! |
455 |
||
456 |
startCreate:aPoint |
|
457 |
self setDefaultActions. |
|
458 |
self halt |
|
60 | 459 |
! ! |
460 |
||
461 |
!UIObjectView methodsFor:'event handling'! |
|
462 |
||
61 | 463 |
elementChangedSize:aView |
464 |
"some element has changed its size; collect them during selectionHiddenLevel |
|
465 |
is on |
|
466 |
" |
|
284 | 467 |
|spv| |
468 |
||
469 |
spv := self findContainerOfView:aView. |
|
470 |
||
471 |
selectionHiddenLevel ~~ 0 ifTrue:[setOfSuperViewsSizeChanged add:spv] |
|
472 |
ifFalse:[spv sizeChanged:nil] |
|
60 | 473 |
! |
474 |
||
475 |
exposeX:x y:y width:w height:h |
|
476 |
"handle an expose event from device; redraw selection |
|
477 |
" |
|
175 | 478 |
resizeData isNil ifTrue:[ |
479 |
super exposeX:x y:y width:w height:h. |
|
480 |
||
481 |
"/ handle any expose events (for subcomponents) before |
|
482 |
"/ redrawing the handles. |
|
483 |
(self sensor hasExposeEventFor:nil) ifTrue:[^ self]. |
|
484 |
||
485 |
self selectionDo:[:aComponent | |
|
486 |
aComponent withAllSubViewsDo:[:v | |
|
487 |
self sensor flushExposeEventsFor:v. |
|
488 |
v exposeX:0 y:0 width:9999 height:9999. |
|
489 |
]. |
|
490 |
self showSelected:aComponent |
|
491 |
] |
|
132 | 492 |
] |
60 | 493 |
|
494 |
! |
|
495 |
||
496 |
keyPress:key x:x y:y |
|
61 | 497 |
"any key pressed |
498 |
" |
|
360 | 499 |
<resource: #keyboard ( #Delete #BackSpace #Cut #Copy #Paste #Cmdu ) > |
60 | 500 |
|
501 |
(key == #Cut or:[key == #Delete or:[key == #BackSpace]]) ifTrue: [ |
|
502 |
^ self deleteSelection |
|
503 |
]. |
|
78 | 504 |
key == #Copy ifTrue:[ ^ self copySelection]. |
505 |
key == #Paste ifTrue:[ ^ self pasteBuffer]. |
|
360 | 506 |
key == #Cmdu ifTrue:[ ^ self undoLast ]. "/ #Undo |
507 |
||
374 | 508 |
super keyPress:key x:x y:y |
509 |
||
510 |
"Modified: / 31.10.1997 / 20:28:00 / cg" |
|
60 | 511 |
! |
512 |
||
513 |
processEvent:anEvent |
|
514 |
"catch expose events for components, and redraw its handles after |
|
515 |
the redraw when this happens |
|
516 |
" |
|
128 | 517 |
(anEvent type == #damage and:[self isSelected:(anEvent view)]) ifTrue:[ |
518 |
self showSelected:(anEvent view) |
|
60 | 519 |
]. |
520 |
^ false. |
|
521 |
||
522 |
||
523 |
! |
|
524 |
||
525 |
sizeChanged:how |
|
61 | 526 |
"size of a view(s) changed |
527 |
" |
|
60 | 528 |
self withSelectionHiddenDo:[ |
529 |
super sizeChanged:how |
|
530 |
] |
|
531 |
||
532 |
||
533 |
! ! |
|
534 |
||
535 |
!UIObjectView methodsFor:'initialization'! |
|
536 |
||
537 |
initialize |
|
61 | 538 |
"setup attributes |
539 |
" |
|
60 | 540 |
super initialize. |
541 |
||
542 |
"funny: since I do not want the created widgets to get pointer |
|
543 |
events, I put an InputView on top of them, which catches those events |
|
544 |
and passes them back to me - have to take care, that this inputView |
|
545 |
is always on top |
|
546 |
" |
|
547 |
inputView := InputView origin:0.0@0.0 extent:1.0@1.0 in:self. |
|
61 | 548 |
setOfSuperViewsSizeChanged := IdentitySet new. |
60 | 549 |
|
550 |
inputView eventReceiver:self. |
|
551 |
inputView enableButtonEvents. |
|
552 |
inputView enableButtonMotionEvents. |
|
553 |
||
554 |
self setDefaultActions. |
|
555 |
||
134 | 556 |
undoHistory := UndoHistory on:self. |
119 | 557 |
enableChannel := true asValue. |
558 |
clipChildren := true. |
|
61 | 559 |
selectionHiddenLevel := 0. |
60 | 560 |
|
561 |
(self class gridShown) ifTrue:[ |
|
562 |
super showGrid |
|
563 |
]. |
|
564 |
||
565 |
! |
|
566 |
||
284 | 567 |
map |
568 |
"make the view visible on the screen and in case of a none empty |
|
569 |
selection the selection will be shown. |
|
570 |
" |
|
571 |
super map. |
|
572 |
self showSelection. |
|
573 |
! |
|
574 |
||
60 | 575 |
realize |
576 |
super realize. |
|
577 |
self windowGroup postEventHook:self |
|
578 |
||
579 |
! ! |
|
580 |
||
581 |
!UIObjectView methodsFor:'misc'! |
|
582 |
||
583 |
cursor:aCursor |
|
61 | 584 |
"set cursor |
585 |
" |
|
60 | 586 |
inputView realized ifTrue:[ |
587 |
inputView cursor:aCursor |
|
588 |
]. |
|
589 |
super cursor:aCursor |
|
590 |
||
591 |
||
592 |
! |
|
593 |
||
175 | 594 |
invertOutlineOf:something |
595 |
"invert outline of an object or collection of objects |
|
61 | 596 |
" |
175 | 597 |
|wasClipped p| |
60 | 598 |
|
599 |
(wasClipped := clipChildren) ifTrue:[ |
|
600 |
self clippedByChildren:(clipChildren := false). |
|
601 |
]. |
|
175 | 602 |
|
603 |
something isCollection ifTrue:[ |
|
604 |
something do:[:v| |
|
605 |
p := v originRelativeTo:self. |
|
606 |
self xoring:[self displayRectangle:(p extent:v extent)]. |
|
607 |
] |
|
608 |
] ifFalse:[ |
|
609 |
p := something originRelativeTo:self. |
|
610 |
self xoring:[self displayRectangle:(p extent:something extent)] |
|
60 | 611 |
]. |
612 |
||
613 |
wasClipped ifTrue:[ |
|
614 |
self clippedByChildren:(clipChildren := true). |
|
615 |
]. |
|
616 |
||
617 |
! |
|
618 |
||
78 | 619 |
minSetOfSuperViews:setOfViews |
620 |
||
621 |
setOfViews isCollection ifFalse:[ |
|
622 |
setOfViews notNil ifTrue:[^ Array with:setOfViews] |
|
623 |
ifFalse:[^ nil] |
|
72 | 624 |
]. |
78 | 625 |
^ setOfViews select:[:aView| |
626 |
(setOfViews detect:[:v|aView isComponentOf:v] ifNone:nil) isNil |
|
627 |
] |
|
72 | 628 |
! |
629 |
||
60 | 630 |
setDefaultActions |
61 | 631 |
"set default actions |
632 |
" |
|
60 | 633 |
pressAction := [:pressPoint | self startSelectOrMove:pressPoint]. |
634 |
shiftPressAction := [:pressPoint | self startSelectMoreOrMove:pressPoint]. |
|
635 |
motionAction := [:movePoint | nil]. |
|
636 |
releaseAction := [nil]. |
|
637 |
keyPressAction := nil. |
|
638 |
||
639 |
self cursor:Cursor normal. |
|
640 |
||
641 |
! ! |
|
642 |
||
643 |
!UIObjectView methodsFor:'object moving'! |
|
644 |
||
645 |
doObjectMove:aPoint |
|
646 |
"move selection |
|
647 |
" |
|
648 |
movedObject notNil ifTrue:[ |
|
175 | 649 |
self invertOutlineOf:movedObject. |
650 |
||
651 |
movedObject keysAndValuesDo:[:i :v| |
|
652 |
self moveObject:v to:(aPoint - (moveDelta at:i)). |
|
653 |
]. |
|
654 |
self invertOutlineOf:movedObject. |
|
60 | 655 |
] |
656 |
||
657 |
! |
|
658 |
||
659 |
endObjectMove |
|
61 | 660 |
"cleanup after object(s) move |
661 |
" |
|
60 | 662 |
movedObject notNil ifTrue:[ |
175 | 663 |
self invertOutlineOf:movedObject. |
128 | 664 |
|
665 |
movedObject size == 1 ifTrue:[ |
|
666 |
movedObject := movedObject first |
|
60 | 667 |
]. |
128 | 668 |
self setSelection:movedObject withRedraw:true. |
60 | 669 |
movedObject := nil. |
670 |
self setDefaultActions. |
|
225 | 671 |
self layoutChanged. |
60 | 672 |
]. |
673 |
! |
|
674 |
||
675 |
moveObject:anObject to:aPoint |
|
676 |
"move anObject to newOrigin, aPoint |
|
677 |
" |
|
678 |
|dX dY org delta| |
|
679 |
||
680 |
anObject notNil ifTrue:[ |
|
681 |
org := anObject computeOrigin. |
|
682 |
||
683 |
delta := aPoint - org. |
|
684 |
delta := (self alignToGrid:aPoint) - org. |
|
685 |
dX := delta x. |
|
686 |
dY := delta y. |
|
687 |
||
134 | 688 |
undoHistory withoutTransactionDo:[ |
60 | 689 |
self shiftLayout:anObject top:dY bottom:dY left:dX right:dX |
690 |
] |
|
691 |
] |
|
692 |
||
693 |
! |
|
694 |
||
695 |
startObjectMoveAt:aPoint |
|
61 | 696 |
"start object(s) move at a point |
697 |
" |
|
128 | 698 |
self startObjectMove:(self selection) at:aPoint. |
699 |
movedObject := self selection. |
|
700 |
||
701 |
movedObject isCollection ifFalse:[ |
|
702 |
movedObject := Array with:movedObject |
|
60 | 703 |
]. |
128 | 704 |
self setSelection:nil withRedraw:true. |
60 | 705 |
|
706 |
moveDelta := movedObject collect:[:aView| |
|
707 |
aPoint - aView computeOrigin |
|
708 |
]. |
|
175 | 709 |
self transaction:#move objects:movedObject do:[:v|self createUndoLayout:v]. |
710 |
self invertOutlineOf:movedObject. |
|
60 | 711 |
! |
712 |
||
713 |
startSelectMoreOrMove:aPoint |
|
714 |
"add/remove to/from selection" |
|
715 |
||
716 |
|anObject| |
|
717 |
||
119 | 718 |
self enabled ifFalse:[^ self]. |
60 | 719 |
|
720 |
anObject := self findObjectAt:aPoint. |
|
721 |
anObject notNil ifTrue:[ |
|
722 |
(self isSelected:anObject) ifTrue:[ |
|
723 |
self removeFromSelection:anObject |
|
724 |
] ifFalse:[ |
|
725 |
self addToSelection:anObject |
|
726 |
] |
|
727 |
] |
|
728 |
! |
|
729 |
||
730 |
startSelectOrMove:aPoint |
|
61 | 731 |
"a button is pressed at a point; start moving or selection |
60 | 732 |
" |
284 | 733 |
|aView b v| |
60 | 734 |
|
119 | 735 |
self enabled ifFalse:[^ self]. |
60 | 736 |
|
61 | 737 |
aView := self singleSelection. |
738 |
||
739 |
aView notNil ifTrue:[ |
|
284 | 740 |
v := self findContainerOfView:aView. |
741 |
||
742 |
v specClass canResizeSubComponents ifTrue:[ |
|
61 | 743 |
b := self whichHandleOf:aView isHitBy:aPoint. |
744 |
||
745 |
(b notNil and:[b ~~ #view]) ifTrue:[ |
|
746 |
^ self startResizeBorder:b of:aView. |
|
747 |
] |
|
100 | 748 |
]. |
749 |
||
284 | 750 |
(self sensor ctrlDown and:[self canChangeLayoutOfView:aView]) ifFalse:[ |
100 | 751 |
aView := nil |
60 | 752 |
] |
753 |
]. |
|
754 |
||
100 | 755 |
aView isNil ifTrue:[ |
756 |
(aView := self findObjectAt:aPoint) isNil ifTrue:[ |
|
131 | 757 |
^ self select:nil |
100 | 758 |
]. |
759 |
||
284 | 760 |
(self canChangeLayoutOfView:aView) ifFalse:[ |
128 | 761 |
^ self select:aView |
100 | 762 |
] |
61 | 763 |
]. |
764 |
||
765 |
(self isSelected:aView) ifFalse:[ |
|
766 |
self select:aView. |
|
60 | 767 |
]. |
768 |
||
769 |
(self numberOfSelections ~~ 1) ifTrue:[ |
|
770 |
releaseAction := [ |
|
771 |
self setDefaultActions. |
|
61 | 772 |
self select:aView |
60 | 773 |
] |
774 |
] ifFalse:[ |
|
775 |
releaseAction := [self setDefaultActions] |
|
776 |
]. |
|
777 |
||
778 |
"prepare move operation for an object |
|
779 |
" |
|
61 | 780 |
|
60 | 781 |
motionAction := [:movePoint| |
72 | 782 |
(aPoint dist:movePoint) > 8.0 ifTrue:[ |
60 | 783 |
self startObjectMoveAt:aPoint |
784 |
] |
|
785 |
]. |
|
786 |
! ! |
|
787 |
||
788 |
!UIObjectView methodsFor:'object resize'! |
|
789 |
||
790 |
actionResize:anObject selector:aSelector |
|
791 |
"create and initialize action for resize |
|
792 |
" |
|
793 |
|selector delta| |
|
794 |
||
795 |
delta := anObject container originRelativeTo:self. |
|
796 |
selector := ('resize:', aSelector, ':') asSymbol. |
|
797 |
||
543
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
798 |
resizeData := ResizeData new |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
799 |
object:anObject selector:selector delta:delta. |
60 | 800 |
|
801 |
"can change cursor dependent on vertical/horizontal resizing |
|
802 |
" |
|
803 |
oldCursor := cursor. |
|
804 |
self cursor:(Cursor leftHand). |
|
805 |
||
543
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
806 |
"Modified: / 2.2.1998 / 13:40:55 / cg" |
60 | 807 |
! |
808 |
||
809 |
doDragResize:aPoint |
|
61 | 810 |
"do a widget resize drag |
811 |
" |
|
60 | 812 |
|p object| |
813 |
||
175 | 814 |
object := resizeData object. |
60 | 815 |
|
816 |
self invertOutlineOf:object. |
|
175 | 817 |
p := (self alignToGrid:aPoint) - (resizeData delta). |
818 |
||
819 |
self perform:(resizeData selector) with:object with:p. |
|
79 | 820 |
"/ object geometryLayout:(object geometryLayout). |
60 | 821 |
self invertOutlineOf:object |
822 |
||
823 |
! |
|
824 |
||
825 |
endResize |
|
61 | 826 |
"cleanup after object resize |
827 |
" |
|
828 |
|object| |
|
829 |
||
175 | 830 |
object := resizeData object. |
831 |
resizeData := nil. |
|
61 | 832 |
|
833 |
self invertOutlineOf:object. |
|
60 | 834 |
self setDefaultActions. |
61 | 835 |
self elementChangedSize:object. |
138 | 836 |
|
837 |
"/ handle any expose events (for subcomponents) before |
|
838 |
"/ redrawing the handles. |
|
839 |
Delay waitForSeconds:0.05. |
|
840 |
[self sensor hasExposeEventFor:nil] whileTrue:[ |
|
841 |
self windowGroup processExposeEvents |
|
842 |
]. |
|
843 |
||
128 | 844 |
self setSelection:object withRedraw:true. |
225 | 845 |
self layoutChanged. |
60 | 846 |
! |
847 |
||
848 |
startResizeBorder:b of:selection |
|
849 |
"resize selected view |
|
850 |
" |
|
851 |
|object| |
|
852 |
||
853 |
object := self singleSelection. |
|
854 |
self actionResize:object selector:b. |
|
855 |
||
72 | 856 |
self transaction:#resize selectionDo:[:aView| |
134 | 857 |
self createUndoLayout:aView |
60 | 858 |
]. |
128 | 859 |
self setSelection:nil withRedraw:true. |
60 | 860 |
|
861 |
motionAction := [:movePoint | self doDragResize:movePoint]. |
|
862 |
releaseAction := [self endResize]. |
|
863 |
self invertOutlineOf:object |
|
864 |
! ! |
|
865 |
||
866 |
!UIObjectView methodsFor:'private handles'! |
|
867 |
||
175 | 868 |
handlesOf:aComponent do:aTwoArgAction |
869 |
"perform action on each handle of a component |
|
870 |
" |
|
871 |
|dlt ext| |
|
872 |
||
873 |
dlt := (aComponent originRelativeTo:self) - aComponent origin. |
|
874 |
dlt := dlt - (3@3). |
|
875 |
ext := 6@6. |
|
876 |
||
877 |
self class handlesOf:aComponent do:[:pnt :wht | |
|
878 |
aTwoArgAction value:(pnt + dlt extent:ext) value:wht |
|
879 |
] |
|
60 | 880 |
! |
881 |
||
882 |
showSelected:aComponent |
|
61 | 883 |
"show object selected |
884 |
" |
|
175 | 885 |
|wasClipped| |
886 |
||
887 |
selectionHiddenLevel == 0 ifTrue:[ |
|
888 |
self paint:Color black. |
|
889 |
||
890 |
(wasClipped := clipChildren) ifTrue:[ |
|
891 |
self clippedByChildren:(clipChildren := false). |
|
892 |
]. |
|
893 |
||
894 |
self handlesOf:aComponent do:[:rectangle :what| |
|
895 |
what == #view ifTrue:[self displayRectangle:rectangle] |
|
896 |
ifFalse:[self fillRectangle:rectangle] |
|
897 |
]. |
|
898 |
||
899 |
wasClipped ifTrue:[ |
|
900 |
self clippedByChildren:(clipChildren := true). |
|
901 |
] |
|
902 |
] |
|
60 | 903 |
! |
904 |
||
905 |
showUnselected:aComponent |
|
61 | 906 |
"show object unselected |
907 |
" |
|
251 | 908 |
|wasClipped r| |
60 | 909 |
|
138 | 910 |
selectionHiddenLevel ~~ 0 ifTrue:[^ self]. |
911 |
||
60 | 912 |
(wasClipped := clipChildren) ifTrue:[ |
913 |
self clippedByChildren:(clipChildren := false). |
|
914 |
]. |
|
915 |
||
175 | 916 |
self handlesOf:aComponent do:[:rec :wht| self clearRectangle:rec ]. |
60 | 917 |
|
918 |
wasClipped ifTrue:[ |
|
919 |
self clippedByChildren:(clipChildren := true). |
|
920 |
]. |
|
921 |
||
922 |
"/ must redraw all components which are affected b the handles |
|
923 |
||
175 | 924 |
r := (aComponent originRelativeTo:self) - (3@3) extent:(aComponent extent + (6@6)). |
60 | 925 |
|
926 |
subViews do:[:anotherComponent | |
|
927 |
|absOrg absFrame| |
|
928 |
||
929 |
anotherComponent ~~ inputView ifTrue:[ |
|
930 |
absOrg := anotherComponent originRelativeTo:self. |
|
931 |
absFrame := absOrg extent:(anotherComponent extent). |
|
932 |
(absFrame intersects:r) ifTrue:[ |
|
933 |
anotherComponent withAllSubViewsDo:[:v | |
|
95 | 934 |
v shown ifTrue:[ |
132 | 935 |
v fill:v viewBackground. |
95 | 936 |
v exposeX:0 y:0 width:9999 height:9999. |
937 |
] |
|
60 | 938 |
] |
939 |
] |
|
940 |
] |
|
941 |
] |
|
942 |
||
95 | 943 |
"Modified: 8.4.1997 / 00:32:26 / cg" |
60 | 944 |
! |
945 |
||
175 | 946 |
whichHandleOf:aComponent isHitBy:aPoint |
61 | 947 |
"returns kind of handle or nil |
948 |
" |
|
175 | 949 |
self handlesOf:aComponent do:[:rectangle :what| |
950 |
(rectangle containsPoint:aPoint) ifTrue:[^ what] |
|
60 | 951 |
]. |
175 | 952 |
^ nil |
60 | 953 |
! ! |
954 |
||
955 |
!UIObjectView methodsFor:'private resizing-subviews'! |
|
956 |
||
957 |
resize:aView bottom:aPoint |
|
61 | 958 |
"resize a views bottom |
959 |
" |
|
134 | 960 |
undoHistory withoutTransactionDo:[ |
60 | 961 |
self shiftLayout:aView top:0 bottom:((aPoint y) - (aView computeCorner y)) |
962 |
] |
|
963 |
! |
|
964 |
||
965 |
resize:aView bottomLeft:aPoint |
|
61 | 966 |
"resize a views bottom and left |
967 |
" |
|
134 | 968 |
undoHistory withoutTransactionDo:[ |
60 | 969 |
self shiftLayout:aView top:0 |
970 |
bottom:((aPoint y) - (aView computeCorner y)) |
|
971 |
left:((aPoint x) - (aView computeOrigin x)) |
|
972 |
right:0 |
|
973 |
||
974 |
] |
|
975 |
||
976 |
||
977 |
! |
|
978 |
||
979 |
resize:aView corner:aPoint |
|
61 | 980 |
"resize a views corner |
981 |
" |
|
60 | 982 |
|delta| |
983 |
||
984 |
delta := aPoint - aView computeCorner. |
|
985 |
||
134 | 986 |
undoHistory withoutTransactionDo:[ |
60 | 987 |
self shiftLayout:aView top:0 bottom:(delta y) left:0 right:(delta x) |
988 |
] |
|
989 |
! |
|
990 |
||
991 |
resize:aView left:aPoint |
|
61 | 992 |
"resize a views left |
993 |
" |
|
134 | 994 |
undoHistory withoutTransactionDo:[ |
60 | 995 |
self shiftLayout:aView left:((aPoint x) - (aView computeOrigin x)) right:0 |
996 |
] |
|
997 |
||
998 |
! |
|
999 |
||
1000 |
resize:aView origin:aPoint |
|
61 | 1001 |
"resize a views origin |
1002 |
" |
|
60 | 1003 |
|delta| |
1004 |
||
1005 |
delta := aPoint - aView computeOrigin. |
|
1006 |
||
134 | 1007 |
undoHistory withoutTransactionDo:[ |
60 | 1008 |
self shiftLayout:aView top:(delta y) bottom:0 left:(delta x) right:0 |
1009 |
] |
|
1010 |
||
1011 |
! |
|
1012 |
||
1013 |
resize:aView right:aPoint |
|
61 | 1014 |
"resize a views right |
1015 |
" |
|
134 | 1016 |
undoHistory withoutTransactionDo:[ |
60 | 1017 |
self shiftLayout:aView left:0 right:((aPoint x) - (aView computeCorner x)) |
1018 |
] |
|
1019 |
! |
|
1020 |
||
1021 |
resize:aView top:aPoint |
|
61 | 1022 |
"resize a views top |
1023 |
" |
|
134 | 1024 |
undoHistory withoutTransactionDo:[ |
60 | 1025 |
self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y)) bottom:0 |
1026 |
] |
|
1027 |
! |
|
1028 |
||
1029 |
resize:aView topRight:aPoint |
|
61 | 1030 |
"resize a views top and right |
1031 |
" |
|
134 | 1032 |
undoHistory withoutTransactionDo:[ |
60 | 1033 |
self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y)) |
1034 |
bottom:0 |
|
1035 |
left:0 |
|
1036 |
right:((aPoint x) - (aView computeCorner x)) |
|
1037 |
||
1038 |
] |
|
1039 |
||
1040 |
! ! |
|
1041 |
||
1042 |
!UIObjectView methodsFor:'private shift-layout'! |
|
1043 |
||
1044 |
shiftLayout:aView left:l right:r |
|
1045 |
"shift layout for a view; in case of an open transaction, the undo |
|
1046 |
action is registered |
|
1047 |
" |
|
1048 |
self shiftLayout:aView top:0 bottom:0 left:l right:r |
|
1049 |
||
1050 |
! |
|
1051 |
||
1052 |
shiftLayout:aView top:t bottom:b |
|
1053 |
"shift layout for a view; in case of an open transaction, the undo |
|
1054 |
action is registered |
|
1055 |
" |
|
1056 |
self shiftLayout:aView top:t bottom:b left:0 right:0 |
|
1057 |
||
1058 |
||
1059 |
! |
|
1060 |
||
1061 |
shiftLayout:aView top:t bottom:b left:l right:r |
|
1062 |
"shift layout for a view; in case of an open transaction, the undo |
|
1063 |
action is registered |
|
1064 |
" |
|
79 | 1065 |
|type layout oldExt| |
61 | 1066 |
|
1067 |
type := self class layoutType:aView. |
|
1068 |
||
1069 |
type notNil ifTrue:[ |
|
134 | 1070 |
self createUndoLayout:aView. |
61 | 1071 |
|
1072 |
type == #Extent ifTrue:[ |
|
79 | 1073 |
oldExt := aView extent. |
1074 |
aView extent:(oldExt + ((r-l) @ (b-t))). |
|
1075 |
^ self |
|
60 | 1076 |
]. |
61 | 1077 |
|
78 | 1078 |
layout := aView geometryLayout copy. |
61 | 1079 |
|
1080 |
layout isLayout ifTrue:[ |
|
1081 |
layout leftOffset:(layout leftOffset + l) |
|
1082 |
topOffset:(layout topOffset + t). |
|
1083 |
||
1084 |
type == #LayoutFrame ifTrue:[ |
|
1085 |
layout bottomOffset:(layout bottomOffset + b). |
|
1086 |
layout rightOffset:(layout rightOffset + r). |
|
1087 |
] |
|
1088 |
] ifFalse:[ |
|
1089 |
type == #Rectangle ifTrue:[ |
|
1090 |
layout left:(layout left + l) |
|
1091 |
right:(layout right + r) |
|
1092 |
top:(layout top + t) |
|
1093 |
bottom:(layout bottom + b). |
|
1094 |
] ifFalse:[ "POINT" |
|
1095 |
layout x:(layout x + l) y:(layout y + t). |
|
1096 |
] |
|
1097 |
]. |
|
1098 |
aView geometryLayout:layout |
|
60 | 1099 |
] |
1100 |
! ! |
|
1101 |
||
1102 |
!UIObjectView methodsFor:'searching'! |
|
1103 |
||
1104 |
findObjectAt:aPoint |
|
1105 |
"find the origin/corner of the currentWidget |
|
1106 |
" |
|
1107 |
|view viewId lastId point listOfViews| |
|
1108 |
||
1109 |
viewId := rootView id. |
|
1110 |
point := aPoint + (device translatePoint:0@0 from:(self id) to:viewId). |
|
1111 |
||
1112 |
inputView lower. |
|
1113 |
||
1114 |
[viewId notNil] whileTrue:[ |
|
1115 |
lastId := viewId. |
|
1116 |
viewId := device viewIdFromPoint:point in:lastId |
|
1117 |
]. |
|
1118 |
||
1119 |
inputView raise. |
|
1120 |
||
1121 |
view := device viewFromId:lastId. |
|
1122 |
||
1123 |
view ~~ inputView ifTrue:[^ view]. |
|
1124 |
||
1125 |
"/ look for 'hidden' views ... |
|
1126 |
||
1127 |
listOfViews := OrderedCollection new. |
|
1128 |
self allSubViewsDo:[:aView | |
|
1129 |
|org| |
|
1130 |
||
1131 |
aView ~~ inputView ifTrue:[ |
|
1132 |
org := device translatePoint:0@0 from:(aView id) to:self id. |
|
1133 |
((org extent:aView extent) containsPoint:aPoint) ifTrue:[ |
|
1134 |
listOfViews add:aView. |
|
1135 |
] |
|
1136 |
] |
|
1137 |
]. |
|
1138 |
||
1139 |
listOfViews size > 0 ifTrue:[ |
|
1140 |
^ listOfViews last |
|
1141 |
]. |
|
1142 |
^ nil |
|
1143 |
||
1144 |
||
1145 |
! ! |
|
1146 |
||
1147 |
!UIObjectView methodsFor:'selections'! |
|
1148 |
||
128 | 1149 |
moveableSelection |
131 | 1150 |
"checks whether the selection is not empty and all selected instances |
1151 |
can be moved. If true the selection is returned otherwise nil |
|
128 | 1152 |
" |
1153 |
|coll| |
|
1154 |
||
1155 |
self hasSelection ifTrue:[ |
|
1156 |
(self canMove:(coll := self selection)) ifTrue:[ |
|
1157 |
^ coll |
|
1158 |
] |
|
1159 |
]. |
|
1160 |
^ nil |
|
1161 |
! |
|
1162 |
||
60 | 1163 |
numberOfSelections |
131 | 1164 |
"return the number of selected instances |
61 | 1165 |
" |
128 | 1166 |
|coll size| |
1167 |
||
1168 |
coll := self selection. |
|
1169 |
size := coll size. |
|
1170 |
||
1171 |
(size ~~ 0 or:[coll isNil]) ifTrue:[^ size]. |
|
1172 |
^ 1 |
|
60 | 1173 |
! |
1174 |
||
149 | 1175 |
selection:something |
1176 |
"change selection to something |
|
1177 |
" |
|
1178 |
self select:something |
|
1179 |
! |
|
1180 |
||
128 | 1181 |
selectionDo:aBlock |
1182 |
"apply block to every selected object |
|
1183 |
" |
|
1184 |
self forEach:(self selection) do:aBlock |
|
1185 |
||
1186 |
||
1187 |
! |
|
1188 |
||
61 | 1189 |
showSelection |
128 | 1190 |
"show the selection - draw handles |
1191 |
" |
|
61 | 1192 |
selectionHiddenLevel == 0 ifTrue:[ |
128 | 1193 |
self selectionDo:[:el| self showSelected:el ] |
60 | 1194 |
]. |
1195 |
! |
|
1196 |
||
1197 |
singleSelection |
|
131 | 1198 |
"checks whether one element is selected; in this case the element is |
1199 |
returned otherwise nil |
|
60 | 1200 |
" |
128 | 1201 |
|coll| |
1202 |
||
1203 |
(coll := self selection) isCollection ifFalse:[ |
|
1204 |
^ coll |
|
60 | 1205 |
]. |
128 | 1206 |
|
1207 |
coll size == 1 ifTrue:[ ^ coll first]. |
|
1208 |
^ nil |
|
60 | 1209 |
! |
1210 |
||
1211 |
singleSelectionDo:aBlock |
|
131 | 1212 |
"checks whether one element is selected; in this case the block |
1213 |
with argument the selected instance will be processed |
|
61 | 1214 |
" |
60 | 1215 |
|view| |
1216 |
||
1217 |
(view := self singleSelection) notNil ifTrue:[ |
|
1218 |
aBlock value:view |
|
1219 |
] |
|
1220 |
! |
|
1221 |
||
1222 |
unselect |
|
61 | 1223 |
"clear selection |
1224 |
" |
|
128 | 1225 |
self select:nil |
60 | 1226 |
! |
1227 |
||
1228 |
withSelectionHiddenDo:aBlock |
|
61 | 1229 |
"apply block with selection hidden (no handles) |
1230 |
" |
|
78 | 1231 |
|coll| |
1232 |
||
138 | 1233 |
selectionHiddenLevel == 0 ifTrue:[ |
61 | 1234 |
self selectionDo:[:aView| self showUnselected:aView]. |
1235 |
device flush. |
|
1236 |
]. |
|
138 | 1237 |
selectionHiddenLevel := selectionHiddenLevel + 1. |
61 | 1238 |
|
1239 |
aBlock valueNowOrOnUnwindDo:[ |
|
1240 |
selectionHiddenLevel == 1 ifTrue:[ |
|
1241 |
setOfSuperViewsSizeChanged notEmpty ifTrue:[ |
|
78 | 1242 |
coll := self minSetOfSuperViews:setOfSuperViewsSizeChanged. |
1243 |
coll do:[:aView| aView sizeChanged:nil]. |
|
61 | 1244 |
setOfSuperViewsSizeChanged := IdentitySet new |
1245 |
]. |
|
138 | 1246 |
selectionHiddenLevel := 0. |
61 | 1247 |
self selectionDo:[:aView| self showSelected:aView]. |
138 | 1248 |
] ifFalse:[ |
1249 |
selectionHiddenLevel := selectionHiddenLevel - 1. |
|
1250 |
] |
|
61 | 1251 |
] |
1252 |
||
1253 |
! |
|
1254 |
||
1255 |
withoutSelectionDo:aBlock |
|
1256 |
"evaluate aBlock while selection is nilled |
|
1257 |
" |
|
60 | 1258 |
|sel| |
1259 |
||
128 | 1260 |
self hasSelection ifFalse:[ |
60 | 1261 |
aBlock value |
128 | 1262 |
] ifTrue:[ |
1263 |
sel := self selection. |
|
1264 |
self setSelection:nil withRedraw:true. |
|
60 | 1265 |
aBlock value. |
128 | 1266 |
self setSelection:sel withRedraw:true. |
60 | 1267 |
] |
1268 |
||
1269 |
||
1270 |
! ! |
|
1271 |
||
131 | 1272 |
!UIObjectView methodsFor:'selections basic'! |
1273 |
||
1274 |
selection |
|
1275 |
"returns the current selection |
|
1276 |
" |
|
1277 |
^ selection |
|
1278 |
||
1279 |
||
1280 |
! |
|
1281 |
||
1282 |
setSelection:aNewSelection withRedraw:doRedraw |
|
1283 |
"set a new selection without change notifications |
|
1284 |
" |
|
225 | 1285 |
|sel| |
1286 |
||
1287 |
(sel := aNewSelection) == self ifTrue:[ |
|
1288 |
sel := nil |
|
1289 |
]. |
|
1290 |
||
131 | 1291 |
doRedraw ifTrue:[ |
1292 |
self hideSelection. |
|
225 | 1293 |
selection := sel. |
131 | 1294 |
self showSelection |
1295 |
] ifFalse:[ |
|
225 | 1296 |
selection := sel |
131 | 1297 |
] |
1298 |
! ! |
|
1299 |
||
60 | 1300 |
!UIObjectView methodsFor:'testing'! |
1301 |
||
284 | 1302 |
hasSelection |
1303 |
"returns true if any widget is selected |
|
61 | 1304 |
" |
284 | 1305 |
^ self numberOfSelections ~~ 0 |
60 | 1306 |
|
1307 |
! |
|
1308 |
||
284 | 1309 |
hasSingleSelection |
1310 |
"returns true if one widget is selected |
|
61 | 1311 |
" |
284 | 1312 |
^ self numberOfSelections == 1 |
1313 |
||
1314 |
! |
|
1315 |
||
1316 |
hasUndoHistory |
|
1317 |
"returns true if undos exists |
|
1318 |
" |
|
1319 |
^ undoHistory isEmpty not |
|
60 | 1320 |
! |
1321 |
||
134 | 1322 |
isModified |
1323 |
"returns true if painter is modified |
|
1324 |
" |
|
1325 |
^ undoHistory isModified |
|
1326 |
! |
|
1327 |
||
128 | 1328 |
isSelected:anObject |
1329 |
"return true, if the argument, anObject is selected |
|
1330 |
" |
|
1331 |
anObject notNil ifTrue:[ |
|
1332 |
self selectionDo:[:el| el == anObject ifTrue:[^ true]] |
|
1333 |
]. |
|
1334 |
^ false |
|
1335 |
||
60 | 1336 |
! ! |
1337 |
||
1338 |
!UIObjectView methodsFor:'transaction'! |
|
1339 |
||
134
d5ab85ec27fd
undo history; keep view identifier
ca |