SubCanvas.st
changeset 503 0a3ef2d34d9d
parent 455 860d66c9f047
child 553 3535a0682ac7
--- a/SubCanvas.st	Tue Aug 26 17:42:47 1997 +0200
+++ b/SubCanvas.st	Tue Aug 26 17:43:33 1997 +0200
@@ -1,5 +1,5 @@
 ScrollableView subclass:#SubCanvas
-	instanceVariableNames:'client spec application'
+	instanceVariableNames:'builder spec client clientHolder specHolder'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Views-Basic'
@@ -8,34 +8,15 @@
 
 !SubCanvas methodsFor:'accessing'!
 
-releaseAllComponents
-    scrolledView destroySubViews.
-! !
-
-!SubCanvas methodsFor:'initialization'!
+builder
+    "return the value of the instance variable 'builder' (automatically generated)"
 
-initialize
-    super initialize.
-    self scrolledView:View new
-! !
-
-!SubCanvas methodsFor:'queries'!
+    ^ builder!
 
-application
-    "return the application, under which this view was opened,
-    "
+client
+    "return the value of the instance variable 'client' (automatically generated)"
 
-    application notNil ifTrue:[
-        ^ application
-    ].
-    ^ super application
-
-    "Modified: 13.1.1997 / 20:30:31 / cg"
-
-
-! !
-
-!SubCanvas methodsFor:'rebuilding'!
+    ^ client!
 
 client:anApplicationModel
     "release existing components and generate new components from
@@ -44,60 +25,156 @@
     ^ self client:anApplicationModel spec:#windowSpec
 !
 
-client:anApplicationModel spec:aWindowSpec
+client:anApplication spec:aWindowSpecOrSelector
     "release existing components and generate new components from
      the applications windowSpec."
 
-    |b newBuilder|
-
-    "/ If the application already has a builder, create a subBilder;
-    "/ otherwise a new one
+    |aBuilder|
 
-    ((anApplicationModel respondsTo:#builder)
-      and:[(b := anApplicationModel builder) notNil]) ifTrue:[
-          newBuilder := b. "/ newSubBuilder
+    (anApplication notNil and:[anApplication respondsTo:#builder]) ifTrue:[
+        aBuilder := anApplication builder
     ] ifFalse:[
-        newBuilder := UIBuilder new
+        aBuilder := UIBuilder new
     ].
-    ^ self client:anApplicationModel spec:aWindowSpec builder:newBuilder
-
-    "Created: 6.3.1997 / 15:53:25 / cg"
-    "Modified: 6.3.1997 / 15:59:44 / cg"
+  ^ self client:anApplication spec:aWindowSpecOrSelector builder:aBuilder
 !
 
-client:anApplicationModel spec:aWindowSpecOrSpecSymbol builder:aBuilder
+client:anApplication spec:aWindowSpecOrSpecSymbol builder:aBuilder
     "release existing components and generate new components from
      the given windowSpec, using the given builder."
 
-    |spec |
+    builder  := aBuilder.
+    spec     := aWindowSpecOrSpecSymbol.
+
+    "/ check for master application
+    (anApplication notNil and:[anApplication masterApplication isNil]) ifTrue:[
+        client := nil.
+        client := self application.
+        client ~~ anApplication ifTrue:[
+            anApplication masterApplication:client
+        ]
+    ].
+    client := anApplication.
+    self rebuild.
+  ^ builder
+!
+
+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.
+    self rebuild.
+! !
+
+!SubCanvas methodsFor:'accessing channels'!
+
+clientHolder
+    ^ clientHolder
+!
+
+clientHolder:aValueHolder
+
+    clientHolder notNil ifTrue:[
+        clientHolder removeDependent:self
+    ].
+    (clientHolder := aValueHolder) notNil ifTrue:[
+        clientHolder addDependent:self
+    ].
+    self client:clientHolder value
+!
+
+specHolder
+    ^ specHolder
+!
+
+specHolder:aValueHolder
+
+    specHolder notNil ifTrue:[
+        specHolder removeDependent:self
+    ].
+    (specHolder := aValueHolder) notNil ifTrue:[
+        specHolder addDependent:self
+    ].
+    self spec:spec value
+! !
+
+!SubCanvas methodsFor:'building'!
+
+rebuild
+    "rebuild
+    "
+    |win|
 
     scrolledView notNil ifTrue:[
         scrolledView destroySubViews
     ].
 
-    spec := aWindowSpecOrSpecSymbol.
-
-    application := anApplicationModel.
-
-    spec isSymbol ifTrue:[
-        anApplicationModel isNil ifTrue:[
-            spec := nil
-        ] ifFalse:[
-            spec := anApplicationModel class interfaceSpecFor:spec
-        ]
+    builder isNil ifTrue:[
+        builder := UIBuilder new
     ].
 
     spec notNil ifTrue:[
-        aBuilder buildFromSpec:spec in:scrolledView.
+        (win := spec) isSymbol ifTrue:[
+            (client isNil or:[(win := client class interfaceSpecFor:spec) isNil]) ifTrue:[
+                ^ self
+            ]
+        ].
+        builder buildFromSpec:win in:scrolledView.
+
+        self realized ifTrue:[
+            scrolledView realizeAllSubViews
+        ]
+    ]
+!
+
+releaseAllComponents
+    scrolledView destroySubViews.
+    builder := nil.
+    spec    := nil.
+    client  := nil.
+! !
+
+!SubCanvas methodsFor:'change & update'!
+
+update:something with:aParameter from:changedObject
+    "one of my models changed its value
+    "
+    changedObject == clientHolder ifTrue:[^ self client:(clientHolder value)].
+    changedObject == specHolder   ifTrue:[^ self spec:(specHolder value)].
+
+    super update:something with:aParameter from:changedObject.
+
+
+! !
+
+!SubCanvas methodsFor:'initialization'!
+
+initialize
+    super initialize.
+    self scrolledView:View new.
+    spec := #windowSpec.
+! !
+
+!SubCanvas methodsFor:'queries'!
+
+application
+    "return the application, under which this view was opened,
+    "
+
+    client notNil ifTrue:[
+        ^ client
     ].
-    self realized ifTrue:[
-        scrolledView realizeAllSubViews
-    ].
-    ^ aBuilder
+    ^ super application
+
 ! !
 
 !SubCanvas class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/SubCanvas.st,v 1.1 1997-07-04 21:17:46 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/SubCanvas.st,v 1.2 1997-08-26 15:43:33 ca Exp $'
 ! !