2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000 The LyX Team.
9 * ======================================================
11 * \author Angus Leeming <a.leeming@ic.ac.uk>
22 #include <boost/smart_ptr.hpp>
30 #include "ButtonPolicies.h"
34 /** This class is an Qt2 GUI base class.
36 class Qt2Base : public QObject, public ViewBC<qt2BC>
41 Qt2Base(ControlBase &, string const &);
47 virtual void build() = 0;
50 /// Create the dialog if necessary, update it and display it.
54 // dialog closed from WM
57 // Apply button clicked
63 // Cancel button clicked
66 // Restore button clicked
70 /// Pointer to the actual instantiation of xform's form
71 virtual QDialog* form() const = 0;
72 /** Filter the inputs on callback from xforms
73 Return true if inputs are valid. */
74 virtual ButtonPolicy::SMInput input(QWidget*, long);
77 /// dialog title, displayed by WM.
82 template <class Dialog>
83 class Qt2DB: public Qt2Base
87 Qt2DB(ControlBase &, string const &);
88 /// Pointer to the actual instantiation of the Qt dialog
89 virtual QDialog* form() const;
90 /// Real GUI implementation.
91 boost::scoped_ptr<Dialog> dialog_;
95 template <class Dialog>
96 Qt2DB<Dialog>::Qt2DB(ControlBase & c, string const & t)
101 template <class Dialog>
102 QDialog* Qt2DB<Dialog>::form() const
104 return dialog_.get();
108 template <class Controller, class Base>
109 class Qt2CB: public Base
113 Qt2CB(ControlBase &, string const &);
114 /// The parent controller
115 Controller & controller() const;
119 template <class Controller, class Base>
120 Qt2CB<Controller, Base>::Qt2CB(ControlBase & c, string const & t)
125 template <class Controller, class Base>
126 Controller & Qt2CB<Controller, Base>::controller() const
128 return static_cast<Controller &>(controller_);
129 //return dynamic_cast<Controller &>(controller_);