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