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