85 |
85 |
86 type := self layoutType:aView. |
86 type := self layoutType:aView. |
87 layout := aView geometryLayout. |
87 layout := aView geometryLayout. |
88 |
88 |
89 layout isNil ifTrue:[ |
89 layout isNil ifTrue:[ |
90 type == #Extent ifTrue:[ |
90 type == #Extent ifTrue:[ |
91 layout := aView bounds asLayout |
91 layout := aView bounds asLayout |
92 ] |
92 ] |
93 ]. |
93 ]. |
94 |
94 |
95 (type isNil or:[layout isNil]) ifTrue:[ |
95 (type isNil or:[layout isNil]) ifTrue:[ |
96 ^ nil |
96 ^ nil |
97 ]. |
97 ]. |
98 |
98 |
99 type == #LayoutFrame ifTrue:[ |
99 type == #LayoutFrame ifTrue:[ |
100 ^ layout copy |
100 ^ layout copy |
101 ]. |
101 ]. |
102 |
102 |
103 layout isLayout ifFalse:[ |
103 layout isLayout ifFalse:[ |
104 type == #Rectangle ifTrue:[ |
104 type == #Rectangle ifTrue:[ |
105 lO := layout left. |
105 lO := layout left. |
106 tO := layout top. |
106 tO := layout top. |
107 rO := layout right. |
107 rO := layout right. |
108 bO := layout bottom. |
108 bO := layout bottom. |
109 ] ifFalse:[ |
109 ] ifFalse:[ |
110 lO := layout x. |
110 lO := layout x. |
111 tO := layout y. |
111 tO := layout y. |
112 rO := lO + aView extent x. |
112 rO := lO + aView extent x. |
113 bO := tO + aView extent y. |
113 bO := tO + aView extent y. |
114 ]. |
114 ]. |
115 |
115 |
116 ^ LayoutFrame leftFraction:0 offset:lO rightFraction:0 offset:rO |
116 ^ LayoutFrame leftFraction:0 offset:lO rightFraction:0 offset:rO |
117 topFraction:0 offset:tO bottomFraction:0 offset:bO |
117 topFraction:0 offset:tO bottomFraction:0 offset:bO |
118 ]. |
118 ]. |
119 |
119 |
120 lF := layout leftFraction. |
120 lF := layout leftFraction. |
121 lO := layout leftOffset. |
121 lO := layout leftOffset. |
122 tF := layout topFraction. |
122 tF := layout topFraction. |
125 bO := tO + aView extent y. |
125 bO := tO + aView extent y. |
126 rF := lF. |
126 rF := lF. |
127 rO := lO + aView extent x. |
127 rO := lO + aView extent x. |
128 |
128 |
129 newLyt := LayoutFrame leftFraction:lF offset:lO rightFraction:rF offset:rO |
129 newLyt := LayoutFrame leftFraction:lF offset:lO rightFraction:rF offset:rO |
130 topFraction:tF offset:tO bottomFraction:bF offset:bO. |
130 topFraction:tF offset:tO bottomFraction:bF offset:bO. |
131 |
131 |
132 ( (type == #AlignmentOrigin) |
132 ( (type == #AlignmentOrigin) |
133 and:[layout leftAlignmentFraction ~~ 0 |
133 and:[layout leftAlignmentFraction ~~ 0 |
134 or:[layout topAlignmentFraction ~~ 0]] |
134 or:[layout topAlignmentFraction ~~ 0]] |
135 ) ifTrue:[ |
135 ) ifTrue:[ |
136 |svRc prBd dlta| |
136 |svRc prBd dlta| |
137 |
137 |
138 svRc := aView superView viewRectangle. |
138 svRc := aView superView viewRectangle. |
139 prBd := aView preferredBounds. |
139 prBd := aView preferredBounds. |
140 dlta := ( ((layout rectangleRelativeTo:svRc preferred:prBd) corner) |
140 dlta := ( ((layout rectangleRelativeTo:svRc preferred:prBd) corner) |
141 - ((newLyt rectangleRelativeTo:svRc preferred:prBd) corner) |
141 - ((newLyt rectangleRelativeTo:svRc preferred:prBd) corner) |
142 ) rounded. |
142 ) rounded. |
143 |
143 |
144 newLyt leftOffset:(lO + dlta x). |
144 newLyt leftOffset:(lO + dlta x). |
145 newLyt rightOffset:(rO + dlta x). |
145 newLyt rightOffset:(rO + dlta x). |
146 newLyt topOffset:(tO + dlta y). |
146 newLyt topOffset:(tO + dlta y). |
147 newLyt bottomOffset:(bO + dlta y). |
147 newLyt bottomOffset:(bO + dlta y). |
148 ]. |
148 ]. |
149 ^ newLyt. |
149 ^ newLyt. |
150 |
150 |
151 "Modified: 28.3.1997 / 19:52:48 / cg" |
151 "Modified: 28.3.1997 / 19:52:48 / cg" |
152 ! ! |
152 ! ! |
180 |type v h| |
180 |type v h| |
181 |
181 |
182 type := self layoutType:aView. |
182 type := self layoutType:aView. |
183 |
183 |
184 (type == #LayoutFrame or:[type == #Rectangle]) ifTrue:[ |
184 (type == #LayoutFrame or:[type == #Rectangle]) ifTrue:[ |
185 v := self isVerticalResizable:aView. |
185 v := self isVerticalResizable:aView. |
186 h := self isHorizontalResizable:aView. |
186 h := self isHorizontalResizable:aView. |
187 |
187 |
188 h ifTrue:[ aBlock value:(aView leftCenter ) value:#left. |
188 h ifTrue:[ aBlock value:(aView leftCenter ) value:#left. |
189 aBlock value:(aView rightCenter) value:#right. |
189 aBlock value:(aView rightCenter) value:#right. |
190 ]. |
190 ]. |
191 v ifTrue:[ aBlock value:(aView topCenter ) value:#top. |
191 v ifTrue:[ aBlock value:(aView topCenter ) value:#top. |
192 aBlock value:(aView bottomCenter) value:#bottom. |
192 aBlock value:(aView bottomCenter) value:#bottom. |
193 ]. |
193 ]. |
194 |
194 |
195 (h and:[v]) ifTrue:[ |
195 (h and:[v]) ifTrue:[ |
196 aBlock value:(aView origin ) value:#origin. |
196 aBlock value:(aView origin ) value:#origin. |
197 aBlock value:(aView topRight ) value:#topRight. |
197 aBlock value:(aView topRight ) value:#topRight. |
198 aBlock value:(aView bottomLeft) value:#bottomLeft. |
198 aBlock value:(aView bottomLeft) value:#bottomLeft. |
199 aBlock value:(aView corner ) value:#corner. |
199 aBlock value:(aView corner ) value:#corner. |
200 ^ self |
200 ^ self |
201 ] |
201 ] |
202 ]. |
202 ]. |
203 |
203 |
204 aBlock value:(aView origin ) value:#view. |
204 aBlock value:(aView origin ) value:#view. |
205 aBlock value:(aView topRight ) value:#view. |
205 aBlock value:(aView topRight ) value:#view. |
206 aBlock value:(aView bottomLeft) value:#view. |
206 aBlock value:(aView bottomLeft) value:#view. |
207 |
207 |
208 type == #Extent ifTrue:[ |
208 type == #Extent ifTrue:[ |
209 v := self isVerticalResizable:aView. |
209 v := self isVerticalResizable:aView. |
210 h := self isHorizontalResizable:aView. |
210 h := self isHorizontalResizable:aView. |
211 |
211 |
212 v ifTrue:[aBlock value:(aView bottomCenter) value:#bottom]. |
212 v ifTrue:[aBlock value:(aView bottomCenter) value:#bottom]. |
213 h ifTrue:[aBlock value:(aView rightCenter ) value:#right ]. |
213 h ifTrue:[aBlock value:(aView rightCenter ) value:#right ]. |
214 |
214 |
215 (h and:[v]) ifTrue:[ |
215 (h and:[v]) ifTrue:[ |
216 aBlock value:(aView corner) value:#corner. |
216 aBlock value:(aView corner) value:#corner. |
217 ^ self |
217 ^ self |
218 ] |
218 ] |
219 ]. |
219 ]. |
220 aBlock value:(aView corner) value:#view. |
220 aBlock value:(aView corner) value:#view. |
221 |
221 |
222 |
222 |
223 ! ! |
223 ! ! |
226 |
226 |
227 isHorizontalResizable:aComponent |
227 isHorizontalResizable:aComponent |
228 "returns true if instance is horizontal resizeable |
228 "returns true if instance is horizontal resizeable |
229 " |
229 " |
230 (aComponent isKindOf:ScrollBar) ifTrue:[ |
230 (aComponent isKindOf:ScrollBar) ifTrue:[ |
231 ^ aComponent orientation == #horizontal |
231 ^ aComponent orientation == #horizontal |
232 ]. |
232 ]. |
233 (aComponent isKindOf:Scroller) ifTrue:[ |
233 (aComponent isKindOf:Scroller) ifTrue:[ |
234 ^ aComponent orientation == #horizontal |
234 ^ aComponent orientation == #horizontal |
235 ]. |
235 ]. |
236 (aComponent isKindOf:Slider) ifTrue:[ |
236 (aComponent isKindOf:Slider) ifTrue:[ |
237 ^ aComponent orientation == #horizontal |
237 ^ aComponent orientation == #horizontal |
238 ]. |
238 ]. |
239 ^ true |
239 ^ true |
240 |
240 |
241 ! |
241 ! |
242 |
242 |
243 isVerticalResizable:aComponent |
243 isVerticalResizable:aComponent |
244 "returns true if instance is vertical resizeable |
244 "returns true if instance is vertical resizeable |
245 " |
245 " |
246 (aComponent isKindOf:EditField) ifTrue:[ |
246 (aComponent isKindOf:EditField) ifTrue:[ |
247 ^ false |
247 ^ false |
248 ]. |
248 ]. |
249 (aComponent isKindOf:ComboBoxView) ifTrue:[ |
249 (aComponent isKindOf:ComboBoxView) ifTrue:[ |
250 ^ false |
250 ^ false |
251 ]. |
251 ]. |
252 (aComponent isKindOf:CheckBox) ifTrue:[ |
252 (aComponent isKindOf:CheckBox) ifTrue:[ |
253 ^ false |
253 ^ false |
254 ]. |
254 ]. |
255 (aComponent isKindOf:ScrollBar) ifTrue:[ |
255 (aComponent isKindOf:ScrollBar) ifTrue:[ |
256 ^ aComponent orientation == #vertical |
256 ^ aComponent orientation == #vertical |
257 ]. |
257 ]. |
258 (aComponent isKindOf:Scroller) ifTrue:[ |
258 (aComponent isKindOf:Scroller) ifTrue:[ |
259 ^ aComponent orientation == #vertical |
259 ^ aComponent orientation == #vertical |
260 ]. |
260 ]. |
261 (aComponent isKindOf:Slider) ifTrue:[ |
261 (aComponent isKindOf:Slider) ifTrue:[ |
262 ^ aComponent orientation == #vertical |
262 ^ aComponent orientation == #vertical |
263 ]. |
263 ]. |
264 ^ true |
264 ^ true |
265 |
265 |
266 ! |
266 ! |
267 |
267 |
269 "returns layout type of aView or nil |
269 "returns layout type of aView or nil |
270 " |
270 " |
271 |layout spec superView| |
271 |layout spec superView| |
272 |
272 |
273 aView notNil ifTrue:[ |
273 aView notNil ifTrue:[ |
274 layout := aView geometryLayout. |
274 layout := aView geometryLayout. |
275 layout notNil ifTrue:[ |
275 layout notNil ifTrue:[ |
276 layout isLayout ifTrue:[ |
276 layout isLayout ifTrue:[ |
277 layout isLayoutFrame ifTrue:[ ^ #LayoutFrame ]. |
277 layout isLayoutFrame ifTrue:[ ^ #LayoutFrame ]. |
278 layout isAlignmentOrigin ifTrue:[ ^ #AlignmentOrigin ]. |
278 layout isAlignmentOrigin ifTrue:[ ^ #AlignmentOrigin ]. |
279 layout isLayoutOrigin ifTrue:[ ^ #LayoutOrigin ]. |
279 layout isLayoutOrigin ifTrue:[ ^ #LayoutOrigin ]. |
280 ] ifFalse:[ |
280 ] ifFalse:[ |
281 layout isRectangle ifTrue:[ ^ #Rectangle ]. |
281 layout isRectangle ifTrue:[ ^ #Rectangle ]. |
282 layout isPoint ifTrue:[ ^ #Point ]. |
282 layout isPoint ifTrue:[ ^ #Point ]. |
283 ] |
283 ] |
284 ] ifFalse:[ |
284 ] ifFalse:[ |
285 (superView := aView superView) notNil ifTrue:[ |
285 (superView := aView superView) notNil ifTrue:[ |
286 spec := superView specClass. |
286 spec := superView specClass. |
287 spec canResizeSubComponents ifTrue:[ |
287 spec canResizeSubComponents ifTrue:[ |
288 ^ #Extent |
288 ^ #Extent |
289 ] |
289 ] |
290 ] |
290 ] |
291 ] |
291 ] |
292 ]. |
292 ]. |
293 ^ nil |
293 ^ nil |
294 |
294 |
295 "Modified: 28.2.1997 / 13:02:16 / cg" |
295 "Modified: 28.2.1997 / 13:02:16 / cg" |
296 ! ! |
296 ! ! |
306 |
306 |
307 gridAlign:aBool |
307 gridAlign:aBool |
308 "change state of aligning to grid |
308 "change state of aligning to grid |
309 " |
309 " |
310 aBool ifTrue:[self alignOn] |
310 aBool ifTrue:[self alignOn] |
311 ifFalse:[self alignOff] |
311 ifFalse:[self alignOff] |
312 |
312 |
313 ! |
313 ! |
314 |
314 |
315 gridParameters |
315 gridParameters |
316 "used by defineGrid, and in a separate method for |
316 "used by defineGrid, and in a separate method for |
317 easier redefinition in subclasses. |
317 easier redefinition in subclasses. |
318 Returns the grid parameters in an array of 7 elements, |
318 Returns the grid parameters in an array of 7 elements, |
319 which control the appearance of the grid-pattern. |
319 which control the appearance of the grid-pattern. |
320 the elements are: |
320 the elements are: |
321 |
321 |
322 bigStepH number of pixels horizontally between 2 major steps |
322 bigStepH number of pixels horizontally between 2 major steps |
323 bigStepV number of pixels vertically between 2 major steps |
323 bigStepV number of pixels vertically between 2 major steps |
324 littleStepH number of pixels horizontally between 2 minor steps |
324 littleStepH number of pixels horizontally between 2 minor steps |
325 littleStepV number of pixels vertically 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) |
326 gridAlignH number of pixels for horizontal grid align (pointer snap) |
327 gridAlignV number of pixels for vertical grid align (pointer snap) |
327 gridAlignV number of pixels for vertical grid align (pointer snap) |
328 docBounds true, if document boundary should be shown |
328 docBounds true, if document boundary should be shown |
329 |
329 |
330 if littleStepH/V are nil, only bigSteps are drawn. |
330 if littleStepH/V are nil, only bigSteps are drawn. |
331 " |
331 " |
332 gridParameters isNil ifTrue:[ |
332 gridParameters isNil ifTrue:[ |
333 gridParameters := #(10 10 nil nil 10 10 false) |
333 gridParameters := #(10 10 nil nil 10 10 false) |
334 ]. |
334 ]. |
335 ^ gridParameters |
335 ^ gridParameters |
336 |
336 |
337 |
337 |
338 ! |
338 ! |
342 easier redefinition in subclasses. |
342 easier redefinition in subclasses. |
343 Returns the grid parameters in an array of 7 elements, |
343 Returns the grid parameters in an array of 7 elements, |
344 which control the appearance of the grid-pattern. |
344 which control the appearance of the grid-pattern. |
345 the elements are: |
345 the elements are: |
346 |
346 |
347 bigStepH number of pixels horizontally between 2 major steps |
347 bigStepH number of pixels horizontally between 2 major steps |
348 bigStepV number of pixels vertically between 2 major steps |
348 bigStepV number of pixels vertically between 2 major steps |
349 littleStepH number of pixels horizontally between 2 minor steps |
349 littleStepH number of pixels horizontally between 2 minor steps |
350 littleStepV number of pixels vertically 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) |
351 gridAlignH number of pixels for horizontal grid align (pointer snap) |
352 gridAlignV number of pixels for vertical grid align (pointer snap) |
352 gridAlignV number of pixels for vertical grid align (pointer snap) |
353 docBounds true, if document boundary should be shown |
353 docBounds true, if document boundary should be shown |
354 |
354 |
355 if littleStepH/V are nil, only bigSteps are drawn. |
355 if littleStepH/V are nil, only bigSteps are drawn. |
356 " |
356 " |
357 newGridParameters size == 7 ifTrue:[ |
357 newGridParameters size == 7 ifTrue:[ |
358 gridParameters := newGridParameters |
358 gridParameters := newGridParameters |
359 ]. |
359 ]. |
360 |
360 |
361 |
361 |
362 ! |
362 ! |
363 |
363 |
364 gridShown:aBool |
364 gridShown:aBool |
365 "change visibility of grid |
365 "change visibility of grid |
366 " |
366 " |
367 aBool ifTrue:[self showGrid] |
367 aBool ifTrue:[self showGrid] |
368 ifFalse:[self hideGrid] |
368 ifFalse:[self hideGrid] |
369 ! |
369 ! |
370 |
370 |
371 hideGrid |
371 hideGrid |
372 "hide grid |
372 "hide grid |
373 " |
373 " |
374 gridShown ifTrue:[ |
374 gridShown ifTrue:[ |
375 self withSelectionHiddenDo:[super hideGrid] |
375 self withSelectionHiddenDo:[super hideGrid] |
376 ] |
376 ] |
377 |
377 |
378 |
378 |
379 ! |
379 ! |
380 |
380 |
469 |spv| |
469 |spv| |
470 |
470 |
471 spv := self findContainerOfView:aView. |
471 spv := self findContainerOfView:aView. |
472 |
472 |
473 selectionHiddenLevel ~~ 0 ifTrue:[setOfSuperViewsSizeChanged add:spv] |
473 selectionHiddenLevel ~~ 0 ifTrue:[setOfSuperViewsSizeChanged add:spv] |
474 ifFalse:[spv sizeChanged:nil] |
474 ifFalse:[spv sizeChanged:nil] |
475 ! |
475 ! |
476 |
476 |
477 exposeX:x y:y width:w height:h |
477 exposeX:x y:y width:w height:h |
478 "handle an expose event from device; redraw selection |
478 "handle an expose event from device; redraw selection |
479 " |
479 " |
480 |
480 |
481 resizeData isNil ifTrue:[ |
481 resizeData isNil ifTrue:[ |
482 super exposeX:x y:y width:w height:h. |
482 super exposeX:x y:y width:w height:h. |
483 |
483 |
484 "/ handle any expose events (for subcomponents) before |
484 "/ handle any expose events (for subcomponents) before |
485 "/ redrawing the handles. |
485 "/ redrawing the handles. |
486 (self sensor hasExposeEventFor:nil) ifTrue:[^ self]. |
486 (self sensor hasExposeEventFor:nil) ifTrue:[^ self]. |
487 |
487 |
488 self selectionDo:[:aComponent | |
488 self selectionDo:[:aComponent | |
489 aComponent withAllSubViewsDo:[:v | |
489 aComponent withAllSubViewsDo:[:v | |
490 self sensor flushExposeEventsFor:v. |
490 v realized ifTrue:[ |
491 v exposeX:0 y:0 width:v width height:v height. |
491 self sensor flushExposeEventsFor:v. |
492 ]. |
492 v exposeX:0 y:0 width:v width height:v height. |
493 self showSelected:aComponent |
493 ] |
494 ] |
494 ]. |
|
495 self showSelected:aComponent |
|
496 ] |
495 ]. |
497 ]. |
496 |
498 |
497 "Modified: / 9.11.1998 / 12:50:34 / cg" |
499 "Modified: / 9.11.1998 / 12:50:34 / cg" |
498 ! |
500 ! |
499 |
501 |
500 keyPress:key x:x y:y |
502 keyPress:key x:x y:y |
501 "any key pressed |
503 "any key pressed |
502 " |
504 " |
503 <resource: #keyboard ( #CursorUp #CursorDown #CursorLeft #CursorRight |
505 <resource: #keyboard ( #CursorUp #CursorDown #CursorLeft #CursorRight |
504 #Delete #BackSpace #Cut #Copy #Paste #Cmdu ) > |
506 #Delete #BackSpace #Cut #Copy #Paste #Cmdu ) > |
505 |
507 |
506 (key == #Cut or:[key == #Delete or:[key == #BackSpace]]) ifTrue: [ |
508 (key == #Cut or:[key == #Delete or:[key == #BackSpace]]) ifTrue: [ |
507 ^ self deleteSelection |
509 ^ self deleteSelection |
508 ]. |
510 ]. |
509 key == #Copy ifTrue:[ ^ self copySelection]. |
511 key == #Copy ifTrue:[ ^ self copySelection]. |
510 key == #Paste ifTrue:[ ^ self pasteBuffer]. |
512 key == #Paste ifTrue:[ ^ self pasteBuffer]. |
511 key == #Cmdu ifTrue:[ ^ self undoLast ]. "/ #Undo |
513 key == #Cmdu ifTrue:[ ^ self undoLast ]. "/ #Undo |
512 |
514 |
632 "invert outline of an object or collection of objects |
634 "invert outline of an object or collection of objects |
633 " |
635 " |
634 |wasClipped| |
636 |wasClipped| |
635 |
637 |
636 (wasClipped := clipChildren) ifTrue:[ |
638 (wasClipped := clipChildren) ifTrue:[ |
637 self clippedByChildren:(clipChildren := false). |
639 self clippedByChildren:(clipChildren := false). |
638 ]. |
640 ]. |
639 |
641 |
640 self xoring:[ |
642 self xoring:[ |
641 |p| |
643 |p| |
642 |
644 |
643 something isCollection ifTrue:[ |
645 something isCollection ifTrue:[ |
644 something do:[:v | |
646 something do:[:v | |
645 |p| |
647 |p| |
646 |
648 |
647 p := v originRelativeTo:self. |
649 p := v originRelativeTo:self. |
648 self displayRectangle:(p extent:v extent). |
650 self displayRectangle:(p extent:v extent). |
649 ]. |
651 ]. |
650 ] ifFalse:[ |
652 ] ifFalse:[ |
651 |p| |
653 |p| |
652 |
654 |
653 p := something originRelativeTo:self. |
655 p := something originRelativeTo:self. |
654 self displayRectangle:(p extent:something extent). |
656 self displayRectangle:(p extent:something extent). |
655 ] |
657 ] |
656 ]. |
658 ]. |
657 |
659 |
658 wasClipped ifTrue:[ |
660 wasClipped ifTrue:[ |
659 self clippedByChildren:(clipChildren := true). |
661 self clippedByChildren:(clipChildren := true). |
660 ]. |
662 ]. |
661 |
663 |
662 ! |
664 ! |
663 |
665 |
664 minSetOfSuperViews:setOfViews |
666 minSetOfSuperViews:setOfViews |
665 |
667 |
666 setOfViews isCollection ifFalse:[ |
668 setOfViews isCollection ifFalse:[ |
667 setOfViews notNil ifTrue:[^ Array with:setOfViews] |
669 setOfViews notNil ifTrue:[^ Array with:setOfViews] |
668 ifFalse:[^ nil] |
670 ifFalse:[^ nil] |
669 ]. |
671 ]. |
670 ^ setOfViews select:[:aView| |
672 ^ setOfViews select:[:aView| |
671 (setOfViews detect:[:v|aView isComponentOf:v] ifNone:nil) isNil |
673 (setOfViews detect:[:v|aView isComponentOf:v] ifNone:nil) isNil |
672 ] |
674 ] |
673 ! |
675 ! |
674 |
676 |
675 redrawObjectsInVisible:redrawFrame |
677 redrawObjectsInVisible:redrawFrame |
676 "my objects are views - they redraw themself" |
678 "my objects are views - they redraw themself" |
696 |
698 |
697 doObjectMove:aPoint |
699 doObjectMove:aPoint |
698 "move selection |
700 "move selection |
699 " |
701 " |
700 movedObject notNil ifTrue:[ |
702 movedObject notNil ifTrue:[ |
701 self invertOutlineOf:movedObject. |
703 self invertOutlineOf:movedObject. |
702 |
704 |
703 movedObject keysAndValuesDo:[:i :v| |
705 movedObject keysAndValuesDo:[:i :v| |
704 self moveObject:v to:(aPoint - (moveDelta at:i)). |
706 self moveObject:v to:(aPoint - (moveDelta at:i)). |
705 ]. |
707 ]. |
706 self invertOutlineOf:movedObject. |
708 self invertOutlineOf:movedObject. |
707 ] |
709 ] |
708 |
710 |
709 ! |
711 ! |
710 |
712 |
711 endObjectMove |
713 endObjectMove |
712 "cleanup after object(s) move |
714 "cleanup after object(s) move |
713 " |
715 " |
714 movedObject notNil ifTrue:[ |
716 movedObject notNil ifTrue:[ |
715 self invertOutlineOf:movedObject. |
717 self invertOutlineOf:movedObject. |
716 |
718 |
717 movedObject size == 1 ifTrue:[ |
719 movedObject size == 1 ifTrue:[ |
718 movedObject := movedObject first |
720 movedObject := movedObject first |
719 ]. |
721 ]. |
720 self setSelection:movedObject withRedraw:true. |
722 self setSelection:movedObject withRedraw:true. |
721 movedObject := nil. |
723 movedObject := nil. |
722 self setDefaultActions. |
724 self setDefaultActions. |
723 self layoutChanged. |
725 self layoutChanged. |
724 ]. |
726 ]. |
725 ! |
727 ! |
726 |
728 |
727 moveObject:anObject to:aPoint |
729 moveObject:anObject to:aPoint |
728 "move anObject to newOrigin, aPoint |
730 "move anObject to newOrigin, aPoint |
729 " |
731 " |
730 |dX dY org delta| |
732 |dX dY org delta| |
731 |
733 |
732 anObject notNil ifTrue:[ |
734 anObject notNil ifTrue:[ |
733 org := anObject computeOrigin. |
735 org := anObject computeOrigin. |
734 |
736 |
735 delta := aPoint - org. |
737 delta := aPoint - org. |
736 delta := (self alignToGrid:aPoint) - org. |
738 delta := (self alignToGrid:aPoint) - org. |
737 dX := delta x. |
739 dX := delta x. |
738 dY := delta y. |
740 dY := delta y. |
739 |
741 |
740 undoHistory withoutTransactionDo:[ |
742 undoHistory withoutTransactionDo:[ |
741 self shiftLayout:anObject top:dY bottom:dY left:dX right:dX |
743 self shiftLayout:anObject top:dY bottom:dY left:dX right:dX |
742 ] |
744 ] |
743 ] |
745 ] |
744 |
746 |
745 ! |
747 ! |
746 |
748 |
747 startObjectMoveAt:aPoint |
749 startObjectMoveAt:aPoint |
787 self enabled ifFalse:[^ self]. |
789 self enabled ifFalse:[^ self]. |
788 |
790 |
789 aView := self singleSelection. |
791 aView := self singleSelection. |
790 |
792 |
791 aView notNil ifTrue:[ |
793 aView notNil ifTrue:[ |
792 v := self findContainerOfView:aView. |
794 v := self findContainerOfView:aView. |
793 |
795 |
794 v specClass canResizeSubComponents ifTrue:[ |
796 v specClass canResizeSubComponents ifTrue:[ |
795 b := self whichHandleOf:aView isHitBy:aPoint. |
797 b := self whichHandleOf:aView isHitBy:aPoint. |
796 |
798 |
797 (b notNil and:[b ~~ #view]) ifTrue:[ |
799 (b notNil and:[b ~~ #view]) ifTrue:[ |
798 ^ self startResizeBorder:b of:aView. |
800 ^ self startResizeBorder:b of:aView. |
799 ] |
801 ] |
800 ]. |
802 ]. |
801 |
803 |
802 (self sensor ctrlDown and:[self canChangeLayoutOfView:aView]) ifFalse:[ |
804 (self sensor ctrlDown and:[self canChangeLayoutOfView:aView]) ifFalse:[ |
803 aView := nil |
805 aView := nil |
804 ] |
806 ] |
805 ]. |
807 ]. |
806 |
808 |
807 aView isNil ifTrue:[ |
809 aView isNil ifTrue:[ |
808 (aView := self findObjectAt:aPoint) isNil ifTrue:[ |
810 (aView := self findObjectAt:aPoint) isNil ifTrue:[ |
809 ^ self select:nil |
811 ^ self select:nil |
810 ]. |
812 ]. |
811 |
813 |
812 (self canChangeLayoutOfView:aView) ifFalse:[ |
814 (self canChangeLayoutOfView:aView) ifFalse:[ |
813 ^ self select:aView |
815 ^ self select:aView |
814 ] |
816 ] |
815 ]. |
817 ]. |
816 |
818 |
817 (self isSelected:aView) ifFalse:[ |
819 (self isSelected:aView) ifFalse:[ |
818 self select:aView. |
820 self select:aView. |
819 ]. |
821 ]. |
820 |
822 |
821 (self numberOfSelections ~~ 1) ifTrue:[ |
823 (self numberOfSelections ~~ 1) ifTrue:[ |
822 releaseAction := [ |
824 releaseAction := [ |
823 self setDefaultActions. |
825 self setDefaultActions. |
824 self select:aView |
826 self select:aView |
825 ] |
827 ] |
826 ] ifFalse:[ |
828 ] ifFalse:[ |
827 releaseAction := [self setDefaultActions] |
829 releaseAction := [self setDefaultActions] |
828 ]. |
830 ]. |
829 |
831 |
830 "prepare move operation for an object |
832 "prepare move operation for an object |
831 " |
833 " |
832 |
834 |
833 motionAction := [:movePoint| |
835 motionAction := [:movePoint| |
834 (aPoint dist:movePoint) > 8.0 ifTrue:[ |
836 (aPoint dist:movePoint) > 8.0 ifTrue:[ |
835 self startObjectMoveAt:aPoint |
837 self startObjectMoveAt:aPoint |
836 ] |
838 ] |
837 ]. |
839 ]. |
838 ! ! |
840 ! ! |
839 |
841 |
840 !UIObjectView methodsFor:'object resize'! |
842 !UIObjectView methodsFor:'object resize'! |
841 |
843 |
992 "/ ]. |
994 "/ ]. |
993 "/ v destroy. |
995 "/ v destroy. |
994 "/ ^ self. |
996 "/ ^ self. |
995 |
997 |
996 (wasClipped := clipChildren) ifTrue:[ |
998 (wasClipped := clipChildren) ifTrue:[ |
997 self clippedByChildren:(clipChildren := false). |
999 self clippedByChildren:(clipChildren := false). |
998 ]. |
1000 ]. |
999 |
1001 |
1000 self handlesOf:aComponent do:[:rec :wht| self clearRectangle:rec ]. |
1002 self handlesOf:aComponent do:[:rec :wht| self clearRectangle:rec ]. |
1001 |
1003 |
1002 wasClipped ifTrue:[ |
1004 wasClipped ifTrue:[ |
1003 self clippedByChildren:(clipChildren := true). |
1005 self clippedByChildren:(clipChildren := true). |
1004 ]. |
1006 ]. |
1005 |
1007 |
1006 "/ must redraw all components which are affected b the handles |
1008 "/ must redraw all components which are affected b the handles |
1007 r := (aComponent originRelativeTo:self) - (3@3) extent:(aComponent extent + (6@6)). |
1009 r := (aComponent originRelativeTo:self) - (3@3) extent:(aComponent extent + (6@6)). |
1008 |
1010 |
1009 subViews do:[:anotherComponent | |
1011 subViews do:[:anotherComponent | |
1010 |absOrg absFrame| |
1012 |absOrg absFrame| |
1011 |
1013 |
1012 anotherComponent ~~ inputView ifTrue:[ |
1014 anotherComponent ~~ inputView ifTrue:[ |
1013 absOrg := anotherComponent originRelativeTo:self. |
1015 absOrg := anotherComponent originRelativeTo:self. |
1014 absFrame := absOrg extent:(anotherComponent extent). |
1016 absFrame := absOrg extent:(anotherComponent extent). |
1015 (absFrame intersects:r) ifTrue:[ |
1017 (absFrame intersects:r) ifTrue:[ |
1016 anotherComponent withAllSubViewsDo:[:v | |
1018 anotherComponent withAllSubViewsDo:[:v | |
1017 v shown ifTrue:[ |
1019 v shown ifTrue:[ |
1018 aSet notNil ifTrue:[ |
1020 aSet notNil ifTrue:[ |
1019 aSet add:v |
1021 aSet add:v |
1020 ] ifFalse:[ |
1022 ] ifFalse:[ |
1021 self handleAffectedViews:v |
1023 self handleAffectedViews:v |
1022 ] |
1024 ] |
1023 ] |
1025 ] |
1024 ] |
1026 ] |
1025 ] |
1027 ] |
1026 ] |
1028 ] |
1027 ]. |
1029 ]. |
1028 |
1030 |
1029 "Modified: / 24.8.1998 / 12:19:38 / cg" |
1031 "Modified: / 24.8.1998 / 12:19:38 / cg" |
1030 ! |
1032 ! |
1031 |
1033 |
1032 whichHandleOf:aComponent isHitBy:aPoint |
1034 whichHandleOf:aComponent isHitBy:aPoint |
1033 "returns kind of handle or nil |
1035 "returns kind of handle or nil |
1034 " |
1036 " |
1035 self handlesOf:aComponent do:[:rectangle :what| |
1037 self handlesOf:aComponent do:[:rectangle :what| |
1036 (rectangle containsPoint:aPoint) ifTrue:[^ what] |
1038 (rectangle containsPoint:aPoint) ifTrue:[^ what] |
1037 ]. |
1039 ]. |
1038 ^ nil |
1040 ^ nil |
1039 ! ! |
1041 ! ! |
1040 |
1042 |
1041 !UIObjectView methodsFor:'private resizing-subviews'! |
1043 !UIObjectView methodsFor:'private resizing-subviews'! |
1042 |
1044 |
1043 resize:aView bottom:aPoint |
1045 resize:aView bottom:aPoint |
1044 "resize a views bottom |
1046 "resize a views bottom |
1045 " |
1047 " |
1046 undoHistory withoutTransactionDo:[ |
1048 undoHistory withoutTransactionDo:[ |
1047 self shiftLayout:aView top:0 bottom:((aPoint y) - (aView computeCorner y)) |
1049 self shiftLayout:aView top:0 bottom:((aPoint y) - (aView computeCorner y)) |
1048 ] |
1050 ] |
1049 ! |
1051 ! |
1050 |
1052 |
1051 resize:aView bottomLeft:aPoint |
1053 resize:aView bottomLeft:aPoint |
1052 "resize a views bottom and left |
1054 "resize a views bottom and left |
1053 " |
1055 " |
1054 undoHistory withoutTransactionDo:[ |
1056 undoHistory withoutTransactionDo:[ |
1055 self shiftLayout:aView top:0 |
1057 self shiftLayout:aView top:0 |
1056 bottom:((aPoint y) - (aView computeCorner y)) |
1058 bottom:((aPoint y) - (aView computeCorner y)) |
1057 left:((aPoint x) - (aView computeOrigin x)) |
1059 left:((aPoint x) - (aView computeOrigin x)) |
1058 right:0 |
1060 right:0 |
1059 |
1061 |
1060 ] |
1062 ] |
1061 |
1063 |
1062 |
1064 |
1063 ! |
1065 ! |
1089 |delta| |
1091 |delta| |
1090 |
1092 |
1091 delta := aPoint - aView computeOrigin. |
1093 delta := aPoint - aView computeOrigin. |
1092 |
1094 |
1093 undoHistory withoutTransactionDo:[ |
1095 undoHistory withoutTransactionDo:[ |
1094 self shiftLayout:aView top:(delta y) bottom:0 left:(delta x) right:0 |
1096 self shiftLayout:aView top:(delta y) bottom:0 left:(delta x) right:0 |
1095 ] |
1097 ] |
1096 |
1098 |
1097 ! |
1099 ! |
1098 |
1100 |
1099 resize:aView right:aPoint |
1101 resize:aView right:aPoint |
1100 "resize a views right |
1102 "resize a views right |
1101 " |
1103 " |
1102 undoHistory withoutTransactionDo:[ |
1104 undoHistory withoutTransactionDo:[ |
1103 self shiftLayout:aView left:0 right:((aPoint x) - (aView computeCorner x)) |
1105 self shiftLayout:aView left:0 right:((aPoint x) - (aView computeCorner x)) |
1104 ] |
1106 ] |
1105 ! |
1107 ! |
1106 |
1108 |
1107 resize:aView top:aPoint |
1109 resize:aView top:aPoint |
1108 "resize a views top |
1110 "resize a views top |
1109 " |
1111 " |
1110 undoHistory withoutTransactionDo:[ |
1112 undoHistory withoutTransactionDo:[ |
1111 self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y)) bottom:0 |
1113 self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y)) bottom:0 |
1112 ] |
1114 ] |
1113 ! |
1115 ! |
1114 |
1116 |
1115 resize:aView topRight:aPoint |
1117 resize:aView topRight:aPoint |
1116 "resize a views top and right |
1118 "resize a views top and right |
1117 " |
1119 " |
1118 undoHistory withoutTransactionDo:[ |
1120 undoHistory withoutTransactionDo:[ |
1119 self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y)) |
1121 self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y)) |
1120 bottom:0 |
1122 bottom:0 |
1121 left:0 |
1123 left:0 |
1122 right:((aPoint x) - (aView computeCorner x)) |
1124 right:((aPoint x) - (aView computeCorner x)) |
1123 |
1125 |
1124 ] |
1126 ] |
1125 |
1127 |
1126 ! ! |
1128 ! ! |
1127 |
1129 |
1151 |type layout oldExt| |
1153 |type layout oldExt| |
1152 |
1154 |
1153 type := self class layoutType:aView. |
1155 type := self class layoutType:aView. |
1154 |
1156 |
1155 type notNil ifTrue:[ |
1157 type notNil ifTrue:[ |
1156 self createUndoLayout:aView. |
1158 self createUndoLayout:aView. |
1157 |
1159 |
1158 type == #Extent ifTrue:[ |
1160 type == #Extent ifTrue:[ |
1159 oldExt := aView extent. |
1161 oldExt := aView extent. |
1160 aView extent:(oldExt + ((r-l) @ (b-t))). |
1162 aView extent:(oldExt + ((r-l) @ (b-t))). |
1161 ^ self |
1163 ^ self |
1162 ]. |
1164 ]. |
1163 |
1165 |
1164 layout := aView geometryLayout copy. |
1166 layout := aView geometryLayout copy. |
1165 |
1167 |
1166 layout isLayout ifTrue:[ |
1168 layout isLayout ifTrue:[ |
1167 layout leftOffset:(layout leftOffset + l) |
1169 layout leftOffset:(layout leftOffset + l) |
1168 topOffset:(layout topOffset + t). |
1170 topOffset:(layout topOffset + t). |
1169 |
1171 |
1170 type == #LayoutFrame ifTrue:[ |
1172 type == #LayoutFrame ifTrue:[ |
1171 layout bottomOffset:(layout bottomOffset + b). |
1173 layout bottomOffset:(layout bottomOffset + b). |
1172 layout rightOffset:(layout rightOffset + r). |
1174 layout rightOffset:(layout rightOffset + r). |
1173 ] |
1175 ] |
1174 ] ifFalse:[ |
1176 ] ifFalse:[ |
1175 type == #Rectangle ifTrue:[ |
1177 type == #Rectangle ifTrue:[ |
1176 layout left:(layout left + l) |
1178 layout left:(layout left + l) |
1177 right:(layout right + r) |
1179 right:(layout right + r) |
1178 top:(layout top + t) |
1180 top:(layout top + t) |
1179 bottom:(layout bottom + b). |
1181 bottom:(layout bottom + b). |
1180 ] ifFalse:[ "POINT" |
1182 ] ifFalse:[ "POINT" |
1181 layout x:(layout x + l) y:(layout y + t). |
1183 layout x:(layout x + l) y:(layout y + t). |
1182 ] |
1184 ] |
1183 ]. |
1185 ]. |
1184 aView geometryLayout:layout |
1186 aView geometryLayout:layout |
1185 ] |
1187 ] |
1186 ! ! |
1188 ! ! |
1187 |
1189 |
1188 !UIObjectView methodsFor:'searching'! |
1190 !UIObjectView methodsFor:'searching'! |
1189 |
1191 |
1331 "apply block with selection hidden (no handles) |
1333 "apply block with selection hidden (no handles) |
1332 " |
1334 " |
1333 |coll| |
1335 |coll| |
1334 |
1336 |
1335 selectionHiddenLevel == 0 ifTrue:[ |
1337 selectionHiddenLevel == 0 ifTrue:[ |
1336 self hideSelection. |
1338 self hideSelection. |
1337 device flush. |
1339 device flush. |
1338 ]. |
1340 ]. |
1339 selectionHiddenLevel := selectionHiddenLevel + 1. |
1341 selectionHiddenLevel := selectionHiddenLevel + 1. |
1340 |
1342 |
1341 aBlock valueNowOrOnUnwindDo:[ |
1343 aBlock valueNowOrOnUnwindDo:[ |
1342 selectionHiddenLevel == 1 ifTrue:[ |
1344 selectionHiddenLevel == 1 ifTrue:[ |
1343 setOfSuperViewsSizeChanged notEmpty ifTrue:[ |
1345 setOfSuperViewsSizeChanged notEmpty ifTrue:[ |
1344 coll := self minSetOfSuperViews:setOfSuperViewsSizeChanged. |
1346 coll := self minSetOfSuperViews:setOfSuperViewsSizeChanged. |
1345 coll do:[:aView| aView sizeChanged:nil]. |
1347 coll do:[:aView| aView sizeChanged:nil]. |
1346 setOfSuperViewsSizeChanged := IdentitySet new |
1348 setOfSuperViewsSizeChanged := IdentitySet new |
1347 ]. |
1349 ]. |
1348 selectionHiddenLevel := 0. |
1350 selectionHiddenLevel := 0. |
1349 self selectionDo:[:aView| self showSelected:aView]. |
1351 self selectionDo:[:aView| self showSelected:aView]. |
1350 ] ifFalse:[ |
1352 ] ifFalse:[ |
1351 selectionHiddenLevel := selectionHiddenLevel - 1. |
1353 selectionHiddenLevel := selectionHiddenLevel - 1. |
1352 ] |
1354 ] |
1353 ] |
1355 ] |
1354 |
1356 |
1355 ! |
1357 ! |
1356 |
1358 |
1357 withoutSelectionDo:aBlock |
1359 withoutSelectionDo:aBlock |
1358 "evaluate aBlock while selection is nilled |
1360 "evaluate aBlock while selection is nilled |
1359 " |
1361 " |
1360 |sel| |
1362 |sel| |
1361 |
1363 |
1362 self hasSelection ifFalse:[ |
1364 self hasSelection ifFalse:[ |
1363 aBlock value |
1365 aBlock value |
1364 ] ifTrue:[ |
1366 ] ifTrue:[ |
1365 sel := self selection. |
1367 sel := self selection. |
1366 self setSelection:nil withRedraw:true. |
1368 self setSelection:nil withRedraw:true. |
1367 aBlock value. |
1369 aBlock value. |
1368 self setSelection:sel withRedraw:true. |
1370 self setSelection:sel withRedraw:true. |
1369 ] |
1371 ] |
1370 |
1372 |
1371 |
1373 |
1372 ! ! |
1374 ! ! |
1373 |
1375 |
1489 |object| |
1491 |object| |
1490 |
1492 |
1491 object := self singleSelection. |
1493 object := self singleSelection. |
1492 |
1494 |
1493 object notNil ifTrue:[ |
1495 object notNil ifTrue:[ |
1494 copiedLayout := object geometryLayout copy |
1496 copiedLayout := object geometryLayout copy |
1495 ] ifFalse:[ |
1497 ] ifFalse:[ |
1496 self warn:'exactly one element must be selected'. |
1498 self warn:'exactly one element must be selected'. |
1497 ] |
1499 ] |
1498 |
1500 |
1499 |
1501 |
1500 |
1502 |
1501 ! |
1503 ! |
1502 |
1504 |
1503 pasteExtent |
1505 pasteExtent |
1504 "paste the copied extent to all objects in the selection |
1506 "paste the copied extent to all objects in the selection |
1505 " |
1507 " |
1506 copiedExtent notNil ifTrue:[ |
1508 copiedExtent notNil ifTrue:[ |
1507 self transaction:#pasteExtent dimensionDo:[:v| |
1509 self transaction:#pasteExtent dimensionDo:[:v| |
1508 self resize:v corner:(v computeOrigin + copiedExtent) |
1510 self resize:v corner:(v computeOrigin + copiedExtent) |
1509 ] |
1511 ] |
1510 ] |
1512 ] |
1511 ! |
1513 ! |
1512 |
1514 |
1513 pasteHeight |
1515 pasteHeight |
1514 "paste the copied extent height to all objects in the selection |
1516 "paste the copied extent height to all objects in the selection |
1515 " |
1517 " |
1516 copiedExtent notNil ifTrue:[ |
1518 copiedExtent notNil ifTrue:[ |
1517 self transaction:#pasteHeight dimensionDo:[:v| |
1519 self transaction:#pasteHeight dimensionDo:[:v| |
1518 self resize:v bottom:(v computeOrigin + copiedExtent) |
1520 self resize:v bottom:(v computeOrigin + copiedExtent) |
1519 ] |
1521 ] |
1520 ] |
1522 ] |
1521 |
1523 |
1522 ! |
1524 ! |
1523 |
1525 |
1524 pasteLayout |
1526 pasteLayout |
1525 "paste layout to all objects in the selection |
1527 "paste layout to all objects in the selection |
1526 " |
1528 " |
1527 copiedLayout notNil ifTrue:[ |
1529 copiedLayout notNil ifTrue:[ |
1528 self transaction:#pasteLayout dimensionDo:[:v| |
1530 self transaction:#pasteLayout dimensionDo:[:v| |
1529 v geometryLayout:(copiedLayout copy) |
1531 v geometryLayout:(copiedLayout copy) |
1530 ] |
1532 ] |
1531 ] |
1533 ] |
1532 ! |
1534 ! |
1533 |
1535 |
1534 pasteWidth |
1536 pasteWidth |
1535 "paste the copied extent width to all objects in the selection |
1537 "paste the copied extent width to all objects in the selection |
1536 " |
1538 " |
1537 copiedExtent notNil ifTrue:[ |
1539 copiedExtent notNil ifTrue:[ |
1538 self transaction:#pasteWidth dimensionDo:[:v| |
1540 self transaction:#pasteWidth dimensionDo:[:v| |
1539 self resize:v right:(v computeOrigin + copiedExtent) |
1541 self resize:v right:(v computeOrigin + copiedExtent) |
1540 ] |
1542 ] |
1541 ] |
1543 ] |
1542 |
1544 |
1543 ! |
1545 ! |
1544 |
1546 |
1545 setExtent:anExtent |
1547 setExtent:anExtent |
1546 "change extent for all selected objects |
1548 "change extent for all selected objects |
1547 " |
1549 " |
1548 self transaction:#extent dimensionDo:[:v| |
1550 self transaction:#extent dimensionDo:[:v| |
1549 v geometryLayout:nil. |
1551 v geometryLayout:nil. |
1550 v extent:anExtent. |
1552 v extent:anExtent. |
1551 ]. |
1553 ]. |
1552 |
1554 |
1553 "Modified: 28.2.1997 / 12:49:00 / cg" |
1555 "Modified: 28.2.1997 / 12:49:00 / cg" |
1554 ! |
1556 ! |
1555 |
1557 |
1556 setLayout:aLayout |
1558 setLayout:aLayout |
1557 "change layout for all selected objects |
1559 "change layout for all selected objects |
1558 " |
1560 " |
1559 self transaction:#layout dimensionDo:[:v| |
1561 self transaction:#layout dimensionDo:[:v| |
1560 v geometryLayout:(aLayout copy) |
1562 v geometryLayout:(aLayout copy) |
1561 ]. |
1563 ]. |
1562 |
1564 |
1563 ! |
1565 ! |
1564 |
1566 |
1565 setMaxExtent |
1567 setMaxExtent |
1581 |
1583 |
1582 setToDefaultExtent |
1584 setToDefaultExtent |
1583 "change extent of all selected views to their default extent |
1585 "change extent of all selected views to their default extent |
1584 " |
1586 " |
1585 self transaction:#defaultExtent dimensionDo:[:v| |
1587 self transaction:#defaultExtent dimensionDo:[:v| |
1586 self resize:v corner:(v computeOrigin + (v preferredExtent)). |
1588 self resize:v corner:(v computeOrigin + (v preferredExtent)). |
1587 ] |
1589 ] |
1588 |
1590 |
1589 ! |
1591 ! |
1590 |
1592 |
1591 setToDefaultHeight |
1593 setToDefaultHeight |
1592 "change height of all selected views to their default height |
1594 "change height of all selected views to their default height |
1593 " |
1595 " |
1594 self transaction:#defaultHeight dimensionDo:[:v| |
1596 self transaction:#defaultHeight dimensionDo:[:v| |
1595 self resize:v bottom:(v computeOrigin + (v preferredExtent)) |
1597 self resize:v bottom:(v computeOrigin + (v preferredExtent)) |
1596 ] |
1598 ] |
1597 |
1599 |
1598 ! |
1600 ! |
1599 |
1601 |
1600 setToDefaultWidth |
1602 setToDefaultWidth |
1601 "change width of all selected views to their default width |
1603 "change width of all selected views to their default width |
1602 " |
1604 " |
1603 self transaction:#defaultWidth dimensionDo:[:v| |
1605 self transaction:#defaultWidth dimensionDo:[:v| |
1604 self resize:v right:(v computeOrigin + (v preferredExtent)) |
1606 self resize:v right:(v computeOrigin + (v preferredExtent)) |
1605 ] |
1607 ] |
1606 |
1608 |
1607 ! |
1609 ! |
1608 |
1610 |
1609 transaction:aType dimensionDo:aOneArgBlock |
1611 transaction:aType dimensionDo:aOneArgBlock |
1610 "change dimension within a transaction for the selected elements by evaluating |
1612 "change dimension within a transaction for the selected elements by evaluating |
1611 the block with the argument a view. |
1613 the block with the argument a view. |
1612 " |
1614 " |
1613 self withSelectionHiddenDo:[ |
1615 self withSelectionHiddenDo:[ |
1614 self transaction:aType selectionDo:[:aView| |
1616 self transaction:aType selectionDo:[:aView| |
1615 (self class layoutType:aView) notNil ifTrue:[ |
1617 (self class layoutType:aView) notNil ifTrue:[ |
1616 self createUndoLayout:aView. |
1618 self createUndoLayout:aView. |
1617 aOneArgBlock value:aView. |
1619 aOneArgBlock value:aView. |
1618 self elementChangedSize:aView. |
1620 self elementChangedSize:aView. |
1619 ] |
1621 ] |
1620 ] |
1622 ] |
1621 ]. |
1623 ]. |
1622 self layoutChanged |
1624 self layoutChanged |
1623 |
1625 |
1624 ! ! |
1626 ! ! |
1625 |
1627 |
1629 "perform a move operation |
1631 "perform a move operation |
1630 " |
1632 " |
1631 |sensor tm| |
1633 |sensor tm| |
1632 |
1634 |
1633 self moveableSelection isNil ifTrue:[ |
1635 self moveableSelection isNil ifTrue:[ |
1634 ^ self |
1636 ^ self |
1635 ]. |
1637 ]. |
1636 sensor := self sensor. |
1638 sensor := self sensor. |
1637 |
1639 |
1638 tm := 0.15. |
1640 tm := 0.15. |
1639 |
1641 |
1640 self withSelectionHiddenDo:[ |
1642 self withSelectionHiddenDo:[ |
1641 self transaction:#move selectionDo:[:aView|self createUndoLayout:aView]. |
1643 self transaction:#move selectionDo:[:aView|self createUndoLayout:aView]. |
1642 |
1644 |
1643 [ |
1645 [ |
1644 self selectionDo:[:aView| aOneArgBlock value:aView ]. |
1646 self selectionDo:[:aView| aOneArgBlock value:aView ]. |
1645 Delay waitForSeconds:tm. |
1647 Delay waitForSeconds:tm. |
1646 tm := 0.02. |
1648 tm := 0.02. |
1647 self layoutChanged. |
1649 self layoutChanged. |
1648 sensor leftButtonPressed. |
1650 sensor leftButtonPressed. |
1649 ] whileTrue. |
1651 ] whileTrue. |
1650 |
1652 |
1651 "/ handle any expose events (for subcomponents) before |
1653 "/ handle any expose events (for subcomponents) before |
1652 "/ redrawing the handles. |
1654 "/ redrawing the handles. |
1653 Delay waitForSeconds:0.05. |
1655 Delay waitForSeconds:0.05. |
1654 [self sensor hasExposeEventFor:nil] whileTrue:[ |
1656 [self sensor hasExposeEventFor:nil] whileTrue:[ |
1655 self windowGroup processExposeEvents |
1657 self windowGroup processExposeEvents |
1656 ] |
1658 ] |
1657 ]. |
1659 ]. |
1658 ! |
1660 ! |
1659 |
1661 |
1660 moveSelectionDown |
1662 moveSelectionDown |
1661 "move selection down |
1663 "move selection down |
1662 " |
1664 " |
1663 |gridY n| |
1665 |gridY n| |
1664 |
1666 |
1665 gridAlign notNil ifTrue:[gridY := gridAlign y] |
1667 gridAlign notNil ifTrue:[gridY := gridAlign y] |
1666 ifFalse:[gridY := 1]. |
1668 ifFalse:[gridY := 1]. |
1667 |
1669 |
1668 self moveDo:[:aView| |
1670 self moveDo:[:aView| |
1669 aligning ifTrue:[ |
1671 aligning ifTrue:[ |
1670 n := ((aView computeCorner y) \\ gridY). |
1672 n := ((aView computeCorner y) \\ gridY). |
1671 |
1673 |
1672 n ~~ 0 ifTrue:[ |
1674 n ~~ 0 ifTrue:[ |
1673 n := gridY - n + 1. |
1675 n := gridY - n + 1. |
1674 ] ifFalse:[ |
1676 ] ifFalse:[ |
1675 n := gridY |
1677 n := gridY |
1676 ] |
1678 ] |
1677 ] ifFalse:[ |
1679 ] ifFalse:[ |
1678 n := 1 |
1680 n := 1 |
1679 ]. |
1681 ]. |
1680 self shiftLayout:aView top:n bottom:n |
1682 self shiftLayout:aView top:n bottom:n |
1681 ] |
1683 ] |
1682 ! |
1684 ! |
1683 |
1685 |
1684 moveSelectionLeft |
1686 moveSelectionLeft |
1685 "move selection left |
1687 "move selection left |
1686 " |
1688 " |
1687 |gridX n| |
1689 |gridX n| |
1688 |
1690 |
1689 gridAlign notNil ifTrue:[gridX := gridAlign x] |
1691 gridAlign notNil ifTrue:[gridX := gridAlign x] |
1690 ifFalse:[gridX := 1]. |
1692 ifFalse:[gridX := 1]. |
1691 |
1693 |
1692 self moveDo:[:aView| |
1694 self moveDo:[:aView| |
1693 aligning ifTrue:[ |
1695 aligning ifTrue:[ |
1694 n := ((aView computeOrigin x) \\ gridX). |
1696 n := ((aView computeOrigin x) \\ gridX). |
1695 n == 0 ifTrue:[n := gridX]. |
1697 n == 0 ifTrue:[n := gridX]. |
1696 n := n negated. |
1698 n := n negated. |
1697 ] ifFalse:[ |
1699 ] ifFalse:[ |
1698 n := -1 |
1700 n := -1 |
1699 ]. |
1701 ]. |
1700 self shiftLayout:aView left:n right:n |
1702 self shiftLayout:aView left:n right:n |
1701 ] |
1703 ] |
1702 ! |
1704 ! |
1703 |
1705 |
1704 moveSelectionRight |
1706 moveSelectionRight |
1705 "move selection right |
1707 "move selection right |
1706 " |
1708 " |
1707 |gridX n| |
1709 |gridX n| |
1708 |
1710 |
1709 gridAlign notNil ifTrue:[gridX := gridAlign x] |
1711 gridAlign notNil ifTrue:[gridX := gridAlign x] |
1710 ifFalse:[gridX := 1]. |
1712 ifFalse:[gridX := 1]. |
1711 |
1713 |
1712 self moveDo:[:aView| |
1714 self moveDo:[:aView| |
1713 aligning ifTrue:[ |
1715 aligning ifTrue:[ |
1714 n := ((aView computeCorner x) \\ gridX). |
1716 n := ((aView computeCorner x) \\ gridX). |
1715 |
1717 |
1716 n ~~ 0 ifTrue:[n := n negated] |
1718 n ~~ 0 ifTrue:[n := n negated] |
1717 ifFalse:[n := gridX] |
1719 ifFalse:[n := gridX] |
1718 ] ifFalse:[ |
1720 ] ifFalse:[ |
1719 n := 1 |
1721 n := 1 |
1720 ]. |
1722 ]. |
1721 self shiftLayout:aView left:n right:n |
1723 self shiftLayout:aView left:n right:n |
1722 ] |
1724 ] |
1723 ! |
1725 ! |
1724 |
1726 |
1725 moveSelectionUp |
1727 moveSelectionUp |
1726 "move selection up |
1728 "move selection up |
1727 " |
1729 " |
1728 |gridY n| |
1730 |gridY n| |
1729 |
1731 |
1730 gridAlign notNil ifTrue:[gridY := gridAlign y] |
1732 gridAlign notNil ifTrue:[gridY := gridAlign y] |
1731 ifFalse:[gridY := 1]. |
1733 ifFalse:[gridY := 1]. |
1732 |
1734 |
1733 self moveDo:[:aView| |
1735 self moveDo:[:aView| |
1734 aligning ifTrue:[ |
1736 aligning ifTrue:[ |
1735 n := ((aView computeOrigin x) \\ gridY). |
1737 n := ((aView computeOrigin x) \\ gridY). |
1736 n == 0 ifTrue:[n := gridY]. |
1738 n == 0 ifTrue:[n := gridY]. |
1737 n := n negated. |
1739 n := n negated. |
1738 ] ifFalse:[ |
1740 ] ifFalse:[ |
1739 n := -1 |
1741 n := -1 |
1740 ]. |
1742 ]. |
1741 self shiftLayout:aView top:n bottom:n |
1743 self shiftLayout:aView top:n bottom:n |
1742 ] |
1744 ] |
1743 |
1745 |
1744 ! ! |
1746 ! ! |
1745 |
1747 |
1746 !UIObjectView methodsFor:'user actions - position'! |
1748 !UIObjectView methodsFor:'user actions - position'! |
1750 of one selection the object is aligned to the bottom of its superview |
1752 of one selection the object is aligned to the bottom of its superview |
1751 " |
1753 " |
1752 |bmost delta sel| |
1754 |bmost delta sel| |
1753 |
1755 |
1754 (sel := self moveableSelection) notNil ifTrue:[ |
1756 (sel := self moveableSelection) notNil ifTrue:[ |
1755 self withSelectionHiddenDo:[ |
1757 self withSelectionHiddenDo:[ |
1756 self numberOfSelections > 1 ifTrue:[ |
1758 self numberOfSelections > 1 ifTrue:[ |
1757 bmost := (sel first) computeCorner y. |
1759 bmost := (sel first) computeCorner y. |
1758 |
1760 |
1759 self transaction:#alignBottom selectionDo:[:v| |
1761 self transaction:#alignBottom selectionDo:[:v| |
1760 (delta := bmost - (v computeCorner y)) ~~ 0 ifTrue:[ |
1762 (delta := bmost - (v computeCorner y)) ~~ 0 ifTrue:[ |
1761 self shiftLayout:v top:delta bottom:delta. |
1763 self shiftLayout:v top:delta bottom:delta. |
1762 ] |
1764 ] |
1763 ] |
1765 ] |
1764 ] ifFalse:[ |
1766 ] ifFalse:[ |
1765 self extentToFrame:#Bottom do:[:aLayout| |
1767 self extentToFrame:#Bottom do:[:aLayout| |
1766 aLayout bottomOffset:0. |
1768 aLayout bottomOffset:0. |
1767 aLayout bottomFraction:1.0 |
1769 aLayout bottomFraction:1.0 |
1768 ] |
1770 ] |
1769 ] |
1771 ] |
1770 ]. |
1772 ]. |
1771 self layoutChanged |
1773 self layoutChanged |
1772 ] |
1774 ] |
1773 |
1775 |
1774 |
1776 |
1775 |
1777 |
1776 ! |
1778 ! |
1780 of one selection the object is aligned to the center/horizontal of its superview |
1782 of one selection the object is aligned to the center/horizontal of its superview |
1781 " |
1783 " |
1782 |view center sel| |
1784 |view center sel| |
1783 |
1785 |
1784 (sel := self moveableSelection) notNil ifTrue:[ |
1786 (sel := self moveableSelection) notNil ifTrue:[ |
1785 self withSelectionHiddenDo:[ |
1787 self withSelectionHiddenDo:[ |
1786 view := self singleSelection. |
1788 view := self singleSelection. |
1787 |
1789 |
1788 view notNil ifTrue:[ |
1790 view notNil ifTrue:[ |
1789 |
1791 |
1790 view := self findContainerOfView:view. |
1792 view := self findContainerOfView:view. |
1791 center := view computeExtent |
1793 center := view computeExtent |
1792 ] ifFalse:[ |
1794 ] ifFalse:[ |
1793 view := sel first. |
1795 view := sel first. |
1794 center := view computeCorner + view computeOrigin. |
1796 center := view computeCorner + view computeOrigin. |
1795 ]. |
1797 ]. |
1796 center := center x // 2. |
1798 center := center x // 2. |
1797 |
1799 |
1798 self transaction:#alignCenterHorizontal selectionDo:[:v| |
1800 self transaction:#alignCenterHorizontal selectionDo:[:v| |
1799 |newX oldX delta| |
1801 |newX oldX delta| |
1800 |
1802 |
1801 oldX := v computeOrigin x. |
1803 oldX := v computeOrigin x. |
1802 newX := center - ((v computeCorner x - oldX) // 2). |
1804 newX := center - ((v computeCorner x - oldX) // 2). |
1803 delta := newX - oldX. |
1805 delta := newX - oldX. |
1804 |
1806 |
1805 self shiftLayout:v left:delta right:delta |
1807 self shiftLayout:v left:delta right:delta |
1806 ] |
1808 ] |
1807 ]. |
1809 ]. |
1808 self layoutChanged |
1810 self layoutChanged |
1809 ] |
1811 ] |
1810 |
1812 |
1811 |
1813 |
1812 |
1814 |
1813 ! |
1815 ! |
1817 of one selection the object is aligned to the center/vertical of its superview |
1819 of one selection the object is aligned to the center/vertical of its superview |
1818 " |
1820 " |
1819 |view center sel| |
1821 |view center sel| |
1820 |
1822 |
1821 (sel := self moveableSelection) notNil ifTrue:[ |
1823 (sel := self moveableSelection) notNil ifTrue:[ |
1822 self withSelectionHiddenDo:[ |
1824 self withSelectionHiddenDo:[ |
1823 view := self singleSelection. |
1825 view := self singleSelection. |
1824 |
1826 |
1825 view notNil ifTrue:[ |
1827 view notNil ifTrue:[ |
1826 view := self findContainerOfView:view. |
1828 view := self findContainerOfView:view. |
1827 center := view computeExtent |
1829 center := view computeExtent |
1828 ] ifFalse:[ |
1830 ] ifFalse:[ |
1829 view := sel first. |
1831 view := sel first. |
1830 center := view computeCorner + view computeOrigin. |
1832 center := view computeCorner + view computeOrigin. |
1831 ]. |
1833 ]. |
1832 center := center y // 2. |
1834 center := center y // 2. |
1833 |
1835 |
1834 self transaction:#alignCenterVertical selectionDo:[:v| |
1836 self transaction:#alignCenterVertical selectionDo:[:v| |
1835 |newY oldY delta| |
1837 |newY oldY delta| |
1836 |
1838 |
1837 oldY := v computeOrigin y. |
1839 oldY := v computeOrigin y. |
1838 newY := center - ((v computeCorner y - oldY) // 2). |
1840 newY := center - ((v computeCorner y - oldY) // 2). |
1839 delta := newY - oldY. |
1841 delta := newY - oldY. |
1840 |
1842 |
1841 self shiftLayout:v top:delta bottom:delta |
1843 self shiftLayout:v top:delta bottom:delta |
1842 ] |
1844 ] |
1843 ]. |
1845 ]. |
1844 self layoutChanged |
1846 self layoutChanged |
1845 ] |
1847 ] |
1846 ! |
1848 ! |
1847 |
1849 |
1848 alignSelectionLeft |
1850 alignSelectionLeft |
1849 "align selection to the left of the first object in the selection; in case |
1851 "align selection to the left of the first object in the selection; in case |
1850 of one selection the object is aligned to the left of its superview |
1852 of one selection the object is aligned to the left of its superview |
1851 " |
1853 " |
1852 |lmost delta sel| |
1854 |lmost delta sel| |
1853 |
1855 |
1854 (sel := self moveableSelection) notNil ifTrue:[ |
1856 (sel := self moveableSelection) notNil ifTrue:[ |
1855 self withSelectionHiddenDo:[ |
1857 self withSelectionHiddenDo:[ |
1856 self numberOfSelections > 1 ifTrue:[ |
1858 self numberOfSelections > 1 ifTrue:[ |
1857 lmost := (sel first) computeOrigin x. |
1859 lmost := (sel first) computeOrigin x. |
1858 |
1860 |
1859 self transaction:#alignLeft selectionDo:[:v| |
1861 self transaction:#alignLeft selectionDo:[:v| |
1860 (delta := lmost - (v computeOrigin x)) ~~ 0 ifTrue:[ |
1862 (delta := lmost - (v computeOrigin x)) ~~ 0 ifTrue:[ |
1861 self shiftLayout:v left:delta right:delta |
1863 self shiftLayout:v left:delta right:delta |
1862 ] |
1864 ] |
1863 ] |
1865 ] |
1864 ] ifFalse:[ |
1866 ] ifFalse:[ |
1865 self extentToFrame:#Left do:[:aLayout| |
1867 self extentToFrame:#Left do:[:aLayout| |
1866 aLayout leftOffset:0. |
1868 aLayout leftOffset:0. |
1867 aLayout leftFraction:0.0. |
1869 aLayout leftFraction:0.0. |
1868 ] |
1870 ] |
1869 ] |
1871 ] |
1870 ]. |
1872 ]. |
1871 self layoutChanged |
1873 self layoutChanged |
1872 ] |
1874 ] |
1873 ! |
1875 ! |
1874 |
1876 |
1875 alignSelectionLeftAndRight |
1877 alignSelectionLeftAndRight |
1876 "align selection to the left/right of the first object in the selection; in case |
1878 "align selection to the left/right of the first object in the selection; in case |
1877 of one selection the object is aligned to the left/right of its superview |
1879 of one selection the object is aligned to the left/right of its superview |
1878 " |
1880 " |
1879 |lmost rmost sel| |
1881 |lmost rmost sel| |
1880 |
1882 |
1881 (sel := self moveableSelection) notNil ifTrue:[ |
1883 (sel := self moveableSelection) notNil ifTrue:[ |
1882 self withSelectionHiddenDo:[ |
1884 self withSelectionHiddenDo:[ |
1883 self numberOfSelections > 1 ifTrue:[ |
1885 self numberOfSelections > 1 ifTrue:[ |
1884 lmost := (sel first) computeOrigin x. |
1886 lmost := (sel first) computeOrigin x. |
1885 rmost := (sel first) computeCorner x. |
1887 rmost := (sel first) computeCorner x. |
1886 |
1888 |
1887 self transaction:#alignLeftRight selectionDo:[:aView| |
1889 self transaction:#alignLeftRight selectionDo:[:aView| |
1888 |layout| |
1890 |layout| |
1889 layout := self class asLayoutFrameFromView:aView. |
1891 layout := self class asLayoutFrameFromView:aView. |
1890 |
1892 |
1891 layout notNil ifTrue:[ |
1893 layout notNil ifTrue:[ |
1892 self createUndoLayout:aView. |
1894 self createUndoLayout:aView. |
1893 aView geometryLayout:layout. |
1895 aView geometryLayout:layout. |
1894 |
1896 |
1895 undoHistory withoutTransactionDo:[ |
1897 undoHistory withoutTransactionDo:[ |
1896 self shiftLayout:aView left:(lmost - (aView computeOrigin x)) |
1898 self shiftLayout:aView left:(lmost - (aView computeOrigin x)) |
1897 right:(rmost - (aView computeCorner x)). |
1899 right:(rmost - (aView computeCorner x)). |
1898 ]. |
1900 ]. |
1899 self elementChangedSize:aView |
1901 self elementChangedSize:aView |
1900 ] |
1902 ] |
1901 ] |
1903 ] |
1902 ] ifFalse:[ |
1904 ] ifFalse:[ |
1903 self extentToFrame:#LeftRight do:[:aLayout| |
1905 self extentToFrame:#LeftRight do:[:aLayout| |
1904 aLayout leftOffset:0. |
1906 aLayout leftOffset:0. |
1905 aLayout leftFraction:0.0. |
1907 aLayout leftFraction:0.0. |
1906 aLayout rightOffset:0. |
1908 aLayout rightOffset:0. |
1907 aLayout rightFraction:1.0. |
1909 aLayout rightFraction:1.0. |
1908 ] |
1910 ] |
1909 ] |
1911 ] |
1910 ]. |
1912 ]. |
1911 self layoutChanged |
1913 self layoutChanged |
1912 ]. |
1914 ]. |
1913 |
1915 |
1914 ! |
1916 ! |
1915 |
1917 |
1916 alignSelectionRight |
1918 alignSelectionRight |
1918 of one selection the object is aligned to the right of its superview |
1920 of one selection the object is aligned to the right of its superview |
1919 " |
1921 " |
1920 |rmost delta sel| |
1922 |rmost delta sel| |
1921 |
1923 |
1922 (sel := self moveableSelection) notNil ifTrue:[ |
1924 (sel := self moveableSelection) notNil ifTrue:[ |
1923 self withSelectionHiddenDo:[ |
1925 self withSelectionHiddenDo:[ |
1924 self numberOfSelections > 1 ifTrue:[ |
1926 self numberOfSelections > 1 ifTrue:[ |
1925 rmost := (sel first) computeCorner x. |
1927 rmost := (sel first) computeCorner x. |
1926 |
1928 |
1927 self transaction:#alignRight selectionDo:[:v| |
1929 self transaction:#alignRight selectionDo:[:v| |
1928 (delta := rmost - (v computeCorner x)) ~~ 0 ifTrue:[ |
1930 (delta := rmost - (v computeCorner x)) ~~ 0 ifTrue:[ |
1929 self shiftLayout:v left:delta right:delta |
1931 self shiftLayout:v left:delta right:delta |
1930 ] |
1932 ] |
1931 ] |
1933 ] |
1932 ] ifFalse:[ |
1934 ] ifFalse:[ |
1933 self extentToFrame:#Right do:[:aLayout| |
1935 self extentToFrame:#Right do:[:aLayout| |
1934 aLayout rightOffset:0. |
1936 aLayout rightOffset:0. |
1935 aLayout rightFraction:1.0. |
1937 aLayout rightFraction:1.0. |
1936 ] |
1938 ] |
1937 ] |
1939 ] |
1938 ]. |
1940 ]. |
1939 self layoutChanged |
1941 self layoutChanged |
1940 ] |
1942 ] |
1941 ! |
1943 ! |
1942 |
1944 |
1943 alignSelectionTop |
1945 alignSelectionTop |
1944 "align selection to the top of the first object in the selection; in case |
1946 "align selection to the top of the first object in the selection; in case |
1945 of one selection the object is aligned to the top of its superview |
1947 of one selection the object is aligned to the top of its superview |
1946 " |
1948 " |
1947 |tmost delta sel| |
1949 |tmost delta sel| |
1948 |
1950 |
1949 (sel := self moveableSelection) notNil ifTrue:[ |
1951 (sel := self moveableSelection) notNil ifTrue:[ |
1950 self withSelectionHiddenDo:[ |
1952 self withSelectionHiddenDo:[ |
1951 self numberOfSelections > 1 ifTrue:[ |
1953 self numberOfSelections > 1 ifTrue:[ |
1952 tmost := (sel first) computeOrigin y. |
1954 tmost := (sel first) computeOrigin y. |
1953 |
1955 |
1954 self transaction:#alignTop selectionDo:[:v| |
1956 self transaction:#alignTop selectionDo:[:v| |
1955 (delta := tmost - (v computeOrigin y)) ~~ 0 ifTrue:[ |
1957 (delta := tmost - (v computeOrigin y)) ~~ 0 ifTrue:[ |
1956 self shiftLayout:v top:delta bottom:delta |
1958 self shiftLayout:v top:delta bottom:delta |
1957 ] |
1959 ] |
1958 ] |
1960 ] |
1959 ] ifFalse:[ |
1961 ] ifFalse:[ |
1960 self extentToFrame:#Top do:[:aLayout| |
1962 self extentToFrame:#Top do:[:aLayout| |
1961 aLayout topOffset:0. |
1963 aLayout topOffset:0. |
1962 aLayout topFraction:0.0. |
1964 aLayout topFraction:0.0. |
1963 ] |
1965 ] |
1964 ] |
1966 ] |
1965 ]. |
1967 ]. |
1966 self layoutChanged |
1968 self layoutChanged |
1967 ] |
1969 ] |
1968 |
1970 |
1969 ! |
1971 ! |
1970 |
1972 |
1971 alignSelectionTopAndBottom |
1973 alignSelectionTopAndBottom |
1973 of one selection the object is aligned to the top/bottom of its superview |
1975 of one selection the object is aligned to the top/bottom of its superview |
1974 " |
1976 " |
1975 |tmost bmost sel| |
1977 |tmost bmost sel| |
1976 |
1978 |
1977 (sel := self moveableSelection) notNil ifTrue:[ |
1979 (sel := self moveableSelection) notNil ifTrue:[ |
1978 self withSelectionHiddenDo:[ |
1980 self withSelectionHiddenDo:[ |
1979 self numberOfSelections > 1 ifTrue:[ |
1981 self numberOfSelections > 1 ifTrue:[ |
1980 tmost := (sel first) computeOrigin y. |
1982 tmost := (sel first) computeOrigin y. |
1981 bmost := (sel first) computeCorner y. |
1983 bmost := (sel first) computeCorner y. |
1982 |
1984 |
1983 self transaction:#alignTopBottom selectionDo:[:aView| |
1985 self transaction:#alignTopBottom selectionDo:[:aView| |
1984 |layout| |
1986 |layout| |
1985 layout := self class asLayoutFrameFromView:aView. |
1987 layout := self class asLayoutFrameFromView:aView. |
1986 |
1988 |
1987 layout notNil ifTrue:[ |
1989 layout notNil ifTrue:[ |
1988 self createUndoLayout:aView. |
1990 self createUndoLayout:aView. |
1989 aView geometryLayout:layout. |
1991 aView geometryLayout:layout. |
1990 |
1992 |
1991 undoHistory withoutTransactionDo:[ |
1993 undoHistory withoutTransactionDo:[ |
1992 self shiftLayout:aView top:(tmost - (aView computeOrigin y)) |
1994 self shiftLayout:aView top:(tmost - (aView computeOrigin y)) |
1993 bottom:(bmost - (aView computeCorner y)). |
1995 bottom:(bmost - (aView computeCorner y)). |
1994 ]. |
1996 ]. |
1995 self elementChangedSize:aView |
1997 self elementChangedSize:aView |
1996 ] |
1998 ] |
1997 ] |
1999 ] |
1998 ] ifFalse:[ |
2000 ] ifFalse:[ |
1999 self extentToFrame:#TopBottom do:[:aLayout| |
2001 self extentToFrame:#TopBottom do:[:aLayout| |
2000 aLayout topOffset:0. |
2002 aLayout topOffset:0. |
2001 aLayout topFraction:0.0. |
2003 aLayout topFraction:0.0. |
2002 aLayout bottomOffset:0. |
2004 aLayout bottomOffset:0. |
2003 aLayout bottomFraction:1.0. |
2005 aLayout bottomFraction:1.0. |
2004 ] |
2006 ] |
2005 ] |
2007 ] |
2006 ]. |
2008 ]. |
2007 self layoutChanged |
2009 self layoutChanged |
2008 ] |
2010 ] |
2009 ! |
2011 ! |
2010 |
2012 |
2011 centerSelection:aOneArgBlockXorY orientation:orientation |
2013 centerSelection:aOneArgBlockXorY orientation:orientation |
2012 "center selection horizontal or vertical dependant on the block result( x or y). |
2014 "center selection horizontal or vertical dependant on the block result( x or y). |
2013 The argument to the block is the point. |
2015 The argument to the block is the point. |
2014 " |
2016 " |
2015 |superview min max delta val| |
2017 |superview min max delta val| |
2016 |
2018 |
2017 (self moveableSelection) isNil ifTrue:[ |
2019 (self moveableSelection) isNil ifTrue:[ |
2018 ^ self |
2020 ^ self |
2019 ]. |
2021 ]. |
2020 |
2022 |
2021 self withSelectionHiddenDo:[ |
2023 self withSelectionHiddenDo:[ |
2022 max := 0. |
2024 max := 0. |
2023 |
2025 |
2024 self selectionDo:[:aView | |
2026 self selectionDo:[:aView | |
2025 superview isNil ifTrue:[ |
2027 superview isNil ifTrue:[ |
2026 superview := self findContainerOfView:aView |
2028 superview := self findContainerOfView:aView |
2027 ] ifFalse:[ |
2029 ] ifFalse:[ |
2028 (self findContainerOfView:aView) == superview ifFalse:[ |
2030 (self findContainerOfView:aView) == superview ifFalse:[ |
2029 ^ self notify:'views must have same superview'. |
2031 ^ self notify:'views must have same superview'. |
2030 ] |
2032 ] |
2031 ]. |
2033 ]. |
2032 val := aOneArgBlockXorY value:(aView computeOrigin). |
2034 val := aOneArgBlockXorY value:(aView computeOrigin). |
2033 |
2035 |
2034 min isNil ifTrue:[min := val] |
2036 min isNil ifTrue:[min := val] |
2035 ifFalse:[min := min min:val]. |
2037 ifFalse:[min := min min:val]. |
2036 |
2038 |
2037 val := aOneArgBlockXorY value:(aView computeCorner). |
2039 val := aOneArgBlockXorY value:(aView computeCorner). |
2038 max := max max:val. |
2040 max := max max:val. |
2039 ]. |
2041 ]. |
2040 |
2042 |
2041 val := aOneArgBlockXorY value:(superview computeExtent). |
2043 val := aOneArgBlockXorY value:(superview computeExtent). |
2042 max := (min + val - max) // 2. |
2044 max := (min + val - max) // 2. |
2043 |
2045 |
2044 max == min ifFalse:[ |
2046 max == min ifFalse:[ |
2045 |type| |
2047 |type| |
2046 (orientation == #y) ifTrue:[type := #centerVertical] |
2048 (orientation == #y) ifTrue:[type := #centerVertical] |
2047 ifFalse:[type := #centerHorizontal]. |
2049 ifFalse:[type := #centerHorizontal]. |
2048 delta := max - min. |
2050 delta := max - min. |
2049 |
2051 |
2050 self transaction:type selectionDo:[:v| |
2052 self transaction:type selectionDo:[:v| |
2051 orientation == #y ifTrue:[ |
2053 orientation == #y ifTrue:[ |
2052 self shiftLayout:v top:delta bottom:delta |
2054 self shiftLayout:v top:delta bottom:delta |
2053 ] ifFalse:[ |
2055 ] ifFalse:[ |
2054 self shiftLayout:v left:delta right:delta |
2056 self shiftLayout:v left:delta right:delta |
2055 ] |
2057 ] |
2056 ] |
2058 ] |
2057 ]. |
2059 ]. |
2058 self layoutChanged |
2060 self layoutChanged |
2059 ] |
2061 ] |
2060 |
2062 |
2061 |
2063 |
2062 ! |
2064 ! |
2063 |
2065 |
2100 |sumWidths min max viewsInOrder topsInOrder count space sel| |
2102 |sumWidths min max viewsInOrder topsInOrder count space sel| |
2101 |
2103 |
2102 sel := self moveableSelection. |
2104 sel := self moveableSelection. |
2103 |
2105 |
2104 (sel notNil and:[self numberOfSelections > 1]) ifFalse:[ |
2106 (sel notNil and:[self numberOfSelections > 1]) ifFalse:[ |
2105 ^ self |
2107 ^ self |
2106 ]. |
2108 ]. |
2107 |
2109 |
2108 self withSelectionHiddenDo:[ |
2110 self withSelectionHiddenDo:[ |
2109 count := 0. |
2111 count := 0. |
2110 sumWidths := 0. |
2112 sumWidths := 0. |
2111 max := 0. |
2113 max := 0. |
2112 |
2114 |
2113 self selectionDo:[:aView | |
2115 self selectionDo:[:aView | |
2114 sumWidths := sumWidths + aView width. |
2116 sumWidths := sumWidths + aView width. |
2115 |
2117 |
2116 min isNil ifTrue:[min := aView left] |
2118 min isNil ifTrue:[min := aView left] |
2117 ifFalse:[min := min min:(aView left)]. |
2119 ifFalse:[min := min min:(aView left)]. |
2118 |
2120 |
2119 max := max max:(aView right). |
2121 max := max max:(aView right). |
2120 count := count + 1 |
2122 count := count + 1 |
2121 ]. |
2123 ]. |
2122 viewsInOrder := Array withAll:sel. |
2124 viewsInOrder := Array withAll:sel. |
2123 topsInOrder := viewsInOrder collect:[:aView | aView left]. |
2125 topsInOrder := viewsInOrder collect:[:aView | aView left]. |
2124 topsInOrder sortWith:viewsInOrder. |
2126 topsInOrder sortWith:viewsInOrder. |
2125 |
2127 |
2126 space := (((max - min) - sumWidths) / (count - 1)) rounded asInteger. |
2128 space := (((max - min) - sumWidths) / (count - 1)) rounded asInteger. |
2127 |
2129 |
2128 self transaction:#spreadHorizontal objects:viewsInOrder do:[:aView| |
2130 self transaction:#spreadHorizontal objects:viewsInOrder do:[:aView| |
2129 |delta| |
2131 |delta| |
2130 |
2132 |
2131 delta := min - aView computeOrigin x. |
2133 delta := min - aView computeOrigin x. |
2132 self shiftLayout:aView left:delta right:delta. |
2134 self shiftLayout:aView left:delta right:delta. |
2133 min := min + aView computeExtent x + space |
2135 min := min + aView computeExtent x + space |
2134 ] |
2136 ] |
2135 ]. |
2137 ]. |
2136 self layoutChanged |
2138 self layoutChanged |
2137 |
2139 |
2138 ! |
2140 ! |
2139 |
2141 |
2143 |sumHeights min max viewsInOrder topsInOrder count space sel| |
2145 |sumHeights min max viewsInOrder topsInOrder count space sel| |
2144 |
2146 |
2145 sel := self moveableSelection. |
2147 sel := self moveableSelection. |
2146 |
2148 |
2147 (sel notNil and:[self numberOfSelections > 1]) ifFalse:[ |
2149 (sel notNil and:[self numberOfSelections > 1]) ifFalse:[ |
2148 ^ self |
2150 ^ self |
2149 ]. |
2151 ]. |
2150 |
2152 |
2151 self withSelectionHiddenDo:[ |
2153 self withSelectionHiddenDo:[ |
2152 count := 0. |
2154 count := 0. |
2153 sumHeights := 0. |
2155 sumHeights := 0. |
2154 max := 0. |
2156 max := 0. |
2155 |
2157 |
2156 self selectionDo:[:aView | |
2158 self selectionDo:[:aView | |
2157 sumHeights := sumHeights + aView height. |
2159 sumHeights := sumHeights + aView height. |
2158 |
2160 |
2159 min isNil ifTrue:[min := aView top] |
2161 min isNil ifTrue:[min := aView top] |
2160 ifFalse:[min := min min:(aView top)]. |
2162 ifFalse:[min := min min:(aView top)]. |
2161 |
2163 |
2162 max := max max:(aView bottom). |
2164 max := max max:(aView bottom). |
2163 count := count + 1 |
2165 count := count + 1 |
2164 ]. |
2166 ]. |
2165 viewsInOrder := Array withAll:sel. |
2167 viewsInOrder := Array withAll:sel. |
2166 topsInOrder := viewsInOrder collect:[:aView|aView top]. |
2168 topsInOrder := viewsInOrder collect:[:aView|aView top]. |
2167 topsInOrder sortWith:viewsInOrder. |
2169 topsInOrder sortWith:viewsInOrder. |
2168 |
2170 |
2169 space := (((max - min) - sumHeights) / (count - 1)) rounded asInteger. |
2171 space := (((max - min) - sumHeights) / (count - 1)) rounded asInteger. |
2170 |
2172 |
2171 self transaction:#spreadVertical objects:viewsInOrder do:[:aView| |
2173 self transaction:#spreadVertical objects:viewsInOrder do:[:aView| |
2172 |delta| |
2174 |delta| |
2173 |
2175 |
2174 delta := min - aView computeOrigin y. |
2176 delta := min - aView computeOrigin y. |
2175 self shiftLayout:aView top:delta bottom:delta. |
2177 self shiftLayout:aView top:delta bottom:delta. |
2176 min := min + aView height + space |
2178 min := min + aView height + space |
2177 ] |
2179 ] |
2178 ]. |
2180 ]. |
2179 self layoutChanged |
2181 self layoutChanged |
2180 ! ! |
2182 ! ! |
2181 |
2183 |
2182 !UIObjectView methodsFor:'user actions - undo history'! |
2184 !UIObjectView methodsFor:'user actions - undo history'! |
2204 "undo last action |
2206 "undo last action |
2205 " |
2207 " |
2206 |newSel oldSel| |
2208 |newSel oldSel| |
2207 |
2209 |
2208 undoHistory isEmpty ifFalse:[ |
2210 undoHistory isEmpty ifFalse:[ |
2209 self hasSelection ifTrue:[ |
2211 self hasSelection ifTrue:[ |
2210 oldSel := OrderedCollection new. |
2212 oldSel := OrderedCollection new. |
2211 newSel := OrderedCollection new. |
2213 newSel := OrderedCollection new. |
2212 |
2214 |
2213 self selectionDo:[:aView||p| |
2215 self selectionDo:[:aView||p| |
2214 (p := self propertyOfView:aView) notNil ifTrue:[ |
2216 (p := self propertyOfView:aView) notNil ifTrue:[ |
2215 oldSel add:(p identifier) |
2217 oldSel add:(p identifier) |
2216 ] |
2218 ] |
2217 ]. |
2219 ]. |
2218 self setSelection:nil withRedraw:true. |
2220 self setSelection:nil withRedraw:true. |
2219 ]. |
2221 ]. |
2220 |
2222 |
2221 self withSelectionHiddenDo:[undoHistory undoLast:1]. |
2223 self withSelectionHiddenDo:[undoHistory undoLast:1]. |
2222 |
2224 |
2223 oldSel notNil ifTrue:[ |
2225 oldSel notNil ifTrue:[ |
2224 oldSel do:[:id||v| |
2226 oldSel do:[:id||v| |
2225 (v := self findViewWithId:id) notNil ifTrue:[newSel add:v] |
2227 (v := self findViewWithId:id) notNil ifTrue:[newSel add:v] |
2226 ]. |
2228 ]. |
2227 self select:newSel. |
2229 self select:newSel. |
2228 ] |
2230 ] |
2229 ]. |
2231 ]. |
2230 ! ! |
2232 ! ! |
2231 |
2233 |
2232 !UIObjectView::ResizeData methodsFor:'accessing'! |
2234 !UIObjectView::ResizeData methodsFor:'accessing'! |
2233 |
2235 |
2332 |
2334 |
2333 withinTransaction:aType text:aTextOrNil do:aBlock |
2335 withinTransaction:aType text:aTextOrNil do:aBlock |
2334 "open a transaction; perform the block; at least close the transaction |
2336 "open a transaction; perform the block; at least close the transaction |
2335 " |
2337 " |
2336 (enabled and:[transaction isNil]) ifTrue:[ |
2338 (enabled and:[transaction isNil]) ifTrue:[ |
2337 transaction := Transaction type:aType text:aTextOrNil. |
2339 transaction := Transaction type:aType text:aTextOrNil. |
2338 |
2340 |
2339 aBlock value. |
2341 aBlock value. |
2340 |
2342 |
2341 transaction isEmpty ifFalse:[ |
2343 transaction isEmpty ifFalse:[ |
2342 identifier := identifier + 1. |
2344 identifier := identifier + 1. |
2343 transaction identifier:identifier. |
2345 transaction identifier:identifier. |
2344 history addLast:transaction. |
2346 history addLast:transaction. |
2345 history size > (self class maxHistorySize) ifTrue:[history removeFirst] |
2347 history size > (self class maxHistorySize) ifTrue:[history removeFirst] |
2346 ]. |
2348 ]. |
2347 transaction := nil |
2349 transaction := nil |
2348 |
2350 |
2349 ] ifFalse:[ |
2351 ] ifFalse:[ |
2350 aBlock value |
2352 aBlock value |
2351 ] |
2353 ] |
2352 ! |
2354 ! |
2353 |
2355 |
2354 withoutTransactionDo:aNoneArgBlock |
2356 withoutTransactionDo:aNoneArgBlock |
2355 "evaluate the block without opening a transaction or keeping changes |
2357 "evaluate the block without opening a transaction or keeping changes |
2407 tabs unit:#cm. |
2409 tabs unit:#cm. |
2408 tabs positions:#(0 5). |
2410 tabs positions:#(0 5). |
2409 tabs align:#(#left #left). |
2411 tabs align:#(#left #left). |
2410 |
2412 |
2411 list := history collect:[:aTrans||e| |
2413 list := history collect:[:aTrans||e| |
2412 e := MultiColListEntry new. |
2414 e := MultiColListEntry new. |
2413 e colAt:1 put:(aTrans typeAsString). |
2415 e colAt:1 put:(aTrans typeAsString). |
2414 e colAt:2 put:(aTrans text ? ''). |
2416 e colAt:2 put:(aTrans text ? ''). |
2415 e tabulatorSpecification:tabs. |
2417 e tabulatorSpecification:tabs. |
2416 e |
2418 e |
2417 ]. |
2419 ]. |
2418 |
2420 |
2419 slv list:list. |
2421 slv list:list. |
2420 slv action:[:index | selection := index ]. |
2422 slv action:[:index | selection := index ]. |
2421 top openModal. |
2423 top openModal. |
2422 |
2424 |
2423 selection notNil ifTrue:[ |
2425 selection notNil ifTrue:[ |
2424 self undoLast:(history size - selection + 1). |
2426 self undoLast:(history size - selection + 1). |
2425 ] |
2427 ] |
2426 ! ! |
2428 ! ! |
2427 |
2429 |
2428 !UIObjectView::UndoHistory methodsFor:'testing'! |
2430 !UIObjectView::UndoHistory methodsFor:'testing'! |
2429 |
2431 |
2548 name := String new:(line size + size). |
2550 name := String new:(line size + size). |
2549 size := 1. |
2551 size := 1. |
2550 sep := Character space. |
2552 sep := Character space. |
2551 |
2553 |
2552 line do:[:c| |
2554 line do:[:c| |
2553 (c isUppercase) ifFalse:[ |
2555 (c isUppercase) ifFalse:[ |
2554 name at:size put:c |
2556 name at:size put:c |
2555 ] ifTrue:[ |
2557 ] ifTrue:[ |
2556 name at:size put:sep. |
2558 name at:size put:sep. |
2557 sep := $&. |
2559 sep := $&. |
2558 size := size + 1. |
2560 size := size + 1. |
2559 name at:size put:(c asLowercase) |
2561 name at:size put:(c asLowercase) |
2560 ]. |
2562 ]. |
2561 size := size + 1 |
2563 size := size + 1 |
2562 ]. |
2564 ]. |
2563 ^ name |
2565 ^ name |
2564 ! ! |
2566 ! ! |
2565 |
2567 |
2566 !UIObjectView::UndoHistory::Transaction methodsFor:'adding'! |
2568 !UIObjectView::UndoHistory::Transaction methodsFor:'adding'! |
2567 |
2569 |
2568 add:anUndoBlock |
2570 add:anUndoBlock |
2569 "add an undo action to the current transaction |
2571 "add an undo action to the current transaction |
2570 " |
2572 " |
2571 actions isNil ifTrue:[ |
2573 actions isNil ifTrue:[ |
2572 actions := anUndoBlock |
2574 actions := anUndoBlock |
2573 ] ifFalse:[ |
2575 ] ifFalse:[ |
2574 actions isCollection ifFalse:[ |
2576 actions isCollection ifFalse:[ |
2575 actions := OrderedCollection with:actions |
2577 actions := OrderedCollection with:actions |
2576 ]. |
2578 ]. |
2577 actions add:anUndoBlock. |
2579 actions add:anUndoBlock. |
2578 ] |
2580 ] |
2579 ! ! |
2581 ! ! |
2580 |
2582 |
2581 !UIObjectView::UndoHistory::Transaction methodsFor:'initialization'! |
2583 !UIObjectView::UndoHistory::Transaction methodsFor:'initialization'! |
2582 |
2584 |