author | Claus Gittinger <cg@exept.de> |
Tue, 13 Jul 1999 18:57:31 +0200 | |
changeset 1191 | 32bb9f029ad2 |
parent 1120 | 230fe13c4e51 |
child 1222 | bcb8b0ec295c |
permissions | -rw-r--r-- |
156 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by eXept Software AG |
|
1120 | 3 |
All Rights Reserved |
156 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
||
14 |
||
60 | 15 |
ObjectView subclass:#UIObjectView |
1100
bf884041701f
Implement common channels in View.
Stefan Vogel <sv@exept.de>
parents:
1048
diff
changeset
|
16 |
instanceVariableNames:'saveSelection inputView undoHistory copiedExtent copiedLayout |
bf884041701f
Implement common channels in View.
Stefan Vogel <sv@exept.de>
parents:
1048
diff
changeset
|
17 |
resizeData clipChildren selectionHiddenLevel gridParameters |
bf884041701f
Implement common channels in View.
Stefan Vogel <sv@exept.de>
parents:
1048
diff
changeset
|
18 |
setOfSuperViewsSizeChanged' |
60 | 19 |
classVariableNames:'' |
20 |
poolDictionaries:'' |
|
21 |
category:'Interface-UIPainter' |
|
22 |
! |
|
23 |
||
543
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
24 |
Object subclass:#ResizeData |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
25 |
instanceVariableNames:'object selector delta' |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
26 |
classVariableNames:'' |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
27 |
poolDictionaries:'' |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
28 |
privateIn:UIObjectView |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
29 |
! |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
30 |
|
60 | 31 |
Object subclass:#UndoHistory |
134 | 32 |
instanceVariableNames:'startIdentifier identifier painter history transaction enabled' |
60 | 33 |
classVariableNames:'' |
34 |
poolDictionaries:'' |
|
35 |
privateIn:UIObjectView |
|
36 |
! |
|
37 |
||
54 | 38 |
Object subclass:#Transaction |
134 | 39 |
instanceVariableNames:'identifier type text actions' |
54 | 40 |
classVariableNames:'' |
41 |
poolDictionaries:'' |
|
42 |
privateIn:UIObjectView::UndoHistory |
|
43 |
! |
|
44 |
||
128 | 45 |
!UIObjectView class methodsFor:'documentation'! |
46 |
||
156 | 47 |
copyright |
48 |
" |
|
49 |
COPYRIGHT (c) 1995 by eXept Software AG |
|
1120 | 50 |
All Rights Reserved |
156 | 51 |
|
52 |
This software is furnished under a license and may be used |
|
53 |
only in accordance with the terms of that license and with the |
|
54 |
inclusion of the above copyright notice. This software may not |
|
55 |
be provided or otherwise made available to, or used by, any |
|
56 |
other person. No title to or ownership of the software is |
|
57 |
hereby transferred. |
|
58 |
" |
|
59 |
||
60 |
||
61 |
! |
|
62 |
||
128 | 63 |
documentation |
64 |
" |
|
131 | 65 |
buildIn view used by the UIPainter; it provides all services for creating, deleting |
66 |
moving and changing layouts of painted components on a canvas. |
|
128 | 67 |
|
68 |
[see also:] |
|
1120 | 69 |
UIBuilder |
70 |
UIPainterView |
|
156 | 71 |
|
72 |
[author:] |
|
1120 | 73 |
Claus Atzkern |
128 | 74 |
" |
75 |
||
76 |
! ! |
|
60 | 77 |
|
63 | 78 |
!UIObjectView class methodsFor:'conversion'! |
79 |
||
80 |
asLayoutFrameFromView:aView |
|
81 |
"convert layout from aView to a frameLayout. On success the frameLayout is |
|
82 |
returned otherwise nil |
|
83 |
" |
|
68 | 84 |
|lF lO rF rO tF tO bF bO type layout newLyt| |
85 |
||
86 |
type := self layoutType:aView. |
|
87 |
layout := aView geometryLayout. |
|
88 |
||
91 | 89 |
layout isNil ifTrue:[ |
1120 | 90 |
type == #Extent ifTrue:[ |
91 |
layout := aView bounds asLayout |
|
92 |
] |
|
91 | 93 |
]. |
94 |
||
68 | 95 |
(type isNil or:[layout isNil]) ifTrue:[ |
1120 | 96 |
^ nil |
63 | 97 |
]. |
98 |
||
68 | 99 |
type == #LayoutFrame ifTrue:[ |
1120 | 100 |
^ layout copy |
68 | 101 |
]. |
102 |
||
103 |
layout isLayout ifFalse:[ |
|
1120 | 104 |
type == #Rectangle ifTrue:[ |
105 |
lO := layout left. |
|
106 |
tO := layout top. |
|
107 |
rO := layout right. |
|
108 |
bO := layout bottom. |
|
109 |
] ifFalse:[ |
|
110 |
lO := layout x. |
|
111 |
tO := layout y. |
|
112 |
rO := lO + aView extent x. |
|
113 |
bO := tO + aView extent y. |
|
114 |
]. |
|
115 |
||
116 |
^ LayoutFrame leftFraction:0 offset:lO rightFraction:0 offset:rO |
|
117 |
topFraction:0 offset:tO bottomFraction:0 offset:bO |
|
63 | 118 |
]. |
119 |
||
68 | 120 |
lF := layout leftFraction. |
121 |
lO := layout leftOffset. |
|
122 |
tF := layout topFraction. |
|
123 |
tO := layout topOffset. |
|
124 |
bF := tF. |
|
125 |
bO := tO + aView extent y. |
|
126 |
rF := lF. |
|
127 |
rO := lO + aView extent x. |
|
128 |
||
129 |
newLyt := LayoutFrame leftFraction:lF offset:lO rightFraction:rF offset:rO |
|
1120 | 130 |
topFraction:tF offset:tO bottomFraction:bF offset:bO. |
68 | 131 |
|
132 |
( (type == #AlignmentOrigin) |
|
133 |
and:[layout leftAlignmentFraction ~~ 0 |
|
134 |
or:[layout topAlignmentFraction ~~ 0]] |
|
135 |
) ifTrue:[ |
|
1120 | 136 |
|svRc prBd dlta| |
137 |
||
138 |
svRc := aView superView viewRectangle. |
|
139 |
prBd := aView preferredBounds. |
|
140 |
dlta := ( ((layout rectangleRelativeTo:svRc preferred:prBd) corner) |
|
141 |
- ((newLyt rectangleRelativeTo:svRc preferred:prBd) corner) |
|
142 |
) rounded. |
|
143 |
||
144 |
newLyt leftOffset:(lO + dlta x). |
|
145 |
newLyt rightOffset:(rO + dlta x). |
|
146 |
newLyt topOffset:(tO + dlta y). |
|
147 |
newLyt bottomOffset:(bO + dlta y). |
|
68 | 148 |
]. |
149 |
^ newLyt. |
|
91 | 150 |
|
151 |
"Modified: 28.3.1997 / 19:52:48 / cg" |
|
63 | 152 |
! ! |
153 |
||
60 | 154 |
!UIObjectView class methodsFor:'defaults'! |
155 |
||
156 |
defaultGrid |
|
157 |
^ 4 @ 4 |
|
158 |
||
159 |
! |
|
160 |
||
161 |
gridShown |
|
162 |
^ false |
|
163 |
||
164 |
! |
|
165 |
||
166 |
handleSize |
|
167 |
"size of blob drawn for handles" |
|
168 |
^ 4 |
|
169 |
||
170 |
! |
|
171 |
||
172 |
hitDelta |
|
173 |
^ 4 |
|
174 |
||
175 |
! ! |
|
176 |
||
175 | 177 |
!UIObjectView class methodsFor:'handles'! |
178 |
||
179 |
handlesOf:aView do:aBlock |
|
180 |
|type v h| |
|
181 |
||
182 |
type := self layoutType:aView. |
|
183 |
||
184 |
(type == #LayoutFrame or:[type == #Rectangle]) ifTrue:[ |
|
1120 | 185 |
v := self isVerticalResizable:aView. |
186 |
h := self isHorizontalResizable:aView. |
|
187 |
||
188 |
h ifTrue:[ aBlock value:(aView leftCenter ) value:#left. |
|
189 |
aBlock value:(aView rightCenter) value:#right. |
|
190 |
]. |
|
191 |
v ifTrue:[ aBlock value:(aView topCenter ) value:#top. |
|
192 |
aBlock value:(aView bottomCenter) value:#bottom. |
|
193 |
]. |
|
194 |
||
195 |
(h and:[v]) ifTrue:[ |
|
196 |
aBlock value:(aView origin ) value:#origin. |
|
197 |
aBlock value:(aView topRight ) value:#topRight. |
|
198 |
aBlock value:(aView bottomLeft) value:#bottomLeft. |
|
199 |
aBlock value:(aView corner ) value:#corner. |
|
200 |
^ self |
|
201 |
] |
|
175 | 202 |
]. |
203 |
||
204 |
aBlock value:(aView origin ) value:#view. |
|
205 |
aBlock value:(aView topRight ) value:#view. |
|
206 |
aBlock value:(aView bottomLeft) value:#view. |
|
207 |
||
208 |
type == #Extent ifTrue:[ |
|
1120 | 209 |
v := self isVerticalResizable:aView. |
210 |
h := self isHorizontalResizable:aView. |
|
211 |
||
212 |
v ifTrue:[aBlock value:(aView bottomCenter) value:#bottom]. |
|
213 |
h ifTrue:[aBlock value:(aView rightCenter ) value:#right ]. |
|
214 |
||
215 |
(h and:[v]) ifTrue:[ |
|
216 |
aBlock value:(aView corner) value:#corner. |
|
217 |
^ self |
|
218 |
] |
|
175 | 219 |
]. |
220 |
aBlock value:(aView corner) value:#view. |
|
221 |
||
222 |
||
223 |
! ! |
|
224 |
||
61 | 225 |
!UIObjectView class methodsFor:'queries'! |
226 |
||
175 | 227 |
isHorizontalResizable:aComponent |
228 |
"returns true if instance is horizontal resizeable |
|
229 |
" |
|
230 |
(aComponent isKindOf:ScrollBar) ifTrue:[ |
|
1120 | 231 |
^ aComponent orientation == #horizontal |
175 | 232 |
]. |
233 |
(aComponent isKindOf:Scroller) ifTrue:[ |
|
1120 | 234 |
^ aComponent orientation == #horizontal |
175 | 235 |
]. |
236 |
(aComponent isKindOf:Slider) ifTrue:[ |
|
1120 | 237 |
^ aComponent orientation == #horizontal |
175 | 238 |
]. |
239 |
^ true |
|
240 |
||
241 |
! |
|
242 |
||
243 |
isVerticalResizable:aComponent |
|
244 |
"returns true if instance is vertical resizeable |
|
245 |
" |
|
246 |
(aComponent isKindOf:EditField) ifTrue:[ |
|
1120 | 247 |
^ false |
175 | 248 |
]. |
249 |
(aComponent isKindOf:ComboBoxView) ifTrue:[ |
|
1120 | 250 |
^ false |
175 | 251 |
]. |
252 |
(aComponent isKindOf:CheckBox) ifTrue:[ |
|
1120 | 253 |
^ false |
175 | 254 |
]. |
255 |
(aComponent isKindOf:ScrollBar) ifTrue:[ |
|
1120 | 256 |
^ aComponent orientation == #vertical |
175 | 257 |
]. |
258 |
(aComponent isKindOf:Scroller) ifTrue:[ |
|
1120 | 259 |
^ aComponent orientation == #vertical |
175 | 260 |
]. |
261 |
(aComponent isKindOf:Slider) ifTrue:[ |
|
1120 | 262 |
^ aComponent orientation == #vertical |
175 | 263 |
]. |
264 |
^ true |
|
265 |
||
266 |
! |
|
267 |
||
61 | 268 |
layoutType:aView |
269 |
"returns layout type of aView or nil |
|
270 |
" |
|
113 | 271 |
|layout spec superView| |
272 |
||
273 |
aView notNil ifTrue:[ |
|
1120 | 274 |
layout := aView geometryLayout. |
275 |
layout notNil ifTrue:[ |
|
276 |
layout isLayout ifTrue:[ |
|
277 |
layout isLayoutFrame ifTrue:[ ^ #LayoutFrame ]. |
|
278 |
layout isAlignmentOrigin ifTrue:[ ^ #AlignmentOrigin ]. |
|
279 |
layout isLayoutOrigin ifTrue:[ ^ #LayoutOrigin ]. |
|
280 |
] ifFalse:[ |
|
281 |
layout isRectangle ifTrue:[ ^ #Rectangle ]. |
|
282 |
layout isPoint ifTrue:[ ^ #Point ]. |
|
283 |
] |
|
284 |
] ifFalse:[ |
|
285 |
(superView := aView superView) notNil ifTrue:[ |
|
286 |
spec := superView specClass. |
|
287 |
spec canResizeSubComponents ifTrue:[ |
|
288 |
^ #Extent |
|
289 |
] |
|
290 |
] |
|
291 |
] |
|
61 | 292 |
]. |
293 |
^ nil |
|
294 |
||
67 | 295 |
"Modified: 28.2.1997 / 13:02:16 / cg" |
61 | 296 |
! ! |
297 |
||
60 | 298 |
!UIObjectView methodsFor:'accessing'! |
299 |
||
300 |
gridAlign |
|
61 | 301 |
"returns state of aligning to grid |
302 |
" |
|
60 | 303 |
^ aligning |
304 |
||
305 |
! |
|
306 |
||
307 |
gridAlign:aBool |
|
61 | 308 |
"change state of aligning to grid |
309 |
" |
|
60 | 310 |
aBool ifTrue:[self alignOn] |
1120 | 311 |
ifFalse:[self alignOff] |
60 | 312 |
|
313 |
! |
|
314 |
||
315 |
gridParameters |
|
316 |
"used by defineGrid, and in a separate method for |
|
317 |
easier redefinition in subclasses. |
|
318 |
Returns the grid parameters in an array of 7 elements, |
|
319 |
which control the appearance of the grid-pattern. |
|
320 |
the elements are: |
|
321 |
||
1120 | 322 |
bigStepH number of pixels horizontally between 2 major steps |
323 |
bigStepV number of pixels vertically between 2 major steps |
|
324 |
littleStepH number of pixels horizontally between 2 minor steps |
|
325 |
littleStepV number of pixels vertically between 2 minor steps |
|
326 |
gridAlignH number of pixels for horizontal grid align (pointer snap) |
|
327 |
gridAlignV number of pixels for vertical grid align (pointer snap) |
|
328 |
docBounds true, if document boundary should be shown |
|
60 | 329 |
|
330 |
if littleStepH/V are nil, only bigSteps are drawn. |
|
331 |
" |
|
360 | 332 |
gridParameters isNil ifTrue:[ |
1120 | 333 |
gridParameters := #(10 10 nil nil 10 10 false) |
360 | 334 |
]. |
335 |
^ gridParameters |
|
336 |
||
337 |
||
338 |
! |
|
339 |
||
340 |
gridParameters:newGridParameters |
|
341 |
"used by defineGrid, and in a separate method for |
|
342 |
easier redefinition in subclasses. |
|
343 |
Returns the grid parameters in an array of 7 elements, |
|
344 |
which control the appearance of the grid-pattern. |
|
345 |
the elements are: |
|
346 |
||
1120 | 347 |
bigStepH number of pixels horizontally between 2 major steps |
348 |
bigStepV number of pixels vertically between 2 major steps |
|
349 |
littleStepH number of pixels horizontally between 2 minor steps |
|
350 |
littleStepV number of pixels vertically between 2 minor steps |
|
351 |
gridAlignH number of pixels for horizontal grid align (pointer snap) |
|
352 |
gridAlignV number of pixels for vertical grid align (pointer snap) |
|
353 |
docBounds true, if document boundary should be shown |
|
360 | 354 |
|
355 |
if littleStepH/V are nil, only bigSteps are drawn. |
|
356 |
" |
|
357 |
newGridParameters size == 7 ifTrue:[ |
|
1120 | 358 |
gridParameters := newGridParameters |
360 | 359 |
]. |
60 | 360 |
|
361 |
||
362 |
! |
|
363 |
||
364 |
gridShown:aBool |
|
61 | 365 |
"change visibility of grid |
366 |
" |
|
60 | 367 |
aBool ifTrue:[self showGrid] |
1120 | 368 |
ifFalse:[self hideGrid] |
60 | 369 |
! |
370 |
||
371 |
hideGrid |
|
61 | 372 |
"hide grid |
373 |
" |
|
60 | 374 |
gridShown ifTrue:[ |
1120 | 375 |
self withSelectionHiddenDo:[super hideGrid] |
60 | 376 |
] |
377 |
||
378 |
||
379 |
! |
|
380 |
||
381 |
showGrid |
|
61 | 382 |
"show grid |
383 |
" |
|
384 |
self withSelectionHiddenDo:[super showGrid] |
|
119 | 385 |
! ! |
386 |
||
387 |
!UIObjectView methodsFor:'accessing behavior'! |
|
388 |
||
1100
bf884041701f
Implement common channels in View.
Stefan Vogel <sv@exept.de>
parents:
1048
diff
changeset
|
389 |
enableStateChanged |
bf884041701f
Implement common channels in View.
Stefan Vogel <sv@exept.de>
parents:
1048
diff
changeset
|
390 |
"set the modification / test mode |
bf884041701f
Implement common channels in View.
Stefan Vogel <sv@exept.de>
parents:
1048
diff
changeset
|
391 |
" |
1102 | 392 |
self shown ifTrue:[ |
1120 | 393 |
enableChannel value ifFalse:[ |
394 |
saveSelection := selection. |
|
395 |
self hideSelection. |
|
396 |
selection := nil. |
|
397 |
inputView unmap. |
|
398 |
] ifTrue:[ |
|
399 |
inputView raise. |
|
400 |
inputView realize. |
|
401 |
selection := saveSelection. |
|
402 |
self showSelection |
|
403 |
] |
|
1100
bf884041701f
Implement common channels in View.
Stefan Vogel <sv@exept.de>
parents:
1048
diff
changeset
|
404 |
] |
bf884041701f
Implement common channels in View.
Stefan Vogel <sv@exept.de>
parents:
1048
diff
changeset
|
405 |
|
bf884041701f
Implement common channels in View.
Stefan Vogel <sv@exept.de>
parents:
1048
diff
changeset
|
406 |
"Created: / 30.3.1999 / 16:17:24 / stefan" |
bf884041701f
Implement common channels in View.
Stefan Vogel <sv@exept.de>
parents:
1048
diff
changeset
|
407 |
! |
bf884041701f
Implement common channels in View.
Stefan Vogel <sv@exept.de>
parents:
1048
diff
changeset
|
408 |
|
119 | 409 |
enabled |
410 |
^ enableChannel value |
|
411 |
! |
|
412 |
||
413 |
enabled:aState |
|
414 |
"set the modification / test mode |
|
415 |
" |
|
1100
bf884041701f
Implement common channels in View.
Stefan Vogel <sv@exept.de>
parents:
1048
diff
changeset
|
416 |
|
bf884041701f
Implement common channels in View.
Stefan Vogel <sv@exept.de>
parents:
1048
diff
changeset
|
417 |
enableChannel value:aState |
bf884041701f
Implement common channels in View.
Stefan Vogel <sv@exept.de>
parents:
1048
diff
changeset
|
418 |
|
bf884041701f
Implement common channels in View.
Stefan Vogel <sv@exept.de>
parents:
1048
diff
changeset
|
419 |
"Modified: / 30.3.1999 / 16:18:12 / stefan" |
60 | 420 |
! |
421 |
||
134 | 422 |
resetModification |
423 |
"set modification state to false |
|
424 |
" |
|
425 |
undoHistory resetModification |
|
426 |
! |
|
427 |
||
60 | 428 |
testMode |
61 | 429 |
"returns true if running test |
60 | 430 |
" |
119 | 431 |
^ enableChannel value not |
60 | 432 |
|
433 |
||
434 |
! |
|
435 |
||
436 |
testMode:aBoolean |
|
61 | 437 |
"change test mode |
60 | 438 |
" |
1102 | 439 |
enableChannel value:(aBoolean not) |
60 | 440 |
! ! |
441 |
||
442 |
!UIObjectView methodsFor:'blocked'! |
|
443 |
||
444 |
addObject:anObject |
|
61 | 445 |
"add the argument, anObject to the contents - with redraw |
446 |
" |
|
1112 | 447 |
self halt:'should not be invoked' |
60 | 448 |
|
449 |
! |
|
450 |
||
451 |
addObjectWithoutRedraw:anObject |
|
61 | 452 |
"add the argument, anObject to the contents - with redraw |
453 |
" |
|
1112 | 454 |
self halt:'should not be invoked' |
60 | 455 |
|
175 | 456 |
! |
457 |
||
458 |
startCreate:aPoint |
|
459 |
self setDefaultActions. |
|
1112 | 460 |
self halt:'should not be invoked' |
60 | 461 |
! ! |
462 |
||
463 |
!UIObjectView methodsFor:'event handling'! |
|
464 |
||
61 | 465 |
elementChangedSize:aView |
466 |
"some element has changed its size; collect them during selectionHiddenLevel |
|
467 |
is on |
|
468 |
" |
|
284 | 469 |
|spv| |
470 |
||
471 |
spv := self findContainerOfView:aView. |
|
472 |
||
473 |
selectionHiddenLevel ~~ 0 ifTrue:[setOfSuperViewsSizeChanged add:spv] |
|
1120 | 474 |
ifFalse:[spv sizeChanged:nil] |
60 | 475 |
! |
476 |
||
477 |
exposeX:x y:y width:w height:h |
|
478 |
"handle an expose event from device; redraw selection |
|
479 |
" |
|
993
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
480 |
|
175 | 481 |
resizeData isNil ifTrue:[ |
1120 | 482 |
super exposeX:x y:y width:w height:h. |
483 |
||
484 |
"/ handle any expose events (for subcomponents) before |
|
485 |
"/ redrawing the handles. |
|
486 |
(self sensor hasExposeEventFor:nil) ifTrue:[^ self]. |
|
487 |
||
488 |
self selectionDo:[:aComponent | |
|
489 |
aComponent withAllSubViewsDo:[:v | |
|
490 |
v realized ifTrue:[ |
|
491 |
self sensor flushExposeEventsFor:v. |
|
492 |
v exposeX:0 y:0 width:v width height:v height. |
|
493 |
] |
|
494 |
]. |
|
495 |
self showSelected:aComponent |
|
496 |
] |
|
993
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
497 |
]. |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
498 |
|
1016 | 499 |
"Modified: / 9.11.1998 / 12:50:34 / cg" |
60 | 500 |
! |
501 |
||
502 |
keyPress:key x:x y:y |
|
61 | 503 |
"any key pressed |
504 |
" |
|
1048 | 505 |
<resource: #keyboard ( #CursorUp #CursorDown #CursorLeft #CursorRight |
1120 | 506 |
#Delete #BackSpace #Cut #Copy #Paste #Cmdu ) > |
60 | 507 |
|
508 |
(key == #Cut or:[key == #Delete or:[key == #BackSpace]]) ifTrue: [ |
|
1120 | 509 |
^ self deleteSelection |
60 | 510 |
]. |
78 | 511 |
key == #Copy ifTrue:[ ^ self copySelection]. |
512 |
key == #Paste ifTrue:[ ^ self pasteBuffer]. |
|
360 | 513 |
key == #Cmdu ifTrue:[ ^ self undoLast ]. "/ #Undo |
514 |
||
1048 | 515 |
key == #CursorUp ifTrue:[^self moveSelectionUp]. |
516 |
key == #CursorDown ifTrue:[^self moveSelectionDown]. |
|
517 |
key == #CursorRight ifTrue:[^self moveSelectionRight]. |
|
518 |
key == #CursorLeft ifTrue:[^self moveSelectionLeft]. |
|
519 |
||
374 | 520 |
super keyPress:key x:x y:y |
521 |
||
1048 | 522 |
"Modified: / 6.3.1999 / 22:47:48 / cg" |
60 | 523 |
! |
524 |
||
525 |
processEvent:anEvent |
|
526 |
"catch expose events for components, and redraw its handles after |
|
527 |
the redraw when this happens |
|
528 |
" |
|
128 | 529 |
(anEvent type == #damage and:[self isSelected:(anEvent view)]) ifTrue:[ |
1120 | 530 |
self showSelected:(anEvent view) |
60 | 531 |
]. |
532 |
^ false. |
|
533 |
||
534 |
||
535 |
! |
|
536 |
||
624
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
537 |
redrawX:nx y:ny width:nw height:nh |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
538 |
"ignore redraws - my components redraw themself |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
539 |
" |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
540 |
! |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
541 |
|
60 | 542 |
sizeChanged:how |
61 | 543 |
"size of a view(s) changed |
544 |
" |
|
60 | 545 |
self withSelectionHiddenDo:[ |
1120 | 546 |
super sizeChanged:how |
60 | 547 |
] |
548 |
||
549 |
||
550 |
! ! |
|
551 |
||
552 |
!UIObjectView methodsFor:'initialization'! |
|
553 |
||
554 |
initialize |
|
61 | 555 |
"setup attributes |
556 |
" |
|
60 | 557 |
super initialize. |
558 |
||
559 |
"funny: since I do not want the created widgets to get pointer |
|
560 |
events, I put an InputView on top of them, which catches those events |
|
561 |
and passes them back to me - have to take care, that this inputView |
|
562 |
is always on top |
|
563 |
" |
|
564 |
inputView := InputView origin:0.0@0.0 extent:1.0@1.0 in:self. |
|
61 | 565 |
setOfSuperViewsSizeChanged := IdentitySet new. |
60 | 566 |
|
567 |
inputView eventReceiver:self. |
|
568 |
inputView enableButtonEvents. |
|
569 |
inputView enableButtonMotionEvents. |
|
570 |
||
571 |
self setDefaultActions. |
|
572 |
||
134 | 573 |
undoHistory := UndoHistory on:self. |
1100
bf884041701f
Implement common channels in View.
Stefan Vogel <sv@exept.de>
parents:
1048
diff
changeset
|
574 |
self enableChannel:(true asValue). |
119 | 575 |
clipChildren := true. |
61 | 576 |
selectionHiddenLevel := 0. |
60 | 577 |
|
578 |
(self class gridShown) ifTrue:[ |
|
1120 | 579 |
super showGrid |
60 | 580 |
]. |
581 |
||
897
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
582 |
"Modified: / 20.7.1998 / 18:14:51 / cg" |
1100
bf884041701f
Implement common channels in View.
Stefan Vogel <sv@exept.de>
parents:
1048
diff
changeset
|
583 |
"Modified: / 30.3.1999 / 16:19:15 / stefan" |
60 | 584 |
! |
585 |
||
284 | 586 |
map |
587 |
"make the view visible on the screen and in case of a none empty |
|
588 |
selection the selection will be shown. |
|
589 |
" |
|
590 |
super map. |
|
591 |
self showSelection. |
|
592 |
! |
|
593 |
||
897
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
594 |
mapped |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
595 |
"make certain that the input view is on top. |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
596 |
" |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
597 |
super mapped. |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
598 |
inputView raise. |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
599 |
|
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
600 |
"Created: / 20.7.1998 / 18:10:20 / cg" |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
601 |
"Modified: / 20.7.1998 / 18:11:32 / cg" |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
602 |
! |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
603 |
|
60 | 604 |
realize |
605 |
super realize. |
|
606 |
self windowGroup postEventHook:self |
|
607 |
||
897
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
608 |
! |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
609 |
|
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
610 |
remap |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
611 |
"make the view visible on the screen and in case of a none empty |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
612 |
selection the selection will be shown. |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
613 |
" |
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
614 |
super remap. |
1112 | 615 |
self halt:'should not be invoked' |
897
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
616 |
|
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
777
diff
changeset
|
617 |
"Created: / 20.7.1998 / 18:08:48 / cg" |
60 | 618 |
! ! |
619 |
||
620 |
!UIObjectView methodsFor:'misc'! |
|
621 |
||
622 |
cursor:aCursor |
|
61 | 623 |
"set cursor |
624 |
" |
|
60 | 625 |
inputView realized ifTrue:[ |
1120 | 626 |
inputView cursor:aCursor |
60 | 627 |
]. |
628 |
super cursor:aCursor |
|
629 |
||
630 |
||
631 |
! |
|
632 |
||
175 | 633 |
invertOutlineOf:something |
634 |
"invert outline of an object or collection of objects |
|
61 | 635 |
" |
993
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
636 |
|wasClipped| |
60 | 637 |
|
638 |
(wasClipped := clipChildren) ifTrue:[ |
|
1120 | 639 |
self clippedByChildren:(clipChildren := false). |
60 | 640 |
]. |
175 | 641 |
|
993
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
642 |
self xoring:[ |
1120 | 643 |
|p| |
644 |
||
645 |
something isCollection ifTrue:[ |
|
646 |
something do:[:v | |
|
647 |
|p| |
|
648 |
||
649 |
p := v originRelativeTo:self. |
|
650 |
self displayRectangle:(p extent:v extent). |
|
651 |
]. |
|
652 |
] ifFalse:[ |
|
653 |
|p| |
|
654 |
||
655 |
p := something originRelativeTo:self. |
|
656 |
self displayRectangle:(p extent:something extent). |
|
657 |
] |
|
60 | 658 |
]. |
659 |
||
660 |
wasClipped ifTrue:[ |
|
1120 | 661 |
self clippedByChildren:(clipChildren := true). |
60 | 662 |
]. |
663 |
||
664 |
! |
|
665 |
||
78 | 666 |
minSetOfSuperViews:setOfViews |
667 |
||
668 |
setOfViews isCollection ifFalse:[ |
|
1120 | 669 |
setOfViews notNil ifTrue:[^ Array with:setOfViews] |
670 |
ifFalse:[^ nil] |
|
72 | 671 |
]. |
78 | 672 |
^ setOfViews select:[:aView| |
1120 | 673 |
(setOfViews detect:[:v|aView isComponentOf:v] ifNone:nil) isNil |
78 | 674 |
] |
72 | 675 |
! |
676 |
||
624
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
677 |
redrawObjectsInVisible:redrawFrame |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
678 |
"my objects are views - they redraw themself" |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
679 |
|
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
680 |
^ self |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
681 |
|
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
682 |
! |
26e7978936fc
ignore redraws - components redraw themself.
Claus Gittinger <cg@exept.de>
parents:
543
diff
changeset
|
683 |
|
60 | 684 |
setDefaultActions |
61 | 685 |
"set default actions |
686 |
" |
|
60 | 687 |
pressAction := [:pressPoint | self startSelectOrMove:pressPoint]. |
688 |
shiftPressAction := [:pressPoint | self startSelectMoreOrMove:pressPoint]. |
|
689 |
motionAction := [:movePoint | nil]. |
|
690 |
releaseAction := [nil]. |
|
691 |
keyPressAction := nil. |
|
692 |
||
693 |
self cursor:Cursor normal. |
|
694 |
||
695 |
! ! |
|
696 |
||
697 |
!UIObjectView methodsFor:'object moving'! |
|
698 |
||
699 |
doObjectMove:aPoint |
|
700 |
"move selection |
|
701 |
" |
|
702 |
movedObject notNil ifTrue:[ |
|
1120 | 703 |
self invertOutlineOf:movedObject. |
704 |
||
705 |
movedObject keysAndValuesDo:[:i :v| |
|
706 |
self moveObject:v to:(aPoint - (moveDelta at:i)). |
|
707 |
]. |
|
708 |
self invertOutlineOf:movedObject. |
|
60 | 709 |
] |
710 |
||
711 |
! |
|
712 |
||
713 |
endObjectMove |
|
61 | 714 |
"cleanup after object(s) move |
715 |
" |
|
60 | 716 |
movedObject notNil ifTrue:[ |
1120 | 717 |
self invertOutlineOf:movedObject. |
718 |
||
719 |
movedObject size == 1 ifTrue:[ |
|
720 |
movedObject := movedObject first |
|
721 |
]. |
|
722 |
self setSelection:movedObject withRedraw:true. |
|
723 |
movedObject := nil. |
|
724 |
self setDefaultActions. |
|
725 |
self layoutChanged. |
|
60 | 726 |
]. |
727 |
! |
|
728 |
||
729 |
moveObject:anObject to:aPoint |
|
730 |
"move anObject to newOrigin, aPoint |
|
731 |
" |
|
732 |
|dX dY org delta| |
|
733 |
||
734 |
anObject notNil ifTrue:[ |
|
1120 | 735 |
org := anObject computeOrigin. |
736 |
||
737 |
delta := aPoint - org. |
|
738 |
delta := (self alignToGrid:aPoint) - org. |
|
739 |
dX := delta x. |
|
740 |
dY := delta y. |
|
741 |
||
742 |
undoHistory withoutTransactionDo:[ |
|
743 |
self shiftLayout:anObject top:dY bottom:dY left:dX right:dX |
|
744 |
] |
|
60 | 745 |
] |
746 |
||
747 |
! |
|
748 |
||
749 |
startObjectMoveAt:aPoint |
|
61 | 750 |
"start object(s) move at a point |
751 |
" |
|
128 | 752 |
self startObjectMove:(self selection) at:aPoint. |
753 |
movedObject := self selection. |
|
754 |
||
755 |
movedObject isCollection ifFalse:[ |
|
1120 | 756 |
movedObject := Array with:movedObject |
60 | 757 |
]. |
128 | 758 |
self setSelection:nil withRedraw:true. |
60 | 759 |
|
760 |
moveDelta := movedObject collect:[:aView| |
|
1120 | 761 |
aPoint - aView computeOrigin |
60 | 762 |
]. |
175 | 763 |
self transaction:#move objects:movedObject do:[:v|self createUndoLayout:v]. |
764 |
self invertOutlineOf:movedObject. |
|
60 | 765 |
! |
766 |
||
767 |
startSelectMoreOrMove:aPoint |
|
768 |
"add/remove to/from selection" |
|
769 |
||
770 |
|anObject| |
|
771 |
||
119 | 772 |
self enabled ifFalse:[^ self]. |
60 | 773 |
|
774 |
anObject := self findObjectAt:aPoint. |
|
775 |
anObject notNil ifTrue:[ |
|
1120 | 776 |
(self isSelected:anObject) ifTrue:[ |
777 |
self removeFromSelection:anObject |
|
778 |
] ifFalse:[ |
|
779 |
self addToSelection:anObject |
|
780 |
] |
|
60 | 781 |
] |
782 |
! |
|
783 |
||
784 |
startSelectOrMove:aPoint |
|
61 | 785 |
"a button is pressed at a point; start moving or selection |
60 | 786 |
" |
284 | 787 |
|aView b v| |
60 | 788 |
|
119 | 789 |
self enabled ifFalse:[^ self]. |
60 | 790 |
|
61 | 791 |
aView := self singleSelection. |
792 |
||
793 |
aView notNil ifTrue:[ |
|
1120 | 794 |
v := self findContainerOfView:aView. |
795 |
||
796 |
v specClass canResizeSubComponents ifTrue:[ |
|
797 |
b := self whichHandleOf:aView isHitBy:aPoint. |
|
798 |
||
799 |
(b notNil and:[b ~~ #view]) ifTrue:[ |
|
800 |
^ self startResizeBorder:b of:aView. |
|
801 |
] |
|
802 |
]. |
|
803 |
||
804 |
(self sensor ctrlDown and:[self canChangeLayoutOfView:aView]) ifFalse:[ |
|
805 |
aView := nil |
|
806 |
] |
|
60 | 807 |
]. |
808 |
||
100 | 809 |
aView isNil ifTrue:[ |
1120 | 810 |
(aView := self findObjectAt:aPoint) isNil ifTrue:[ |
811 |
^ self select:nil |
|
812 |
]. |
|
813 |
||
814 |
(self canChangeLayoutOfView:aView) ifFalse:[ |
|
815 |
^ self select:aView |
|
816 |
] |
|
61 | 817 |
]. |
818 |
||
819 |
(self isSelected:aView) ifFalse:[ |
|
1120 | 820 |
self select:aView. |
60 | 821 |
]. |
822 |
||
823 |
(self numberOfSelections ~~ 1) ifTrue:[ |
|
1120 | 824 |
releaseAction := [ |
825 |
self setDefaultActions. |
|
826 |
self select:aView |
|
827 |
] |
|
60 | 828 |
] ifFalse:[ |
1120 | 829 |
releaseAction := [self setDefaultActions] |
60 | 830 |
]. |
831 |
||
832 |
"prepare move operation for an object |
|
833 |
" |
|
61 | 834 |
|
60 | 835 |
motionAction := [:movePoint| |
1120 | 836 |
(aPoint dist:movePoint) > 8.0 ifTrue:[ |
837 |
self startObjectMoveAt:aPoint |
|
838 |
] |
|
60 | 839 |
]. |
840 |
! ! |
|
841 |
||
842 |
!UIObjectView methodsFor:'object resize'! |
|
843 |
||
844 |
actionResize:anObject selector:aSelector |
|
845 |
"create and initialize action for resize |
|
846 |
" |
|
847 |
|selector delta| |
|
848 |
||
849 |
delta := anObject container originRelativeTo:self. |
|
850 |
selector := ('resize:', aSelector, ':') asSymbol. |
|
851 |
||
543
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
852 |
resizeData := ResizeData new |
1120 | 853 |
object:anObject selector:selector delta:delta. |
60 | 854 |
|
855 |
"can change cursor dependent on vertical/horizontal resizing |
|
856 |
" |
|
857 |
oldCursor := cursor. |
|
858 |
self cursor:(Cursor leftHand). |
|
859 |
||
543
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
860 |
"Modified: / 2.2.1998 / 13:40:55 / cg" |
60 | 861 |
! |
862 |
||
863 |
doDragResize:aPoint |
|
61 | 864 |
"do a widget resize drag |
865 |
" |
|
60 | 866 |
|p object| |
867 |
||
175 | 868 |
object := resizeData object. |
60 | 869 |
|
870 |
self invertOutlineOf:object. |
|
175 | 871 |
p := (self alignToGrid:aPoint) - (resizeData delta). |
872 |
||
873 |
self perform:(resizeData selector) with:object with:p. |
|
79 | 874 |
"/ object geometryLayout:(object geometryLayout). |
60 | 875 |
self invertOutlineOf:object |
876 |
||
877 |
! |
|
878 |
||
879 |
endResize |
|
61 | 880 |
"cleanup after object resize |
881 |
" |
|
882 |
|object| |
|
883 |
||
175 | 884 |
object := resizeData object. |
885 |
resizeData := nil. |
|
61 | 886 |
|
887 |
self invertOutlineOf:object. |
|
60 | 888 |
self setDefaultActions. |
61 | 889 |
self elementChangedSize:object. |
138 | 890 |
|
891 |
"/ handle any expose events (for subcomponents) before |
|
892 |
"/ redrawing the handles. |
|
893 |
Delay waitForSeconds:0.05. |
|
894 |
[self sensor hasExposeEventFor:nil] whileTrue:[ |
|
1120 | 895 |
self windowGroup processExposeEvents |
138 | 896 |
]. |
897 |
||
128 | 898 |
self setSelection:object withRedraw:true. |
225 | 899 |
self layoutChanged. |
60 | 900 |
! |
901 |
||
902 |
startResizeBorder:b of:selection |
|
903 |
"resize selected view |
|
904 |
" |
|
905 |
|object| |
|
906 |
||
907 |
object := self singleSelection. |
|
908 |
self actionResize:object selector:b. |
|
909 |
||
72 | 910 |
self transaction:#resize selectionDo:[:aView| |
1120 | 911 |
self createUndoLayout:aView |
60 | 912 |
]. |
128 | 913 |
self setSelection:nil withRedraw:true. |
60 | 914 |
|
915 |
motionAction := [:movePoint | self doDragResize:movePoint]. |
|
916 |
releaseAction := [self endResize]. |
|
917 |
self invertOutlineOf:object |
|
918 |
! ! |
|
919 |
||
920 |
!UIObjectView methodsFor:'private handles'! |
|
921 |
||
768 | 922 |
handleAffectedViews:aViewOrSeqOfViews |
923 |
"update affected views |
|
924 |
" |
|
777 | 925 |
|c| |
768 | 926 |
|
927 |
self forEach:aViewOrSeqOfViews do:[:v| |
|
1120 | 928 |
v shown ifTrue:[ |
929 |
v fill:v viewBackground. |
|
930 |
v borderWidth ~~ 0 ifTrue:[ |
|
931 |
c := v borderColor. |
|
932 |
v borderColor:(Color colorId:1). |
|
933 |
v borderColor:c. |
|
934 |
]. |
|
935 |
v exposeX:0 y:0 width:(v width) height:(v height) |
|
936 |
] |
|
768 | 937 |
] |
997
2a8a32256d4a
only send expose event for the views area
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
938 |
|
2a8a32256d4a
only send expose event for the views area
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
939 |
"Modified: / 16.9.1998 / 01:40:30 / cg" |
768 | 940 |
! |
941 |
||
175 | 942 |
handlesOf:aComponent do:aTwoArgAction |
943 |
"perform action on each handle of a component |
|
944 |
" |
|
945 |
|dlt ext| |
|
946 |
||
947 |
dlt := (aComponent originRelativeTo:self) - aComponent origin. |
|
948 |
dlt := dlt - (3@3). |
|
949 |
ext := 6@6. |
|
950 |
||
951 |
self class handlesOf:aComponent do:[:pnt :wht | |
|
1120 | 952 |
aTwoArgAction value:(pnt + dlt extent:ext) value:wht |
175 | 953 |
] |
60 | 954 |
! |
955 |
||
956 |
showUnselected:aComponent |
|
61 | 957 |
"show object unselected |
958 |
" |
|
768 | 959 |
self showUnselected:aComponent addAffectedViewsTo:nil |
960 |
! |
|
961 |
||
962 |
showUnselected:aComponent addAffectedViewsTo:aSet |
|
963 |
"show object unselected. If the set, an IdentitySet, is not nil, the |
|
964 |
affected subviews are added into the set, otherwise an expose event |
|
967
c3f483120cd7
redraw handle areas by mapping a little view over the handles
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
965 |
to each affected component is raised. |
768 | 966 |
" |
967
c3f483120cd7
redraw handle areas by mapping a little view over the handles
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
967 |
|wasClipped r v| |
60 | 968 |
|
138 | 969 |
selectionHiddenLevel ~~ 0 ifTrue:[^ self]. |
970 |
||
993
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
971 |
"/ "/ new: simply create a little view ontop, |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
972 |
"/ "/ and move it over the handles. This will generate |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
973 |
"/ "/ the required expose events automatically. |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
974 |
"/ "/ mhmh - does not work correctly with inverted frame (exposes destroy it) |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
975 |
"/ |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
976 |
"/ v := SimpleView in:self. |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
977 |
"/ self handlesOf:aComponent do:[:rec :wht | |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
978 |
"/ r isNil |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
979 |
"/ ifTrue:[r := rec] |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
980 |
"/ ifFalse:[r := r merge:rec]. |
967
c3f483120cd7
redraw handle areas by mapping a little view over the handles
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
981 |
"/ ]. |
c3f483120cd7
redraw handle areas by mapping a little view over the handles
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
982 |
"/ |
993
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
983 |
"/ "/ if the area is small, make one big rectangle-expose |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
984 |
"/ r area < 10000 ifTrue:[ |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
985 |
"/ v origin:r origin extent:r extent. |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
986 |
"/ v map. |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
987 |
"/ v unmap. |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
988 |
"/ ] ifFalse:[ |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
989 |
"/ self handlesOf:aComponent do:[:rec :wht | |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
990 |
"/ v origin:rec origin extent:rec extent. |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
991 |
"/ v map. |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
992 |
"/ v unmap. |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
993 |
"/ ]. |
967
c3f483120cd7
redraw handle areas by mapping a little view over the handles
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
994 |
"/ ]. |
993
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
995 |
"/ v destroy. |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
996 |
"/ ^ self. |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
997 |
|
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
998 |
(wasClipped := clipChildren) ifTrue:[ |
1120 | 999 |
self clippedByChildren:(clipChildren := false). |
993
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1000 |
]. |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1001 |
|
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1002 |
self handlesOf:aComponent do:[:rec :wht| self clearRectangle:rec ]. |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1003 |
|
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1004 |
wasClipped ifTrue:[ |
1120 | 1005 |
self clippedByChildren:(clipChildren := true). |
993
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1006 |
]. |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1007 |
|
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1008 |
"/ must redraw all components which are affected b the handles |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1009 |
r := (aComponent originRelativeTo:self) - (3@3) extent:(aComponent extent + (6@6)). |
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1010 |
|
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1011 |
subViews do:[:anotherComponent | |
1120 | 1012 |
|absOrg absFrame| |
1013 |
||
1014 |
anotherComponent ~~ inputView ifTrue:[ |
|
1015 |
absOrg := anotherComponent originRelativeTo:self. |
|
1016 |
absFrame := absOrg extent:(anotherComponent extent). |
|
1017 |
(absFrame intersects:r) ifTrue:[ |
|
1018 |
anotherComponent withAllSubViewsDo:[:v | |
|
1019 |
v shown ifTrue:[ |
|
1020 |
aSet notNil ifTrue:[ |
|
1021 |
aSet add:v |
|
1022 |
] ifFalse:[ |
|
1023 |
self handleAffectedViews:v |
|
1024 |
] |
|
1025 |
] |
|
1026 |
] |
|
1027 |
] |
|
1028 |
] |
|
993
88a214788277
reenabled old showUnselected code.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1029 |
]. |
967
c3f483120cd7
redraw handle areas by mapping a little view over the handles
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
1030 |
|
c3f483120cd7
redraw handle areas by mapping a little view over the handles
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
1031 |
"Modified: / 24.8.1998 / 12:19:38 / cg" |
60 | 1032 |
! |
1033 |
||
175 | 1034 |
whichHandleOf:aComponent isHitBy:aPoint |
61 | 1035 |
"returns kind of handle or nil |
1036 |
" |
|
175 | 1037 |
self handlesOf:aComponent do:[:rectangle :what| |
1120 | 1038 |
(rectangle containsPoint:aPoint) ifTrue:[^ what] |
60 | 1039 |
]. |
175 | 1040 |
^ nil |
60 | 1041 |
! ! |
1042 |
||
1043 |
!UIObjectView methodsFor:'private resizing-subviews'! |
|
1044 |
||
1045 |
resize:aView bottom:aPoint |
|
61 | 1046 |
"resize a views bottom |
1047 |
" |
|
134 | 1048 |
undoHistory withoutTransactionDo:[ |
1120 | 1049 |
self shiftLayout:aView top:0 bottom:((aPoint y) - (aView computeCorner y)) |
60 | 1050 |
] |
1051 |
! |
|
1052 |
||
1053 |
resize:aView bottomLeft:aPoint |
|
61 | 1054 |
"resize a views bottom and left |
1055 |
" |
|
134 | 1056 |
undoHistory withoutTransactionDo:[ |
1120 | 1057 |
self shiftLayout:aView top:0 |
1058 |
bottom:((aPoint y) - (aView computeCorner y)) |
|
1059 |
left:((aPoint x) - (aView computeOrigin x)) |
|
1060 |
right:0 |
|
60 | 1061 |
|
1062 |
] |
|
1063 |
||
1064 |
||
1065 |
! |
|
1066 |
||
1067 |
resize:aView corner:aPoint |
|
61 | 1068 |
"resize a views corner |
1069 |
" |
|
60 | 1070 |
|delta| |
1071 |
||
1072 |
delta := aPoint - aView computeCorner. |
|
1073 |
||
134 | 1074 |
undoHistory withoutTransactionDo:[ |
1120 | 1075 |
self shiftLayout:aView top:0 bottom:(delta y) left:0 right:(delta x) |
60 | 1076 |
] |
1077 |
! |
|
1078 |
||
1079 |
resize:aView left:aPoint |
|
61 | 1080 |
"resize a views left |
1081 |
" |
|
134 | 1082 |
undoHistory withoutTransactionDo:[ |
1120 | 1083 |
self shiftLayout:aView left:((aPoint x) - (aView computeOrigin x)) right:0 |
60 | 1084 |
] |
1085 |
||
1086 |
! |
|
1087 |
||
1088 |
resize:aView origin:aPoint |
|
61 | 1089 |
"resize a views origin |
1090 |
" |
|
60 | 1091 |
|delta| |
1092 |
||
1093 |
delta := aPoint - aView computeOrigin. |
|
1094 |
||
134 | 1095 |
undoHistory withoutTransactionDo:[ |
1120 | 1096 |
self shiftLayout:aView top:(delta y) bottom:0 left:(delta x) right:0 |
60 | 1097 |
] |
1098 |
||
1099 |
! |
|
1100 |
||
1101 |
resize:aView right:aPoint |
|
61 | 1102 |
"resize a views right |
1103 |
" |
|
134 | 1104 |
undoHistory withoutTransactionDo:[ |
1120 | 1105 |
self shiftLayout:aView left:0 right:((aPoint x) - (aView computeCorner x)) |
60 | 1106 |
] |
1107 |
! |
|
1108 |
||
1109 |
resize:aView top:aPoint |
|
61 | 1110 |
"resize a views top |
1111 |
" |
|
134 | 1112 |
undoHistory withoutTransactionDo:[ |
1120 | 1113 |
self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y)) bottom:0 |
60 | 1114 |
] |
1115 |
! |
|
1116 |
||
1117 |
resize:aView topRight:aPoint |
|
61 | 1118 |
"resize a views top and right |
1119 |
" |
|
134 | 1120 |
undoHistory withoutTransactionDo:[ |
1120 | 1121 |
self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y)) |
1122 |
bottom:0 |
|
1123 |
left:0 |
|
1124 |
right:((aPoint x) - (aView computeCorner x)) |
|
60 | 1125 |
|
1126 |
] |
|
1127 |
||
1128 |
! ! |
|
1129 |
||
1130 |
!UIObjectView methodsFor:'private shift-layout'! |
|
1131 |
||
1132 |
shiftLayout:aView left:l right:r |
|
1133 |
"shift layout for a view; in case of an open transaction, the undo |
|
1134 |
action is registered |
|
1135 |
" |
|
1136 |
self shiftLayout:aView top:0 bottom:0 left:l right:r |
|
1137 |
||
1138 |
! |
|
1139 |
||
1140 |
shiftLayout:aView top:t bottom:b |
|
1141 |
"shift layout for a view; in case of an open transaction, the undo |
|
1142 |
action is registered |
|
1143 |
" |
|
1144 |
self shiftLayout:aView top:t bottom:b left:0 right:0 |
|
1145 |
||
1146 |
||
1147 |
! |
|
1148 |
||
1149 |
shiftLayout:aView top:t bottom:b left:l right:r |
|
1150 |
"shift layout for a view; in case of an open transaction, the undo |
|
1151 |
action is registered |
|
1152 |
" |
|
79 | 1153 |
|type layout oldExt| |
61 | 1154 |
|
1155 |
type := self class layoutType:aView. |
|
1156 |
||
1157 |
type notNil ifTrue:[ |
|
1120 | 1158 |
self createUndoLayout:aView. |
1159 |
||
1160 |
type == #Extent ifTrue:[ |
|
1161 |
oldExt := aView extent. |
|
1162 |
aView extent:(oldExt + ((r-l) @ (b-t))). |
|
1163 |
^ self |
|
1164 |
]. |
|
1165 |
||
1166 |
layout := aView geometryLayout copy. |
|
1167 |
||
1168 |
layout isLayout ifTrue:[ |
|
1169 |
layout leftOffset:(layout leftOffset + l) |
|
1170 |
topOffset:(layout topOffset + t). |
|
61 | 1171 |
|
1120 | 1172 |
type == #LayoutFrame ifTrue:[ |
1173 |
layout bottomOffset:(layout bottomOffset + b). |
|
1174 |
layout rightOffset:(layout rightOffset + r). |
|
1175 |
] |
|
1176 |
] ifFalse:[ |
|
1177 |
type == #Rectangle ifTrue:[ |
|
1178 |
layout left:(layout left + l) |
|
1179 |
right:(layout right + r) |
|
1180 |
top:(layout top + t) |
|
1181 |
bottom:(layout bottom + b). |
|
1182 |
] ifFalse:[ "POINT" |
|
1183 |
layout x:(layout x + l) y:(layout y + t). |
|
1184 |
] |
|
1185 |
]. |
|
1186 |
aView geometryLayout:layout |
|
60 | 1187 |
] |
1188 |
! ! |
|
1189 |
||
1190 |
!UIObjectView methodsFor:'searching'! |
|
1191 |
||
1192 |
findObjectAt:aPoint |
|
1193 |
"find the origin/corner of the currentWidget |
|
1194 |
" |
|
1195 |
|view viewId lastId point listOfViews| |
|
1196 |
||
1197 |
viewId := rootView id. |
|
1198 |
point := aPoint + (device translatePoint:0@0 from:(self id) to:viewId). |
|
1199 |
||
1200 |
inputView lower. |
|
1201 |
||
1202 |
[viewId notNil] whileTrue:[ |
|
1120 | 1203 |
lastId := viewId. |
1204 |
viewId := device viewIdFromPoint:point in:lastId |
|
60 | 1205 |
]. |
1206 |
||
1207 |
inputView raise. |
|
1208 |
||
1209 |
view := device viewFromId:lastId. |
|
1210 |
||
1211 |
view ~~ inputView ifTrue:[^ view]. |
|
1212 |
||
1213 |
"/ look for 'hidden' views ... |
|
1214 |
||
1215 |
listOfViews := OrderedCollection new. |
|
1216 |
self allSubViewsDo:[:aView | |
|
1120 | 1217 |
|org| |
1218 |
||
1219 |
aView ~~ inputView ifTrue:[ |
|
1220 |
org := device translatePoint:0@0 from:(aView id) to:self id. |
|
1221 |
((org extent:aView extent) containsPoint:aPoint) ifTrue:[ |
|
1222 |
listOfViews add:aView. |
|
1223 |
] |
|
1224 |
] |
|
60 | 1225 |
]. |
1226 |
||
1227 |
listOfViews size > 0 ifTrue:[ |
|
1120 | 1228 |
^ listOfViews last |
60 | 1229 |
]. |
1230 |
^ nil |
|
1231 |
||
1232 |
||
1233 |
! ! |
|
1234 |
||
1235 |
!UIObjectView methodsFor:'selections'! |
|
1236 |
||
768 | 1237 |
hideSelection |
1238 |
"hide the selection - undraw hilights - whatever that is" |
|
1239 |
||
1240 |
|aSet| |
|
1241 |
||
1242 |
self selectionDo:[:object| |
|
1120 | 1243 |
aSet isNil ifTrue:[ |
1244 |
aSet := IdentitySet new |
|
1245 |
]. |
|
1246 |
self showUnselected:object addAffectedViewsTo:aSet. |
|
768 | 1247 |
]. |
1248 |
self handleAffectedViews:aSet. |
|
1249 |
||
1250 |
||
1251 |
! |
|
1252 |
||
128 | 1253 |
moveableSelection |
131 | 1254 |
"checks whether the selection is not empty and all selected instances |
1255 |
can be moved. If true the selection is returned otherwise nil |
|
128 | 1256 |
" |
1257 |
|coll| |
|
1258 |
||
1259 |
self hasSelection ifTrue:[ |
|
1120 | 1260 |
(self canMove:(coll := self selection)) ifTrue:[ |
1261 |
^ coll |
|
1262 |
] |
|
128 | 1263 |
]. |
1264 |
^ nil |
|
1265 |
! |
|
1266 |
||
60 | 1267 |
numberOfSelections |
131 | 1268 |
"return the number of selected instances |
61 | 1269 |
" |
128 | 1270 |
|coll size| |
1271 |
||
1272 |
coll := self selection. |
|
1273 |
size := coll size. |
|
1274 |
||
1275 |
(size ~~ 0 or:[coll isNil]) ifTrue:[^ size]. |
|
1276 |
^ 1 |
|
60 | 1277 |
! |
1278 |
||
149 | 1279 |
selection:something |
1280 |
"change selection to something |
|
1281 |
" |
|
1282 |
self select:something |
|
1283 |
! |
|
1284 |
||
128 | 1285 |
selectionDo:aBlock |
1286 |
"apply block to every selected object |
|
1287 |
" |
|
1288 |
self forEach:(self selection) do:aBlock |
|
1289 |
||
1290 |
||
1291 |
! |
|
1292 |
||
61 | 1293 |
showSelection |
128 | 1294 |
"show the selection - draw handles |
1295 |
" |
|
61 | 1296 |
selectionHiddenLevel == 0 ifTrue:[ |
1120 | 1297 |
self selectionDo:[:el| self showSelected:el ] |
60 | 1298 |
]. |
1299 |
! |
|
1300 |
||
1301 |
singleSelection |
|
131 | 1302 |
"checks whether one element is selected; in this case the element is |
1303 |
returned otherwise nil |
|
60 | 1304 |
" |
128 | 1305 |
|coll| |
1306 |
||
1307 |
(coll := self selection) isCollection ifFalse:[ |
|
1120 | 1308 |
^ coll |
60 | 1309 |
]. |
128 | 1310 |
|
1311 |
coll size == 1 ifTrue:[ ^ coll first]. |
|
1312 |
^ nil |
|
60 | 1313 |
! |
1314 |
||
1315 |
singleSelectionDo:aBlock |
|
131 | 1316 |
"checks whether one element is selected; in this case the block |
1317 |
with argument the selected instance will be processed |
|
61 | 1318 |
" |
60 | 1319 |
|view| |
1320 |
||
1321 |
(view := self singleSelection) notNil ifTrue:[ |
|
1120 | 1322 |
aBlock value:view |
60 | 1323 |
] |
1324 |
! |
|
1325 |
||
1326 |
unselect |
|
61 | 1327 |
"clear selection |
1328 |
" |
|
128 | 1329 |
self select:nil |
60 | 1330 |
! |
1331 |
||
1332 |
withSelectionHiddenDo:aBlock |
|
61 | 1333 |
"apply block with selection hidden (no handles) |
1334 |
" |
|
78 | 1335 |
|coll| |
1336 |
||
138 | 1337 |
selectionHiddenLevel == 0 ifTrue:[ |
1120 | 1338 |
self hideSelection. |
1339 |
device flush. |
|
61 | 1340 |
]. |
138 | 1341 |
selectionHiddenLevel := selectionHiddenLevel + 1. |
61 | 1342 |
|
1343 |
aBlock valueNowOrOnUnwindDo:[ |
|
1120 | 1344 |
selectionHiddenLevel == 1 ifTrue:[ |
1345 |
setOfSuperViewsSizeChanged notEmpty ifTrue:[ |
|
1346 |
coll := self minSetOfSuperViews:setOfSuperViewsSizeChanged. |
|
1347 |
coll do:[:aView| aView sizeChanged:nil]. |
|
1348 |
setOfSuperViewsSizeChanged := IdentitySet new |
|
1349 |
]. |
|
1350 |
selectionHiddenLevel := 0. |
|
1351 |
self selectionDo:[:aView| self showSelected:aView]. |
|
1352 |
] ifFalse:[ |
|
1353 |
selectionHiddenLevel := selectionHiddenLevel - 1. |
|
1354 |
] |
|
61 | 1355 |
] |
1356 |
||
1357 |
! |
|
1358 |
||
1359 |
withoutSelectionDo:aBlock |
|
1360 |
"evaluate aBlock while selection is nilled |
|
1361 |
" |
|
60 | 1362 |
|sel| |
1363 |
||
128 | 1364 |
self hasSelection ifFalse:[ |
1120 | 1365 |
aBlock value |
128 | 1366 |
] ifTrue:[ |
1120 | 1367 |
sel := self selection. |
1368 |
self setSelection:nil withRedraw:true. |
|
1369 |
aBlock value. |
|
1370 |
self setSelection:sel withRedraw:true. |
|
60 | 1371 |
] |
1372 |
||
1373 |
||
1374 |
! ! |
|
1375 |
||
131 | 1376 |
!UIObjectView methodsFor:'selections basic'! |
1377 |
||
1378 |
selection |
|
1379 |
"returns the current selection |
|
1380 |
" |
|
1381 |
^ selection |
|
1382 |
||
1383 |
||
1384 |
! |
|
1385 |
||
1386 |
setSelection:aNewSelection withRedraw:doRedraw |
|
1387 |
"set a new selection without change notifications |
|
1388 |
" |
|
225 | 1389 |
|sel| |
1390 |
||
1391 |
(sel := aNewSelection) == self ifTrue:[ |
|
1120 | 1392 |
sel := nil |
225 | 1393 |
]. |
1394 |
||
131 | 1395 |
doRedraw ifTrue:[ |
1120 | 1396 |
self hideSelection. |
1397 |
selection := sel. |
|
1398 |
self showSelection |
|
131 | 1399 |
] ifFalse:[ |
1120 | 1400 |
selection := sel |
131 | 1401 |
] |
1402 |
! ! |
|
1403 |
||
60 | 1404 |
!UIObjectView methodsFor:'testing'! |
1405 |
||
284 | 1406 |
hasSelection |
1407 |
"returns true if any widget is selected |
|
61 | 1408 |
" |
284 | 1409 |
^ self numberOfSelections ~~ 0 |
60 | 1410 |
|
1411 |
! |
|
1412 |
||
284 | 1413 |
hasSingleSelection |
1414 |
"returns true if one widget is selected |
|
61 | 1415 |
" |
284 | 1416 |
^ self numberOfSelections == 1 |
1417 |
||
1418 |
! |
|
1419 |
||
1420 |
hasUndoHistory |
|
1421 |
"returns true if undos exists |
|
1422 |
" |
|
1423 |
^ undoHistory isEmpty not |
|
60 | 1424 |
! |
1425 |
||
134 | 1426 |
isModified |
1427 |
"returns true if painter is modified |
|
1428 |
" |
|
1429 |
^ undoHistory isModified |
|
1430 |
! |
|
1431 |
||
128 | 1432 |
isSelected:anObject |
1433 |
"return true, if the argument, anObject is selected |
|
1434 |
" |
|
1435 |
anObject notNil ifTrue:[ |
|
1120 | 1436 |
self selectionDo:[:el| el == anObject ifTrue:[^ true]] |
128 | 1437 |
]. |
1438 |
^ false |
|
1439 |
||
60 | 1440 |
! ! |
1441 |
||
1442 |
!UIObjectView methodsFor:'transaction'! |
|
1443 |
||
134 | 1444 |
createUndoLayout:aView |
1445 |
"prepare undo action for a view changing its layout |
|
1446 |
" |
|
1447 |
self subclassResponsibility |
|
1448 |
||
1449 |
! |
|
1450 |
||
60 | 1451 |
transaction:aType objects:something do:aOneArgBlock |
1452 |
"opens a transaction and evaluates a block within the transaction; the |
|
1453 |
argument to the block is a view from derived from something |
|
1454 |
" |
|
1455 |
self subclassResponsibility |
|
1456 |
||
1457 |
||
1458 |
! |
|
1459 |
||
1460 |
transaction:aType selectionDo:aOneArgBlock |
|
1461 |
"opens a transaction and evaluates a block within the transaction; the |
|
1462 |
argument to the block is a view from the selection |
|
1463 |
" |
|
128 | 1464 |
self transaction:aType objects:(self selection) do:aOneArgBlock |
60 | 1465 |
|
1466 |
||
1467 |
! ! |
|
1468 |
||
1469 |
!UIObjectView methodsFor:'user actions - dimension'! |
|
1470 |
||
1471 |
copyExtent |
|
61 | 1472 |
"copy the extent from the selected object |
1473 |
" |
|
60 | 1474 |
|object| |
1475 |
||
1476 |
object := self singleSelection. |
|
1477 |
||
1478 |
object notNil ifTrue:[ |
|
1120 | 1479 |
copiedExtent := object computeExtent |
60 | 1480 |
] ifFalse:[ |
1120 | 1481 |
self warn:'exactly one element must be selected'. |
60 | 1482 |
] |
1483 |
||
1484 |
||
1485 |
||
1486 |
! |
|
1487 |
||
89 | 1488 |
copyLayout |
1489 |
"copy the layout from the selected object |
|
1490 |
" |
|
1491 |
|object| |
|
1492 |
||
1493 |
object := self singleSelection. |
|
1494 |
||
1495 |
object notNil ifTrue:[ |
|
1120 | 1496 |
copiedLayout := object geometryLayout copy |
89 | 1497 |
] ifFalse:[ |
1120 | 1498 |
self warn:'exactly one element must be selected'. |
89 | 1499 |
] |
1500 |
||
1501 |
||
1502 |
||
1503 |
! |
|
1504 |
||
60 | 1505 |
pasteExtent |
61 | 1506 |
"paste the copied extent to all objects in the selection |
1507 |
" |
|
60 | 1508 |
copiedExtent notNil ifTrue:[ |
1120 | 1509 |
self transaction:#pasteExtent dimensionDo:[:v| |
1510 |
self resize:v corner:(v computeOrigin + copiedExtent) |
|
1511 |
] |
|
60 | 1512 |
] |
1513 |
! |
|
1514 |
||
1515 |
pasteHeight |
|
61 | 1516 |
"paste the copied extent height to all objects in the selection |
1517 |
" |
|
60 | 1518 |
copiedExtent notNil ifTrue:[ |
1120 | 1519 |
self transaction:#pasteHeight dimensionDo:[:v| |
1520 |
self resize:v bottom:(v computeOrigin + copiedExtent) |
|
1521 |
] |
|
60 | 1522 |
] |
1523 |
||
1524 |
! |
|
1525 |
||
89 | 1526 |
pasteLayout |
1527 |
"paste layout to all objects in the selection |
|
1528 |
" |
|
1529 |
copiedLayout notNil ifTrue:[ |
|
1120 | 1530 |
self transaction:#pasteLayout dimensionDo:[:v| |
1531 |
v geometryLayout:(copiedLayout copy) |
|
1532 |
] |
|
89 | 1533 |
] |
1534 |
! |
|
1535 |
||
60 | 1536 |
pasteWidth |
61 | 1537 |
"paste the copied extent width to all objects in the selection |
1538 |
" |
|
60 | 1539 |
copiedExtent notNil ifTrue:[ |
1120 | 1540 |
self transaction:#pasteWidth dimensionDo:[:v| |
1541 |
self resize:v right:(v computeOrigin + copiedExtent) |
|
1542 |
] |
|
60 | 1543 |
] |
1544 |
||
1545 |
! |
|
1546 |
||
61 | 1547 |
setExtent:anExtent |
1548 |
"change extent for all selected objects |
|
1549 |
" |
|
134 | 1550 |
self transaction:#extent dimensionDo:[:v| |
1120 | 1551 |
v geometryLayout:nil. |
1552 |
v extent:anExtent. |
|
67 | 1553 |
]. |
1554 |
||
1555 |
"Modified: 28.2.1997 / 12:49:00 / cg" |
|
60 | 1556 |
! |
1557 |
||
149 | 1558 |
setLayout:aLayout |
1559 |
"change layout for all selected objects |
|
1560 |
" |
|
1561 |
self transaction:#layout dimensionDo:[:v| |
|
1120 | 1562 |
v geometryLayout:(aLayout copy) |
149 | 1563 |
]. |
1564 |
||
1565 |
! |
|
1566 |
||
353 | 1567 |
setMaxExtent |
1568 |
"set the topViews maxExtent to its current extent |
|
1569 |
" |
|
1112 | 1570 |
self halt:'should not be invoked' |
353 | 1571 |
|
1572 |
"Modified: / 27.10.1997 / 03:26:16 / cg" |
|
1573 |
! |
|
1574 |
||
1575 |
setMinExtent |
|
1576 |
"set the topViews minExtent to its current extent |
|
1577 |
" |
|
1112 | 1578 |
self halt:'should not be invoked' |
353 | 1579 |
|
1580 |
"Created: / 27.10.1997 / 03:24:02 / cg" |
|
1581 |
"Modified: / 27.10.1997 / 03:26:34 / cg" |
|
1582 |
! |
|
1583 |
||
60 | 1584 |
setToDefaultExtent |
61 | 1585 |
"change extent of all selected views to their default extent |
1586 |
" |
|
134 | 1587 |
self transaction:#defaultExtent dimensionDo:[:v| |
1120 | 1588 |
self resize:v corner:(v computeOrigin + (v preferredExtent)). |
60 | 1589 |
] |
1590 |
||
1591 |
! |
|
1592 |
||
1593 |
setToDefaultHeight |
|
61 | 1594 |
"change height of all selected views to their default height |
1595 |
" |
|
134 | 1596 |
self transaction:#defaultHeight dimensionDo:[:v| |
1120 | 1597 |
self resize:v bottom:(v computeOrigin + (v preferredExtent)) |
60 | 1598 |
] |
1599 |
||
1600 |
! |
|
1601 |
||
1602 |
setToDefaultWidth |
|
61 | 1603 |
"change width of all selected views to their default width |
1604 |
" |
|
134 | 1605 |
self transaction:#defaultWidth dimensionDo:[:v| |
1120 | 1606 |
self resize:v right:(v computeOrigin + (v preferredExtent)) |
60 | 1607 |
] |
1608 |
||
1609 |
! |
|
1610 |
||
134 | 1611 |
transaction:aType dimensionDo:aOneArgBlock |
60 | 1612 |
"change dimension within a transaction for the selected elements by evaluating |
1613 |
the block with the argument a view. |
|
1614 |
" |
|
61 | 1615 |
self withSelectionHiddenDo:[ |
1120 | 1616 |
self transaction:aType selectionDo:[:aView| |
1617 |
(self class layoutType:aView) notNil ifTrue:[ |
|
1618 |
self createUndoLayout:aView. |
|
1619 |
aOneArgBlock value:aView. |
|
1620 |
self elementChangedSize:aView. |
|
1621 |
] |
|
1622 |
] |
|
61 | 1623 |
]. |
225 | 1624 |
self layoutChanged |
61 | 1625 |
|
60 | 1626 |
! ! |
1627 |
||
1628 |
!UIObjectView methodsFor:'user actions - move'! |
|
1629 |
||
138 | 1630 |
moveDo:aOneArgBlock |
1631 |
"perform a move operation |
|
1632 |
" |
|
1633 |
|sensor tm| |
|
1634 |
||
1635 |
self moveableSelection isNil ifTrue:[ |
|
1120 | 1636 |
^ self |
138 | 1637 |
]. |
1638 |
sensor := self sensor. |
|
1639 |
||
1640 |
tm := 0.15. |
|
1641 |
||
1642 |
self withSelectionHiddenDo:[ |
|
1120 | 1643 |
self transaction:#move selectionDo:[:aView|self createUndoLayout:aView]. |
1644 |
||
1645 |
[ |
|
1646 |
self selectionDo:[:aView| aOneArgBlock value:aView ]. |
|
1647 |
Delay waitForSeconds:tm. |
|
1648 |
tm := 0.02. |
|
1649 |
self layoutChanged. |
|
1650 |
sensor leftButtonPressed. |
|
1651 |
] whileTrue. |
|
1652 |
||
1653 |
"/ handle any expose events (for subcomponents) before |
|
1654 |
"/ redrawing the handles. |
|
1655 |
Delay waitForSeconds:0.05. |
|
1656 |
[self sensor hasExposeEventFor:nil] whileTrue:[ |
|
1657 |
self windowGroup processExposeEvents |
|
1658 |
] |
|
138 | 1659 |
]. |
1660 |
! |
|
1661 |
||
113 | 1662 |
moveSelectionDown |
61 | 1663 |
"move selection down |
1664 |
" |
|
138 | 1665 |
|gridY n| |
1666 |
||
1667 |
gridAlign notNil ifTrue:[gridY := gridAlign y] |
|
1120 | 1668 |
ifFalse:[gridY := 1]. |
138 | 1669 |
|
1670 |
self moveDo:[:aView| |
|
1120 | 1671 |
aligning ifTrue:[ |
1672 |
n := ((aView computeCorner y) \\ gridY). |
|
1673 |
||
1674 |
n ~~ 0 ifTrue:[ |
|
1675 |
n := gridY - n + 1. |
|
1676 |
] ifFalse:[ |
|
1677 |
n := gridY |
|
1678 |
] |
|
1679 |
] ifFalse:[ |
|
1680 |
n := 1 |
|
1681 |
]. |
|
1682 |
self shiftLayout:aView top:n bottom:n |
|
60 | 1683 |
] |
1684 |
! |
|
1685 |
||
113 | 1686 |
moveSelectionLeft |
60 | 1687 |
"move selection left |
1688 |
" |
|
113 | 1689 |
|gridX n| |
60 | 1690 |
|
138 | 1691 |
gridAlign notNil ifTrue:[gridX := gridAlign x] |
1120 | 1692 |
ifFalse:[gridX := 1]. |
138 | 1693 |
|
1694 |
self moveDo:[:aView| |
|
1120 | 1695 |
aligning ifTrue:[ |
1696 |
n := ((aView computeOrigin x) \\ gridX). |
|
1697 |
n == 0 ifTrue:[n := gridX]. |
|
1698 |
n := n negated. |
|
1699 |
] ifFalse:[ |
|
1700 |
n := -1 |
|
1701 |
]. |
|
1702 |
self shiftLayout:aView left:n right:n |
|
60 | 1703 |
] |
1704 |
! |
|
1705 |
||
113 | 1706 |
moveSelectionRight |
1707 |
"move selection right |
|
1708 |
" |
|
1709 |
|gridX n| |
|
1710 |
||
138 | 1711 |
gridAlign notNil ifTrue:[gridX := gridAlign x] |
1120 | 1712 |
ifFalse:[gridX := 1]. |
138 | 1713 |
|
1714 |
self moveDo:[:aView| |
|
1120 | 1715 |
aligning ifTrue:[ |
1716 |
n := ((aView computeCorner x) \\ gridX). |
|
1717 |
||
1718 |
n ~~ 0 ifTrue:[n := n negated] |
|
1719 |
ifFalse:[n := gridX] |
|
1720 |
] ifFalse:[ |
|
1721 |
n := 1 |
|
1722 |
]. |
|
1723 |
self shiftLayout:aView left:n right:n |
|
113 | 1724 |
] |
1725 |
! |
|
1726 |
||
1727 |
moveSelectionUp |
|
60 | 1728 |
"move selection up |
1729 |
" |
|
113 | 1730 |
|gridY n| |
60 | 1731 |
|
138 | 1732 |
gridAlign notNil ifTrue:[gridY := gridAlign y] |
1120 | 1733 |
ifFalse:[gridY := 1]. |
138 | 1734 |
|
1735 |
self moveDo:[:aView| |
|
1120 | 1736 |
aligning ifTrue:[ |
1737 |
n := ((aView computeOrigin x) \\ gridY). |
|
1738 |
n == 0 ifTrue:[n := gridY]. |
|
1739 |
n := n negated. |
|
1740 |
] ifFalse:[ |
|
1741 |
n := -1 |
|
1742 |
]. |
|
1743 |
self shiftLayout:aView top:n bottom:n |
|
60 | 1744 |
] |
1745 |
||
1746 |
! ! |
|
1747 |
||
1748 |
!UIObjectView methodsFor:'user actions - position'! |
|
1749 |
||
1750 |
alignSelectionBottom |
|
61 | 1751 |
"align selection to the bottom of the first object in the selection; in case |
1752 |
of one selection the object is aligned to the bottom of its superview |
|
1753 |
" |
|
128 | 1754 |
|bmost delta sel| |
1755 |
||
1756 |
(sel := self moveableSelection) notNil ifTrue:[ |
|
1120 | 1757 |
self withSelectionHiddenDo:[ |
1758 |
self numberOfSelections > 1 ifTrue:[ |
|
1759 |
bmost := (sel first) computeCorner y. |
|
1760 |
||
1761 |
self transaction:#alignBottom selectionDo:[:v| |
|
1762 |
(delta := bmost - (v computeCorner y)) ~~ 0 ifTrue:[ |
|
1763 |
self shiftLayout:v top:delta bottom:delta. |
|
1764 |
] |
|
1765 |
] |
|
1766 |
] ifFalse:[ |
|
1767 |
self extentToFrame:#Bottom do:[:aLayout| |
|
1768 |
aLayout bottomOffset:0. |
|
1769 |
aLayout bottomFraction:1.0 |
|
1770 |
] |
|
1771 |
] |
|
1772 |
]. |
|
1773 |
self layoutChanged |
|
60 | 1774 |
] |
1775 |
||
1776 |
||
1777 |
||
1778 |
! |
|
1779 |
||
1780 |
alignSelectionCenterHor |
|
61 | 1781 |
"align selection to the center/horizontal of the first object in the selection; in case |
1782 |
of one selection the object is aligned to the center/horizontal of its superview |
|
1783 |
" |
|
128 | 1784 |
|view center sel| |
1785 |
||
1786 |
(sel := self moveableSelection) notNil ifTrue:[ |
|
1120 | 1787 |
self withSelectionHiddenDo:[ |
1788 |
view := self singleSelection. |
|
1789 |
||
1790 |
view notNil ifTrue:[ |
|
284 | 1791 |
|
1120 | 1792 |
view := self findContainerOfView:view. |
1793 |
center := view computeExtent |
|
1794 |
] ifFalse:[ |
|
1795 |
view := sel first. |
|
1796 |
center := view computeCorner + view computeOrigin. |
|
1797 |
]. |
|
1798 |
center := center x // 2. |
|
1799 |
||
1800 |
self transaction:#alignCenterHorizontal selectionDo:[:v| |
|
1801 |
|newX oldX delta| |
|
1802 |
||
1803 |
oldX := v computeOrigin x. |
|
1804 |
newX := center - ((v computeCorner x - oldX) // 2). |
|
1805 |
delta := newX - oldX. |
|
1806 |
||
1807 |
self shiftLayout:v left:delta right:delta |
|
1808 |
] |
|
1809 |
]. |
|
1810 |
self layoutChanged |
|
60 | 1811 |
] |
1812 |
||
1813 |
||
1814 |
||
1815 |
! |
|
1816 |
||
1817 |
alignSelectionCenterVer |
|
61 | 1818 |
"align selection to the center/vertical of the first object in the selection; in case |
1819 |
of one selection the object is aligned to the center/vertical of its superview |
|
1820 |
" |
|
128 | 1821 |
|view center sel| |
1822 |
||
1823 |
(sel := self moveableSelection) notNil ifTrue:[ |
|
1120 | 1824 |
self withSelectionHiddenDo:[ |
1825 |
view := self singleSelection. |
|
1826 |
||
1827 |
view notNil ifTrue:[ |
|
1828 |
view := self findContainerOfView:view. |
|
1829 |
center := view computeExtent |
|
1830 |
] ifFalse:[ |
|
1831 |
view := sel first. |
|
1832 |
center := view computeCorner + view computeOrigin. |
|
1833 |
]. |
|
1834 |
center := center y // 2. |
|
1835 |
||
1836 |
self transaction:#alignCenterVertical selectionDo:[:v| |
|
1837 |
|newY oldY delta| |
|
1838 |
||
1839 |
oldY := v computeOrigin y. |
|
1840 |
newY := center - ((v computeCorner y - oldY) // 2). |
|
1841 |
delta := newY - oldY. |
|
1842 |
||
1843 |
self shiftLayout:v top:delta bottom:delta |
|
1844 |
] |
|
1845 |
]. |
|
1846 |
self layoutChanged |
|
60 | 1847 |
] |
1848 |
! |
|
1849 |
||
1850 |
alignSelectionLeft |
|
61 | 1851 |
"align selection to the left of the first object in the selection; in case |
1852 |
of one selection the object is aligned to the left of its superview |
|
1853 |
" |
|
128 | 1854 |
|lmost delta sel| |
1855 |
||
1856 |
(sel := self moveableSelection) notNil ifTrue:[ |
|
1120 | 1857 |
self withSelectionHiddenDo:[ |
1858 |
self numberOfSelections > 1 ifTrue:[ |
|
1859 |
lmost := (sel first) computeOrigin x. |
|
1860 |
||
1861 |
self transaction:#alignLeft selectionDo:[:v| |
|
1862 |
(delta := lmost - (v computeOrigin x)) ~~ 0 ifTrue:[ |
|
1863 |
self shiftLayout:v left:delta right:delta |
|
1864 |
] |
|
1865 |
] |
|
1866 |
] ifFalse:[ |
|
1867 |
self extentToFrame:#Left do:[:aLayout| |
|
1868 |
aLayout leftOffset:0. |
|
1869 |
aLayout leftFraction:0.0. |
|
1870 |
] |
|
1871 |
] |
|
1872 |
]. |
|
1873 |
self layoutChanged |
|
60 | 1874 |
] |
1875 |
! |
|
1876 |
||
1877 |
alignSelectionLeftAndRight |
|
61 | 1878 |
"align selection to the left/right of the first object in the selection; in case |
1879 |
of one selection the object is aligned to the left/right of its superview |
|
1880 |
" |
|
128 | 1881 |
|lmost rmost sel| |
1882 |
||
1883 |
(sel := self moveableSelection) notNil ifTrue:[ |
|
1120 | 1884 |
self withSelectionHiddenDo:[ |
1885 |
self numberOfSelections > 1 ifTrue:[ |
|
1886 |
lmost := (sel first) computeOrigin x. |
|
1887 |
rmost := (sel first) computeCorner x. |
|
1888 |
||
1889 |
self transaction:#alignLeftRight selectionDo:[:aView| |
|
1890 |
|layout| |
|
1891 |
layout := self class asLayoutFrameFromView:aView. |
|
1892 |
||
1893 |
layout notNil ifTrue:[ |
|
1894 |
self createUndoLayout:aView. |
|
1895 |
aView geometryLayout:layout. |
|
1896 |
||
1897 |
undoHistory withoutTransactionDo:[ |
|
1898 |
self shiftLayout:aView left:(lmost - (aView computeOrigin x)) |
|
1899 |
right:(rmost - (aView computeCorner x)). |
|
1900 |
]. |
|
1901 |
self elementChangedSize:aView |
|
1902 |
] |
|
1903 |
] |
|
1904 |
] ifFalse:[ |
|
1905 |
self extentToFrame:#LeftRight do:[:aLayout| |
|
1906 |
aLayout leftOffset:0. |
|
1907 |
aLayout leftFraction:0.0. |
|
1908 |
aLayout rightOffset:0. |
|
1909 |
aLayout rightFraction:1.0. |
|
1910 |
] |
|
1911 |
] |
|
1912 |
]. |
|
1913 |
self layoutChanged |
|
61 | 1914 |
]. |
1915 |
||
60 | 1916 |
! |
1917 |
||
1918 |
alignSelectionRight |
|
61 | 1919 |
"align selection to the right of the first object in the selection; in case |
1920 |
of one selection the object is aligned to the right of its superview |
|
1921 |
" |
|
128 | 1922 |
|rmost delta sel| |
1923 |
||
1924 |
(sel := self moveableSelection) notNil ifTrue:[ |
|
1120 | 1925 |
self withSelectionHiddenDo:[ |
1926 |
self numberOfSelections > 1 ifTrue:[ |
|
1927 |
rmost := (sel first) computeCorner x. |
|
1928 |
||
1929 |
self transaction:#alignRight selectionDo:[:v| |
|
1930 |
(delta := rmost - (v computeCorner x)) ~~ 0 ifTrue:[ |
|
1931 |
self shiftLayout:v left:delta right:delta |
|
1932 |
] |
|
1933 |
] |
|
1934 |
] ifFalse:[ |
|
1935 |
self extentToFrame:#Right do:[:aLayout| |
|
1936 |
aLayout rightOffset:0. |
|
1937 |
aLayout rightFraction:1.0. |
|
1938 |
] |
|
1939 |
] |
|
1940 |
]. |
|
1941 |
self layoutChanged |
|
60 | 1942 |
] |
1943 |
! |
|
1944 |
||
1945 |
alignSelectionTop |
|
61 | 1946 |
"align selection to the top of the first object in the selection; in case |
1947 |
of one selection the object is aligned to the top of its superview |
|
1948 |
" |
|
128 | 1949 |
|tmost delta sel| |
1950 |
||
1951 |
(sel := self moveableSelection) notNil ifTrue:[ |
|
1120 | 1952 |
self withSelectionHiddenDo:[ |
1953 |
self numberOfSelections > 1 ifTrue:[ |
|
1954 |
tmost := (sel first) computeOrigin y. |
|
1955 |
||
1956 |
self transaction:#alignTop selectionDo:[:v| |
|
1957 |
(delta := tmost - (v computeOrigin y)) ~~ 0 ifTrue:[ |
|
1958 |
self shiftLayout:v top:delta bottom:delta |
|
1959 |
] |
|
1960 |
] |
|
1961 |
] ifFalse:[ |
|
1962 |
self extentToFrame:#Top do:[:aLayout| |
|
1963 |
aLayout topOffset:0. |
|
1964 |
aLayout topFraction:0.0. |
|
1965 |
] |
|
1966 |
] |
|
1967 |
]. |
|
1968 |
self layoutChanged |
|
60 | 1969 |
] |
1970 |
||
1971 |
! |
|
1972 |
||
1973 |
alignSelectionTopAndBottom |
|
61 | 1974 |
"align selection to the top/bottom of the first object in the selection; in case |
1975 |
of one selection the object is aligned to the top/bottom of its superview |
|
1976 |
" |
|
128 | 1977 |
|tmost bmost sel| |
1978 |
||
1979 |
(sel := self moveableSelection) notNil ifTrue:[ |
|
1120 | 1980 |
self withSelectionHiddenDo:[ |
1981 |
self numberOfSelections > 1 ifTrue:[ |
|
1982 |
tmost := (sel first) computeOrigin y. |
|
1983 |
bmost := (sel first) computeCorner y. |
|
1984 |
||
1985 |
self transaction:#alignTopBottom selectionDo:[:aView| |
|
1986 |
|layout| |
|
1987 |
layout := self class asLayoutFrameFromView:aView. |
|
1988 |
||
1989 |
layout notNil ifTrue:[ |
|
1990 |
self createUndoLayout:aView. |
|
1991 |
aView geometryLayout:layout. |
|
1992 |
||
1993 |
undoHistory withoutTransactionDo:[ |
|
1994 |
self shiftLayout:aView top:(tmost - (aView computeOrigin y)) |
|
1995 |
bottom:(bmost - (aView computeCorner y)). |
|
1996 |
]. |
|
1997 |
self elementChangedSize:aView |
|
1998 |
] |
|
1999 |
] |
|
2000 |
] ifFalse:[ |
|
2001 |
self extentToFrame:#TopBottom do:[:aLayout| |
|
2002 |
aLayout topOffset:0. |
|
2003 |
aLayout topFraction:0.0. |
|
2004 |
aLayout bottomOffset:0. |
|
2005 |
aLayout bottomFraction:1.0. |
|
2006 |
] |
|
2007 |
] |
|
2008 |
]. |
|
2009 |
self layoutChanged |
|
60 | 2010 |
] |
2011 |
! |
|
2012 |
||
2013 |
centerSelection:aOneArgBlockXorY orientation:orientation |
|
2014 |
"center selection horizontal or vertical dependant on the block result( x or y). |
|
2015 |
The argument to the block is the point. |
|
2016 |
" |
|
2017 |
|superview min max delta val| |
|
2018 |
||
128 | 2019 |
(self moveableSelection) isNil ifTrue:[ |
1120 | 2020 |
^ self |
61 | 2021 |
]. |
2022 |
||
2023 |
self withSelectionHiddenDo:[ |
|
1120 | 2024 |
max := 0. |
2025 |
||
2026 |
self selectionDo:[:aView | |
|
2027 |
superview isNil ifTrue:[ |
|
2028 |
superview := self findContainerOfView:aView |
|
2029 |
] ifFalse:[ |
|
2030 |
(self findContainerOfView:aView) == superview ifFalse:[ |
|
2031 |
^ self notify:'views must have same superview'. |
|
2032 |
] |
|
2033 |
]. |
|
2034 |
val := aOneArgBlockXorY value:(aView computeOrigin). |
|
2035 |
||
2036 |
min isNil ifTrue:[min := val] |
|
2037 |
ifFalse:[min := min min:val]. |
|
2038 |
||
2039 |
val := aOneArgBlockXorY value:(aView computeCorner). |
|
2040 |
max := max max:val. |
|
2041 |
]. |
|
2042 |
||
2043 |
val := aOneArgBlockXorY value:(superview computeExtent). |
|
2044 |
max := (min + val - max) // 2. |
|
2045 |
||
2046 |
max == min ifFalse:[ |
|
2047 |
|type| |
|
2048 |
(orientation == #y) ifTrue:[type := #centerVertical] |
|
2049 |
ifFalse:[type := #centerHorizontal]. |
|
2050 |
delta := max - min. |
|
2051 |
||
2052 |
self transaction:type selectionDo:[:v| |
|
2053 |
orientation == #y ifTrue:[ |
|
2054 |
self shiftLayout:v top:delta bottom:delta |
|
2055 |
] ifFalse:[ |
|
2056 |
self shiftLayout:v left:delta right:delta |
|
2057 |
] |
|
2058 |
] |
|
2059 |
]. |
|
2060 |
self layoutChanged |
|
60 | 2061 |
] |
2062 |
||
2063 |
||
2064 |
! |
|
2065 |
||
2066 |
centerSelectionHor |
|
2067 |
"center selection horizontal |
|
2068 |
" |
|
2069 |
self centerSelection:[:aPoint| aPoint x] orientation:#x |
|
2070 |
||
2071 |
||
2072 |
! |
|
2073 |
||
2074 |
centerSelectionVer |
|
2075 |
"center selection vertical |
|
2076 |
" |
|
2077 |
self centerSelection:[:aPoint| aPoint y] orientation:#y |
|
2078 |
! |
|
2079 |
||
72 | 2080 |
extentToFrame:toWhat do:aBlock |
2081 |
"align to frame (Left Right ...) and perform the block on a frameLayout |
|
2082 |
" |
|
2083 |
|layout type| |
|
2084 |
||
2085 |
type := ('extent', toWhat asString) asSymbol. |
|
2086 |
||
2087 |
self transaction:type selectionDo:[:aView| |
|
1120 | 2088 |
layout := self class asLayoutFrameFromView:aView. |
2089 |
||
2090 |
layout notNil ifTrue:[ |
|
2091 |
self createUndoLayout:aView. |
|
2092 |
aBlock value:layout. |
|
2093 |
aView geometryLayout:layout. |
|
2094 |
self elementChangedSize:aView. |
|
2095 |
] |
|
72 | 2096 |
] |
2097 |
! |
|
2098 |
||
60 | 2099 |
spreadSelectionHor |
61 | 2100 |
"spread multiple selection horizontal |
2101 |
" |
|
128 | 2102 |
|sumWidths min max viewsInOrder topsInOrder count space sel| |
2103 |
||
2104 |
sel := self moveableSelection. |
|
2105 |
||
2106 |
(sel notNil and:[self numberOfSelections > 1]) ifFalse:[ |
|
1120 | 2107 |
^ self |
60 | 2108 |
]. |
2109 |
||
61 | 2110 |
self withSelectionHiddenDo:[ |
1120 | 2111 |
count := 0. |
2112 |
sumWidths := 0. |
|
2113 |
max := 0. |
|
2114 |
||
2115 |
self selectionDo:[:aView | |
|
2116 |
sumWidths := sumWidths + aView width. |
|
2117 |
||
2118 |
min isNil ifTrue:[min := aView left] |
|
2119 |
ifFalse:[min := min min:(aView left)]. |
|
2120 |
||
2121 |
max := max max:(aView right). |
|
2122 |
count := count + 1 |
|
2123 |
]. |
|
2124 |
viewsInOrder := Array withAll:sel. |
|
2125 |
topsInOrder := viewsInOrder collect:[:aView | aView left]. |
|
2126 |
topsInOrder sortWith:viewsInOrder. |
|
2127 |
||
2128 |
space := (((max - min) - sumWidths) / (count - 1)) rounded asInteger. |
|
2129 |
||
2130 |
self transaction:#spreadHorizontal objects:viewsInOrder do:[:aView| |
|
2131 |
|delta| |
|
2132 |
||
2133 |
delta := min - aView computeOrigin x. |
|
2134 |
self shiftLayout:aView left:delta right:delta. |
|
2135 |
min := min + aView computeExtent x + space |
|
2136 |
] |
|
61 | 2137 |
]. |
225 | 2138 |
self layoutChanged |
60 | 2139 |
|
2140 |
! |
|
2141 |
||
2142 |
spreadSelectionVer |
|
61 | 2143 |
"spread multiple selection vertical |
2144 |
" |
|
128 | 2145 |
|sumHeights min max viewsInOrder topsInOrder count space sel| |
2146 |
||
2147 |
sel := self moveableSelection. |
|
2148 |
||
2149 |
(sel notNil and:[self numberOfSelections > 1]) ifFalse:[ |
|
1120 | 2150 |
^ self |
60 | 2151 |
]. |
2152 |
||
61 | 2153 |
self withSelectionHiddenDo:[ |
1120 | 2154 |
count := 0. |
2155 |
sumHeights := 0. |
|
2156 |
max := 0. |
|
2157 |
||
2158 |
self selectionDo:[:aView | |
|
2159 |
sumHeights := sumHeights + aView height. |
|
2160 |
||
2161 |
min isNil ifTrue:[min := aView top] |
|
2162 |
ifFalse:[min := min min:(aView top)]. |
|
2163 |
||
2164 |
max := max max:(aView bottom). |
|
2165 |
count := count + 1 |
|
2166 |
]. |
|
2167 |
viewsInOrder := Array withAll:sel. |
|
2168 |
topsInOrder := viewsInOrder collect:[:aView|aView top]. |
|
2169 |
topsInOrder sortWith:viewsInOrder. |
|
2170 |
||
2171 |
space := (((max - min) - sumHeights) / (count - 1)) rounded asInteger. |
|
2172 |
||
2173 |
self transaction:#spreadVertical objects:viewsInOrder do:[:aView| |
|
2174 |
|delta| |
|
2175 |
||
2176 |
delta := min - aView computeOrigin y. |
|
2177 |
self shiftLayout:aView top:delta bottom:delta. |
|
2178 |
min := min + aView height + space |
|
2179 |
] |
|
61 | 2180 |
]. |
225 | 2181 |
self layoutChanged |
60 | 2182 |
! ! |
2183 |
||
2184 |
!UIObjectView methodsFor:'user actions - undo history'! |
|
2185 |
||
72 | 2186 |
enableUndoHistory:aState |
2187 |
"enable or disable undo history |
|
2188 |
" |
|
2189 |
undoHistory enabled:aState |
|
2190 |
! |
|
2191 |
||
60 | 2192 |
openUndoMenu |
61 | 2193 |
"open undo menu |
2194 |
" |
|
149 | 2195 |
self select:nil. |
138 | 2196 |
undoHistory openUndoMenu |
60 | 2197 |
! |
2198 |
||
2199 |
removeUndoHistory |
|
2200 |
"delete total undo history |
|
2201 |
" |
|
134 | 2202 |
undoHistory on:self |
60 | 2203 |
! |
2204 |
||
2205 |
undoLast |
|
61 | 2206 |
"undo last action |
2207 |
" |
|
138 | 2208 |
|newSel oldSel| |
2209 |
||
134 | 2210 |
undoHistory isEmpty ifFalse:[ |
1120 | 2211 |
self hasSelection ifTrue:[ |
2212 |
oldSel := OrderedCollection new. |
|
2213 |
newSel := OrderedCollection new. |
|
2214 |
||
2215 |
self selectionDo:[:aView||p| |
|
2216 |
(p := self propertyOfView:aView) notNil ifTrue:[ |
|
2217 |
oldSel add:(p identifier) |
|
2218 |
] |
|
2219 |
]. |
|
2220 |
self setSelection:nil withRedraw:true. |
|
2221 |
]. |
|
2222 |
||
2223 |
self withSelectionHiddenDo:[undoHistory undoLast:1]. |
|
2224 |
||
2225 |
oldSel notNil ifTrue:[ |
|
2226 |
oldSel do:[:id||v| |
|
2227 |
(v := self findViewWithId:id) notNil ifTrue:[newSel add:v] |
|
2228 |
]. |
|
2229 |
self select:newSel. |
|
2230 |
] |
|
61 | 2231 |
]. |
60 | 2232 |
! ! |
2233 |
||
543
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2234 |
!UIObjectView::ResizeData methodsFor:'accessing'! |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2235 |
|
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2236 |
delta |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2237 |
^ delta |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2238 |
|
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2239 |
"Created: / 2.2.1998 / 13:40:32 / cg" |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2240 |
! |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2241 |
|
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2242 |
object |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2243 |
^ object |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2244 |
|
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2245 |
"Created: / 2.2.1998 / 13:40:24 / cg" |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2246 |
! |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2247 |
|
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2248 |
object:anObject selector:aSymbol delta:anInteger |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2249 |
object := anObject. |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2250 |
selector := aSymbol. |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2251 |
delta := anInteger. |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2252 |
|
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2253 |
"Created: / 2.2.1998 / 13:39:22 / cg" |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2254 |
! |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2255 |
|
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2256 |
selector |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2257 |
^ selector |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2258 |
|
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2259 |
"Created: / 2.2.1998 / 13:40:42 / cg" |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2260 |
! ! |
e3f2bf2dfb59
eliminated use of Structure - added private ResizeData class instead
Claus Gittinger <cg@exept.de>
parents:
374
diff
changeset
|
2261 |
|
60 | 2262 |
!UIObjectView::UndoHistory class methodsFor:'constants'! |
2263 |
||
2264 |
maxHistorySize |
|
2265 |
"returns maximum size of history before removing oldest |
|
2266 |
record |
|
2267 |
" |
|
134 | 2268 |
^ 100 |
60 | 2269 |
|
2270 |
||
2271 |
! ! |
|
2272 |
||
131 | 2273 |
!UIObjectView::UndoHistory class methodsFor:'documentation'! |
2274 |
||
2275 |
documentation |
|
2276 |
" |
|
2277 |
undo history used by the UIPainter-Tool; to each operation, an undo block |
|
2278 |
and some text is stored. In case of a required undo, the corresponding |
|
2279 |
undo block will be performed. |
|
2280 |
||
2281 |
[see also:] |
|
1120 | 2282 |
UIObjectView |
2283 |
UIPainterView |
|
156 | 2284 |
|
2285 |
[author:] |
|
1120 | 2286 |
Claus Atzkern |
131 | 2287 |
" |
2288 |
||
2289 |
||
2290 |
! ! |
|
2291 |
||
60 | 2292 |
!UIObjectView::UndoHistory class methodsFor:'instance creation'! |
2293 |
||
134 | 2294 |
on:aPainter |
2295 |
|history| |
|
2296 |
||
2297 |
history := self new. |
|
2298 |
history on:aPainter. |
|
2299 |
^ history |
|
60 | 2300 |
|
2301 |
||
2302 |
! ! |
|
2303 |
||
2304 |
!UIObjectView::UndoHistory methodsFor:'accessing'! |
|
2305 |
||
134 | 2306 |
addUndoSelector:aSelector withArgs:anArray |
2307 |
"add a selector with arguments to the current opened transaction; in case that no |
|
2308 |
transaction is opened or disabled the block will not be kept in the history. |
|
2309 |
" |
|
2310 |
self isTransactionOpen ifTrue:[ |
|
1120 | 2311 |
transaction add:(Association key:aSelector value:anArray) |
134 | 2312 |
] |
2313 |
||
2314 |
||
2315 |
! ! |
|
2316 |
||
2317 |
!UIObjectView::UndoHistory methodsFor:'accessing behavior'! |
|
2318 |
||
72 | 2319 |
enabled |
2320 |
^ enabled |
|
2321 |
! |
|
2322 |
||
2323 |
enabled:aState |
|
2324 |
enabled := aState |
|
2325 |
! |
|
2326 |
||
134 | 2327 |
resetModification |
2328 |
"set modification state to false |
|
2329 |
" |
|
2330 |
startIdentifier := identifier |
|
2331 |
! ! |
|
2332 |
||
2333 |
!UIObjectView::UndoHistory methodsFor:'activation'! |
|
2334 |
||
2335 |
withinTransaction:aType text:aTextOrNil do:aBlock |
|
2336 |
"open a transaction; perform the block; at least close the transaction |
|
72 | 2337 |
" |
134 | 2338 |
(enabled and:[transaction isNil]) ifTrue:[ |
1120 | 2339 |
transaction := Transaction type:aType text:aTextOrNil. |
2340 |
||
2341 |
aBlock value. |
|
2342 |
||
2343 |
transaction isEmpty ifFalse:[ |
|
2344 |
identifier := identifier + 1. |
|
2345 |
transaction identifier:identifier. |
|
2346 |
history addLast:transaction. |
|
2347 |
history size > (self class maxHistorySize) ifTrue:[history removeFirst] |
|
2348 |
]. |
|
2349 |
transaction := nil |
|
134 | 2350 |
|
2351 |
] ifFalse:[ |
|
1120 | 2352 |
aBlock value |
134 | 2353 |
] |
2354 |
! |
|
2355 |
||
2356 |
withoutTransactionDo:aNoneArgBlock |
|
2357 |
"evaluate the block without opening a transaction or keeping changes |
|
2358 |
within a still opened transaction |
|
2359 |
" |
|
2360 |
|oldState| |
|
2361 |
||
2362 |
oldState := enabled. |
|
2363 |
enabled := false. |
|
2364 |
aNoneArgBlock value. |
|
2365 |
enabled := oldState. |
|
60 | 2366 |
! ! |
2367 |
||
2368 |
!UIObjectView::UndoHistory methodsFor:'initialization'! |
|
2369 |
||
134 | 2370 |
on:aPainter |
2371 |
"setup for a painter and delete all existing history records |
|
60 | 2372 |
" |
134 | 2373 |
identifier := 0. |
2374 |
startIdentifier := 0. |
|
2375 |
||
2376 |
painter := aPainter. |
|
60 | 2377 |
history := OrderedCollection new. |
2378 |
transaction := nil. |
|
2379 |
enabled := true. |
|
2380 |
||
2381 |
||
2382 |
! ! |
|
2383 |
||
2384 |
!UIObjectView::UndoHistory methodsFor:'menu'! |
|
2385 |
||
2386 |
openUndoMenu |
|
72 | 2387 |
|list tabs top slv hzp inset selection okButton| |
60 | 2388 |
|
2389 |
history isEmpty ifTrue:[ |
|
1120 | 2390 |
^ self |
60 | 2391 |
]. |
2392 |
||
2393 |
top := StandardSystemView new label:'undo history'; extent:250@350. |
|
2394 |
slv := ScrollableView for:SelectionInListView origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
2395 |
hzp := HorizontalPanelView origin:0.0@1.0 corner:1.0@1.0 in:top. |
|
2396 |
hzp horizontalLayout:#fitSpace. |
|
2397 |
||
2398 |
(Button abortButtonIn:hzp) action:[ selection := nil. top destroy ]. |
|
2399 |
okButton := Button okButtonIn:hzp. |
|
2400 |
okButton label:'undo to end'. |
|
2401 |
okButton action:[ top destroy ]. |
|
2402 |
||
2403 |
inset := hzp preferredExtent y. |
|
2404 |
hzp topInset:(inset negated). |
|
2405 |
slv bottomInset:inset. |
|
2406 |
slv := slv scrolledView. |
|
2407 |
||
72 | 2408 |
tabs := TabulatorSpecification new. |
2409 |
tabs unit:#cm. |
|
2410 |
tabs positions:#(0 5). |
|
208 | 2411 |
tabs align:#(#left #left). |
72 | 2412 |
|
60 | 2413 |
list := history collect:[:aTrans||e| |
1120 | 2414 |
e := MultiColListEntry new. |
2415 |
e colAt:1 put:(aTrans typeAsString). |
|
2416 |
e colAt:2 put:(aTrans text ? ''). |
|
2417 |
e tabulatorSpecification:tabs. |
|
2418 |
e |
|
60 | 2419 |
]. |
2420 |
||
2421 |
slv list:list. |
|
2422 |
slv action:[:index | selection := index ]. |
|
2423 |
top openModal. |
|
2424 |
||
2425 |
selection notNil ifTrue:[ |
|
1120 | 2426 |
self undoLast:(history size - selection + 1). |
60 | 2427 |
] |
2428 |
! ! |
|
2429 |
||
2430 |
!UIObjectView::UndoHistory methodsFor:'testing'! |
|
2431 |
||
2432 |
isEmpty |
|
2433 |
"returns true if undo history is empty |
|
2434 |
" |
|
2435 |
^ history isEmpty |
|
2436 |
||
2437 |
||
2438 |
! |
|
2439 |
||
134 | 2440 |
isModified |
2441 |
"returns true if history is modified |
|
2442 |
" |
|
2443 |
self isEmpty ifTrue:[ |
|
1120 | 2444 |
^ false |
134 | 2445 |
]. |
2446 |
^ history last identifier ~~ startIdentifier |
|
2447 |
! |
|
2448 |
||
60 | 2449 |
isTransactionOpen |
2450 |
^ (enabled and:[transaction notNil]) |
|
2451 |
! ! |
|
2452 |
||
2453 |
!UIObjectView::UndoHistory methodsFor:'undo'! |
|
2454 |
||
2455 |
undoLast:nTransactions |
|
2456 |
"undo last n transactions; an open transaction will be closed; |
|
2457 |
transactions during undo are disabled |
|
2458 |
" |
|
134 | 2459 |
|repeatTimes transaction actions| |
60 | 2460 |
|
2461 |
transaction := nil. |
|
134 | 2462 |
enabled := false. |
2463 |
repeatTimes := nTransactions min:(history size). |
|
2464 |
||
2465 |
repeatTimes timesRepeat:[ |
|
1120 | 2466 |
transaction := history removeLast. |
2467 |
actions := transaction actions. |
|
2468 |
||
2469 |
actions isCollection ifTrue:[ |
|
2470 |
actions reverseDo:[:aBlock| |
|
2471 |
painter perform:(aBlock key) with:(aBlock value) |
|
2472 |
] |
|
2473 |
] ifFalse:[ |
|
2474 |
painter perform:(actions key) with:(actions value) |
|
2475 |
] |
|
134 | 2476 |
]. |
2477 |
enabled := true. |
|
60 | 2478 |
! ! |
2479 |
||
2480 |
!UIObjectView::UndoHistory::Transaction class methodsFor:'documentation'! |
|
2481 |
||
131 | 2482 |
documentation |
2483 |
" |
|
2484 |
represents one undo record, keeping the associated type and printable text |
|
2485 |
and the undo action performed on an undo request |
|
2486 |
||
2487 |
[see also:] |
|
1120 | 2488 |
UndoHistory |
156 | 2489 |
|
2490 |
[author:] |
|
1120 | 2491 |
Claus Atzkern |
131 | 2492 |
" |
2493 |
||
60 | 2494 |
! ! |
2495 |
||
54 | 2496 |
!UIObjectView::UndoHistory::Transaction class methodsFor:'instance creation'! |
2497 |
||
2498 |
type:aType text:aTextOrNil |
|
2499 |
^ self new type:aType text:aTextOrNil |
|
2500 |
||
2501 |
||
2502 |
! ! |
|
2503 |
||
2504 |
!UIObjectView::UndoHistory::Transaction methodsFor:'accessing'! |
|
2505 |
||
134 | 2506 |
actions |
2507 |
"returns actions associated with transaction |
|
2508 |
" |
|
2509 |
^ actions |
|
2510 |
! |
|
2511 |
||
2512 |
identifier |
|
2513 |
"gets my identifier |
|
2514 |
" |
|
2515 |
^ identifier |
|
2516 |
! |
|
2517 |
||
2518 |
identifier:anIdentifier |
|
2519 |
"sets my identifier |
|
2520 |
" |
|
2521 |
identifier := anIdentifier |
|
2522 |
! |
|
2523 |
||
54 | 2524 |
text |
134 | 2525 |
"returns text or nil assigned to transaction |
54 | 2526 |
" |
2527 |
^ text |
|
2528 |
! |
|
2529 |
||
2530 |
type |
|
134 | 2531 |
"returns type assigned to transaction |
54 | 2532 |
" |
2533 |
^ type |
|
2534 |
! |
|
2535 |
||
2536 |
type:aType |
|
134 | 2537 |
"change type assigned to transaction |
54 | 2538 |
" |
2539 |
type := aType |
|
72 | 2540 |
! |
2541 |
||
2542 |
typeAsString |
|
2543 |
"returns type as printable string |
|
2544 |
" |
|
2545 |
|line name size sep| |
|
2546 |
||
2547 |
line := type asString. |
|
2548 |
size := 0. |
|
2549 |
line do:[:c| (c isUppercase) ifTrue:[size := size+1] ]. |
|
2550 |
name := String new:(line size + size). |
|
2551 |
size := 1. |
|
2552 |
sep := Character space. |
|
2553 |
||
2554 |
line do:[:c| |
|
1120 | 2555 |
(c isUppercase) ifFalse:[ |
2556 |
name at:size put:c |
|
2557 |
] ifTrue:[ |
|
2558 |
name at:size put:sep. |
|
2559 |
sep := $&. |
|
2560 |
size := size + 1. |
|
2561 |
name at:size put:(c asLowercase) |
|
2562 |
]. |
|
2563 |
size := size + 1 |
|
72 | 2564 |
]. |
2565 |
^ name |
|
54 | 2566 |
! ! |
2567 |
||
134 | 2568 |
!UIObjectView::UndoHistory::Transaction methodsFor:'adding'! |
54 | 2569 |
|
2570 |
add:anUndoBlock |
|
134 | 2571 |
"add an undo action to the current transaction |
54 | 2572 |
" |
2573 |
actions isNil ifTrue:[ |
|
1120 | 2574 |
actions := anUndoBlock |
54 | 2575 |
] ifFalse:[ |
1120 | 2576 |
actions isCollection ifFalse:[ |
2577 |
actions := OrderedCollection with:actions |
|
2578 |
]. |
|
2579 |
actions add:anUndoBlock. |
|
54 | 2580 |
] |
2581 |
! ! |
|
2582 |
||
2583 |
!UIObjectView::UndoHistory::Transaction methodsFor:'initialization'! |
|
2584 |
||
2585 |
type:aType text:aTextOrNil |
|
134 | 2586 |
"initialize transaction |
54 | 2587 |
" |
2588 |
type := aType. |
|
2589 |
text := aTextOrNil. |
|
2590 |
! ! |
|
2591 |
||
2592 |
!UIObjectView::UndoHistory::Transaction methodsFor:'testing'! |
|
2593 |
||
2594 |
isEmpty |
|
2595 |
"returns true if no undo action is registered |
|
2596 |
" |
|
2597 |
^ actions isNil |
|
47 | 2598 |
! ! |
2599 |
||
60 | 2600 |
!UIObjectView class methodsFor:'documentation'! |
2601 |
||
2602 |
version |
|
2603 |
^ '$Header$' |
|
2604 |
! ! |