2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000 The LyX Team.
9 * ======================================================
11 * \author Angus Leeming <a.leeming@ic.ac.uk>
30 #include "ButtonPolicies.h"
31 #include "ControlButtons.h"
33 #include <boost/smart_ptr.hpp>
37 /** This class is an Qt2 GUI base class.
39 class Qt2Base : public QObject, public ViewBC<Qt2BC>
44 Qt2Base(ControlButtons &, const QString &);
50 virtual void build() = 0;
53 /// Create the dialog if necessary, update it and display it.
56 /// the dialog has changed contents
57 virtual void changed();
59 /// is the dialog currently valid ?
60 virtual bool isValid();
63 // dialog closed from WM
66 // Apply button clicked
72 // Cancel button clicked
75 // Restore button clicked
79 /// Pointer to the actual instantiation of xform's form
80 virtual QDialog* form() const = 0;
83 /// dialog title, displayed by WM.
88 template <class Dialog>
89 class Qt2DB: public Qt2Base
93 Qt2DB(ControlButtons &, const QString&);
94 /// Pointer to the actual instantiation of the Qt dialog
95 virtual QDialog* form() const;
96 /// Real GUI implementation.
97 boost::scoped_ptr<Dialog> dialog_;
101 template <class Dialog>
102 Qt2DB<Dialog>::Qt2DB(ControlButtons & c, const QString& t)
107 template <class Dialog>
108 QDialog* Qt2DB<Dialog>::form() const
110 return dialog_.get();
114 template <class Controller, class Base>
115 class Qt2CB: public Base
119 Qt2CB(ControlButtons &, const QString&);
120 /// The parent controller
121 Controller & controller() const;
125 template <class Controller, class Base>
126 Qt2CB<Controller, Base>::Qt2CB(ControlButtons & c, const QString& t)
131 template <class Controller, class Base>
132 Controller & Qt2CB<Controller, Base>::controller() const
134 return static_cast<Controller &>(controller_);
135 //return dynamic_cast<Controller &>(controller_);