author | Claus Gittinger <cg@exept.de> |
Wed, 20 May 1998 02:30:52 +0200 | |
changeset 839 | 61e34bfb0ee1 |
parent 777 | ce2a772e73fa |
child 897 | 43f9bdc12ae4 |
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 |
||
624
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
525 |
redrawX:nx y:ny width:nw height:nh |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
526 |
"ignore redraws - my components redraw themself |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
527 |
" |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
528 |
! |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
529 |
|
60 | 530 |
sizeChanged:how |
61 | 531 |
"size of a view(s) changed |
532 |
" |
|
60 | 533 |
self withSelectionHiddenDo:[ |
534 |
super sizeChanged:how |
|
535 |
] |
|
536 |
||
537 |
||
538 |
! ! |
|
539 |
||
540 |
!UIObjectView methodsFor:'initialization'! |
|
541 |
||
542 |
initialize |
|
61 | 543 |
"setup attributes |
544 |
" |
|
60 | 545 |
super initialize. |
546 |
||
547 |
"funny: since I do not want the created widgets to get pointer |
|
548 |
events, I put an InputView on top of them, which catches those events |
|
549 |
and passes them back to me - have to take care, that this inputView |
|
550 |
is always on top |
|
551 |
" |
|
552 |
inputView := InputView origin:0.0@0.0 extent:1.0@1.0 in:self. |
|
61 | 553 |
setOfSuperViewsSizeChanged := IdentitySet new. |
60 | 554 |
|
555 |
inputView eventReceiver:self. |
|
556 |
inputView enableButtonEvents. |
|
557 |
inputView enableButtonMotionEvents. |
|
558 |
||
559 |
self setDefaultActions. |
|
560 |
||
134 | 561 |
undoHistory := UndoHistory on:self. |
119 | 562 |
enableChannel := true asValue. |
563 |
clipChildren := true. |
|
61 | 564 |
selectionHiddenLevel := 0. |
60 | 565 |
|
566 |
(self class gridShown) ifTrue:[ |
|
567 |
super showGrid |
|
568 |
]. |
|
569 |
||
570 |
! |
|
571 |
||
284 | 572 |
map |
573 |
"make the view visible on the screen and in case of a none empty |
|
574 |
selection the selection will be shown. |
|
575 |
" |
|
576 |
super map. |
|
577 |
self showSelection. |
|
578 |
! |
|
579 |
||
60 | 580 |
realize |
581 |
super realize. |
|
582 |
self windowGroup postEventHook:self |
|
583 |
||
584 |
! ! |
|
585 |
||
586 |
!UIObjectView methodsFor:'misc'! |
|
587 |
||
588 |
cursor:aCursor |
|
61 | 589 |
"set cursor |
590 |
" |
|
60 | 591 |
inputView realized ifTrue:[ |
592 |
inputView cursor:aCursor |
|
593 |
]. |
|
594 |
super cursor:aCursor |
|
595 |
||
596 |
||
597 |
! |
|
598 |
||
175 | 599 |
invertOutlineOf:something |
600 |
"invert outline of an object or collection of objects |
|
61 | 601 |
" |
175 | 602 |
|wasClipped p| |
60 | 603 |
|
604 |
(wasClipped := clipChildren) ifTrue:[ |
|
605 |
self clippedByChildren:(clipChildren := false). |
|
606 |
]. |
|
175 | 607 |
|
608 |
something isCollection ifTrue:[ |
|
609 |
something do:[:v| |
|
610 |
p := v originRelativeTo:self. |
|
611 |
self xoring:[self displayRectangle:(p extent:v extent)]. |
|
612 |
] |
|
613 |
] ifFalse:[ |
|
614 |
p := something originRelativeTo:self. |
|
615 |
self xoring:[self displayRectangle:(p extent:something extent)] |
|
60 | 616 |
]. |
617 |
||
618 |
wasClipped ifTrue:[ |
|
619 |
self clippedByChildren:(clipChildren := true). |
|
620 |
]. |
|
621 |
||
622 |
! |
|
623 |
||
78 | 624 |
minSetOfSuperViews:setOfViews |
625 |
||
626 |
setOfViews isCollection ifFalse:[ |
|
627 |
setOfViews notNil ifTrue:[^ Array with:setOfViews] |
|
628 |
ifFalse:[^ nil] |
|
72 | 629 |
]. |
78 | 630 |
^ setOfViews select:[:aView| |
631 |
(setOfViews detect:[:v|aView isComponentOf:v] ifNone:nil) isNil |
|
632 |
] |
|
72 | 633 |
! |
634 |
||
624
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
635 |
redrawObjectsInVisible:redrawFrame |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
636 |
"my objects are views - they redraw themself" |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
637 |
|
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
638 |
^ self |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
639 |
|
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
640 |
! |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
641 |
|
60 | 642 |
setDefaultActions |
61 | 643 |
"set default actions |
644 |
" |
|
60 | 645 |
pressAction := [:pressPoint | self startSelectOrMove:pressPoint]. |
646 |
shiftPressAction := [:pressPoint | self startSelectMoreOrMove:pressPoint]. |
|
647 |
motionAction := [:movePoint | nil]. |
|
648 |
releaseAction := [nil]. |
|
649 |
keyPressAction := nil. |
|
650 |
||
651 |
self cursor:Cursor normal. |
|
652 |
||
653 |
! ! |
|
654 |
||
655 |
!UIObjectView methodsFor:'object moving'! |
|
656 |
||
657 |
doObjectMove:aPoint |
|
658 |
"move selection |
|
659 |
" |
|
660 |
movedObject notNil ifTrue:[ |
|
175 | 661 |
self invertOutlineOf:movedObject. |
662 |
||
663 |
movedObject keysAndValuesDo:[:i :v| |
|
664 |
self moveObject:v to:(aPoint - (moveDelta at:i)). |
|
665 |
]. |
|
666 |
self invertOutlineOf:movedObject. |
|
60 | 667 |
] |
668 |
||
669 |
! |
|
670 |
||
671 |
endObjectMove |
|
61 | 672 |
"cleanup after object(s) move |
673 |
" |
|
60 | 674 |
movedObject notNil ifTrue:[ |
175 | 675 |
self invertOutlineOf:movedObject. |
128 | 676 |
|
677 |
movedObject size == 1 ifTrue:[ |
|
678 |
movedObject := movedObject first |
|
60 | 679 |
]. |
128 | 680 |
self setSelection:movedObject withRedraw:true. |
60 | 681 |
movedObject := nil. |
682 |
self setDefaultActions. |
|
225 | 683 |
self layoutChanged. |
60 | 684 |
]. |
685 |
! |
|
686 |
||
687 |
moveObject:anObject to:aPoint |
|
688 |
"move anObject to newOrigin, aPoint |
|
689 |
" |
|
690 |
|dX dY org delta| |
|
691 |
||
692 |
anObject notNil ifTrue:[ |
|
693 |
org := anObject computeOrigin. |
|
694 |
||
695 |
delta := aPoint - org. |
|
696 |
delta := (self alignToGrid:aPoint) - org. |
|
697 |
dX := delta x. |
|
698 |
dY := delta y. |
|
699 |
||
134 | 700 |
undoHistory withoutTransactionDo:[ |
60 | 701 |
self shiftLayout:anObject top:dY bottom:dY left:dX right:dX |
702 |
] |
|
703 |
] |
|
704 |
||
705 |
! |
|
706 |
||
707 |
startObjectMoveAt:aPoint |
|
61 | 708 |
"start object(s) move at a point |
709 |
" |
|
128 | 710 |
self startObjectMove:(self selection) at:aPoint. |
711 |
movedObject := self selection. |
|
712 |
||
713 |
movedObject isCollection ifFalse:[ |
|
714 |
movedObject := Array with:movedObject |
|
60 | 715 |
]. |
128 | 716 |
self setSelection:nil withRedraw:true. |
60 | 717 |
|
718 |
moveDelta := movedObject collect:[:aView| |
|
719 |
aPoint - aView computeOrigin |
|
720 |
]. |
|
175 | 721 |
self transaction:#move objects:movedObject do:[:v|self createUndoLayout:v]. |
722 |
self invertOutlineOf:movedObject. |
|
60 | 723 |
! |
724 |
||
725 |
startSelectMoreOrMove:aPoint |
|
726 |
"add/remove to/from selection" |
|
727 |
||
728 |
|anObject| |
|
729 |
||
119 | 730 |
self enabled ifFalse:[^ self]. |
60 | 731 |
|
732 |
anObject := self findObjectAt:aPoint. |
|
733 |
anObject notNil ifTrue:[ |
|
734 |
(self isSelected:anObject) ifTrue:[ |
|
735 |
self removeFromSelection:anObject |
|
736 |
] ifFalse:[ |
|
737 |
self addToSelection:anObject |
|
738 |
] |
|
739 |
] |
|
740 |
! |
|
741 |
||
742 |
startSelectOrMove:aPoint |
|
61 | 743 |
"a button is pressed at a point; start moving or selection |
60 | 744 |
" |
284 | 745 |
|aView b v| |
60 | 746 |
|
119 | 747 |
self enabled ifFalse:[^ self]. |
60 | 748 |
|
61 | 749 |
aView := self singleSelection. |
750 |
||
751 |
aView notNil ifTrue:[ |
|
284 | 752 |
v := self findContainerOfView:aView. |
753 |
||
754 |
v specClass canResizeSubComponents ifTrue:[ |
|
61 | 755 |
b := self whichHandleOf:aView isHitBy:aPoint. |
756 |
||
757 |
(b notNil and:[b ~~ #view]) ifTrue:[ |
|
758 |
^ self startResizeBorder:b of:aView. |
|
759 |
] |
|
100 | 760 |
]. |
761 |
||
284 | 762 |
(self sensor ctrlDown and:[self canChangeLayoutOfView:aView]) ifFalse:[ |
100 | 763 |
aView := nil |
60 | 764 |
] |
765 |
]. |
|
766 |
||
100 | 767 |
aView isNil ifTrue:[ |
768 |
(aView := self findObjectAt:aPoint) isNil ifTrue:[ |
|
131 | 769 |
^ self select:nil |
100 | 770 |
]. |
771 |
||
284 | 772 |
(self canChangeLayoutOfView:aView) ifFalse:[ |
128 | 773 |
^ self select:aView |
100 | 774 |
] |
61 | 775 |
]. |
776 |
||
777 |
(self isSelected:aView) ifFalse:[ |
|
778 |
self select:aView. |
|
60 | 779 |
]. |
780 |
||
781 |
(self numberOfSelections ~~ 1) ifTrue:[ |
|
782 |
releaseAction := [ |
|
783 |
self setDefaultActions. |
|
61 | 784 |
self select:aView |
60 | 785 |
] |
786 |
] ifFalse:[ |
|
787 |
releaseAction := [self setDefaultActions] |
|
788 |
]. |
|
789 |
||
790 |
"prepare move operation for an object |
|
791 |
" |
|
61 | 792 |
|
60 | 793 |
motionAction := [:movePoint| |
72 | 794 |
(aPoint dist:movePoint) > 8.0 ifTrue:[ |
60 | 795 |
self startObjectMoveAt:aPoint |
796 |
] |
|
797 |
]. |
|
798 |
! ! |
|
799 |
||
800 |
!UIObjectView methodsFor:'object resize'! |
|
801 |
||
802 |
actionResize:anObject selector:aSelector |
|
803 |
"create and initialize action for resize |
|
804 |
" |
|
805 |
|selector delta| |
|
806 |
||
807 |
delta := anObject container originRelativeTo:self. |
|
808 |
selector := ('resize:', aSelector, ':') asSymbol. |
|
809 |
||
543
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
810 |
resizeData := ResizeData new |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
811 |
object:anObject selector:selector delta:delta. |
60 | 812 |
|
813 |
"can change cursor dependent on vertical/horizontal resizing |
|
814 |
" |
|
815 |
oldCursor := cursor. |
|
816 |
self cursor:(Cursor leftHand). |
|
817 |
||
543
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
818 |
"Modified: / 2.2.1998 / 13:40:55 / cg" |
60 | 819 |
! |
820 |
||
821 |
doDragResize:aPoint |
|
61 | 822 |
"do a widget resize drag |
823 |
" |
|
60 | 824 |
|p object| |
825 |
||
175 | 826 |
object := resizeData object. |
60 | 827 |
|
828 |
self invertOutlineOf:object. |
|
175 | 829 |
p := (self alignToGrid:aPoint) - (resizeData delta). |
830 |
||
831 |
self perform:(resizeData selector) with:object with:p. |
|
79 | 832 |
"/ object geometryLayout:(object geometryLayout). |
60 | 833 |
self invertOutlineOf:object |
834 |
||
835 |
! |
|
836 |
||
837 |
endResize |
|
61 | 838 |
"cleanup after object resize |
839 |
" |
|
840 |
|object| |
|
841 |
||
175 | 842 |
object := resizeData object. |
843 |
resizeData := nil. |
|
61 | 844 |
|
845 |
self invertOutlineOf:object. |
|
60 | 846 |
self setDefaultActions. |
61 | 847 |
self elementChangedSize:object. |
138 | 848 |
|
849 |
"/ handle any expose events (for subcomponents) before |
|
850 |
"/ redrawing the handles. |
|
851 |
Delay waitForSeconds:0.05. |
|
852 |
[self sensor hasExposeEventFor:nil] whileTrue:[ |
|
853 |
self windowGroup processExposeEvents |
|
854 |
]. |
|
855 |
||
128 | 856 |
self setSelection:object withRedraw:true. |
225 | 857 |
self layoutChanged. |
60 | 858 |
! |
859 |
||
860 |
startResizeBorder:b of:selection |
|
861 |
"resize selected view |
|
862 |
" |
|
863 |
|object| |
|
864 |
||
865 |
object := self singleSelection. |
|
866 |
self actionResize:object selector:b. |
|
867 |
||
72 | 868 |
self transaction:#resize selectionDo:[:aView| |
134 | 869 |
self createUndoLayout:aView |
60 | 870 |
]. |
128 | 871 |
self setSelection:nil withRedraw:true. |
60 | 872 |
|
873 |
motionAction := [:movePoint | self doDragResize:movePoint]. |
|
874 |
releaseAction := [self endResize]. |
|
875 |
self invertOutlineOf:object |
|
876 |
! ! |
|
877 |
||
878 |
!UIObjectView methodsFor:'private handles'! |
|
879 |
||
768 | 880 |
handleAffectedViews:aViewOrSeqOfViews |
881 |
"update affected views |
|
882 |
" |
|
777 | 883 |
|c| |
768 | 884 |
|
885 |
self forEach:aViewOrSeqOfViews do:[:v| |
|
886 |
v shown ifTrue:[ |
|
887 |
v fill:v viewBackground. |
|
777 | 888 |
v borderWidth ~~ 0 ifTrue:[ |
889 |
c := v borderColor. |
|
890 |
v borderColor:(Color colorId:1). |
|
891 |
v borderColor:c. |
|
768 | 892 |
]. |
893 |
v exposeX:0 y:0 width:9999 height:9999 |
|
894 |
] |
|
895 |
] |
|
896 |
! |
|
897 |
||
175 | 898 |
handlesOf:aComponent do:aTwoArgAction |
899 |
"perform action on each handle of a component |
|
900 |
" |
|
901 |
|dlt ext| |
|
902 |
||
903 |
dlt := (aComponent originRelativeTo:self) - aComponent origin. |
|
904 |
dlt := dlt - (3@3). |
|
905 |
ext := 6@6. |
|
906 |
||
907 |
self class handlesOf:aComponent do:[:pnt :wht | |
|
908 |
aTwoArgAction value:(pnt + dlt extent:ext) value:wht |
|
909 |
] |
|
60 | 910 |
! |
911 |
||
912 |
showUnselected:aComponent |
|
61 | 913 |
"show object unselected |
914 |
" |
|
768 | 915 |
self showUnselected:aComponent addAffectedViewsTo:nil |
916 |
! |
|
917 |
||
918 |
showUnselected:aComponent addAffectedViewsTo:aSet |
|
919 |
"show object unselected. If the set, an IdentitySet, is not nil, the |
|
920 |
affected subviews are added into the set, otherwise an expose event |
|
921 |
to each affected cpomponent is raised. |
|
922 |
" |
|
251 | 923 |
|wasClipped r| |
60 | 924 |
|
138 | 925 |
selectionHiddenLevel ~~ 0 ifTrue:[^ self]. |
926 |
||
60 | 927 |
(wasClipped := clipChildren) ifTrue:[ |
928 |
self clippedByChildren:(clipChildren := false). |
|
929 |
]. |
|
930 |
||
175 | 931 |
self handlesOf:aComponent do:[:rec :wht| self clearRectangle:rec ]. |
60 | 932 |
|
933 |
wasClipped ifTrue:[ |
|
934 |
self clippedByChildren:(clipChildren := true). |
|
935 |
]. |
|
936 |
||
937 |
"/ must redraw all components which are affected b the handles |
|
175 | 938 |
r := (aComponent originRelativeTo:self) - (3@3) extent:(aComponent extent + (6@6)). |
60 | 939 |
|
940 |
subViews do:[:anotherComponent | |
|
941 |
|absOrg absFrame| |
|
942 |
||
943 |
anotherComponent ~~ inputView ifTrue:[ |
|
944 |
absOrg := anotherComponent originRelativeTo:self. |
|
945 |
absFrame := absOrg extent:(anotherComponent extent). |
|
946 |
(absFrame intersects:r) ifTrue:[ |
|
947 |
anotherComponent withAllSubViewsDo:[:v | |
|
95 | 948 |
v shown ifTrue:[ |
768 | 949 |
aSet notNil ifTrue:[ |
950 |
aSet add:v |
|
951 |
] ifFalse:[ |
|
952 |
self handleAffectedViews:v |
|
953 |
] |
|
95 | 954 |
] |
60 | 955 |
] |
956 |
] |
|
957 |
] |
|
768 | 958 |
]. |
959 |
||
60 | 960 |
! |
961 |
||
175 | 962 |
whichHandleOf:aComponent isHitBy:aPoint |
61 | 963 |
"returns kind of handle or nil |
964 |
" |
|
175 | 965 |
self handlesOf:aComponent do:[:rectangle :what| |
966 |
(rectangle containsPoint:aPoint) ifTrue:[^ what] |
|
60 | 967 |
]. |
175 | 968 |
^ nil |
60 | 969 |
! ! |
970 |
||
971 |
!UIObjectView methodsFor:'private resizing-subviews'! |
|
972 |
||
973 |
resize:aView bottom:aPoint |
|
61 | 974 |
"resize a views bottom |
975 |
" |
|
134 | 976 |
undoHistory withoutTransactionDo:[ |
60 | 977 |
self shiftLayout:aView top:0 bottom:((aPoint y) - (aView computeCorner y)) |
978 |
] |
|
979 |
! |
|
980 |
||
981 |
resize:aView bottomLeft:aPoint |
|
61 | 982 |
"resize a views bottom and left |
983 |
" |
|
134 | 984 |
undoHistory withoutTransactionDo:[ |
60 | 985 |
self shiftLayout:aView top:0 |
986 |
bottom:((aPoint y) - (aView computeCorner y)) |
|
987 |
left:((aPoint x) - (aView computeOrigin x)) |
|
988 |
right:0 |
|
989 |
||
990 |
] |
|
991 |
||
992 |
||
993 |
! |
|
994 |
||
995 |
resize:aView corner:aPoint |
|
61 | 996 |
"resize a views corner |
997 |
" |
|
60 | 998 |
|delta| |
999 |
||
1000 |
delta := aPoint - aView computeCorner. |
|
1001 |
||
134 | 1002 |
undoHistory withoutTransactionDo:[ |
60 | 1003 |
self shiftLayout:aView top:0 bottom:(delta y) left:0 right:(delta x) |
1004 |
] |
|
1005 |
! |
|
1006 |
||
1007 |
resize:aView left:aPoint |
|
61 | 1008 |
"resize a views left |
1009 |
" |
|
134 | 1010 |
undoHistory withoutTransactionDo:[ |
60 | 1011 |
self shiftLayout:aView left:((aPoint x) - (aView computeOrigin x)) right:0 |
1012 |
] |
|
1013 |
||
1014 |
! |
|
1015 |
||
1016 |
resize:aView origin:aPoint |
|
61 | 1017 |
"resize a views origin |
1018 |
" |
|
60 | 1019 |
|delta| |
1020 |
||
1021 |
delta := aPoint - aView computeOrigin. |
|
1022 |
||
134 | 1023 |
undoHistory withoutTransactionDo:[ |
60 | 1024 |
self shiftLayout:aView top:(delta y) bottom:0 left:(delta x) right:0 |
1025 |
] |
|
1026 |
||
1027 |
! |
|
1028 |
||
1029 |
resize:aView right:aPoint |
|
61 | 1030 |
"resize a views right |
1031 |
" |
|
134 | 1032 |
undoHistory withoutTransactionDo:[ |
60 | 1033 |
self shiftLayout:aView left:0 right:((aPoint x) - (aView computeCorner x)) |
1034 |
] |
|
1035 |
! |
|
1036 |
||
1037 |
resize:aView top:aPoint |
|
61 | 1038 |
"resize a views top |
1039 |
" |
|
134 | 1040 |
undoHistory withoutTransactionDo:[ |
60 | 1041 |
self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y)) bottom:0 |
1042 |
] |
|
1043 |
! |
|
1044 |
||
1045 |
resize:aView topRight:aPoint |
|
61 | 1046 |
"resize a views top and right |
1047 |
" |
|
134 | 1048 |
undoHistory withoutTransactionDo:[ |
60 | 1049 |
self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y)) |
1050 |
bottom:0 |
|
1051 |
left:0 |
|
1052 |
right:((aPoint x) - (aView computeCorner x)) |
|
1053 |
||
1054 |
] |
|
1055 |
||
1056 |
! ! |
|
1057 |
||
1058 |
!UIObjectView methodsFor:'private shift-layout'! |
|
1059 |
||
1060 |
shiftLayout:aView left:l right:r |
|
1061 |
"shift layout for a view; in case of an open transaction, the undo |
|
1062 |
action is registered |
|
1063 |
" |
|
1064 |
self shiftLayout:aView top:0 bottom:0 left:l right:r |
|
1065 |
||
1066 |
! |
|
1067 |
||
1068 |
shiftLayout:aView top:t bottom:b |
|
1069 |
"shift layout for a view; in case of an open transaction, the undo |
|
1070 |
action is registered |
|
1071 |
" |
|
1072 |
self shiftLayout:aView top:t bottom:b left:0 right:0 |
|
1073 |
||
1074 |
||
1075 |
! |
|
1076 |
||
1077 |
shiftLayout:aView top:t bottom:b left:l right:r |
|
1078 |
"shift layout for a view; in case of an open transaction, the undo |
|
1079 |
action is registered |
|
1080 |
" |
|
79 | 1081 |
|type layout oldExt| |
61 | 1082 |
|
1083 |
type := self class layoutType:aView. |
|
1084 |
||
1085 |
type notNil ifTrue:[ |
|
134 | 1086 |
self createUndoLayout:aView. |
61 | 1087 |
|
1088 |
type == #Extent ifTrue:[ |
|
79 | 1089 |
oldExt := aView extent. |
1090 |
aView extent:(oldExt + ((r-l) @ (b-t))). |
|
1091 |
^ self |
|
60 | 1092 |
]. |
61 | 1093 |
|
78 | 1094 |
layout := aView geometryLayout copy. |
61 | 1095 |
|
1096 |
layout isLayout ifTrue:[ |
|
1097 |
layout leftOffset:(layout leftOffset + l) |
|
1098 |
topOffset:(layout topOffset + t). |
|
1099 |
||
1100 |
type == #LayoutFrame ifTrue:[ |
|
1101 |
layout bottomOffset:(layout bottomOffset + b). |
|
1102 |
layout rightOffset:(layout rightOffset + r). |
|
1103 |
] |
|
1104 |
] ifFalse:[ |
|
1105 |
type == #Rectangle ifTrue:[ |
|
1106 |
layout left:(layout left + l) |
|
1107 |
right:(layout right + r) |
|
1108 |
top:(layout top + t) |
|
1109 |
bottom:(layout bottom + b). |
|
1110 |
] ifFalse:[ "POINT" |
|
1111 |
layout x:(layout x + l) y:(layout y + t). |
|
1112 |
] |
|
1113 |
]. |
|
1114 |
aView geometryLayout:layout |
|
60 | 1115 |
] |
1116 |
! ! |
|
1117 |
||
1118 |
!UIObjectView methodsFor:'searching'! |
|
1119 |
||
1120 |
findObjectAt:aPoint |
|
1121 |
"find the origin/corner of the currentWidget |
|
1122 |
" |
|
1123 |
|view viewId lastId point listOfViews| |
|
1124 |
||
1125 |
viewId := rootView id. |
|
1126 |
point := aPoint + (device translatePoint:0@0 from:(self id) to:viewId). |
|
1127 |
||
1128 |
inputView lower. |
|
1129 |
||
1130 |
[viewId notNil] whileTrue:[ |
|
1131 |
lastId := viewId. |
|
1132 |
viewId := device viewIdFromPoint:point in:lastId |
|
1133 |
]. |
|
1134 |
||
1135 |
inputView raise. |
|
1136 |
||
1137 |
view := device viewFromId:lastId. |
|
1138 |
||
1139 |
view ~~ inputView ifTrue:[^ view]. |
|
1140 |
||
1141 |
"/ look for 'hidden' views ... |
|
1142 |
||
1143 |
listOfViews := OrderedCollection new. |
|
1144 |
self allSubViewsDo:[:aView | |
|
1145 |
|org| |
|
1146 |
||
1147 |
aView ~~ inputView ifTrue:[ |
|
1148 |
org := device translatePoint:0@0 from:(aView id) to:self id. |
|
1149 |
((org extent:aView extent) containsPoint:aPoint) ifTrue:[ |
|
1150 |
listOfViews add:aView. |
|
1151 |
] |
|
1152 |
] |
|
1153 |
]. |
|
1154 |
||
1155 |
listOfViews size > 0 ifTrue:[ |
|
1156 |
^ listOfViews last |
|
1157 |
]. |
|
1158 |
^ nil |
|
1159 |
||
1160 |
||
1161 |
! ! |
|
1162 |
||
1163 |
!UIObjectView methodsFor:'selections'! |
|
1164 |
||
768 | 1165 |
hideSelection |
1166 |
"hide the selection - undraw hilights - whatever that is" |
|
1167 |
||
1168 |
|aSet| |
|
1169 |
||
1170 |
self selectionDo:[:object| |
|
1171 |
aSet isNil ifTrue:[ |
|
1172 |
aSet := IdentitySet new |
|
1173 |
]. |
|
1174 |
self showUnselected:object addAffectedViewsTo:aSet. |
|
1175 |
]. |
|
1176 |
self handleAffectedViews:aSet. |
|
1177 |
||
1178 |
||
1179 |
! |
|
1180 |
||
128 | 1181 |
moveableSelection |
131 | 1182 |
"checks whether the selection is not empty and all selected instances |
1183 |
can be moved. If true the selection is returned otherwise nil |
|
128 | 1184 |
" |
1185 |
|coll| |
|
1186 |
||
1187 |
self hasSelection ifTrue:[ |
|
1188 |
(self canMove:(coll := self selection)) ifTrue:[ |
|
1189 |
^ coll |
|
1190 |
] |
|
1191 |
]. |
|
1192 |
^ nil |
|
1193 |
! |
|
1194 |
||
60 | 1195 |
numberOfSelections |
131 | 1196 |
"return the number of selected instances |
61 | 1197 |
" |
128 | 1198 |
|coll size| |
1199 |
||
1200 |
coll := self selection. |
|
1201 |
size := coll size. |
|
1202 |
||
1203 |
(size ~~ 0 or:[coll isNil]) ifTrue:[^ size]. |
|
1204 |
^ 1 |
|
60 | 1205 |
! |
1206 |
||
149 | 1207 |
selection:something |
1208 |
"change selection to something |
|
1209 |
" |
|
1210 |
self select:something |
|
1211 |
! |
|
1212 |
||
128 | 1213 |
selectionDo:aBlock |
1214 |
"apply block to every selected object |
|
1215 |
" |
|
1216 |
self forEach:(self selection) do:aBlock |
|
1217 |
||
1218 |
||
1219 |
! |
|
1220 |
||
61 | 1221 |
showSelection |
128 | 1222 |
"show the selection - draw handles |
1223 |
" |
|
61 | 1224 |
selectionHiddenLevel == 0 ifTrue:[ |
128 | 1225 |
self selectionDo:[:el| self showSelected:el ] |
60 | 1226 |
]. |
1227 |
! |
|
1228 |
||
1229 |
singleSelection |
|
131 | 1230 |
"checks whether one element is selected; in this case the element is |
1231 |
returned otherwise nil |
|
60 | 1232 |
" |
128 | 1233 |
|coll| |
1234 |
||
1235 |
(coll := self selection) isCollection ifFalse:[ |
|
1236 |
^ coll |
|
60 | 1237 |
]. |
128 | 1238 |
|
1239 |
coll size == 1 ifTrue:[ ^ coll first]. |
|
1240 |
^ nil |
|
60 | 1241 |
! |
1242 |
||
1243 |
singleSelectionDo:aBlock |
|
131 | 1244 |
"checks whether one element is selected; in this case the block |
1245 |
with argument the selected instance will be processed |
|
61 | 1246 |
" |
60 | 1247 |
|view| |
1248 |
||
1249 |
(view := self singleSelection) notNil ifTrue:[ |
|
1250 |
aBlock value:view |
|
1251 |
] |
|
1252 |
! |
|
1253 |
||
1254 |
unselect |
|
61 | 1255 |
"clear selection |
1256 |
" |
|
128 | 1257 |
self select:nil |
60 | 1258 |
! |
1259 |
||
1260 |
withSelectionHiddenDo:aBlock |
|
61 | 1261 |
"apply block with selection hidden (no handles) |
1262 |
" |
|
78 | 1263 |
|coll| |
1264 |
||
138 | 1265 |
selectionHiddenLevel == 0 ifTrue:[ |
768 | 1266 |
self hideSelection. |
61 | 1267 |
device flush. |
1268 |
]. |
|
138 | 1269 |
selectionHiddenLevel := selectionHiddenLevel + 1. |
61 | 1270 |
|
1271 |
aBlock valueNowOrOnUnwindDo:[ |
|
1272 |
selectionHiddenLevel == 1 ifTrue:[ |
|
1273 |
setOfSuperViewsSizeChanged notEmpty ifTrue:[ |
|
78 | 1274 |
coll := self minSetOfSuperViews:setOfSuperViewsSizeChanged. |
1275 |
coll do:[:aView| aView sizeChanged:nil]. |
|
61 | 1276 |
setOfSuperViewsSizeChanged := IdentitySet new |
1277 |
]. |
|
138 | 1278 |
selectionHiddenLevel := 0. |
61 | 1279 |
self selectionDo:[:aView| self showSelected:aView]. |
138 | 1280 |
] ifFalse:[ |
1281 |
selectionHiddenLevel := selectionHiddenLevel - 1. |
|
1282 |
] |
|
61 | 1283 |
] |
1284 |
||
1285 |
! |
|
1286 |
||
1287 |
withoutSelectionDo:aBlock |
|
1288 |
"evaluate aBlock while selection is nilled |
|
1289 |
" |
|
60 | 1290 |
|sel| |
1291 |
||
128 | 1292 |
self hasSelection ifFalse:[ |
60 | 1293 |
aBlock value |
128 | 1294 |
] ifTrue:[ |
1295 |
sel := self selection. |
|
1296 |
self setSelection:nil withRedraw:true. |
|
60 | 1297 |
aBlock value. |
128 | 1298 |
self setSelection:sel withRedraw:true. |
60 | 1299 |
] |
1300 |
||
1301 |
||
1302 |
! ! |
|
1303 |
||
131 | 1304 |
!UIObjectView methodsFor:'selections basic'! |
1305 |
||
1306 |
selection |
|
1307 |
"returns the current selection |
|
1308 |
" |
|
1309 |
^ selection |
|
1310 |
||
1311 |
||
1312 |
! |
|
1313 |
||
1314 |
setSelection:aNewSelection withRedraw:doRedraw |
|
1315 |
"set a new selection without change notifications |
|
1316 |
" |
|
225 | 1317 |
|sel| |
1318 |
||
1319 |
(sel := aNewSelection) == self ifTrue:[ |
|
1320 |
sel := nil |
|
1321 |
]. |
|
1322 |
||
131 | 1323 |
doRedraw ifTrue:[ |
1324 |
self hideSelection. |
|
225 | 1325 |
selection := sel. |
131 | 1326 |
self showSelection |
1327 |
] ifFalse:[ |
|
225 | 1328 |
selection := sel |
131 | 1329 |
] |
1330 |
! ! |
|
1331 |
||
60 | 1332 |
!UIObjectView methodsFor:'testing'! |
1333 |
||
284 | 1334 |
hasSelection |
1335 |
"returns true if any widget is selected |
|
61 | 1336 |
" |
284 | 1337 |
^ self numberOfSelections ~~ 0 |
60 | 1338 |
|
1339 |
! |
|