author | Claus Gittinger <cg@exept.de> |
Tue, 26 Feb 2008 11:42:57 +0100 | |
changeset 2303 | 17d06263ee96 |
parent 2267 | f93749e64030 |
child 2349 | 6fdcf778c5ab |
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. |
|
2246 | 618 |
self clearRectangle:redrawFrame. |
1911 | 619 |
|
620 |
self selectionDo:[:aComponent | |
|
621 |
|anyHandleToRedraw| |
|
622 |
||
623 |
anyHandleToRedraw := false. |
|
624 |
self handlesOf:aComponent do:[:hRect :typeOfHandle | |
|
625 |
(hRect intersects:redrawFrame) ifTrue:[ |
|
626 |
anyHandleToRedraw := true. |
|
627 |
]. |
|
628 |
]. |
|
629 |
anyHandleToRedraw ifTrue:[ |
|
630 |
self showSelected:aComponent |
|
631 |
] |
|
632 |
] |
|
2246 | 633 |
|
634 |
"Modified: / 16-01-2008 / 17:57:09 / cg" |
|
624
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
635 |
! |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
636 |
|
60 | 637 |
sizeChanged:how |
61 | 638 |
"size of a view(s) changed |
639 |
" |
|
60 | 640 |
self withSelectionHiddenDo:[ |
1672 | 641 |
super sizeChanged:how. |
642 |
]. |
|
60 | 643 |
! ! |
644 |
||
645 |
!UIObjectView methodsFor:'initialization'! |
|
646 |
||
647 |
initialize |
|
61 | 648 |
"setup attributes |
649 |
" |
|
60 | 650 |
super initialize. |
651 |
||
61 | 652 |
setOfSuperViewsSizeChanged := IdentitySet new. |
60 | 653 |
self setDefaultActions. |
654 |
||
1954 | 655 |
undoHistory := UndoHistory on:self. |
656 |
||
1100
bf884041701f
Implement common channels in View.
Stefan Vogel <sv@exept.de>
parents:
1048
diff
changeset
|
657 |
self enableChannel:(true asValue). |
119 | 658 |
clipChildren := true. |
61 | 659 |
selectionHiddenLevel := 0. |
60 | 660 |
|
661 |
(self class gridShown) ifTrue:[ |
|
1672 | 662 |
super showGrid |
60 | 663 |
]. |
664 |
||
897
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
665 |
"Modified: / 20.7.1998 / 18:14:51 / cg" |
1100
bf884041701f
Implement common channels in View.
Stefan Vogel <sv@exept.de>
parents:
1048
diff
changeset
|
666 |
"Modified: / 30.3.1999 / 16:19:15 / stefan" |
60 | 667 |
! |
668 |
||
284 | 669 |
map |
670 |
"make the view visible on the screen and in case of a none empty |
|
671 |
selection the selection will be shown. |
|
672 |
" |
|
673 |
super map. |
|
674 |
self showSelection. |
|
675 |
! |
|
676 |
||
60 | 677 |
realize |
1672 | 678 |
|windowGroup| |
679 |
||
60 | 680 |
super realize. |
1672 | 681 |
windowGroup := self windowGroup. |
682 |
windowGroup addPreEventHook:self. |
|
683 |
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
|
684 |
! |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
685 |
|
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
686 |
remap |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
687 |
"make the view visible on the screen and in case of a none empty |
1746 | 688 |
selection the selection will be shown" |
689 |
||
690 |
self shouldNotImplement |
|
60 | 691 |
! ! |
692 |
||
693 |
!UIObjectView methodsFor:'misc'! |
|
694 |
||
175 | 695 |
invertOutlineOf:something |
696 |
"invert outline of an object or collection of objects |
|
61 | 697 |
" |
993
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
698 |
|wasClipped| |
60 | 699 |
|
700 |
(wasClipped := clipChildren) ifTrue:[ |
|
1451 | 701 |
self clippedByChildren:(clipChildren := false). |
60 | 702 |
]. |
175 | 703 |
|
993
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
704 |
self xoring:[ |
1451 | 705 |
|p| |
706 |
||
707 |
something isCollection ifTrue:[ |
|
708 |
something do:[:v | |
|
709 |
|p| |
|
710 |
||
711 |
p := v originRelativeTo:self. |
|
712 |
self displayRectangle:(p extent:v extent). |
|
713 |
]. |
|
714 |
] ifFalse:[ |
|
715 |
|p| |
|
716 |
||
717 |
p := something originRelativeTo:self. |
|
718 |
self displayRectangle:(p extent:something extent). |
|
719 |
] |
|
60 | 720 |
]. |
721 |
||
722 |
wasClipped ifTrue:[ |
|
1451 | 723 |
self clippedByChildren:(clipChildren := true). |
60 | 724 |
]. |
725 |
! |
|
726 |
||
2255 | 727 |
minClosedViewSetFor:setOfViews |
728 |
"return the minimum closure for a given set of view; |
|
729 |
That is the minimum set of views which contains the given set of views. |
|
730 |
Concrete: all subviews from setOfViews of which any superView is already in the set |
|
731 |
is excluded from the result" |
|
732 |
||
78 | 733 |
setOfViews isCollection ifFalse:[ |
1903
f409fa760169
refactored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
1895
diff
changeset
|
734 |
setOfViews notNil ifTrue:[^ Array with:setOfViews]. |
f409fa760169
refactored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
1895
diff
changeset
|
735 |
^ nil |
72 | 736 |
]. |
1903
f409fa760169
refactored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
1895
diff
changeset
|
737 |
^ setOfViews |
f409fa760169
refactored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
1895
diff
changeset
|
738 |
select:[:aView| |
f409fa760169
refactored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
1895
diff
changeset
|
739 |
(setOfViews contains:[:v | aView isComponentOf:v]) not |
f409fa760169
refactored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
1895
diff
changeset
|
740 |
] |
72 | 741 |
! |
742 |
||
624
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
743 |
redrawObjectsInVisible:redrawFrame |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
744 |
"my objects are views - they redraw themself" |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
745 |
|
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
746 |
^ self |
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 |
! |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
749 |
|
60 | 750 |
setDefaultActions |
61 | 751 |
"set default actions |
752 |
" |
|
60 | 753 |
pressAction := [:pressPoint | self startSelectOrMove:pressPoint]. |
754 |
shiftPressAction := [:pressPoint | self startSelectMoreOrMove:pressPoint]. |
|
1861 | 755 |
ctrlPressAction := [:pressPoint | self startSelectMoreOrMove:pressPoint]. |
60 | 756 |
motionAction := [:movePoint | nil]. |
757 |
releaseAction := [nil]. |
|
758 |
keyPressAction := nil. |
|
1827 | 759 |
doublePressAction := [:pressPoint | self doublePressed: pressPoint]. |
60 | 760 |
|
761 |
self cursor:Cursor normal. |
|
762 |
! ! |
|
763 |
||
764 |
!UIObjectView methodsFor:'object moving'! |
|
765 |
||
766 |
doObjectMove:aPoint |
|
767 |
"move selection |
|
768 |
" |
|
769 |
movedObject notNil ifTrue:[ |
|
1120 | 770 |
self invertOutlineOf:movedObject. |
771 |
||
772 |
movedObject keysAndValuesDo:[:i :v| |
|
773 |
self moveObject:v to:(aPoint - (moveDelta at:i)). |
|
774 |
]. |
|
775 |
self invertOutlineOf:movedObject. |
|
60 | 776 |
] |
777 |
||
778 |
! |
|
779 |
||
780 |
endObjectMove |
|
61 | 781 |
"cleanup after object(s) move |
2205
0582767018d7
endObjectMove - send expose to all - workaround drawing
ca
parents:
2203
diff
changeset
|
782 |
send expose to each view - workaround.... |
61 | 783 |
" |
2205
0582767018d7
endObjectMove - send expose to all - workaround drawing
ca
parents:
2203
diff
changeset
|
784 |
|newSel| |
0582767018d7
endObjectMove - send expose to all - workaround drawing
ca
parents:
2203
diff
changeset
|
785 |
|
0582767018d7
endObjectMove - send expose to all - workaround drawing
ca
parents:
2203
diff
changeset
|
786 |
movedObject isNil ifTrue:[^ self]. |
0582767018d7
endObjectMove - send expose to all - workaround drawing
ca
parents:
2203
diff
changeset
|
787 |
|
0582767018d7
endObjectMove - send expose to all - workaround drawing
ca
parents:
2203
diff
changeset
|
788 |
movedObject size == 1 ifTrue:[ newSel := movedObject first ] |
0582767018d7
endObjectMove - send expose to all - workaround drawing
ca
parents:
2203
diff
changeset
|
789 |
ifFalse:[ newSel := movedObject ]. |
0582767018d7
endObjectMove - send expose to all - workaround drawing
ca
parents:
2203
diff
changeset
|
790 |
movedObject := nil. |
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 |
self withSelectionHiddenDo:[ |
0582767018d7
endObjectMove - send expose to all - workaround drawing
ca
parents:
2203
diff
changeset
|
793 |
self setSelection:newSel withRedraw:false. |
0582767018d7
endObjectMove - send expose to all - workaround drawing
ca
parents:
2203
diff
changeset
|
794 |
|
0582767018d7
endObjectMove - send expose to all - workaround drawing
ca
parents:
2203
diff
changeset
|
795 |
self allSubViewsDo:[:v| |
0582767018d7
endObjectMove - send expose to all - workaround drawing
ca
parents:
2203
diff
changeset
|
796 |
v shown ifTrue:[ |
0582767018d7
endObjectMove - send expose to all - workaround drawing
ca
parents:
2203
diff
changeset
|
797 |
v fill:v viewBackground. |
0582767018d7
endObjectMove - send expose to all - workaround drawing
ca
parents:
2203
diff
changeset
|
798 |
v exposeX:0 y:0 width:v width height:v height. |
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 |
|
0582767018d7
endObjectMove - send expose to all - workaround drawing
ca
parents:
2203
diff
changeset
|
802 |
self setDefaultActions. |
0582767018d7
endObjectMove - send expose to all - workaround drawing
ca
parents:
2203
diff
changeset
|
803 |
self layoutChanged. |
60 | 804 |
]. |
805 |
! |
|
806 |
||
807 |
moveObject:anObject to:aPoint |
|
808 |
"move anObject to newOrigin, aPoint |
|
809 |
" |
|
810 |
|dX dY org delta| |
|
811 |
||
812 |
anObject notNil ifTrue:[ |
|
1954 | 813 |
org := anObject computeOrigin. |
814 |
||
815 |
delta := aPoint - org. |
|
816 |
delta := (self alignToGrid:aPoint) - org. |
|
817 |
dX := delta x. |
|
818 |
dY := delta y. |
|
819 |
||
820 |
undoHistory withoutTransactionDo:[ |
|
821 |
self shiftLayout:anObject top:dY bottom:dY left:dX right:dX |
|
822 |
] |
|
60 | 823 |
] |
824 |
! |
|
825 |
||
826 |
startObjectMoveAt:aPoint |
|
61 | 827 |
"start object(s) move at a point |
828 |
" |
|
128 | 829 |
self startObjectMove:(self selection) at:aPoint. |
830 |
movedObject := self selection. |
|
831 |
||
832 |
movedObject isCollection ifFalse:[ |
|
1451 | 833 |
movedObject := Array with:movedObject |
60 | 834 |
]. |
128 | 835 |
self setSelection:nil withRedraw:true. |
60 | 836 |
|
837 |
moveDelta := movedObject collect:[:aView| |
|
1451 | 838 |
aPoint - aView computeOrigin |
60 | 839 |
]. |
175 | 840 |
self transaction:#move objects:movedObject do:[:v|self createUndoLayout:v]. |
841 |
self invertOutlineOf:movedObject. |
|
60 | 842 |
! |
843 |
||
844 |
startSelectMoreOrMove:aPoint |
|
845 |
"add/remove to/from selection" |
|
846 |
||
847 |
|anObject| |
|
848 |
||
119 | 849 |
self enabled ifFalse:[^ self]. |
60 | 850 |
|
851 |
anObject := self findObjectAt:aPoint. |
|
852 |
anObject notNil ifTrue:[ |
|
1120 | 853 |
(self isSelected:anObject) ifTrue:[ |
854 |
self removeFromSelection:anObject |
|
855 |
] ifFalse:[ |
|
856 |
self addToSelection:anObject |
|
857 |
] |
|
60 | 858 |
] |
859 |
! |
|
860 |
||
861 |
startSelectOrMove:aPoint |
|
61 | 862 |
"a button is pressed at a point; start moving or selection |
60 | 863 |
" |
284 | 864 |
|aView b v| |
60 | 865 |
|
119 | 866 |
self enabled ifFalse:[^ self]. |
60 | 867 |
|
61 | 868 |
aView := self singleSelection. |
869 |
||
870 |
aView notNil ifTrue:[ |
|
1120 | 871 |
v := self findContainerOfView:aView. |
872 |
||
873 |
v specClass canResizeSubComponents ifTrue:[ |
|
874 |
b := self whichHandleOf:aView isHitBy:aPoint. |
|
875 |
||
876 |
(b notNil and:[b ~~ #view]) ifTrue:[ |
|
877 |
^ self startResizeBorder:b of:aView. |
|
878 |
] |
|
879 |
]. |
|
880 |
||
881 |
(self sensor ctrlDown and:[self canChangeLayoutOfView:aView]) ifFalse:[ |
|
882 |
aView := nil |
|
883 |
] |
|
60 | 884 |
]. |
885 |
||
100 | 886 |
aView isNil ifTrue:[ |
1120 | 887 |
(aView := self findObjectAt:aPoint) isNil ifTrue:[ |
888 |
^ self select:nil |
|
889 |
]. |
|
890 |
||
891 |
(self canChangeLayoutOfView:aView) ifFalse:[ |
|
892 |
^ self select:aView |
|
893 |
] |
|
61 | 894 |
]. |
895 |
||
896 |
(self isSelected:aView) ifFalse:[ |
|
1120 | 897 |
self select:aView. |
60 | 898 |
]. |
899 |
||
900 |
(self numberOfSelections ~~ 1) ifTrue:[ |
|
1120 | 901 |
releaseAction := [ |
902 |
self setDefaultActions. |
|
903 |
self select:aView |
|
904 |
] |
|
60 | 905 |
] ifFalse:[ |
1120 | 906 |
releaseAction := [self setDefaultActions] |
60 | 907 |
]. |
908 |
||
909 |
"prepare move operation for an object |
|
910 |
" |
|
61 | 911 |
|
60 | 912 |
motionAction := [:movePoint| |
1120 | 913 |
(aPoint dist:movePoint) > 8.0 ifTrue:[ |
914 |
self startObjectMoveAt:aPoint |
|
915 |
] |
|
60 | 916 |
]. |
917 |
! ! |
|
918 |
||
919 |
!UIObjectView methodsFor:'object resize'! |
|
920 |
||
921 |
actionResize:anObject selector:aSelector |
|
922 |
"create and initialize action for resize |
|
923 |
" |
|
924 |
|selector delta| |
|
925 |
||
926 |
delta := anObject container originRelativeTo:self. |
|
927 |
selector := ('resize:', aSelector, ':') asSymbol. |
|
928 |
||
543
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
929 |
resizeData := ResizeData new |
1120 | 930 |
object:anObject selector:selector delta:delta. |
60 | 931 |
|
932 |
"can change cursor dependent on vertical/horizontal resizing |
|
933 |
" |
|
934 |
oldCursor := cursor. |
|
935 |
self cursor:(Cursor leftHand). |
|
936 |
||
543
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
937 |
"Modified: / 2.2.1998 / 13:40:55 / cg" |
60 | 938 |
! |
939 |
||
940 |
doDragResize:aPoint |
|
61 | 941 |
"do a widget resize drag |
942 |
" |
|
60 | 943 |
|p object| |
944 |
||
175 | 945 |
object := resizeData object. |
60 | 946 |
|
947 |
self invertOutlineOf:object. |
|
175 | 948 |
p := (self alignToGrid:aPoint) - (resizeData delta). |
949 |
||
950 |
self perform:(resizeData selector) with:object with:p. |
|
1451 | 951 |
Delay waitForSeconds:0.05. |
952 |
[self sensor hasExposeEventFor:nil] whileTrue:[ |
|
953 |
self windowGroup processExposeEvents |
|
954 |
]. |
|
955 |
||
79 | 956 |
"/ object geometryLayout:(object geometryLayout). |
60 | 957 |
self invertOutlineOf:object |
958 |
! |
|
959 |
||
960 |
endResize |
|
61 | 961 |
"cleanup after object resize |
962 |
" |
|
963 |
|object| |
|
964 |
||
175 | 965 |
object := resizeData object. |
966 |
resizeData := nil. |
|
61 | 967 |
|
968 |
self invertOutlineOf:object. |
|
60 | 969 |
self setDefaultActions. |
61 | 970 |
self elementChangedSize:object. |
138 | 971 |
|
972 |
"/ handle any expose events (for subcomponents) before |
|
973 |
"/ redrawing the handles. |
|
974 |
Delay waitForSeconds:0.05. |
|
975 |
[self sensor hasExposeEventFor:nil] whileTrue:[ |
|
1451 | 976 |
self windowGroup processExposeEvents |
138 | 977 |
]. |
978 |
||
128 | 979 |
self setSelection:object withRedraw:true. |
1827 | 980 |
self forEach:selection do:[:aView | |
981 |
self recomputeShapeIfTransparentBox:aView. |
|
982 |
]. |
|
225 | 983 |
self layoutChanged. |
60 | 984 |
! |
985 |
||
1827 | 986 |
layoutChanged |
987 |
! |
|
988 |
||
60 | 989 |
startResizeBorder:b of:selection |
990 |
"resize selected view |
|
991 |
" |
|
992 |
|object| |
|
993 |
||
994 |
object := self singleSelection. |
|
995 |
self actionResize:object selector:b. |
|
996 |
||
72 | 997 |
self transaction:#resize selectionDo:[:aView| |
1451 | 998 |
self createUndoLayout:aView |
60 | 999 |
]. |
128 | 1000 |
self setSelection:nil withRedraw:true. |
60 | 1001 |
|
1002 |
motionAction := [:movePoint | self doDragResize:movePoint]. |
|
1003 |
releaseAction := [self endResize]. |
|
1004 |
self invertOutlineOf:object |
|
1005 |
! ! |
|
1006 |
||
1954 | 1007 |
!UIObjectView methodsFor:'private'! |
1008 |
||
1009 |
undoHistoryChanged |
|
1010 |
self hasUndoHistoryHolder value:(self hasUndoHistory). |
|
1011 |
! ! |
|
1012 |
||
1714 | 1013 |
!UIObjectView methodsFor:'private-handles'! |
60 | 1014 |
|
175 | 1015 |
handlesOf:aComponent do:aTwoArgAction |
1016 |
"perform action on each handle of a component |
|
1017 |
" |
|
1018 |
|dlt ext| |
|
1019 |
||
1020 |
dlt := (aComponent originRelativeTo:self) - aComponent origin. |
|
1451 | 1021 |
dlt := dlt - (4@4). |
1022 |
ext := 8@8. |
|
175 | 1023 |
|
1024 |
self class handlesOf:aComponent do:[:pnt :wht | |
|
1427 | 1025 |
aTwoArgAction value:(pnt + dlt extent:ext) value:wht |
175 | 1026 |
] |
60 | 1027 |
! |
1028 |
||
175 | 1029 |
whichHandleOf:aComponent isHitBy:aPoint |
61 | 1030 |
"returns kind of handle or nil |
1031 |
" |
|
175 | 1032 |
self handlesOf:aComponent do:[:rectangle :what| |
1120 | 1033 |
(rectangle containsPoint:aPoint) ifTrue:[^ what] |
60 | 1034 |
]. |
175 | 1035 |
^ nil |
60 | 1036 |
! ! |
1037 |
||
1714 | 1038 |
!UIObjectView methodsFor:'private-resizing subviews'! |
60 | 1039 |
|
1827 | 1040 |
recomputeShapeIfTransparentBox:aView |
1829 | 1041 |
(aView notNil and:[aView isTransparentBox]) ifTrue:[ |
1827 | 1042 |
aView computeShape. |
1043 |
aView clear; redraw |
|
1044 |
]. |
|
1045 |
! |
|
1046 |
||
60 | 1047 |
resize:aView bottom:aPoint |
1954 | 1048 |
"resize a views bottom" |
1049 |
||
134 | 1050 |
undoHistory withoutTransactionDo:[ |
1954 | 1051 |
self shiftLayout:aView top:0 bottom:((aPoint y) - (aView computeCorner y)) |
1052 |
]. |
|
60 | 1053 |
! |
1054 |
||
1055 |
resize:aView bottomLeft:aPoint |
|
1954 | 1056 |
"resize a views bottom and left" |
1057 |
||
134 | 1058 |
undoHistory withoutTransactionDo:[ |
1954 | 1059 |
self shiftLayout:aView top:0 |
1060 |
bottom:((aPoint y) - (aView computeCorner y)) |
|
1061 |
left:((aPoint x) - (aView computeOrigin x)) |
|
1062 |
right:0 |
|
60 | 1063 |
|
1064 |
] |
|
1065 |
! |
|
1066 |
||
1067 |
resize:aView corner:aPoint |
|
1954 | 1068 |
"resize a views corner" |
1069 |
||
60 | 1070 |
|delta| |
1071 |
||
1072 |
delta := aPoint - aView computeCorner. |
|
1073 |
||
134 | 1074 |
undoHistory withoutTransactionDo:[ |
1954 | 1075 |
self shiftLayout:aView top:0 bottom:(delta y) left:0 right:(delta x) |
60 | 1076 |
] |
1077 |
! |
|
1078 |
||
1079 |
resize:aView left:aPoint |
|
1954 | 1080 |
"resize a views left" |
1081 |
||
134 | 1082 |
undoHistory withoutTransactionDo:[ |
1954 | 1083 |
self shiftLayout:aView left:((aPoint x) - (aView computeOrigin x)) right:0 |
60 | 1084 |
] |
1085 |
! |
|
1086 |
||
1087 |
resize:aView origin:aPoint |
|
1954 | 1088 |
"resize a views origin" |
1089 |
||
60 | 1090 |
|delta| |
1091 |
||
1092 |
delta := aPoint - aView computeOrigin. |
|
1093 |
||
134 | 1094 |
undoHistory withoutTransactionDo:[ |
1954 | 1095 |
self shiftLayout:aView top:(delta y) bottom:0 left:(delta x) right:0 |
60 | 1096 |
] |
1097 |
! |
|
1098 |
||
1099 |
resize:aView right:aPoint |
|
1954 | 1100 |
"resize a views right" |
1101 |
||
134 | 1102 |
undoHistory withoutTransactionDo:[ |
1954 | 1103 |
self shiftLayout:aView left:0 right:((aPoint x) - (aView computeCorner x)) |
60 | 1104 |
] |
1105 |
! |
|
1106 |
||
1107 |
resize:aView top:aPoint |
|
1954 | 1108 |
"resize a views top" |
1109 |
||
134 | 1110 |
undoHistory withoutTransactionDo:[ |
1954 | 1111 |
self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y)) bottom:0 |
60 | 1112 |
] |
1113 |
! |
|
1114 |
||
1115 |
resize:aView topRight:aPoint |
|
1954 | 1116 |
"resize a views top and right" |
1117 |
||
134 | 1118 |
undoHistory withoutTransactionDo:[ |
1954 | 1119 |
self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y)) |
1120 |
bottom:0 |
|
1121 |
left:0 |
|
1122 |
right:((aPoint x) - (aView computeCorner x)) |
|
60 | 1123 |
|
1124 |
] |
|
1125 |
! ! |
|
1126 |
||
1714 | 1127 |
!UIObjectView methodsFor:'private-shift layout'! |
60 | 1128 |
|
1129 |
shiftLayout:aView left:l right:r |
|
1130 |
"shift layout for a view; in case of an open transaction, the undo |
|
1131 |
action is registered |
|
1132 |
" |
|
1133 |
self shiftLayout:aView top:0 bottom:0 left:l right:r |
|
1134 |
||
1135 |
! |
|
1136 |
||
1137 |
shiftLayout:aView top:t bottom:b |
|
1138 |
"shift layout for a view; in case of an open transaction, the undo |
|
1139 |
action is registered |
|
1140 |
" |
|
1141 |
self shiftLayout:aView top:t bottom:b left:0 right:0 |
|
1142 |
||
1143 |
||
1144 |
! |
|
1145 |
||
1146 |
shiftLayout:aView top:t bottom:b left:l right:r |
|
1147 |
"shift layout for a view; in case of an open transaction, the undo |
|
1148 |
action is registered |
|
1149 |
" |
|
79 | 1150 |
|type layout oldExt| |
61 | 1151 |
|
1152 |
type := self class layoutType:aView. |
|
1153 |
||
1154 |
type notNil ifTrue:[ |
|
1120 | 1155 |
self createUndoLayout:aView. |
1156 |
||
1157 |
type == #Extent ifTrue:[ |
|
1158 |
oldExt := aView extent. |
|
1159 |
aView extent:(oldExt + ((r-l) @ (b-t))). |
|
1160 |
^ self |
|
1161 |
]. |
|
1162 |
||
1163 |
layout := aView geometryLayout copy. |
|
1164 |
||
1165 |
layout isLayout ifTrue:[ |
|
1166 |
layout leftOffset:(layout leftOffset + l) |
|
1167 |
topOffset:(layout topOffset + t). |
|
61 | 1168 |
|
1120 | 1169 |
type == #LayoutFrame ifTrue:[ |
1170 |
layout bottomOffset:(layout bottomOffset + b). |
|
1171 |
layout rightOffset:(layout rightOffset + r). |
|
1172 |
] |
|
1173 |
] ifFalse:[ |
|
1174 |
type == #Rectangle ifTrue:[ |
|
1175 |
layout left:(layout left + l) |
|
1176 |
right:(layout right + r) |
|
1177 |
top:(layout top + t) |
|
1178 |
bottom:(layout bottom + b). |
|
1179 |
] ifFalse:[ "POINT" |
|
1180 |
layout x:(layout x + l) y:(layout y + t). |
|
1181 |
] |
|
1182 |
]. |
|
1183 |
aView geometryLayout:layout |
|
60 | 1184 |
] |
1185 |
! ! |
|
1186 |
||
1187 |
!UIObjectView methodsFor:'searching'! |
|
1188 |
||
1189 |
findObjectAt:aPoint |
|
1190 |
"find the origin/corner of the currentWidget |
|
1191 |
" |
|
1672 | 1192 |
|view viewId lastId point| |
60 | 1193 |
|
1500
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1451
diff
changeset
|
1194 |
point := aPoint + (device translatePoint:0@0 fromView:self toView:rootView). |
60 | 1195 |
|
1500
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1451
diff
changeset
|
1196 |
viewId := rootView id. |
60 | 1197 |
[viewId notNil] whileTrue:[ |
1500
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1451
diff
changeset
|
1198 |
lastId := viewId. |
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1451
diff
changeset
|
1199 |
viewId := device viewIdFromPoint:point in:lastId |
60 | 1200 |
]. |
1201 |
||
1202 |
view := device viewFromId:lastId. |
|
1672 | 1203 |
view == self ifTrue:[ ^ nil]. |
1204 |
^ view |
|
1205 |
"/ view ~~ inputView ifTrue:[^ view]. |
|
1206 |
"/ |
|
1207 |
"/ "/ look for 'hidden' views ... |
|
1208 |
"/ |
|
1209 |
"/ listOfViews := OrderedCollection new. |
|
1210 |
"/ self allSubViewsDo:[:aView | |
|
1211 |
"/ |org| |
|
1212 |
"/ |
|
1213 |
"/ aView ~~ inputView ifTrue:[ |
|
1214 |
"/ org := device translatePoint:0@0 fromView:aView toView:self. |
|
1215 |
"/ ((org extent:aView extent) containsPoint:aPoint) ifTrue:[ |
|
1216 |
"/ listOfViews add:aView. |
|
1217 |
"/ ] |
|
1218 |
"/ ] |
|
1219 |
"/ ]. |
|
1220 |
"/ |
|
1221 |
"/ listOfViews size > 0 ifTrue:[ |
|
1222 |
"/ ^ listOfViews last |
|
1223 |
"/ ]. |
|
1224 |
"/ ^ nil |
|
1225 |
"/ |
|
1226 |
"/ "Modified: / 10.10.2001 / 14:05:07 / cg" |
|
1227 |
"/ |
|
1228 |
"/ |
|
60 | 1229 |
! ! |
1230 |
||
1231 |
!UIObjectView methodsFor:'selections'! |
|
1232 |
||
768 | 1233 |
hideSelection |
1427 | 1234 |
"hide the selection - undraw hilights - whatever that is |
1235 |
" |
|
1236 |
self showUnselected:selection. |
|
768 | 1237 |
! |
1238 |
||
128 | 1239 |
moveableSelection |
131 | 1240 |
"checks whether the selection is not empty and all selected instances |
1241 |
can be moved. If true the selection is returned otherwise nil |
|
128 | 1242 |
" |
1243 |
|coll| |
|
1244 |
||
1245 |
self hasSelection ifTrue:[ |
|
1120 | 1246 |
(self canMove:(coll := self selection)) ifTrue:[ |
1247 |
^ coll |
|
1248 |
] |
|
128 | 1249 |
]. |
1250 |
^ nil |
|
1251 |
! |
|
1252 |
||
60 | 1253 |
numberOfSelections |
131 | 1254 |
"return the number of selected instances |
61 | 1255 |
" |
128 | 1256 |
|coll size| |
1257 |
||
1258 |
coll := self selection. |
|
1259 |
size := coll size. |
|
1260 |
||
1261 |
(size ~~ 0 or:[coll isNil]) ifTrue:[^ size]. |
|
1262 |
^ 1 |
|
60 | 1263 |
! |
1264 |
||
1827 | 1265 |
selectNextUpInHierarchy |
1266 |
self halt. |
|
1267 |
! |
|
1268 |
||
2215 | 1269 |
selection:newSelection |
1270 |
"change selection to newSelection" |
|
1271 |
||
1272 |
self select:newSelection |
|
149 | 1273 |
! |
1274 |
||
128 | 1275 |
selectionDo:aBlock |
1276 |
"apply block to every selected object |
|
1277 |
" |
|
1278 |
self forEach:(self selection) do:aBlock |
|
1279 |
||
1280 |
||
1281 |
! |
|
1282 |
||
61 | 1283 |
showSelection |
128 | 1284 |
"show the selection - draw handles |
1285 |
" |
|
61 | 1286 |
selectionHiddenLevel == 0 ifTrue:[ |
1120 | 1287 |
self selectionDo:[:el| self showSelected:el ] |
60 | 1288 |
]. |
1289 |
! |
|
1290 |
||
1291 |
singleSelection |
|
2267
f93749e64030
changed #singleSelection - make more comprehendable
Stefan Vog |