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