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
12 /* A base class for the MCV-ed xforms dialogs.
24 #include "ButtonPolicies.h"
25 #include "FeedbackController.h"
27 #include <boost/scoped_ptr.hpp>
29 #include "forms_fwd.h"
35 /** This class is an XForms GUI base class.
37 class FormBase : public ViewBase, public FeedbackController
41 FormBase(string const &, bool allowResize);
45 /** input callback function. invoked only by the xforms callback
48 void InputCB(FL_OBJECT *, long);
50 Tooltips & tooltips();
54 virtual void build() = 0;
57 /// Create the dialog if necessary, update it and display it.
60 /** Prepare the way to:
61 * 1. display feedback as the mouse moves over ob. This feedback will
62 * typically be rather more verbose than just a tooltip.
63 * 2. activate the button controller after a paste with the middle
66 static void setPrehandler(FL_OBJECT * ob);
72 /// Pointer to the actual instantiation of xform's form
73 virtual FL_FORM * form() const = 0;
74 /// Filter the inputs on callback from xforms
75 virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
77 /** Redraw the form (on receipt of a Signal indicating, for example,
78 * that the xform colors have been re-mapped).
80 virtual void redraw();
82 /// The dialog's minimum allowable dimensions.
86 /// Can the dialog be resized after it has been created?
88 /// dialog title, displayed by WM.
95 template <class Dialog>
96 class FormDB: public FormBase
100 FormDB(string const &, bool allowResize=true);
101 /// Pointer to the actual instantiation of xform's form
102 virtual FL_FORM * form() const;
103 /// Real GUI implementation.
104 boost::scoped_ptr<Dialog> dialog_;
108 template <class Dialog>
109 FormDB<Dialog>::FormDB(string const & t, bool allowResize)
110 : FormBase(t, allowResize)
114 template <class Dialog>
115 FL_FORM * FormDB<Dialog>::form() const
117 if (dialog_.get()) return dialog_->form;
122 template <class Controller, class Base>
123 class FormCB: public Base
127 FormCB(string const &, bool allowResize = true);
128 /// The parent controller
129 Controller & controller();
131 Controller const & controller() const;
135 template <class Controller, class Base>
136 FormCB<Controller, Base>::FormCB(string const & t, bool allowResize)
137 : Base(t, allowResize)
141 template <class Controller, class Base>
142 Controller & FormCB<Controller, Base>::controller()
144 return static_cast<Controller &>(getController());
148 template <class Controller, class Base>
149 Controller const & FormCB<Controller, Base>::controller() const
151 return static_cast<Controller const &>(getController());