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