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