UIPainterView.st
changeset 128 9779b7459a1c
parent 121 96d6feeeb049
child 131 715b3dbba87d
--- a/UIPainterView.st	Mon May 26 13:06:42 1997 +0200
+++ b/UIPainterView.st	Mon May 26 13:08:24 1997 +0200
@@ -17,16 +17,16 @@
 	category:'Interface-UIPainter'
 !
 
-MultiSelectionInList subclass:#ListHolder
-	instanceVariableNames:'painter propertyList masterElement disabledChanged'
-	classVariableNames:''
+Object subclass:#ViewProperty
+	instanceVariableNames:'view spec identifier'
+	classVariableNames:'Identifier'
 	poolDictionaries:''
 	privateIn:UIPainterView
 !
 
-Object subclass:#ViewProperty
-	instanceVariableNames:'view spec identifier'
-	classVariableNames:'Identifier'
+MultiSelectionInList subclass:#ListHolder
+	instanceVariableNames:'painter propertyList masterElement disabledChanged'
+	classVariableNames:''
 	poolDictionaries:''
 	privateIn:UIPainterView
 !
@@ -56,7 +56,12 @@
 
 documentation
 "
-    not yet finished, not yet published, not yet released.
+    buildIn view used by the UIPainter; from this view, the layout of the
+    new application derives from.
+
+    [see also:]
+        UIBuilder
+        UIObjectView
 "
 ! !
 
@@ -329,14 +334,12 @@
     "
     |newSel|
 
-    selection notNil ifTrue:[
-        self selectionDo:[:aView||p|
-            (p := self propertyOfView:aView) notNil ifTrue:[
-                newSel isNil ifTrue:[
-                    newSel := OrderedCollection new
-                ].
-                newSel add:(listHolder indexOfName:(p name))
-            ]
+    self selectionDo:[:aView||p|
+        (p := self propertyOfView:aView) notNil ifTrue:[
+            newSel isNil ifTrue:[
+                newSel := OrderedCollection new
+            ].
+            newSel add:(listHolder indexOfName:(p name))
         ]
     ].
     listHolder removeDependent:self.
@@ -355,10 +358,27 @@
     loIdx size ~~ 0 ifTrue:[
         newSel := loIdx collect:[:i|(listHolder propertyAt:i) view]
     ].
-    self withSelectionHiddenDo:[
-        selection := newSel
+    self updateSelectionFrom:newSel.
+!
+
+updateSelectionFrom:aSel
+    "update selection from a new selection
+    "
+    |csel|
+
+    selectionHiddenLevel == 0 ifTrue:[
+        aSel isCollection ifTrue:[
+            self selectionDo:[:el|
+                (aSel includes:el) ifFalse:[self showUnselected:el]
+            ]
+        ] ifFalse:[
+            self selectionDo:[:el|
+                aSel == el ifFalse:[self showUnselected:el]
+            ]
+        ]
     ].
-
+    self setSelection:aSel withRedraw:false.
+    self showSelection
 ! !
 
 !UIPainterView methodsFor:'copy & cut & paste'!
@@ -368,7 +388,7 @@
     "
     |specs coll|
 
-    coll := self minSetOfSuperViews:selection.
+    coll := self minSetOfSuperViews:(self selection).
 
     coll notNil ifTrue:[
         self unselect.
@@ -385,7 +405,7 @@
     "
     |text specs coll|
 
-    coll := self minSetOfSuperViews:selection.
+    coll := self minSetOfSuperViews:(self selection).
 
     coll notNil ifTrue:[
         listHolder disableNotificationsWhileEvaluating:[
@@ -879,7 +899,9 @@
 groupEnterFields
     |props group objects|
 
-    selection isNil ifTrue:[^ self].
+    self hasSelection ifFalse:[
+        ^ self
+    ].
     self selectionDo:[:aView |
         (aView isKindOf:EditField) ifFalse:[
             self warn:'select EditFields only !!'.
@@ -909,7 +931,9 @@
 groupRadioButtons
     |props name group objects|
 
-    selection isNil ifTrue:[^ self].
+    self hasSelection ifFalse:[
+        ^ self
+    ].
     self selectionDo:[:aView |
         (aView isKindOf:RadioButton) ifFalse:[
             self warn:'select RadioButtons only !!'.
@@ -995,9 +1019,8 @@
 showFontPanel
     |action theFont fontPanel|
 
-    fontPanel := FontPanel new. 
-
-    selection notNil ifTrue:[
+    self hasSelection ifTrue:[
+        fontPanel := FontPanel new. 
         action := [:aFontDescription | theFont := aFontDescription].
         fontPanel action:action.
         fontPanel showAtPointer.
@@ -1006,8 +1029,6 @@
             self changeFont:theFont
         ]
     ]
-
-    "Modified: 10.4.1997 / 10:06:15 / cg"
 !
 
 showMiddleButtonMenu
@@ -1022,18 +1043,13 @@
 
     canPaste := self canPaste:(self getSelection).
 
-    selection isNil ifTrue:[
+    self hasSelection ifTrue:[
+        canPaste := (canPaste and:[self canPasteInto:(self selection)])
+    ] ifFalse:[
         menu disableAll
-    ] ifFalse:[
-        canPaste := (canPaste and:[self canPasteInto:selection])
     ].
-    menu enabledAt:#paste put:[|can|
-        can := self canPaste:(self getSelection).
-        selection isNil ifTrue:[can]
-                       ifFalse:[(can and:[self canPasteInto:selection])]
-    ].
-
-    menu enabledAt:#undo put:(undoHistory notEmpty).
+    menu enabledAt:#paste put:canPaste.
+    menu enabledAt:#undo  put:(undoHistory notEmpty).
     menu startUp.
   ^ nil
 
@@ -1274,9 +1290,7 @@
     ].
 
     aCollection size > 1 ifTrue:[
-        self withSelectionHiddenDo:[
-            selection := aCollection
-        ].
+        self updateSelectionFrom:aCollection.
         self selectionChanged
     ]
 ! !
@@ -1602,6 +1616,102 @@
 
 ! !
 
+!UIPainterView::ViewProperty class methodsFor:'documentation'!
+
+version
+    ^ '$Header$'
+! !
+
+!UIPainterView::ViewProperty class methodsFor:'instance creation'!
+
+new
+    Identifier notNil ifTrue:[Identifier := Identifier + 1]
+                     ifFalse:[Identifier := 1].
+
+  ^ self basicNew initialize
+! !
+
+!UIPainterView::ViewProperty methodsFor:'accessing'!
+
+group
+    ^ nil
+!
+
+identifier
+    "return the unique identifier assigned to property
+    "
+    ^ identifier
+!
+
+spec
+    "return the value of the instance variable 'spec' (automatically generated)"
+
+    ^ spec!
+
+spec:something
+    "set the value of the instance variable 'spec' (automatically generated)"
+
+    spec := something.!
+
+view
+    "return the value of the instance variable 'view' (automatically generated)"
+
+    ^ view!
+
+view:something
+    "set the value of the instance variable 'view' (automatically generated)"
+
+    view := something.! !
+
+!UIPainterView::ViewProperty methodsFor:'initialization'!
+
+initialize
+    super initialize.
+    identifier := Identifier
+! !
+
+!UIPainterView::ViewProperty methodsFor:'misc'!
+
+extractNumberStartingAt:anIndex
+    "return the number from the name starting at anIndex or 0.
+    "
+    |val|
+
+    val := 0.
+
+    self name from:anIndex do:[:c|
+        c isDigit ifTrue:[val := val * 10 + c digitValue]
+                 ifFalse:[^ 0]
+    ].
+    ^ val
+        
+! !
+
+!UIPainterView::ViewProperty methodsFor:'spec messages'!
+
+doesNotUnderstand:aMessage
+    spec notNil ifTrue:[
+        (spec respondsTo:(aMessage selector)) ifTrue:[^ aMessage sendTo:spec]
+    ].
+    ^ nil
+!
+
+layout
+    spec layout
+!
+
+layout:aLayout
+    spec layout:aLayout
+!
+
+name
+    ^ spec name
+!
+
+name:aName
+    spec name:aName
+! !
+
 !UIPainterView::ListHolder class methodsFor:'instance creation'!
 
 for:aPainter
@@ -1933,102 +2043,6 @@
     super selectionIndex:aSel
 ! !
 
-!UIPainterView::ViewProperty class methodsFor:'documentation'!
-
-version
-    ^ '$Header$'
-! !
-
-!UIPainterView::ViewProperty class methodsFor:'instance creation'!
-
-new
-    Identifier notNil ifTrue:[Identifier := Identifier + 1]
-                     ifFalse:[Identifier := 1].
-
-  ^ self basicNew initialize
-! !
-
-!UIPainterView::ViewProperty methodsFor:'accessing'!
-
-group
-    ^ nil
-!
-
-identifier
-    "return the unique identifier assigned to property
-    "
-    ^ identifier
-!
-
-spec
-    "return the value of the instance variable 'spec' (automatically generated)"
-
-    ^ spec!
-
-spec:something
-    "set the value of the instance variable 'spec' (automatically generated)"
-
-    spec := something.!
-
-view
-    "return the value of the instance variable 'view' (automatically generated)"
-
-    ^ view!
-
-view:something
-    "set the value of the instance variable 'view' (automatically generated)"
-
-    view := something.! !
-
-!UIPainterView::ViewProperty methodsFor:'initialization'!
-
-initialize
-    super initialize.
-    identifier := Identifier
-! !
-
-!UIPainterView::ViewProperty methodsFor:'misc'!
-
-extractNumberStartingAt:anIndex
-    "return the number from the name starting at anIndex or 0.
-    "
-    |val|
-
-    val := 0.
-
-    self name from:anIndex do:[:c|
-        c isDigit ifTrue:[val := val * 10 + c digitValue]
-                 ifFalse:[^ 0]
-    ].
-    ^ val
-        
-! !
-
-!UIPainterView::ViewProperty methodsFor:'spec messages'!
-
-doesNotUnderstand:aMessage
-    spec notNil ifTrue:[
-        (spec respondsTo:(aMessage selector)) ifTrue:[^ aMessage sendTo:spec]
-    ].
-    ^ nil
-!
-
-layout
-    spec layout
-!
-
-layout:aLayout
-    spec layout:aLayout
-!
-
-name
-    ^ spec name
-!
-
-name:aName
-    spec name:aName
-! !
-
 !UIPainterView::GroupProperties methodsFor:'accessing'!
 
 controlledObjects