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>
17 #include <boost/smart_ptr.hpp>
30 #include "ButtonPolicies.h"
34 /** This class is an Qt2 GUI base class.
36 class FormBase : public QObject, public ViewBC<qt2BC>
41 FormBase(ControlBase &, string const &);
43 virtual ~FormBase() {}
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 FormDB: public FormBase
87 FormDB(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 FormDB<Dialog>::FormDB(ControlBase & c, string const & t)
101 template <class Dialog>
102 QDialog* FormDB<Dialog>::form() const
104 return dialog_.get();
108 template <class Controller, class Base>
109 class FormCB: public Base
113 FormCB(ControlBase &, string const &);
114 /// The parent controller
115 Controller & controller() const;
119 template <class Controller, class Base>
120 FormCB<Controller, Base>::FormCB(ControlBase & c, string const & t)
125 template <class Controller, class Base>
126 Controller & FormCB<Controller, Base>::controller() const
128 return static_cast<Controller &>(controller_);
129 //return dynamic_cast<Controller &>(controller_);