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
43 void InputCB(FL_OBJECT *, long);
45 Tooltips & tooltips();
49 virtual void build() = 0;
52 /// Create the dialog if necessary, update it and display it.
55 /** Prepare the way to:
56 1. display feedback as the mouse moves over ob. This feedback will
57 typically be rather more verbose than just a tooltip.
58 2. activate the button controller after a paste with the middle
61 static void setPrehandler(FL_OBJECT * ob);
64 /// Pointer to the actual instantiation of xform's form
65 virtual FL_FORM * form() const = 0;
66 /// Filter the inputs on callback from xforms
67 virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
69 /** Redraw the form (on receipt of a Signal indicating, for example,
70 that the xform colors have been re-mapped). */
71 virtual void redraw();
73 /// The dialog's minimum allowable dimensions.
77 /// Can the dialog be resized after it has been created?
79 /// dialog title, displayed by WM.
86 template <class Dialog>
87 class FormDB: public FormBase
91 FormDB(ControlButtons &, string const &, bool allowResize=true);
92 /// Pointer to the actual instantiation of xform's form
93 virtual FL_FORM * form() const;
94 /// Real GUI implementation.
95 boost::scoped_ptr<Dialog> dialog_;
99 template <class Dialog>
100 FormDB<Dialog>::FormDB(ControlButtons & c, string const & t, bool allowResize)
101 : FormBase(c, t, allowResize)
105 template <class Dialog>
106 FL_FORM * FormDB<Dialog>::form() const
108 if (dialog_.get()) return dialog_->form;
113 template <class Controller, class Base>
114 class FormCB: public Base
118 FormCB(Controller &, string const &, bool allowResize=true);
119 /// The parent controller
120 Controller & controller() const;
124 template <class Controller, class Base>
125 FormCB<Controller, Base>::FormCB(Controller & c, string const & t,
127 : Base(c, t, allowResize)
131 template <class Controller, class Base>
132 Controller & FormCB<Controller, Base>::controller() const
134 return static_cast<Controller &>(controller_);
135 //return dynamic_cast<Controller &>(controller_);