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.
55 /// reset after an update
58 /// the dialog has changed contents
59 virtual void changed();
61 /// is the dialog currently valid ?
62 virtual bool isValid();
65 // dialog closed from WM
68 // Restore button clicked
74 // Apply button clicked
77 // Close button clicked
81 /// Pointer to the actual instantiation of xform's form
82 virtual QDialog* form() const = 0;
85 /// dialog title, displayed by WM.
90 template <class Dialog>
91 class Qt2DB: public Qt2Base
94 Qt2DB(ControlButtons &, const QString&);
96 /// Pointer to the actual instantiation of the Qt dialog
97 virtual QDialog* form() const;
98 /// Real GUI implementation.
99 boost::scoped_ptr<Dialog> dialog_;
104 template <class Dialog>
105 Qt2DB<Dialog>::Qt2DB(ControlButtons & c, const QString& t)
110 template <class Dialog>
111 QDialog* Qt2DB<Dialog>::form() const
113 return dialog_.get();
117 template <class Controller, class Base>
118 class Qt2CB: public Base
122 Qt2CB(ControlButtons &, const QString&);
123 /// The parent controller
124 Controller & controller() const;
128 template <class Controller, class Base>
129 Qt2CB<Controller, Base>::Qt2CB(ControlButtons & c, const QString& t)
134 template <class Controller, class Base>
135 Controller & Qt2CB<Controller, Base>::controller() const
137 return static_cast<Controller &>(controller_);
138 //return dynamic_cast<Controller &>(controller_);