--- a/UIObjectView.st Mon May 11 09:39:28 2009 +0200
+++ b/UIObjectView.st Mon May 11 09:39:35 2009 +0200
@@ -189,72 +189,80 @@
!UIObjectView class methodsFor:'handles'!
-handlesOf:aView do:aBlock
+handlesOf:aViewOrComponent do:aBlock
|type v h|
- type := self layoutType:aView.
+ (aViewOrComponent isKindOf:LineSegmentMorph) ifTrue:[
+ aBlock value:(aViewOrComponent startPoint) value:#startPoint.
+ aBlock value:(aViewOrComponent endPoint) value:#endPoint.
+ ^ self.
+ ].
+
+ type := self layoutType:aViewOrComponent.
(type == #LayoutFrame or:[type == #Rectangle]) ifTrue:[
- v := self isVerticalResizable:aView.
- h := self isHorizontalResizable:aView.
+ v := self isVerticalResizable:aViewOrComponent.
+ h := self isHorizontalResizable:aViewOrComponent.
h ifTrue:[
- aBlock value:(aView leftCenter rounded ) value:#left.
- aBlock value:(aView rightCenter rounded) value:#right
+ aBlock value:(aViewOrComponent leftCenter rounded ) value:#left.
+ aBlock value:(aViewOrComponent rightCenter rounded) value:#right
].
v ifTrue:[
- aBlock value:(aView topCenter rounded ) value:#top.
- aBlock value:(aView bottomCenter rounded) value:#bottom.
+ aBlock value:(aViewOrComponent topCenter rounded ) value:#top.
+ aBlock value:(aViewOrComponent bottomCenter rounded) value:#bottom.
].
(h and:[v]) ifTrue:[
- aBlock value:(aView origin ) value:#origin.
- aBlock value:(aView topRight ) value:#topRight.
- aBlock value:(aView bottomLeft) value:#bottomLeft.
- aBlock value:(aView corner ) value:#corner.
+ aBlock value:(aViewOrComponent origin ) value:#origin.
+ aBlock value:(aViewOrComponent topRight ) value:#topRight.
+ aBlock value:(aViewOrComponent bottomLeft) value:#bottomLeft.
+ aBlock value:(aViewOrComponent corner ) value:#corner.
^ self
]
].
- aBlock value:(aView origin ) value:#view.
- aBlock value:(aView topRight ) value:#view.
- aBlock value:(aView bottomLeft) value:#view.
+ aBlock value:(aViewOrComponent origin ) value:#view.
+ aBlock value:(aViewOrComponent topRight ) value:#view.
+ aBlock value:(aViewOrComponent bottomLeft) value:#view.
type == #Extent ifTrue:[
- v := self isVerticalResizable:aView.
- h := self isHorizontalResizable:aView.
-
- v ifTrue:[ aBlock value:(aView bottomCenter rounded) value:#bottom ].
- h ifTrue:[ aBlock value:(aView rightCenter rounded ) value:#right ].
+ v := self isVerticalResizable:aViewOrComponent.
+ h := self isHorizontalResizable:aViewOrComponent.
+
+ v ifTrue:[ aBlock value:(aViewOrComponent bottomCenter rounded) value:#bottom ].
+ h ifTrue:[ aBlock value:(aViewOrComponent rightCenter rounded ) value:#right ].
(h and:[v]) ifTrue:[
- aBlock value:(aView corner) value:#corner.
+ aBlock value:(aViewOrComponent corner) value:#corner.
^ self
]
].
- aBlock value:(aView corner) value:#view.
+ aBlock value:(aViewOrComponent corner) value:#view.
! !
!UIObjectView class methodsFor:'queries'!
isHorizontalResizable:aComponent
- "returns true if instance is horizontal resizeable
+ "returns true if aComponent is horizontal resizeable
"
(aComponent isKindOf:ScrollBar) ifTrue:[
- ^ aComponent orientation == #horizontal
+ ^ aComponent orientation == #horizontal
].
(aComponent isKindOf:Scroller) ifTrue:[
- ^ aComponent orientation == #horizontal
+ ^ aComponent orientation == #horizontal
].
(aComponent isKindOf:Slider) ifTrue:[
- ^ aComponent orientation == #horizontal
+ ^ aComponent orientation == #horizontal
+ ].
+ (aComponent isKindOf:LineSegmentMorph) ifTrue:[
+ ^ false
].
^ true
-
!
isVerticalResizable:aComponent
- "returns true if instance is vertical resizeable
+ "returns true if aComponent is vertical resizeable
"
"/ (aComponent isKindOf:EditField) ifTrue:[
"/ ^ false
@@ -274,33 +282,39 @@
"/ (aComponent isKindOf:Slider) ifTrue:[
"/ ^ aComponent orientation == #vertical
"/ ].
+ (aComponent isKindOf:LineSegmentMorph) ifTrue:[
+ ^ false
+ ].
^ true
!
-layoutType:aView
- "returns layout type of aView or nil
- "
+layoutType:aViewOrComponent
+ "returns layout type of aView or nil"
+
|layout spec superView|
- aView notNil ifTrue:[
- layout := aView geometryLayout.
- layout notNil ifTrue:[
- layout isLayout ifTrue:[
- layout isLayoutFrame ifTrue:[ ^ #LayoutFrame ].
- layout isAlignmentOrigin ifTrue:[ ^ #AlignmentOrigin ].
- layout isLayoutOrigin ifTrue:[ ^ #LayoutOrigin ].
- ] ifFalse:[
- layout isRectangle ifTrue:[ ^ #Rectangle ].
- layout isPoint ifTrue:[ ^ #Point ].
- ]
- ] ifFalse:[
- (superView := aView superView) notNil ifTrue:[
- spec := superView specClass.
- spec canResizeSubComponents ifTrue:[
- ^ #Extent
- ]
- ]
- ]
+ aViewOrComponent isNil ifTrue:[ ^ nil ].
+ (aViewOrComponent isKindOf:LineSegmentMorph) ifTrue:[
+ ^ nil
+ ].
+
+ layout := aViewOrComponent geometryLayout.
+ layout notNil ifTrue:[
+ layout isLayout ifTrue:[
+ layout isLayoutFrame ifTrue:[ ^ #LayoutFrame ].
+ layout isAlignmentOrigin ifTrue:[ ^ #AlignmentOrigin ].
+ layout isLayoutOrigin ifTrue:[ ^ #LayoutOrigin ].
+ ] ifFalse:[
+ layout isRectangle ifTrue:[ ^ #Rectangle ].
+ layout isPoint ifTrue:[ ^ #Point ].
+ ].
+ ] ifFalse:[
+ (superView := aViewOrComponent superView) notNil ifTrue:[
+ spec := superView specClass.
+ spec canResizeSubComponents ifTrue:[
+ ^ #Extent
+ ]
+ ]
].
^ nil
@@ -1046,17 +1060,19 @@
!UIObjectView methodsFor:'private-handles'!
handlesOf:aComponent do:aTwoArgAction
- "perform action on each handle of a component
- "
+ "perform aTwoArgAction on each handle of a component"
+
|dlt ext|
dlt := (aComponent originRelativeTo:self) - aComponent origin.
dlt := dlt - (4@4).
ext := 8@8.
- self class handlesOf:aComponent do:[:pnt :wht |
- aTwoArgAction value:(pnt + dlt extent:ext) value:wht
- ]
+ self class
+ handlesOf:aComponent
+ do:[:pnt :wht |
+ aTwoArgAction value:(pnt + dlt extent:ext) value:wht
+ ]
!
whichHandleOf:aComponent isHitBy:aPoint
@@ -1109,6 +1125,15 @@
]
!
+resize:aComponent endPoint:newEndPoint
+ "move a component's endPoint"
+
+ undoHistory
+ withoutTransactionDo:[
+ self shiftLayout:aComponent startPoint:0 endPoint:(newEndPoint - (aComponent endPoint))
+ ]
+!
+
resize:aView left:aPoint
"resize a views left"
@@ -1137,6 +1162,15 @@
]
!
+resize:aComponent startPoint:newStartPoint
+ "move a component's startPoint"
+
+ undoHistory
+ withoutTransactionDo:[
+ self shiftLayout:aComponent startPoint:(newStartPoint - (aComponent startPoint)) endPoint:0
+ ]
+!
+
resize:aView top:aPoint
"resize a views top"
@@ -1162,62 +1196,87 @@
!UIObjectView methodsFor:'private-shift layout'!
+shiftLayout:aViewOrComponent horizontal:n
+ "shift layout for a view; in case of an open transaction, the undo action is registered"
+
+ (aViewOrComponent isKindOf:LineSegmentMorph) ifTrue:[
+ self shiftLayout:aViewOrComponent
+ startPoint:(n @ 0) endPoint:(n @ 0)
+ ] ifFalse:[
+ self shiftLayout:aViewOrComponent top:0 bottom:0 left:n right:n
+ ]
+!
+
shiftLayout:aView left:l right:r
- "shift layout for a view; in case of an open transaction, the undo
- action is registered
- "
+ "shift layout for a view; in case of an open transaction, the undo action is registered"
+
self shiftLayout:aView top:0 bottom:0 left:l right:r
-
+!
+
+shiftLayout:aComponent startPoint:deltaS endPoint:deltaE
+ "shift coordinates; in case of an open transaction, the undo action is registered"
+
+ self createUndoStartPointEndPoint:aComponent.
+ aComponent
+ startPoint:(aComponent startPoint + deltaS)
+ endPoint:(aComponent endPoint + deltaE).
!
shiftLayout:aView top:t bottom:b
- "shift layout for a view; in case of an open transaction, the undo
- action is registered
- "
+ "shift layout for a view; in case of an open transaction, the undo action is registered"
+
self shiftLayout:aView top:t bottom:b left:0 right:0
-
-
!
shiftLayout:aView top:t bottom:b left:l right:r
- "shift layout for a view; in case of an open transaction, the undo
- action is registered
- "
+ "shift layout for a view; in case of an open transaction, the undo action is registered"
+
|type layout oldExt|
type := self class layoutType:aView.
type notNil ifTrue:[
- self createUndoLayout:aView.
-
- type == #Extent ifTrue:[
- oldExt := aView extent.
- aView extent:(oldExt + ((r-l) @ (b-t))).
- ^ self
- ].
-
- layout := aView geometryLayout copy.
-
- layout isLayout ifTrue:[
- layout leftOffset:(layout leftOffset + l)
- topOffset:(layout topOffset + t).
+ self createUndoLayout:aView.
+
+ type == #Extent ifTrue:[
+ oldExt := aView extent.
+ aView extent:(oldExt + ((r-l) @ (b-t))).
+ ^ self
+ ].
+
+ layout := aView geometryLayout copy.
+
+ layout isLayout ifTrue:[
+ layout leftOffset:(layout leftOffset + l)
+ topOffset:(layout topOffset + t).
- type == #LayoutFrame ifTrue:[
- layout bottomOffset:(layout bottomOffset + b).
- layout rightOffset:(layout rightOffset + r).
- ]
- ] ifFalse:[
- type == #Rectangle ifTrue:[
- layout left:(layout left + l)
- right:(layout right + r)
- top:(layout top + t)
- bottom:(layout bottom + b).
- ] ifFalse:[ "POINT"
- layout x:(layout x + l) y:(layout y + t).
- ]
- ].
- aView geometryLayout:layout
+ type == #LayoutFrame ifTrue:[
+ layout bottomOffset:(layout bottomOffset + b).
+ layout rightOffset:(layout rightOffset + r).
+ ]
+ ] ifFalse:[
+ type == #Rectangle ifTrue:[
+ layout left:(layout left + l)
+ right:(layout right + r)
+ top:(layout top + t)
+ bottom:(layout bottom + b).
+ ] ifFalse:[ "POINT"
+ layout x:(layout x + l) y:(layout y + t).
+ ]
+ ].
+ aView geometryLayout:layout
]
+!
+
+shiftLayout:aViewOrComponent vertical:n
+ "shift layout for a view; in case of an open transaction, the undo action is registered"
+
+ (aViewOrComponent isKindOf:LineSegmentMorph) ifTrue:[
+ self shiftLayout:aViewOrComponent
+ startPoint:(0 @ n) endPoint:(0 @ n)
+ ] ifFalse:[
+ self shiftLayout:aViewOrComponent top:n bottom:n left:0 right:0
+ ].
! !
!UIObjectView methodsFor:'searching'!
@@ -1909,6 +1968,7 @@
[
self selectionDo:[:aView| aOneArgBlock value:aView ].
+
sensor leftButtonPressed ifTrue:[
self windowGroup processExposeEvents.
Delay waitForSeconds:tm.
@@ -1934,8 +1994,8 @@
!
moveSelectionDown:howMany
- "move selection down
- "
+ "move selection down (pixelwise or aligned-grid wise)"
+
|gridY n|
gridAlign notNil ifTrue:[gridY := gridAlign y]
@@ -1951,10 +2011,13 @@
n := gridY
]
] ifFalse:[
- n := 1
+ n := 1.
+ self sensor shiftDown ifTrue:[
+ n := 8.
+ ].
].
n := n * howMany.
- self shiftLayout:aView top:n bottom:n
+ self shiftLayout:aView vertical:n
]
!
@@ -1966,8 +2029,8 @@
!
moveSelectionLeft:howMany
- "move selection left
- "
+ "move selection to the left (pixelwise or aligned-grid wise)"
+
|gridX n|
gridAlign notNil ifTrue:[gridX := gridAlign x]
@@ -1979,10 +2042,13 @@
n == 0 ifTrue:[n := gridX].
n := n negated.
] ifFalse:[
- n := -1
+ n := -1.
+ self sensor shiftDown ifTrue:[
+ n := -8.
+ ].
].
n := n * howMany.
- self shiftLayout:aView left:n right:n
+ self shiftLayout:aView horizontal:n
]
!
@@ -1993,7 +2059,7 @@
!
moveSelectionRight:howMany
- "move selection to the right by howMany pixels"
+ "move selection to the right (pixelwise or aligned-grid wise)"
|gridX n|
@@ -2007,10 +2073,13 @@
n ~~ 0 ifTrue:[n := n negated]
ifFalse:[n := gridX]
] ifFalse:[
- n := 1
+ n := 1.
+ self sensor shiftDown ifTrue:[
+ n := 8.
+ ].
].
n := n * howMany.
- self shiftLayout:aView left:n right:n
+ self shiftLayout:aView horizontal:n
]
!
@@ -2021,8 +2090,8 @@
!
moveSelectionUp:howMany
- "move selection up
- "
+ "move selection up (pixelwise or aligned-grid wise)"
+
|gridY n|
gridAlign notNil ifTrue:[gridY := gridAlign y]
@@ -2034,10 +2103,13 @@
n == 0 ifTrue:[n := gridY].
n := n negated.
] ifFalse:[
- n := -1
+ n := -1.
+ self sensor shiftDown ifTrue:[
+ n := -8.
+ ].
].
n := n * howMany.
- self shiftLayout:aView top:n bottom:n
+ self shiftLayout:aView vertical:n
]
! !