4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS.
17 #include <boost/scoped_ptr.hpp>
19 #include <qapplication.h>
28 /** This class is an Qt2 GUI base class.
30 class QDialogView : public QObject, public Dialog::View {
34 QDialogView(Dialog &, std::string const &);
36 virtual ~QDialogView() {}
38 bool readOnly() const;
40 /// build the actual dialog
41 virtual void build_dialog() = 0;
43 virtual void build() = 0;
46 /// Create the dialog if necessary, update it and display it.
48 /// update the dialog's contents
49 virtual void update_contents() = 0;
51 virtual bool isVisible() const;
53 /// the dialog has changed contents
54 virtual void changed();
56 /// is the dialog currently valid ?
57 virtual bool isValid();
65 // dialog closed from WM
68 // Restore button clicked
74 // Apply button clicked
77 // Close button clicked
80 /// Pointer to the actual instantiation of the Qt dialog
81 virtual QDialog * form() const = 0;
85 template <class GUIDialog>
86 class QView: public QDialogView {
88 QView(Dialog &, std::string const &);
91 virtual void update();
96 /// Pointer to the actual instantiation of the Qt dialog
97 virtual QDialog * form() const;
99 /// Real GUI implementation.
100 boost::scoped_ptr<GUIDialog> dialog_;
105 template <class GUIDialog>
106 QView<GUIDialog>::QView(Dialog & p, std::string const & t)
111 template <class GUIDialog>
112 QDialog * QView<GUIDialog>::form() const
114 /* Brain dead MSVC compiler wants to know the class hierarchy at the
115 definition site of the template, rather than the instantation point
116 to downcast correctly. So, rather than including all dialogs to
117 provide that, we just cast it with the ugly hammer. */
118 return (QDialog *) dialog_.get();
122 template <class GUIDialog>
123 void QView<GUIDialog>::update()
125 form()->setUpdatesEnabled(false);
127 // protect the BC from unwarranted state transitions
133 form()->setUpdatesEnabled(true);
138 template <class GUIDialog>
139 void QView<GUIDialog>::build()
141 // protect the BC from unwarranted state transitions
149 template <class Controller, class Base>
150 class QController: public Base
154 QController(Dialog &, std::string const &);
156 /// The parent controller
157 Controller & controller();
158 /// The parent controller
159 Controller const & controller() const;
163 template <class Controller, class Base>
164 QController<Controller, Base>::QController(Dialog & p, std::string const & t)
169 template <class Controller, class Base>
170 Controller & QController<Controller, Base>::controller()
172 return static_cast<Controller &>(this->getController());
176 template <class Controller, class Base>
177 Controller const & QController<Controller, Base>::controller() const
179 return static_cast<Controller const &>(this->getController());
182 } // namespace frontend
185 #endif // QDIALOGVIEW_H