window spec
authorca
Fri, 15 Aug 1997 17:36:02 +0200
changeset 281 aabb4037f6a3
parent 280 1dd13e8107e2
child 282 bb88d92ae887
window spec
UIPainter.st
UIPainterView.st
--- a/UIPainter.st	Wed Aug 13 15:16:57 1997 +0200
+++ b/UIPainter.st	Fri Aug 15 17:36:02 1997 +0200
@@ -1603,6 +1603,43 @@
 
 !UIPainter methodsFor:'selection'!
 
+canvasSelected
+    |spec|
+
+    self hasValidSelection value:false.
+    self canStepIn value:false.
+    self canStepOut value:false.
+    self hasSingleSelection value:false.
+
+    spec := treeView canvasSpec.
+    (builder componentAt:#noteBook) setSelection:nil.
+    self setupSlicesFrom:spec hasLayout:false.
+    tabSelection := nil.
+
+    layoutTool layoutView:nil.
+    specTool specification:spec.
+    self modifiedChannel value:false.
+    self tabSelection:(self tabList value first).
+    specTool selection:tabSelection.
+    (self noteBookView subViews at:2) raise.
+    (builder componentAt:#noteBook) setSelection:1.
+    self modifiedChannel value:false.
+
+!
+
+setupSlicesFrom:aSpec hasLayout:hasLayout
+
+    |slices list|
+
+    slices := aSpec class slices.
+    list   := slices collect:[:aSlice| aSlice first asString].
+
+    hasLayout ifTrue:[
+        list add:(layoutTool class label)
+    ].
+    self tabList value:list.
+!
+
 tabSelection
     "returns current name of section
     "
@@ -1646,7 +1683,10 @@
             self accept
         ]
     ].
-
+    treeView isCanvasSelected ifTrue:[
+        ^ self canvasSelected
+    ].
+        
     props := treeView propertySelected.
     oldSelection := tabSelection.
     tabSelection := nil.
@@ -1661,15 +1701,10 @@
         spec := props spec copy.
 
         layoutTool layoutView == view ifFalse:[
-            slices := spec class slices.
-            size   := slices size + 1.
-            list   := Array new:size.
-            slices keysAndValuesDo:[:i :s|list at:i put:(s first asString)].
-            list at:size put:(layoutTool class label).
-            (self tabList) value:list.
-        ] ifTrue:[
-            list := self tabList value
+            self setupSlicesFrom:spec hasLayout:true.
         ].
+        list := self tabList value.
+
         (list findFirst:[:n| n = oldSelection ]) ~~ 0 ifTrue:[
             tabSelection := oldSelection
         ] ifFalse:[
@@ -2287,6 +2322,32 @@
     model root expand.
     self enableChannel:(aCanvas enableChannel).
 
+!
+
+canvasName:aName
+    "change id of canvas
+    "
+    |name|
+
+    (    aName size ~~ 0
+     and:[(name := aName string withoutSeparators) size ~~ 0
+     and:[(self propertyDetect:[:p| p name = name]) isNil
+     and:[(listOfNodes at:1) name ~= name]]]
+    ) ifTrue:[
+        (listOfNodes at:1) name:name.
+         self redrawLine:1.
+    ]
+!
+
+canvasSpec
+    "returns spec assigned to canvas
+    "
+    |spec|
+
+    spec := WindowSpec new.
+    spec fromView:(self canvas topView) callBack:nil.
+    spec name:(listOfNodes at:1) name.
+  ^ spec
 ! !
 
 !UIPainter::TreeView methodsFor:'accessing property'!
@@ -2478,6 +2539,23 @@
 
 !UIPainter::TreeView methodsFor:'change & update'!
 
+canvasNameChanged:aName
+    "called if identification name assigned to window (canvas) changed
+    "
+    |name node|
+
+    node := listOfNodes at:1.
+
+    (    aName size ~~ 0
+     and:[(name := aName string withoutSeparators) size ~~ 0
+     and:[(self propertyDetect:[:p| p name = name]) isNil
+     and:[node name ~= name]]]
+    ) ifTrue:[
+        node name:name.
+        self redrawLine:1.
+    ].
+!
+
 layoutChanged
     "layout of any component changed; in case of single selection, the
      application will be informed to update its layout
@@ -2712,6 +2790,13 @@
         ]
     ].
   ^ true
+!
+
+isCanvasSelected
+    "returns true in case of a single selection and the
+     selection is the canvas (index 1)
+    "
+    ^ (selection size == 1 and:[self isInSelection:1])
 ! !
 
 !UIPainter::TreeView methodsFor:'user interactions'!
--- a/UIPainterView.st	Wed Aug 13 15:16:57 1997 +0200
+++ b/UIPainterView.st	Fri Aug 15 17:36:02 1997 +0200
@@ -499,7 +499,7 @@
         ]
     ].
     spec := FullSpec new.
-    spec fromBuilder:self components:(SpecCollection new collection:specArray).
+    spec fromBuilder:self topView components:(SpecCollection new collection:specArray).
     specArray := spec literalArrayEncoding.
 
     str := WriteStream on:String new.
@@ -909,6 +909,11 @@
     "
     |props name builder v|
 
+    aSpec class == WindowSpec ifTrue:[
+        aSpec setAttributesIn:self topView with:(UIBuilder new).
+        ^ treeView canvasNameChanged:aSpec name.
+    ].
+
     self singleSelection notNil ifTrue:[
         self withSelectionHiddenDo:[
             self transaction:#specification selectionDo:[:aView|