author | Claus Gittinger <cg@exept.de> |
Tue, 04 Dec 2001 14:23:46 +0100 | |
changeset 1542 | 76c2549d878f |
parent 1521 | 2efd2b9419c4 |
child 1555 | 4ecde43a73d6 |
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 |
||
1437 | 26 |
Object subclass:#ResizeData |
27 |
instanceVariableNames:'object selector delta' |
|
28 |
classVariableNames:'' |
|
29 |
poolDictionaries:'' |
|
30 |
privateIn:UIObjectView |
|
31 |
! |
|
32 |
||
60 | 33 |
Object subclass:#UndoHistory |
134 | 34 |
instanceVariableNames:'startIdentifier identifier painter history transaction enabled' |
60 | 35 |
classVariableNames:'' |
36 |
poolDictionaries:'' |
|
37 |
privateIn:UIObjectView |
|
38 |
! |
|
39 |
||
54 | 40 |
Object subclass:#Transaction |
134 | 41 |
instanceVariableNames:'identifier type text actions' |
54 | 42 |
classVariableNames:'' |
43 |
poolDictionaries:'' |
|
44 |
privateIn:UIObjectView::UndoHistory |
|
45 |
! |
|
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:[ |
|
1451 | 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:[ |
1451 | 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:[ |
|
1451 | 684 |
self clippedByChildren:(clipChildren := true). |
60 | 685 |
]. |
686 |
! |
|
687 |
||
78 | 688 |
minSetOfSuperViews:setOfViews |
689 |
||
690 |
setOfViews isCollection ifFalse:[ |
|
1120 | 691 |
setOfViews notNil ifTrue:[^ Array with:setOfViews] |
692 |
ifFalse:[^ nil] |
|
72 | 693 |
]. |
78 | 694 |
^ setOfViews select:[:aView| |
1120 | 695 |
(setOfViews detect:[:v|aView isComponentOf:v] ifNone:nil) isNil |
78 | 696 |
] |
72 | 697 |
! |
698 |
||
624
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
699 |
redrawObjectsInVisible:redrawFrame |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
700 |
"my objects are views - they redraw themself" |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
701 |
|
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
702 |
^ self |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
703 |
|
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 |
|
60 | 706 |
setDefaultActions |
61 | 707 |
"set default actions |
708 |
" |
|
60 | 709 |
pressAction := [:pressPoint | self startSelectOrMove:pressPoint]. |
710 |
shiftPressAction := [:pressPoint | self startSelectMoreOrMove:pressPoint]. |
|
711 |
motionAction := [:movePoint | nil]. |
|
712 |
releaseAction := [nil]. |
|
713 |
keyPressAction := nil. |
|
714 |
||
715 |
self cursor:Cursor normal. |
|
716 |
||
717 |
! ! |
|
718 |
||
719 |
!UIObjectView methodsFor:'object moving'! |
|
720 |
||
721 |
doObjectMove:aPoint |
|
722 |
"move selection |
|
723 |
" |
|
724 |
movedObject notNil ifTrue:[ |
|
1120 | 725 |
self invertOutlineOf:movedObject. |
726 |
||
727 |
movedObject keysAndValuesDo:[:i :v| |
|
728 |
self moveObject:v to:(aPoint - (moveDelta at:i)). |
|
729 |
]. |
|
730 |
self invertOutlineOf:movedObject. |
|
60 | 731 |
] |
732 |
||
733 |
! |
|
734 |
||
735 |
endObjectMove |
|
61 | 736 |
"cleanup after object(s) move |
737 |
" |
|
60 | 738 |
movedObject notNil ifTrue:[ |
1120 | 739 |
self invertOutlineOf:movedObject. |
740 |
||
741 |
movedObject size == 1 ifTrue:[ |
|
742 |
movedObject := movedObject first |
|
743 |
]. |
|
744 |
self setSelection:movedObject withRedraw:true. |
|
745 |
movedObject := nil. |
|
746 |
self setDefaultActions. |
|
747 |
self layoutChanged. |
|
60 | 748 |
]. |
749 |
! |
|
750 |
||
751 |
moveObject:anObject to:aPoint |
|
752 |
"move anObject to newOrigin, aPoint |
|
753 |
" |
|
754 |
|dX dY org delta| |
|
755 |
||
756 |
anObject notNil ifTrue:[ |
|
1120 | 757 |
org := anObject computeOrigin. |
758 |
||
759 |
delta := aPoint - org. |
|
760 |
delta := (self alignToGrid:aPoint) - org. |
|
761 |
dX := delta x. |
|
762 |
dY := delta y. |
|
763 |
||
764 |
undoHistory withoutTransactionDo:[ |
|
765 |
self shiftLayout:anObject top:dY bottom:dY left:dX right:dX |
|
766 |
] |
|
60 | 767 |
] |
768 |
||
769 |
! |
|
770 |
||
771 |
startObjectMoveAt:aPoint |
|
61 | 772 |
"start object(s) move at a point |
773 |
" |
|
128 | 774 |
self startObjectMove:(self selection) at:aPoint. |
775 |
movedObject := self selection. |
|
776 |
||
777 |
movedObject isCollection ifFalse:[ |
|
1451 | 778 |
movedObject := Array with:movedObject |
60 | 779 |
]. |
128 | 780 |
self setSelection:nil withRedraw:true. |
60 | 781 |
|
782 |
moveDelta := movedObject collect:[:aView| |
|
1451 | 783 |
aPoint - aView computeOrigin |
60 | 784 |
]. |
175 | 785 |
self transaction:#move objects:movedObject do:[:v|self createUndoLayout:v]. |
786 |
self invertOutlineOf:movedObject. |
|
60 | 787 |
! |
788 |
||
789 |
startSelectMoreOrMove:aPoint |
|
790 |
"add/remove to/from selection" |
|
791 |
||
792 |
|anObject| |
|
793 |
||
119 | 794 |
self enabled ifFalse:[^ self]. |
60 | 795 |
|
796 |
anObject := self findObjectAt:aPoint. |
|
797 |
anObject notNil ifTrue:[ |
|
1120 | 798 |
(self isSelected:anObject) ifTrue:[ |
799 |
self removeFromSelection:anObject |
|
800 |
] ifFalse:[ |
|
801 |
self addToSelection:anObject |
|
802 |
] |
|
60 | 803 |
] |
804 |
! |
|
805 |
||
806 |
startSelectOrMove:aPoint |
|
61 | 807 |
"a button is pressed at a point; start moving or selection |
60 | 808 |
" |
284 | 809 |
|aView b v| |
60 | 810 |
|
119 | 811 |
self enabled ifFalse:[^ self]. |
60 | 812 |
|
61 | 813 |
aView := self singleSelection. |
814 |
||
815 |
aView notNil ifTrue:[ |
|
1120 | 816 |
v := self findContainerOfView:aView. |
817 |
||
818 |
v specClass canResizeSubComponents ifTrue:[ |
|
819 |
b := self whichHandleOf:aView isHitBy:aPoint. |
|
820 |
||
821 |
(b notNil and:[b ~~ #view]) ifTrue:[ |
|
822 |
^ self startResizeBorder:b of:aView. |
|
823 |
] |
|
824 |
]. |
|
825 |
||
826 |
(self sensor ctrlDown and:[self canChangeLayoutOfView:aView]) ifFalse:[ |
|
827 |
aView := nil |
|
828 |
] |
|
60 | 829 |
]. |
830 |
||
100 | 831 |
aView isNil ifTrue:[ |
1120 | 832 |
(aView := self findObjectAt:aPoint) isNil ifTrue:[ |
833 |
^ self select:nil |
|
834 |
]. |
|
835 |
||
836 |
(self canChangeLayoutOfView:aView) ifFalse:[ |
|
837 |
^ self select:aView |
|
838 |
] |
|
61 | 839 |
]. |
840 |
||
841 |
(self isSelected:aView) ifFalse:[ |
|
1120 | 842 |
self select:aView. |
60 | 843 |
]. |
844 |
||
845 |
(self numberOfSelections ~~ 1) ifTrue:[ |
|
1120 | 846 |
releaseAction := [ |
847 |
self setDefaultActions. |
|
848 |
self select:aView |
|
849 |
] |
|
60 | 850 |
] ifFalse:[ |
1120 | 851 |
releaseAction := [self setDefaultActions] |
60 | 852 |
]. |
853 |
||
854 |
"prepare move operation for an object |
|
855 |
" |
|
61 | 856 |
|
60 | 857 |
motionAction := [:movePoint| |
1120 | 858 |
(aPoint dist:movePoint) > 8.0 ifTrue:[ |
859 |
self startObjectMoveAt:aPoint |
|
860 |
] |
|
60 | 861 |
]. |
862 |
! ! |
|
863 |
||
864 |
!UIObjectView methodsFor:'object resize'! |
|
865 |
||
866 |
actionResize:anObject selector:aSelector |
|
867 |
"create and initialize action for resize |
|
868 |
" |
|
869 |
|selector delta| |
|
870 |
||
871 |
delta := anObject container originRelativeTo:self. |
|
872 |
selector := ('resize:', aSelector, ':') asSymbol. |
|
873 |
||
543
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
874 |
resizeData := ResizeData new |
1120 | 875 |
object:anObject selector:selector delta:delta. |
60 | 876 |
|
877 |
"can change cursor dependent on vertical/horizontal resizing |
|
878 |
" |
|
879 |
oldCursor := cursor. |
|
880 |
self cursor:(Cursor leftHand). |
|
881 |
||
543
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
882 |
"Modified: / 2.2.1998 / 13:40:55 / cg" |
60 | 883 |
! |
884 |
||
885 |
doDragResize:aPoint |
|
61 | 886 |
"do a widget resize drag |
887 |
" |
|
60 | 888 |
|p object| |
889 |
||
175 | 890 |
object := resizeData object. |
60 | 891 |
|
892 |
self invertOutlineOf:object. |
|
175 | 893 |
p := (self alignToGrid:aPoint) - (resizeData delta). |
894 |
||
895 |
self perform:(resizeData selector) with:object with:p. |
|
1451 | 896 |
Delay waitForSeconds:0.05. |
897 |
[self sensor hasExposeEventFor:nil] whileTrue:[ |
|
898 |
self windowGroup processExposeEvents |
|
899 |
]. |
|
900 |
||
79 | 901 |
"/ object geometryLayout:(object geometryLayout). |
60 | 902 |
self invertOutlineOf:object |
903 |
! |
|
904 |
||
905 |
endResize |
|
61 | 906 |
"cleanup after object resize |
907 |
" |
|
908 |
|object| |
|
909 |
||
175 | 910 |
object := resizeData object. |
911 |
resizeData := nil. |
|
61 | 912 |
|
913 |
self invertOutlineOf:object. |
|
60 | 914 |
self setDefaultActions. |
61 | 915 |
self elementChangedSize:object. |
138 | 916 |
|
917 |
"/ handle any expose events (for subcomponents) before |
|
918 |
"/ redrawing the handles. |
|
919 |
Delay waitForSeconds:0.05. |
|
920 |
[self sensor hasExposeEventFor:nil] whileTrue:[ |
|
1451 | 921 |
self windowGroup processExposeEvents |
138 | 922 |
]. |
923 |
||
128 | 924 |
self setSelection:object withRedraw:true. |
225 | 925 |
self layoutChanged. |
60 | 926 |
! |
927 |
||
928 |
startResizeBorder:b of:selection |
|
929 |
"resize selected view |
|
930 |
" |
|
931 |
|object| |
|
932 |
||
933 |
object := self singleSelection. |
|
934 |
self actionResize:object selector:b. |
|
935 |
||
72 | 936 |
self transaction:#resize selectionDo:[:aView| |
1451 | 937 |
self createUndoLayout:aView |
60 | 938 |
]. |
128 | 939 |
self setSelection:nil withRedraw:true. |
60 | 940 |
|
941 |
motionAction := [:movePoint | self doDragResize:movePoint]. |
|
942 |
releaseAction := [self endResize]. |
|
943 |
self invertOutlineOf:object |
|
944 |
! ! |
|
945 |
||
946 |
!UIObjectView methodsFor:'private handles'! |
|
947 |
||
175 | 948 |
handlesOf:aComponent do:aTwoArgAction |
949 |
"perform action on each handle of a component |
|
950 |
" |
|
951 |
|dlt ext| |
|
952 |
||
953 |
dlt := (aComponent originRelativeTo:self) - aComponent origin. |
|
1451 | 954 |
dlt := dlt - (4@4). |
955 |
ext := 8@8. |
|
175 | 956 |
|
957 |
self class handlesOf:aComponent do:[:pnt :wht | |
|
1427 | 958 |
aTwoArgAction value:(pnt + dlt extent:ext) value:wht |
175 | 959 |
] |
60 | 960 |
! |
961 |
||
175 | 962 |
whichHandleOf:aComponent isHitBy:aPoint |
61 | 963 |
"returns kind of handle or nil |
964 |
" |
|
175 | 965 |
self handlesOf:aComponent do:[:rectangle :what| |
1120 | 966 |
(rectangle containsPoint:aPoint) ifTrue:[^ what] |
60 | 967 |
]. |
175 | 968 |
^ nil |
60 | 969 |
! ! |
970 |
||
971 |
!UIObjectView methodsFor:'private resizing-subviews'! |
|
972 |
||
973 |
resize:aView bottom:aPoint |
|
61 | 974 |
"resize a views bottom |
975 |
" |
|
134 | 976 |
undoHistory withoutTransactionDo:[ |
1120 | 977 |
self shiftLayout:aView top:0 bottom:((aPoint y) - (aView computeCorner y)) |
60 | 978 |
] |
979 |
! |
|
980 |
||
981 |
resize:aView bottomLeft:aPoint |
|
61 | 982 |
"resize a views bottom and left |
983 |
" |
|
134 | 984 |
undoHistory withoutTransactionDo:[ |
1120 | 985 |
self shiftLayout:aView top:0 |
986 |
bottom:((aPoint y) - (aView computeCorner y)) |
|
987 |
left:((aPoint x) - (aView computeOrigin x)) |
|
988 |
right:0 |
|
60 | 989 |
|
990 |
] |
|
991 |
||
992 |
||
993 |
! |
|
994 |
||
995 |
resize:aView corner:aPoint |
|
61 | 996 |
"resize a views corner |
997 |
" |
|
60 | 998 |
|delta| |
999 |
||
1000 |
delta := aPoint - aView computeCorner. |
|
1001 |
||
134 | 1002 |
undoHistory withoutTransactionDo:[ |
1120 | 1003 |
self shiftLayout:aView top:0 bottom:(delta y) left:0 right:(delta x) |
60 | 1004 |
] |
1005 |
! |
|
1006 |
||
1007 |
resize:aView left:aPoint |
|
61 | 1008 |
"resize a views left |
1009 |
" |
|
134 | 1010 |
undoHistory withoutTransactionDo:[ |
1120 | 1011 |
self shiftLayout:aView left:((aPoint x) - (aView computeOrigin x)) right:0 |
60 | 1012 |
] |
1013 |
||
1014 |
! |
|
1015 |
||
1016 |
resize:aView origin:aPoint |
|
61 | 1017 |
"resize a views origin |
1018 |
" |
|
60 | 1019 |
|delta| |
1020 |
||
1021 |
delta := aPoint - aView computeOrigin. |
|
1022 |
||
134 | 1023 |
undoHistory withoutTransactionDo:[ |
1120 | 1024 |
self shiftLayout:aView top:(delta y) bottom:0 left:(delta x) right:0 |
60 | 1025 |
] |
1026 |
||
1027 |
! |
|
1028 |
||
1029 |
resize:aView right:aPoint |
|
61 | 1030 |
"resize a views right |
1031 |
" |
|
134 | 1032 |
undoHistory withoutTransactionDo:[ |
1120 | 1033 |
self shiftLayout:aView left:0 right:((aPoint x) - (aView computeCorner x)) |
60 | 1034 |
] |
1035 |
! |
|
1036 |
||
1037 |
resize:aView top:aPoint |
|
61 | 1038 |
"resize a views top |
1039 |
" |
|
134 | 1040 |
undoHistory withoutTransactionDo:[ |
1120 | 1041 |
self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y)) bottom:0 |
60 | 1042 |
] |
1043 |
! |
|
1044 |
||
1045 |
resize:aView topRight:aPoint |
|
61 | 1046 |
"resize a views top and right |
1047 |
" |
|
134 | 1048 |
undoHistory withoutTransactionDo:[ |
1120 | 1049 |
self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y)) |
1050 |
bottom:0 |
|
1051 |
left:0 |
|
1052 |
right:((aPoint x) - (aView computeCorner x)) |
|
60 | 1053 |
|
1054 |
] |
|
1055 |
||
1056 |
! ! |
|
1057 |
||
1058 |
!UIObjectView methodsFor:'private shift-layout'! |
|
1059 |
||
1060 |
shiftLayout:aView left:l right:r |
|
1061 |
"shift layout for a view; in case of an open transaction, the undo |
|
1062 |
action is registered |
|
1063 |
" |
|
1064 |
self shiftLayout:aView top:0 bottom:0 left:l right:r |
|
1065 |
||
1066 |
! |
|
1067 |
||
1068 |
shiftLayout:aView top:t bottom:b |
|
1069 |
"shift layout for a view; in case of an open transaction, the undo |
|
1070 |
action is registered |
|
1071 |
" |
|
1072 |
self shiftLayout:aView top:t bottom:b left:0 right:0 |
|
1073 |
||
1074 |
||
1075 |
! |
|
1076 |
||
1077 |
shiftLayout:aView top:t bottom:b left:l right:r |
|
1078 |
"shift layout for a view; in case of an open transaction, the undo |
|
1079 |
action is registered |
|
1080 |
" |
|
79 | 1081 |
|type layout oldExt| |
61 | 1082 |
|
1083 |
type := self class layoutType:aView. |
|
1084 |
||
1085 |
type notNil ifTrue:[ |
|
1120 | 1086 |
self createUndoLayout:aView. |
1087 |
||
1088 |
type == #Extent ifTrue:[ |
|
1089 |
oldExt := aView extent. |
|
1090 |
aView extent:(oldExt + ((r-l) @ (b-t))). |
|
1091 |
^ self |
|
1092 |
]. |
|
1093 |
||
1094 |
layout := aView geometryLayout copy. |
|
1095 |
||
1096 |
layout isLayout ifTrue:[ |
|
1097 |
layout leftOffset:(layout leftOffset + l) |
|
1098 |
topOffset:(layout topOffset + t). |
|
61 | 1099 |
|
1120 | 1100 |
type == #LayoutFrame ifTrue:[ |
1101 |
layout bottomOffset:(layout bottomOffset + b). |
|
1102 |
layout rightOffset:(layout rightOffset + r). |
|
1103 |
] |
|
1104 |
] ifFalse:[ |
|
1105 |
type == #Rectangle ifTrue:[ |
|
1106 |
layout left:(layout left + l) |
|
1107 |
right:(layout right + r) |
|
1108 |
top:(layout top + t) |
|
1109 |
bottom:(layout bottom + b). |
|
1110 |
] ifFalse:[ "POINT" |
|
1111 |
layout x:(layout x + l) y:(layout y + t). |
|
1112 |
] |
|
1113 |
]. |
|
1114 |
aView geometryLayout:layout |
|
60 | 1115 |
] |
1116 |
! ! |
|
1117 |
||
1118 |
!UIObjectView methodsFor:'searching'! |
|
1119 |
||
1120 |
findObjectAt:aPoint |
|
1121 |
"find the origin/corner of the currentWidget |
|
1122 |
" |
|
1123 |
|view viewId lastId point listOfViews| |
|
1124 |
||
1500
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1451
diff
changeset
|
1125 |
point := aPoint + (device translatePoint:0@0 fromView:self toView:rootView). |
60 | 1126 |
|
1127 |
inputView lower. |
|
1128 |
||
1500
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1451
diff
changeset
|
1129 |
viewId := rootView id. |
60 | 1130 |
[viewId notNil] whileTrue:[ |
1500
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1451
diff
changeset
|
1131 |
lastId := viewId. |
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1451
diff
changeset
|
1132 |
viewId := device viewIdFromPoint:point in:lastId |
60 | 1133 |
]. |
1134 |
||
1135 |
inputView raise. |
|
1136 |
||
1137 |
view := device viewFromId:lastId. |
|
1138 |
||
1139 |
view ~~ inputView ifTrue:[^ view]. |
|
1140 |
||
1141 |
"/ look for 'hidden' views ... |
|
1142 |
||
1143 |
listOfViews := OrderedCollection new. |
|
1144 |
self allSubViewsDo:[:aView | |
|
1500
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1451
diff
changeset
|
1145 |
|org| |
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1451
diff
changeset
|
1146 |
|
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1451
diff
changeset
|
1147 |
aView ~~ inputView ifTrue:[ |
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1451
diff
changeset
|
1148 |
org := device translatePoint:0@0 fromView:aView toView:self. |
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1451
diff
changeset
|
1149 |
((org extent:aView extent) containsPoint:aPoint) ifTrue:[ |
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1451
diff
changeset
|
1150 |
listOfViews add:aView. |
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1451
diff
changeset
|
1151 |
] |
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1451
diff
changeset
|
1152 |
] |
60 | 1153 |
]. |
1154 |
||
1155 |
listOfViews size > 0 ifTrue:[ |
|
1500
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1451
diff
changeset
|
1156 |
^ listOfViews last |
60 | 1157 |
]. |
1158 |
^ nil |
|
1159 |
||
1500
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1451
diff
changeset
|
1160 |
"Modified: / 10.10.2001 / 14:05:07 / cg" |
60 | 1161 |
! ! |
1162 |
||
1163 |
!UIObjectView methodsFor:'selections'! |
|
1164 |
||
768 | 1165 |
hideSelection |
1427 | 1166 |
"hide the selection - undraw hilights - whatever that is |
1167 |
" |
|
1168 |
self showUnselected:selection. |
|
768 | 1169 |
! |
1170 |
||
128 | 1171 |
moveableSelection |
131 | 1172 |
"checks whether the selection is not empty and all selected instances |
1173 |
can be moved. If true the selection is returned otherwise nil |
|
128 | 1174 |
" |
1175 |
|coll| |
|
1176 |
||
1177 |
self hasSelection ifTrue:[ |
|
1120 | 1178 |
(self canMove:(coll := self selection)) ifTrue:[ |
1179 |
^ coll |
|
1180 |
] |
|
128 | 1181 |
]. |
1182 |
^ nil |
|
1183 |
! |
|
1184 |
||
60 | 1185 |
numberOfSelections |
131 | 1186 |
"return the number of selected instances |
61 | 1187 |
" |
128 | 1188 |
|coll size| |
1189 |
||
1190 |
coll := self selection. |
|
1191 |
size := coll size. |
|
1192 |
||
1193 |
(size ~~ 0 or:[coll isNil]) ifTrue:[^ size]. |
|
1194 |
^ 1 |
|
60 | 1195 |
! |
1196 |
||
149 | 1197 |
selection:something |
1198 |
"change selection to something |
|
1199 |
" |
|
1200 |
self select:something |
|
1201 |
! |
|
1202 |
||
128 | 1203 |
selectionDo:aBlock |
1204 |
"apply block to every selected object |
|
1205 |
" |
|
1206 |
self forEach:(self selection) do:aBlock |
|
1207 |
||
1208 |
||
1209 |
! |
|
1210 |
||
61 | 1211 |
showSelection |
128 | 1212 |
"show the selection - draw handles |
1213 |
" |
|
61 | 1214 |
selectionHiddenLevel == 0 ifTrue:[ |
1120 | 1215 |
self selectionDo:[:el| self showSelected:el ] |
60 | 1216 |
]. |
1217 |
! |
|
1218 |
||
1219 |
singleSelection |
|
131 | 1220 |
"checks whether one element is selected; in this case the element is |
1221 |
returned otherwise nil |
|
60 | 1222 |
" |
128 | 1223 |
|coll| |
1224 |
||
1225 |
(coll := self selection) isCollection ifFalse:[ |
|
1120 | 1226 |
^ coll |
60 | 1227 |
]. |
128 | 1228 |
|
1229 |
coll size == 1 ifTrue:[ ^ coll first]. |
|
1230 |
^ nil |
|
60 | 1231 |
! |
1232 |
||
1233 |
singleSelectionDo:aBlock |
|
131 | 1234 |
"checks whether one element is selected; in this case the block |
1235 |
with argument the selected instance will be processed |
|
61 | 1236 |
" |
60 | 1237 |
|view| |
1238 |
||
1239 |
(view := self singleSelection) notNil ifTrue:[ |
|
1120 | 1240 |
aBlock value:view |
60 | 1241 |
] |
1242 |
! |
|
1243 |
||
1230
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
1244 |
twoElementSelection |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
1245 |
"checks whether exactly two elements are selected; |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
1246 |
in this case, return the selection collection. |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
1247 |
otherwise return nil |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
1248 |
" |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
1249 |
|coll| |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
1250 |
|
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
1251 |
(coll := self selection) isCollection ifFalse:[ |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
1252 |
^ nil "/ single |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
1253 |
]. |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
1254 |
|
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
1255 |
coll size == 2 ifTrue:[ ^ coll]. |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
1256 |
^ nil |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
1257 |
! |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
1258 |
|
60 | 1259 |
unselect |
61 | 1260 |
"clear selection |
1261 |
" |
|
128 | 1262 |
self select:nil |
60 | 1263 |
! |
1264 |
||
1265 |
withSelectionHiddenDo:aBlock |
|
61 | 1266 |
"apply block with selection hidden (no handles) |
1267 |
" |
|
78 | 1268 |
|coll| |
1269 |
||
138 | 1270 |
selectionHiddenLevel == 0 ifTrue:[ |
1120 | 1271 |
self hideSelection. |
1272 |
device flush. |
|
61 | 1273 |
]. |
138 | 1274 |
selectionHiddenLevel := selectionHiddenLevel + 1. |
61 | 1275 |
|
1276 |
aBlock valueNowOrOnUnwindDo:[ |
|
1120 | 1277 |
selectionHiddenLevel == 1 ifTrue:[ |
1278 |