UIObjectView.st
changeset 113 1854c2e61c4e
parent 100 01775d3d8489
child 119 39acd704ad51
--- a/UIObjectView.st	Wed May 21 12:41:29 1997 +0200
+++ b/UIObjectView.st	Wed May 21 12:42:03 1997 +0200
@@ -126,23 +126,27 @@
 layoutType:aView
     "returns layout type of aView or nil
     "
-    |layout spec|
-
-    layout := aView geometryLayout.
-
-    layout notNil ifTrue:[
-        layout isLayout ifTrue:[
-            layout isLayoutFrame        ifTrue:[ ^ #LayoutFrame ].
-            layout isAlignmentOrigin    ifTrue:[ ^ #AlignmentOrigin ].
-            layout isLayoutOrigin       ifTrue:[ ^ #LayoutOrigin ].
+    |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:[
-            layout isRectangle          ifTrue:[ ^ #Rectangle ].
-            layout isPoint              ifTrue:[ ^ #Point ].
+            (superView := aView superView) notNil ifTrue:[
+                spec := superView specClass.
+                spec canResizeSubComponents ifTrue:[
+                    ^ #Extent
+                ]
+            ]
         ]
-    ] ifFalse:[
-        spec := aView superView specClass.
-
-        spec canResizeSubComponents     ifTrue:[ ^ #Extent ].
     ].
     ^ nil
 
@@ -151,6 +155,14 @@
 
 !UIObjectView methodsFor:'accessing'!
 
+canModify
+    ^ testMode not
+!
+
+canModify:aBool
+    self testMode:(aBool not)
+!
+
 gridAlign
     "returns state of aligning to grid
     "
@@ -232,7 +244,8 @@
         ] ifFalse:[
             inputView raise.
             inputView realize
-        ]
+        ].
+        self changed:#canModify
     ]
 
 
@@ -517,7 +530,6 @@
     inputView raise.
 
     self setupInitialLayoutFor:object.
-    self changed:#tree.
     self select:object.
     actionData := nil.
 
@@ -1192,7 +1204,7 @@
     "
     (self canSelect:something) ifTrue:[
         super addToSelection:something.
-        self changed:#selection.
+        self selectionChanged.
     ]
 !
 
@@ -1210,8 +1222,10 @@
 removeFromSelection:something
     "remove something from selection
     "
-    super removeFromSelection:something.
-    self changed:#selection
+    something notNil ifTrue:[
+        super removeFromSelection:something.
+        self selectionChanged
+    ].
 
 !
 
@@ -1220,9 +1234,11 @@
     "
     (self canSelect:something) ifTrue:[
         super select:something.
-        self changed:#selection
+        self selectionChanged
     ]
 
+
+
 !
 
 selection
@@ -1233,6 +1249,13 @@
 
 !
 
+selectionChanged
+    "called whenever the selection changed
+    "
+    self subclassResponsibility
+
+!
+
 showSelection
     selectionHiddenLevel == 0 ifTrue:[
         super showSelection.
@@ -1264,9 +1287,10 @@
     "
     selection notNil ifTrue:[
         super unselect.
-        self changed:#selection
+        self selectionChanged
     ]
 
+
 !
 
 withSelectionHiddenDo:aBlock
@@ -1604,27 +1628,26 @@
 
 !UIObjectView methodsFor:'user actions - move'!
 
-moveSelectionDown:aNumber
+moveSelectionDown
     "move selection down
     "
-    |gridY|
+    |gridY n|
 
     (self canMove:selection) ifTrue:[
         gridAlign notNil ifTrue:[gridY := gridAlign y].
 
         self withSelectionHiddenDo:[
-            self transaction:#moveDown selectionDo:[:aView|
-                |n d|
-
-                n := aNumber.
-
+            self selectionDo:[:aView|
                 aligning ifTrue:[
-                    d := ((aView computeCorner y) \\ gridY).
-                    n := n * gridY.
-
-                    d ~~ 0 ifTrue:[
-                        n := n - d + 1.
+                    n := ((aView computeCorner y) \\ gridY).
+
+                    n ~~ 0 ifTrue:[
+                        n := gridY - n + 1.
+                    ] ifFalse:[
+                        n := gridY
                     ]
+                ] ifFalse:[
+                    n := 1
                 ].
                 self shiftLayout:aView top:n bottom:n
             ]
@@ -1634,56 +1657,22 @@
 
 !
 
-moveSelectionLeft:aNumber
+moveSelectionLeft
     "move selection left
     "
-    |gridX|
+    |gridX n|
 
     (self canMove:selection) ifTrue:[
         gridAlign notNil ifTrue:[gridX := gridAlign x].
 
         self withSelectionHiddenDo:[
-            self transaction:#moveLeft selectionDo:[:aView|
-                |n d|
-
-                n := aNumber.
-
+            self selectionDo:[:aView|
                 aligning ifTrue:[
-                    d := ((aView computeOrigin x) \\ gridX).
-                    d ~~ 0 ifTrue:[
-                        n := n-1.
-                    ].
-                    n := (n * gridX) + d.
-                ].
-                n := n negated.
-                self shiftLayout:aView left:n right:n
-            ]
-        ].
-        self changed:#layout
-    ]
-!
-
-moveSelectionRight:aNumber
-    "move selection right
-    "
-    |gridX|
-
-    (self canMove:selection) ifTrue:[
-        gridAlign notNil ifTrue:[gridX := gridAlign x].
-
-        self withSelectionHiddenDo:[
-            self transaction:#moveRight selectionDo:[:aView|
-                |n d|
-
-                n := aNumber.
-
-                aligning ifTrue:[
-                    d := ((aView computeCorner x) \\ gridX).
-                    n := n * gridX.
-
-                    d ~~ 0 ifTrue:[
-                        n := n - d + 1.
-                    ]
+                    n := ((aView computeOrigin x) \\ gridX).
+                    n == 0 ifTrue:[n := gridX].
+                    n := n negated.
+                ] ifFalse:[
+                    n := -1
                 ].
                 self shiftLayout:aView left:n right:n
             ]
@@ -1692,28 +1681,48 @@
     ]
 !
 
-moveSelectionUp:aNumber
+moveSelectionRight
+    "move selection right
+    "
+    |gridX n|
+
+    (self canMove:selection) ifTrue:[
+        gridAlign notNil ifTrue:[gridX := gridAlign x].
+
+        self withSelectionHiddenDo:[
+            self selectionDo:[:aView|
+                aligning ifTrue:[
+                    n := ((aView computeCorner x) \\ gridX).
+
+                    n ~~ 0 ifTrue:[n := n negated]
+                          ifFalse:[n := gridX]
+                ] ifFalse:[
+                    n := 1
+                ].
+                self shiftLayout:aView left:n right:n
+            ]
+        ].
+        self changed:#layout
+    ]
+!
+
+moveSelectionUp
     "move selection up
     "
-    |gridY|
+    |gridY n|
 
     (self canMove:selection) ifTrue:[
         gridAlign notNil ifTrue:[gridY := gridAlign y].
 
         self withSelectionHiddenDo:[
-            self transaction:#moveUp selectionDo:[:aView|
-                |n d|
-
-                n := aNumber.
-
+            self selectionDo:[:aView|
                 aligning ifTrue:[
-                    d := ((aView computeOrigin x) \\ gridY).
-                    d ~~ 0 ifTrue:[
-                        n := n-1.
-                    ].
-                    n := (n * gridY) + d.
+                    n := ((aView computeOrigin x) \\ gridY).
+                    n == 0 ifTrue:[n := gridY].
+                    n := n negated.
+                ] ifFalse:[
+                    n := -1
                 ].
-                n := n negated.
                 self shiftLayout:aView top:n bottom:n
             ]
         ].
@@ -2169,7 +2178,6 @@
     self withSelectionHiddenDo:[
         undoHistory openUndoMenu
     ].
-    self changed:#tree
 
 !
 
@@ -2187,7 +2195,7 @@
     self withSelectionHiddenDo:[
         undoHistory undoLast:1
     ].
-    self changed:#tree
+
 ! !
 
 !UIObjectView::UndoHistory class methodsFor:'constants'!