John Levon wrote: > On Fri, Jun 13, 2003 at 12:09:21AM +0000, Angus Leeming wrote: > >> John, please have a look at this. > > Looks fine, thanks for doing this. > > regards > john
You haven't answered my question ;-) > Would you like me to create new files QMathMatrix.[Ch] rather than > store two classes, QMath and QMathMatrix, in QMath.[Ch]? Actually, since QMath, QMathMatrix and indeed QDelimiter are functionally identical, we could templatise them: template<typename MathDialog> class QMath : public QController<ControlMath2, QView<MathDialog> > { public: friend class MathDialog; typedef QController<ControlMath2, QView<MathDialog> > Base; QMath(Dialog &); private: virtual void apply() {} virtual void update_contents() {} virtual void build_dialog(); }; template<typename MathDialog> QMath<MathDialog>::QMath(Dialog & parent) : Base(parent, _("LyX: Math Panel")) {} template<typename MathDialog> QMath<MathDialog>::build_dialog() { dialog_.reset(new MathDialog(this)); } And build them in Dialogs::build: #include "QMathDialog.h" #include "QMathMatrixDialog.h" #include "QDelimiterDialog.h" } else if (name == "math") { dialog->setController(new ControlMath2(*dialog)); dialog->setView(new QMath<QMathDialog>(*dialog)); dialog->bc().bp(new IgnorantPolicy); } else if (name == "mathmatrix") { dialog->setController(new ControlMath2(*dialog)); dialog->setView(new QMath<QMathMatrixDialog>(*dialog)); dialog->bc().bp(new IgnorantPolicy); } else if (name == "mathdelimiter") { dialog->setController(new ControlMath2(*dialog)); dialog->setView(new QMath<QDelimiterDialog>(*dialog)); dialog->bc().bp(new IgnorantPolicy); } ... Note that this would "pollute" Dialogs.C with these QMathXYZDialog.h header files... So, which way do you want to go? * Leave as is. Three separate classes Qmath, QMathMatrix, QMathDelimiter all in QMath.[Ch]. * Three separate classes need three separate files. * Define a template in QMath.h... Your call, as you'll end up maintaining it ;-) -- Angus