new indication of the master widget
authortz
Wed, 22 Apr 1998 23:26:07 +0200
changeset 805 99e70b6c02e5
parent 804 b66537045e04
child 806 4faf081e981d
new indication of the master widget
UIPainter.st
--- a/UIPainter.st	Wed Apr 22 22:17:27 1998 +0200
+++ b/UIPainter.st	Wed Apr 22 23:26:07 1998 +0200
@@ -818,8 +818,6 @@
               )
           )
       )
-
-    "Modified: / 19.4.1998 / 20:43:10 / cg"
 ! !
 
 !UIPainter class methodsFor:'menu specs'!
@@ -3377,31 +3375,23 @@
 cvsSelection:aSelection
     "canvas changed its selection
     "
-    |sel list|
-
-    (     aSelection isNil
-     or:[(aSelection isCollection and:[aSelection isEmpty])]
-    ) ifTrue:[
-        ^ self cvsEventsDisabledDo:[ self selection:sel ]
+    |sel list size|
+
+    ((sel := aSelection) isNil or:[sel isCollection]) ifFalse:[
+        sel := Array with:sel
     ].
-    list := OrderedCollection new.
-
-    aSelection isCollection ifTrue:[
-        aSelection notNil ifTrue:[sel := aSelection]
-    ] ifFalse:[
-        sel := Array with:aSelection
+
+    (size := sel size) ~~ 0 ifTrue:[
+        list := OrderedCollection new:size.
+
+        sel do:[:aView||item|
+            (item := self itemOfView:aView) notNil ifTrue:[
+                list add:item.
+                model doMakeVisible:item.
+            ]
+        ].
+        sel := list collect:[:anItem| self indexOfNode:anItem ].
     ].
-
-    list := OrderedCollection new:(sel size).
-    self setSelection:nil.
-
-    sel do:[:aView||item|
-        (item := self itemOfView:aView) notNil ifTrue:[
-            list add:item.
-            model doMakeVisible:item.
-        ]
-    ].
-    sel := list collect:[:anItem| self indexOfNode:anItem ].
     self cvsEventsDisabledDo:[ self selection:sel ].            
 
 
@@ -3561,6 +3551,23 @@
     ]
 
 
+!
+
+drawLabelIndex:anIndex atX:textX y:yCenter
+    "draws a tiny rectangle for indicating the master node (first selected node)"
+
+    |dX|
+
+    super drawLabelIndex:anIndex atX:textX y:yCenter.
+
+    ((selection size > 1) and: [selection first == anIndex]) ifTrue:[
+        dX := textInset - 1.
+        self paint:self application painter handleMasterColor.
+        self fillRectangleX:(textX - dX - 2)
+                          y:yCenter + 2 - (fontHeight // 2)
+                      width:dX
+                     height:dX
+    ]
 ! !
 
 !UIPainter::TreeView methodsFor:'initialization'!
@@ -3587,16 +3594,8 @@
     [:aNode|
         |spec|
         (spec := aNode contents spec) notNil
-        ifTrue:  
-        [   
-            ((selection size > 1) and: [(listOfNodes at:selection first) == aNode])
-                ifTrue: [(Text string:'M' foregroundColor:Color black backgroundColor:Color red), ' ',(self nameForSpecInList:spec)] 
-                ifFalse:[self nameForSpecInList:spec]
-        ] 
-        ifFalse: 
-        [
-            aNode name
-        ]
+            ifTrue: [self nameForSpecInList:spec] 
+            ifFalse:[aNode name]
     ]
 ! !