On Wednesday 28 February 2001 13:52, Allan Rae wrote:
> P.S. Yeah, I know I should checkout BRANCH_MVC.

;-)

In BRANCH_MVC you would find a directory frontends/controllers. It contains 
the GUI-I controllers for GUI-specific views. They are all derived from 
ControlBase:

class ControlBase {
        ButtonController & bc_;
        ViewBase & view_;
}

ButtonController is currently identical to your original class, except that 
refresh() is now an abstract method to be instantiated by a GUI-specific 
derived class. (Actually, it's not identical. The class stores and manages 
(ie deletes) the ButtonPolicy; this was what incurred Lars' wrath originally.)

Similarly, all GUI-specific views are derived from ViewBase. 

We could keep ButtonController & bc_ in ControlBase if the class were changed 
to be a pure abstract class containing the interface (which is the same, 
whatever the policy). Then each individual controller could pass a 
        new PoliciedButtonController<WhateverPolicy> 
to the ControlBase c-tor, where

template <class BP>
class PoliciedButtonController: public ButtonController {
        BP policy;
}

This would resolve the ButtonPolicy issue. All that remains to sort out is 
that ControlBase would delete bc_ but not "new" it. (Same result: Lars' 
disgust!)  Maybe his mail about boost's scoped_ptr would help here.

> Anyway, if you are just going to create an instance of a BC in each
> dialogs controller then converting back to a template will take a couple
> of minutes followed by hours of fun converting all the other dialogs to
> have separate controllers and removing BC from the FormBase.

:-(

Actually, it'll do the dialogs good to be converted. Some of them 
(Preferences springs to mind) are a little creaky. Creating the controllers 
provides the oportunity to create classes like lyxrcParams. They can be used 
locally by the controller/view for the time being, but can be designed to 
have a nice, clean interface. Once working, that can be ported back into the 
LyX kernel without breaking everything in the process.

class lyxrcParams {
public:
        enum Strings {
                DATE_INSERT,
                POPUP_FONT_NAME
        };
        enum Ints {
                OVERRIDE_X_DEADKEYS,
                USE_KBMAP
        };

        string get(Strings) const;
        void set(Strings, string const &);

        int get(Ints) const;
        int set(Ints, int);
};

Reply via email to