Move rest of menuHolder/menuPerformer stuff to view.
authorStefan Vogel <sv@exept.de>
Fri, 03 Jan 1997 03:04:26 +0100
changeset 1151 1a3682212ea9
parent 1150 a3d2fa5c5e6a
child 1152 21c666e130dd
Move rest of menuHolder/menuPerformer stuff to view.
View.st
--- a/View.st	Thu Jan 02 17:39:36 1997 +0100
+++ b/View.st	Fri Jan 03 03:04:26 1997 +0100
@@ -56,8 +56,12 @@
         menuMsg         <nil | Symbol>      the menuMessage; typically
                                             dependentViews send this message to
                                             the model to ask for a popup menu.
-                                            Some classes allow setting an explicit
-                                            menuHolder and menuPerformer.
+
+        menuHolder      <any>               an Object, that will receive the
+                                            menuMsg to retrieve a popup menu.
+
+        menuPerformer   <any>               an Object, that will reveive the
+                                            selected message from a popup menu.
 
     [see also:]
         StandardSystemView TopView DialogBox
@@ -159,6 +163,15 @@
      should redefine this to return nil"
 
     ^ #value:
+!
+
+defaultMenuMessage   
+    "subclasses which by default do NOT want to send menu messages
+     should return nil"
+
+    ^ nil
+
+    "Created: 3.1.1997 / 01:50:36 / stefan"
 ! !
 
 !View methodsFor:'accessing-channels'!
@@ -349,11 +362,13 @@
 !
 
 model:aModel
-    "set the model.
+    "Set the model.
      Here, if I am my own menuPerformer/menuHolder,
-     set the menuHolder to the model. This is a compatibility kludge,
+     set the menuHolder and menuPerformer to the model. 
+     This is a compatibility kludge,
      since typically, ST-80 code expects the model to provide a menu
-     and the view to perform it.
+     and perform it. If the model does not support a menu message,
+     it will be forwarded to the view.
      Those apps which want the view to provide the (default) menu have to reset
      this by sending #menuHolder: message (again)"
 
@@ -371,7 +386,7 @@
         controller model:aModel
     ]
 
-    "Modified: 31.12.1996 / 15:02:28 / stefan"
+    "Modified: 3.1.1997 / 01:46:40 / stefan"
 !
 
 modelInterface
@@ -523,12 +538,22 @@
 
     aspectMsg := self class defaultAspectMessage.
     changeMsg := self class defaultChangeMessage.
+    menuMsg := self class defaultMenuMessage.
+
+    "
+     initialize menu to be provided and performed by myself.
+     This allows textViews without a model to provide a
+     reasonable menu AND allows models to provide their own menu.
+    "
+    menuHolder := menuPerformer := self.
 
     model notNil ifTrue:[
-	controller notNil ifTrue:[
-	    controller model:model
-	]
+        controller notNil ifTrue:[
+            controller model:model
+        ]
     ].
+
+    "Modified: 3.1.1997 / 01:56:22 / stefan"
 ! !
 
 !View methodsFor:'realization'!
@@ -547,5 +572,5 @@
 !View class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/View.st,v 1.54 1997-01-02 16:29:06 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/View.st,v 1.55 1997-01-03 02:04:26 stefan Exp $'
 ! !