4 * Copyright 2000-2002 the LyX Team
5 * Read the file COPYING
7 * \author Angus Leeming, a.leeming@ic.ac.uk
10 /* A base class for the MCV-ed xforms dialogs.
22 #include "ButtonPolicies.h"
23 #include "FeedbackController.h"
25 #include <boost/scoped_ptr.hpp>
27 #include "forms_fwd.h"
33 /** This class is an XForms GUI base class.
35 class FormBase : public ViewBase, public FeedbackController
39 FormBase(string const &, bool allowResize);
43 /** input callback function. invoked only by the xforms callback
46 void InputCB(FL_OBJECT *, long);
48 Tooltips & tooltips();
52 virtual void build() = 0;
55 /// Create the dialog if necessary, update it and display it.
58 /** Prepare the way to:
59 * 1. display feedback as the mouse moves over ob. This feedback will
60 * typically be rather more verbose than just a tooltip.
61 * 2. activate the button controller after a paste with the middle
64 static void setPrehandler(FL_OBJECT * ob);
70 /// Pointer to the actual instantiation of xform's form
71 virtual FL_FORM * form() const = 0;
72 /// Filter the inputs on callback from xforms
73 virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
75 /** Redraw the form (on receipt of a Signal indicating, for example,
76 * that the xform colors have been re-mapped).
78 virtual void redraw();
80 /// The dialog's minimum allowable dimensions.
84 /// Can the dialog be resized after it has been created?
86 /// dialog title, displayed by WM.
93 template <class Dialog>
94 class FormDB: public FormBase
98 FormDB(string const &, bool allowResize=true);
99 /// Pointer to the actual instantiation of xform's form
100 virtual FL_FORM * form() const;
101 /// Real GUI implementation.
102 boost::scoped_ptr<Dialog> dialog_;
106 template <class Dialog>
107 FormDB<Dialog>::FormDB(string const & t, bool allowResize)
108 : FormBase(t, allowResize)
112 template <class Dialog>
113 FL_FORM * FormDB<Dialog>::form() const
115 if (dialog_.get()) return dialog_->form;
120 template <class Controller, class Base>
121 class FormCB: public Base
125 FormCB(string const &, bool allowResize = true);
126 /// The parent controller
127 Controller & controller();
129 Controller const & controller() const;
133 template <class Controller, class Base>
134 FormCB<Controller, Base>::FormCB(string const & t, bool allowResize)
135 : Base(t, allowResize)
139 template <class Controller, class Base>
140 Controller & FormCB<Controller, Base>::controller()
142 return static_cast<Controller &>(getController());
146 template <class Controller, class Base>
147 Controller const & FormCB<Controller, Base>::controller() const
149 return static_cast<Controller const &>(getController());