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