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.
16 #include <boost/smart_ptr.hpp>
17 #include FORMS_H_LOCATION // Can't forward-declare FL_FORM
25 #include "ButtonPolicies.h"
26 #include "FeedbackController.h"
31 /** This class is an XForms GUI base class.
33 class FormBase : public ViewBC<xformsBC>, public FeedbackController
37 FormBase(ControlButtons &, string const &, bool allowResize);
41 /** input callback function. invoked only by the xforms callback
44 void InputCB(FL_OBJECT *, long);
46 Tooltips & tooltips();
50 virtual void build() = 0;
53 /// Create the dialog if necessary, update it and display it.
56 /** Prepare the way to:
57 * 1. display feedback as the mouse moves over ob. This feedback will
58 * typically be rather more verbose than just a tooltip.
59 * 2. activate the button controller after a paste with the middle
62 static void setPrehandler(FL_OBJECT * ob);
65 /// Pointer to the actual instantiation of xform's form
66 virtual FL_FORM * form() const = 0;
67 /// Filter the inputs on callback from xforms
68 virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
70 /** Redraw the form (on receipt of a Signal indicating, for example,
71 * that the xform colors have been re-mapped).
73 virtual void redraw();
75 /// The dialog's minimum allowable dimensions.
79 /// Can the dialog be resized after it has been created?
81 /// dialog title, displayed by WM.
88 template <class Dialog>
89 class FormDB: public FormBase
93 FormDB(ControlButtons &, string const &, bool allowResize=true);
94 /// Pointer to the actual instantiation of xform's form
95 virtual FL_FORM * form() const;
96 /// Real GUI implementation.
97 boost::scoped_ptr<Dialog> dialog_;
101 template <class Dialog>
102 FormDB<Dialog>::FormDB(ControlButtons & c, string const & t, bool allowResize)
103 : FormBase(c, t, allowResize)
107 template <class Dialog>
108 FL_FORM * FormDB<Dialog>::form() const
110 if (dialog_.get()) return dialog_->form;
115 template <class Controller, class Base>
116 class FormCB: public Base
120 FormCB(Controller &, string const &, bool allowResize=true);
121 /// The parent controller
122 Controller & controller() const;
126 template <class Controller, class Base>
127 FormCB<Controller, Base>::FormCB(Controller & c, string const & t,
129 : Base(c, t, allowResize)
133 template <class Controller, class Base>
134 Controller & FormCB<Controller, Base>::controller() const
136 return static_cast<Controller &>(controller_);
137 //return dynamic_cast<Controller &>(controller_);