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>
24 /** This class is an Qt2 GUI base class.
26 class QDialogView : public QObject, public Dialog::View {
30 QDialogView(Dialog &, std::string const &);
32 virtual ~QDialogView() {}
34 bool readOnly() const;
36 /// build the actual dialog
37 virtual void build_dialog() = 0;
39 virtual void build() = 0;
42 /// Create the dialog if necessary, update it and display it.
44 /// update the dialog's contents
45 virtual void update_contents() = 0;
47 virtual bool isVisible() const;
49 /// the dialog has changed contents
50 virtual void changed();
52 /// is the dialog currently valid ?
53 virtual bool isValid();
61 // dialog closed from WM
64 // Restore button clicked
70 // Apply button clicked
73 // Close button clicked
76 /// Pointer to the actual instantiation of the Qt dialog
77 virtual QDialog * form() const = 0;
81 template <class GUIDialog>
82 class QView: public QDialogView {
84 QView(Dialog &, std::string const &);
87 virtual void update();
92 /// Pointer to the actual instantiation of the Qt dialog
93 virtual QDialog * form() const;
95 /// Real GUI implementation.
96 boost::scoped_ptr<GUIDialog> dialog_;
101 template <class GUIDialog>
102 QView<GUIDialog>::QView(Dialog & p, std::string const & t)
107 template <class GUIDialog>
108 QDialog * QView<GUIDialog>::form() const
110 return dialog_.get();
114 template <class GUIDialog>
115 void QView<GUIDialog>::update()
117 form()->setUpdatesEnabled(false);
119 // protect the BC from unwarranted state transitions
121 qApp->processEvents();
124 qApp->processEvents();
127 form()->setUpdatesEnabled(true);
132 template <class GUIDialog>
133 void QView<GUIDialog>::build()
135 // protect the BC from unwarranted state transitions
137 qApp->processEvents();
140 qApp->processEvents();
145 template <class Controller, class Base>
146 class QController: public Base
150 QController(Dialog &, std::string const &);
152 /// The parent controller
153 Controller & controller();
154 /// The parent controller
155 Controller const & controller() const;
159 template <class Controller, class Base>
160 QController<Controller, Base>::QController(Dialog & p, std::string const & t)
165 template <class Controller, class Base>
166 Controller & QController<Controller, Base>::controller()
168 return static_cast<Controller &>(this->getController());
172 template <class Controller, class Base>
173 Controller const & QController<Controller, Base>::controller() const
175 return static_cast<Controller const &>(this->getController());
179 #endif // QDIALOGVIEW_H