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