Who said that this might delay GUII if "Angus gets carried away with his 
controller separation"? Shame on you, Allan!

Here is a working example of View-Controller separation for the citation 
dialog. The attached file contains two directories:

CURRENT/
CURRENT/form_citation.fd
CURRENT/FormCitation.C
CURRENT/FormCitation.h
PROPOSED/
PROPOSED/FormCitation.C
PROPOSED/FormCitation.h                                                       

CURRENT contains the present Citation dialog code, but I've folded in all the 
FormBase-FormInset stuff to see exactly what was going on. This has resulted 
in changes to form_citation.fd (the Callback function names). I also took the 
opportunity to rename the FL_OBJECTs with Allan-standard names!

PROPOSED contains the View-Controller separated stuff. 

At the moment, classes ViewCitation, ControlCitation and FormCitation (the 
xforms instantiation) are defined and declared in FormCitation.[Ch]. 
Obviously the Controller and View abstract base class would eventually go in 
their own file in frontends/ (or frontends/dialogs/ ?).

To try it out you'll need to copy form_ciation.fd into forms/ and replace the 
existing FormCitation.[Ch]. You'll also need to apply the patch below to 
Dialogs.C.

There is no change in functionality, but now FormCitation is responsible only 
for the InsetCommandParams instance passed to it. The Controller deals with 
the kernel.

I'd value comments.
Angus


Index: src/frontends/xforms/Dialogs.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/Dialogs.C,v
retrieving revision 1.20
diff -u -r1.20 Dialogs.C
--- src/frontends/xforms/Dialogs.C      2000/11/15 03:22:07     1.20
+++ src/frontends/xforms/Dialogs.C      2001/01/11 14:58:54
@@ -45,7 +45,11 @@
 
 Dialogs::Dialogs(LyXView * lv)
 {
-       dialogs_.push_back(new FormCitation(lv, this));
+       // No attempt made to derive ControlCitation from DialogBase. 
+       // Would happen in reality.
+       ControlCitation * citation = new ControlCitation(*lv, *this);
+       citation->setView(new FormCitation(*citation));
+
        dialogs_.push_back(new FormCopyright(lv, this));
        dialogs_.push_back(new FormDocument(lv, this));
        dialogs_.push_back(new FormError(lv, this));




mvc.tar.bz2

Reply via email to