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