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