Now that the previews work and the code is maintainable, I thought I'd return 
to the world of GUI-I and try and clean up the controllers code.

The final instantiation of a dialog is done using a template class GUI. My 
question is, should GUI derive from Controller or contain a Controller. Both 
will work well, so the choice is ours.

The code is shown below. Any opinions?

Angus


HAS A
++++++
template <typename Controller, typename GUIview,
          typename Policy,     typename GUIbc>
class GUI {
public:
        ///
        GUI(LyXView & lv, Dialogs & d) : controller_(lv, d), view_(d)
        {
                controller_.setView(view_);
                controller_.setButtonController(bc_);
                view_.setController(controller_);               
        }
        ///
        Controller & controller() { return controller_; }
        ///
        Controller const & controller() const { return controller_; }

private:
        ///
        Controller controller_;
        ///
        ButtonController<Policy, GUIbc> bc_;
        ///
        GUIview view_;
};


IS A
++++
template <typename Controller, typename GUIview,
          typename Policy,     typename GUIbc>
class GUI : Controller {
public:
        ///
        GUI(LyXView & lv, Dialogs & d) : Controller(lv, d), view_(d)
        {
                setView(view_);
                setButtonController(bc_);
                view_.setController(*this);             
        }

private:
        ///
        ButtonController<Policy, GUIbc> bc_;
        ///
        GUIview view_;
};


Reply via email to