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