added component handling;
authorClaus Gittinger <cg@exept.de>
Sun, 10 May 2009 12:58:19 +0200
changeset 2499 11be77599ca9
parent 2498 ca273c14b7bf
child 2500 3e2feb544801
added component handling; cleaned up the code and fixed bugs; redraw during move/resize; handle redraw bugs fixed
UIPainterView.st
--- a/UIPainterView.st	Sun May 10 12:56:49 2009 +0200
+++ b/UIPainterView.st	Sun May 10 12:58:19 2009 +0200
@@ -295,6 +295,7 @@
         viewsToRemove size == 1 ifTrue:[
             |subviews index|
 
+            newSelection components notEmptyOrNil ifTrue:[ self halt ].
             subviews := newSelection subViews.
 
             subviews size > 1 ifTrue:[
@@ -1616,26 +1617,29 @@
 !
 
 generateWindowSpec
-    |spec|
+    |spec addToSpec|
 
     spec := OrderedCollection new.
 
-    self subViews do:[:aView|
-        |vSpec|
-
-        "/ care for wrapped views ...
-        vSpec := self fullSpecFor:aView.
-        vSpec isNil ifTrue:[
-            aView subViews size == 1 ifTrue:[
-                vSpec := self fullSpecFor:(aView subViews first).
-            ]
+    addToSpec :=
+        [:aView|
+            |vSpec|
+
+            "/ care for wrapped views ...
+            vSpec := self fullSpecFor:aView.
+            vSpec isNil ifTrue:[
+                aView subViews size == 1 ifTrue:[
+                    vSpec := self fullSpecFor:(aView subViews first).
+                ]
+            ].
+            vSpec isNil ifTrue:[
+                self warn:'Oops - could not create spec for some view'
+            ].
+            spec add:vSpec
         ].
-        vSpec isNil ifTrue:[
-            self warn:'Oops - could not create spec for some view'
-        ].
-        spec add:vSpec
-    ].
-
+
+    self subViews do:addToSpec.
+    self components do:addToSpec.
     spec := treeView generateFullSpecForComponents:spec named:methodName.
     ^ spec
 !
@@ -2037,43 +2041,47 @@
     |wasClipped sel hColor bg|
 
     selectionHiddenLevel == 0 ifTrue:[
-	sel := treeView selection.
-	(sel size > 1 and:
-	[(treeView model list at: sel first) contents view == aComponent])
-	ifTrue: [
-	    hColor := handleMasterColor
-	] ifFalse:[
-	    bg := aComponent viewBackground.
-	    bg isColor ifTrue:[
-		bg brightness < 0.5 ifTrue:[
-		    hColor := handleColorWhite
-		] ifFalse:[
-		    hColor := handleColorBlack
-		]
-	    ] ifFalse:[
-		hColor := handleColorBlack
-	    ]
-	].
-
-	self paint:hColor.
-
-	(wasClipped := clipChildren) ifTrue:[
-	    self clippedByChildren:(clipChildren := false).
-	].
-
-	self handlesOf:aComponent do:[:aRectangle :what| |l t w h|
-	    l := aRectangle left   + 1.
-	    t := aRectangle top    + 1.
-	    w := aRectangle width  - 2.
-	    h := aRectangle height - 2.
-
-	    what == #view ifTrue:[self displayRectangleX:l y:t width:w height:h]
-			 ifFalse:[self fillRectangleX:l y:t width:w height:h]
-	].
-
-	wasClipped ifTrue:[
-	    self clippedByChildren:(clipChildren := true).
-	]
+        sel := treeView selection.
+        (sel size > 1 and: [(treeView model list at: sel first) contents view == aComponent])
+        ifTrue: [
+            hColor := handleMasterColor
+        ] ifFalse:[
+            bg := aComponent viewBackground.
+            bg isColor ifTrue:[
+                bg brightness < 0.5 ifTrue:[
+                    hColor := handleColorWhite
+                ] ifFalse:[
+                    hColor := handleColorBlack
+                ]
+            ] ifFalse:[
+                hColor := handleColorBlack
+            ]
+        ].
+
+        self paint:hColor.
+
+        (wasClipped := clipChildren) ifTrue:[
+            self clippedByChildren:(clipChildren := false).
+        ].
+
+        self handlesOf:aComponent do:[:aRectangle :what| 
+            |l t w h|
+
+            l := aRectangle left   + 1.
+            t := aRectangle top    + 1.
+            w := aRectangle width  - 2.
+            h := aRectangle height - 2.
+
+            what == #view ifTrue:[
+                self displayRectangleX:l y:t width:w height:h
+            ] ifFalse:[
+                self fillRectangleX:l y:t width:w height:h
+            ]
+        ].
+
+        wasClipped ifTrue:[
+            self clippedByChildren:(clipChildren := true).
+        ]
     ]
 
     "Modified: / 6.12.2001 / 00:00:16 / cg"
@@ -2135,9 +2143,12 @@
     |view prop|
 
     view := super findObjectAt:aPoint.
+    view isNil ifTrue:[^ nil].
+
     "/ stupid check, if I know about this view
     prop := self propertyOfView:view.
     prop notNil ifTrue:[^ prop view].
+self halt.
     ^ nil
 !
 
@@ -2367,44 +2378,48 @@
     ].
 
     "/ remember view<->spec associations to tree
-    aBuilder componentCreationHook:[:aView :aSpec :builder|
-        |newProperty copyOfSpec nameOfSpec beforeIndex|
-
-        (viewPosition notNil and:[aSpecification == aSpec]) ifTrue:[
-            subviewToRealize := aView.
-
-            [ (subviewToRealize notNil and:[subviewToRealize superView ~~ aFrame]) ] whileTrue:[
-                subviewToRealize := subviewToRealize superView.
+    aBuilder 
+        componentCreationHook:[:aView :aSpec :builder|
+            |newProperty copyOfSpec nameOfSpec beforeIndex|
+
+            (viewPosition notNil and:[aSpecification == aSpec]) ifTrue:[
+                subviewToRealize := aView.
+
+                [ (subviewToRealize notNil and:[subviewToRealize superView ~~ aFrame]) ] whileTrue:[
+                    subviewToRealize := subviewToRealize superView.
+                ].
+                subviewToRealize notNil ifTrue:[
+                    beforeIndex := viewPosition.
+                    aFrame changeSequenceOrderFor:subviewToRealize to:viewPosition.
+                ].
             ].
-            subviewToRealize notNil ifTrue:[
-                beforeIndex := viewPosition.
-                aFrame changeSequenceOrderFor:subviewToRealize to:viewPosition.
+
+            newProperty := ViewProperty new.
+            copyOfSpec := aSpec copy.
+            newProperty spec:copyOfSpec.
+            newProperty view:aView.
+
+            "/ break refs to child-specs
+            "/ (not needed, as we keep the child info in the view hierarchy)
+            copyOfSpec class supportsSubComponents ifTrue:[
+                copyOfSpec component:nil
             ].
+
+            nameOfSpec := copyOfSpec name.
+
+            (nameOfSpec isNil or:[(self propertyOfName:nameOfSpec) notNil]) ifTrue:[
+                copyOfSpec name:(nameOfSpec := self uniqueNameFor:copyOfSpec)
+            ].
+            aView name:nameOfSpec.
+            treeView addProperty:newProperty beforeIndex:beforeIndex.
         ].
 
-        newProperty := ViewProperty new.
-        copyOfSpec := aSpec copy.
-        newProperty spec:copyOfSpec.
-        newProperty view:aView.
-
-        "/ break refs to child-specs
-        "/ (not needed, as we keep the child info in the view hierarchy)
-        copyOfSpec class supportsSubComponents ifTrue:[
-            copyOfSpec component:nil
-        ].
-
-        nameOfSpec := copyOfSpec name.
-
-        (nameOfSpec isNil or:[(self propertyOfName:nameOfSpec) notNil]) ifTrue:[
-            copyOfSpec name:(self uniqueNameFor:copyOfSpec)
-        ].
-        treeView addProperty:newProperty beforeIndex:beforeIndex.
-    ].
     newView := aSpecification buildViewWithLayoutFor:aBuilder in:aFrame.
 
     subviewToRealize notNil ifTrue:[
         subviewToRealize realize.
 
+        aFrame components notEmptyOrNil ifTrue:[ self halt ].
         aFrame subViews from:(viewPosition + 1 ) do:[:v|
             v shown ifTrue:[v raise]
         ].
@@ -2423,6 +2438,7 @@
 
     (mySpec notNil and:[mySpec class supportsSubComponents]) ifTrue:[
         (aView subViews notNil) ifTrue:[
+            aView components notEmptyOrNil ifTrue:[ self halt ].
             aView subViews do:[:aSubView||spec|
                 spec := self fullSpecFor:aSubView.
                 spec notNil ifTrue:[
@@ -2539,28 +2555,28 @@
     |props name|
 
     aSpec class == WindowSpec ifTrue:[
-	 ^ treeView canvasSpec:aSpec
+         ^ treeView canvasSpec:aSpec
     ].
 
     self singleSelection notNil ifTrue:[
-	self withSelectionHiddenDo:[
-	    self transaction:#specification selectionDo:[:aView|
-		props   := self propertyOfView:aView.
-		name    := (aSpec name) withoutSeparators.
-
-		name = props name ifFalse:[
-		    (self propertyOfName:name) notNil ifTrue:[
-			name := props name
-		    ]
-		].
-
-		aSpec name:name.
-		self createUndoSpecModify:props.
-		self rebuildView:aView fromSpec:aSpec withBuilder:nil.
-		props spec:(aSpec copy).
-		treeView propertyChanged:props.
-	    ]
-	]
+        self withSelectionHiddenDo:[
+            self transaction:#specification selectionDo:[:aView|
+                props   := self propertyOfView:aView.
+                name    := (aSpec name) withoutSeparators.
+
+                (name = props name) ifFalse:[
+                    (self propertyOfName:name) notNil ifTrue:[
+                        name := props name
+                    ]
+                ].
+
+                aSpec name:name.
+                self createUndoSpecModify:props.
+                self rebuildView:aView fromSpec:aSpec withBuilder:nil.
+                props spec:(aSpec copy).
+                treeView propertyChanged:props.
+            ]
+        ]
     ]
 
     "Modified: / 30.10.2001 / 13:59:45 / cg"