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 ViewBC<xformsBC>, public FeedbackController
39 FormBase(ControlButtons &, Dialogs &,
40 string const &, bool allowResize);
44 /** input callback function. invoked only by the xforms callback
47 void InputCB(FL_OBJECT *, long);
49 Tooltips & tooltips();
53 virtual void build() = 0;
56 /// Create the dialog if necessary, update it and display it.
59 /** Prepare the way to:
60 * 1. display feedback as the mouse moves over ob. This feedback will
61 * typically be rather more verbose than just a tooltip.
62 * 2. activate the button controller after a paste with the middle
65 static void setPrehandler(FL_OBJECT * ob);
68 /// Pointer to the actual instantiation of xform's form
69 virtual FL_FORM * form() const = 0;
70 /// Filter the inputs on callback from xforms
71 virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
73 /** Redraw the form (on receipt of a Signal indicating, for example,
74 * that the xform colors have been re-mapped).
76 virtual void redraw();
78 /// The dialog's minimum allowable dimensions.
82 /// Can the dialog be resized after it has been created?
84 /// dialog title, displayed by WM.
91 template <class Dialog>
92 class FormDB: public FormBase
96 FormDB(ControlButtons &, Dialogs &,
97 string const &, bool allowResize=true);
98 /// Pointer to the actual instantiation of xform's form
99 virtual FL_FORM * form() const;
100 /// Real GUI implementation.
101 boost::scoped_ptr<Dialog> dialog_;
105 template <class Dialog>
106 FormDB<Dialog>::FormDB(ControlButtons & c, Dialogs & d,
107 string const & t, bool allowResize)
108 : FormBase(c, d, 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(Controller &, Dialogs &,
126 string const &, bool allowResize = true);
127 /// The parent controller
128 Controller & controller() const;
132 template <class Controller, class Base>
133 FormCB<Controller, Base>::FormCB(Controller & c, Dialogs & d,
134 string const & t, bool allowResize)
135 : Base(c, d, t, allowResize)
139 template <class Controller, class Base>
140 Controller & FormCB<Controller, Base>::controller() const
142 return static_cast<Controller &>(controller_);
143 //return dynamic_cast<Controller &>(controller_);