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>
22 #include <qapplication.h>
26 /** This class is an Qt2 GUI base class.
28 class QDialogView : public QObject, public Dialog::View {
32 QDialogView(Dialog &, string const &);
34 virtual ~QDialogView() {}
36 bool readOnly() const;
38 /// build the actual dialog
39 virtual void build_dialog() = 0;
41 virtual void build() = 0;
44 /// Create the dialog if necessary, update it and display it.
46 /// update the dialog's contents
47 virtual void update_contents() = 0;
49 virtual bool isVisible() const;
51 /// the dialog has changed contents
52 virtual void changed();
54 /// is the dialog currently valid ?
55 virtual bool isValid();
63 // dialog closed from WM
66 // Restore button clicked
72 // Apply button clicked
75 // Close button clicked
78 /// Pointer to the actual instantiation of the Qt dialog
79 virtual QDialog * form() const = 0;
83 template <class GUIDialog>
84 class QView: public QDialogView {
86 QView(Dialog &, string const &);
89 virtual void update();
94 /// Pointer to the actual instantiation of the Qt dialog
95 virtual QDialog * form() const;
97 /// Real GUI implementation.
98 boost::scoped_ptr<GUIDialog> dialog_;
103 template <class GUIDialog>
104 QView<GUIDialog>::QView(Dialog & p, string const & t)
109 template <class GUIDialog>
110 QDialog * QView<GUIDialog>::form() const
112 return dialog_.get();
116 template <class GUIDialog>
117 void QView<GUIDialog>::update()
119 form()->setUpdatesEnabled(false);
121 // protect the BC from unwarranted state transitions
123 qApp->processEvents();
126 qApp->processEvents();
129 form()->setUpdatesEnabled(true);
134 template <class GUIDialog>
135 void QView<GUIDialog>::build()
137 // protect the BC from unwarranted state transitions
139 qApp->processEvents();
142 qApp->processEvents();
147 template <class Controller, class Base>
148 class QController: public Base
152 QController(Dialog &, string const &);
154 /// The parent controller
155 Controller & controller();
156 /// The parent controller
157 Controller const & controller() const;
161 template <class Controller, class Base>
162 QController<Controller, Base>::QController(Dialog & p, string const & t)
167 template <class Controller, class Base>
168 Controller & QController<Controller, Base>::controller()
170 return static_cast<Controller &>(this->getController());
174 template <class Controller, class Base>
175 Controller const & QController<Controller, Base>::controller() const
177 return static_cast<Controller const &>(this->getController());
181 #endif // QDIALOGVIEW_H