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>
28 /** This class is an Qt2 GUI base class.
30 class QDialogView : public QObject, public Dialog::View {
34 QDialogView(Dialog &, lyx::docstring const &);
36 virtual ~QDialogView() {}
38 bool readOnly() const;
40 /// the dialog has changed contents
41 virtual void changed();
47 /// build the actual dialog
48 virtual void build_dialog() = 0;
50 virtual void build() = 0;
53 /// Create the dialog if necessary, update it and display it.
55 /// update the dialog's contents
56 virtual void update_contents() = 0;
58 virtual bool isVisible() const;
60 /// is the dialog currently valid ?
61 virtual bool isValid();
67 // dialog closed from WM
70 // Restore button clicked
76 // Apply button clicked
79 // Close button clicked
82 /// Pointer to the actual instantiation of the Qt dialog
83 virtual QDialog * form() const = 0;
87 template <class GUIDialog>
88 class QView: public QDialogView {
90 QView(Dialog &, lyx::docstring const &);
93 virtual void update();
98 /// Pointer to the actual instantiation of the Qt dialog
99 virtual QDialog * form() const;
101 /// Real GUI implementation.
102 boost::scoped_ptr<GUIDialog> dialog_;
107 template <class GUIDialog>
108 QView<GUIDialog>::QView(Dialog & p, lyx::docstring const & t)
113 template <class GUIDialog>
114 QDialog * QView<GUIDialog>::form() const
116 /* Brain dead MSVC compiler wants to know the class hierarchy at the
117 definition site of the template, rather than the instantation point
118 to downcast correctly. So, rather than including all dialogs to
119 provide that, we just cast it with the ugly hammer. */
120 return (QDialog *) dialog_.get();
124 template <class GUIDialog>
125 void QView<GUIDialog>::update()
127 form()->setUpdatesEnabled(false);
129 // protect the BC from unwarranted state transitions
135 form()->setUpdatesEnabled(true);
140 template <class GUIDialog>
141 void QView<GUIDialog>::build()
143 // protect the BC from unwarranted state transitions
151 template <class Controller, class Base>
152 class QController: public Base
156 QController(Dialog &, docstring const &);
158 /// The parent controller
159 Controller & controller();
160 /// The parent controller
161 Controller const & controller() const;
165 template <class Controller, class Base>
166 QController<Controller, Base>::QController(Dialog & p, docstring const & t)
171 template <class Controller, class Base>
172 Controller & QController<Controller, Base>::controller()
174 return static_cast<Controller &>(this->getController());
178 template <class Controller, class Base>
179 Controller const & QController<Controller, Base>::controller() const
181 return static_cast<Controller const &>(this->getController());
184 } // namespace frontend
187 #endif // QDIALOGVIEW_H