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
129 qApp->processEvents();
132 qApp->processEvents();
135 form()->setUpdatesEnabled(true);
140 template <class GUIDialog>
141 void QView<GUIDialog>::build()
143 // protect the BC from unwarranted state transitions
145 qApp->processEvents();
148 qApp->processEvents();
153 template <class Controller, class Base>
154 class QController: public Base
158 QController(Dialog &, std::string const &);
160 /// The parent controller
161 Controller & controller();
162 /// The parent controller
163 Controller const & controller() const;
167 template <class Controller, class Base>
168 QController<Controller, Base>::QController(Dialog & p, std::string const & t)
173 template <class Controller, class Base>
174 Controller & QController<Controller, Base>::controller()
176 return static_cast<Controller &>(this->getController());
180 template <class Controller, class Base>
181 Controller const & QController<Controller, Base>::controller() const
183 return static_cast<Controller const &>(this->getController());
186 } // namespace frontend
189 #endif // QDIALOGVIEW_H