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.
16 #include <boost/scoped_ptr.hpp>
18 #include <qapplication.h>
27 /** This class is an Qt2 GUI base class.
29 class QDialogView : public QObject, public Dialog::View {
33 QDialogView(Dialog &, std::string const &);
35 virtual ~QDialogView() {}
37 bool readOnly() const;
39 /// build the actual dialog
40 virtual void build_dialog() = 0;
42 virtual void build() = 0;
45 /// Create the dialog if necessary, update it and display it.
47 /// update the dialog's contents
48 virtual void update_contents() = 0;
50 virtual bool isVisible() const;
52 /// the dialog has changed contents
53 virtual void changed();
55 /// is the dialog currently valid ?
56 virtual bool isValid();
64 // dialog closed from WM
67 // Restore button clicked
73 // Apply button clicked
76 // Close button clicked
79 /// Pointer to the actual instantiation of the Qt dialog
80 virtual QDialog * form() const = 0;
84 template <class GUIDialog>
85 class QView: public QDialogView {
87 QView(Dialog &, std::string const &);
90 virtual void update();
95 /// Pointer to the actual instantiation of the Qt dialog
96 virtual QDialog * form() const;
98 /// Real GUI implementation.
99 boost::scoped_ptr<GUIDialog> dialog_;
104 template <class GUIDialog>
105 QView<GUIDialog>::QView(Dialog & p, std::string const & t)
110 template <class GUIDialog>
111 QDialog * QView<GUIDialog>::form() const
113 return dialog_.get();
117 template <class GUIDialog>
118 void QView<GUIDialog>::update()
120 form()->setUpdatesEnabled(false);
122 // protect the BC from unwarranted state transitions
124 qApp->processEvents();
127 qApp->processEvents();
130 form()->setUpdatesEnabled(true);
135 template <class GUIDialog>
136 void QView<GUIDialog>::build()
138 // protect the BC from unwarranted state transitions
140 qApp->processEvents();
143 qApp->processEvents();
148 template <class Controller, class Base>
149 class QController: public Base
153 QController(Dialog &, std::string const &);
155 /// The parent controller
156 Controller & controller();
157 /// The parent controller
158 Controller const & controller() const;
162 template <class Controller, class Base>
163 QController<Controller, Base>::QController(Dialog & p, std::string const & t)
168 template <class Controller, class Base>
169 Controller & QController<Controller, Base>::controller()
171 return static_cast<Controller &>(this->getController());
175 template <class Controller, class Base>
176 Controller const & QController<Controller, Base>::controller() const
178 return static_cast<Controller const &>(this->getController());
181 } // namespace frontend
184 #endif // QDIALOGVIEW_H