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"
32 /** This class is an XForms GUI base class.
34 class FormBase : public ViewBC<xformsBC>, public FeedbackController
38 FormBase(ControlButtons &, string const &, bool allowResize);
42 /** input callback function. invoked only by the xforms callback
45 void InputCB(FL_OBJECT *, long);
47 Tooltips & tooltips();
51 virtual void build() = 0;
54 /// Create the dialog if necessary, update it and display it.
57 /** Prepare the way to:
58 * 1. display feedback as the mouse moves over ob. This feedback will
59 * typically be rather more verbose than just a tooltip.
60 * 2. activate the button controller after a paste with the middle
63 static void setPrehandler(FL_OBJECT * ob);
66 /// Pointer to the actual instantiation of xform's form
67 virtual FL_FORM * form() const = 0;
68 /// Filter the inputs on callback from xforms
69 virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
71 /** Redraw the form (on receipt of a Signal indicating, for example,
72 * that the xform colors have been re-mapped).
74 virtual void redraw();
76 /// The dialog's minimum allowable dimensions.
80 /// Can the dialog be resized after it has been created?
82 /// dialog title, displayed by WM.
89 template <class Dialog>
90 class FormDB: public FormBase
94 FormDB(ControlButtons &, string const &, bool allowResize=true);
95 /// Pointer to the actual instantiation of xform's form
96 virtual FL_FORM * form() const;
97 /// Real GUI implementation.
98 boost::scoped_ptr<Dialog> dialog_;
102 template <class Dialog>
103 FormDB<Dialog>::FormDB(ControlButtons & c, string const & t, bool allowResize)
104 : FormBase(c, t, allowResize)
108 template <class Dialog>
109 FL_FORM * FormDB<Dialog>::form() const
111 if (dialog_.get()) return dialog_->form;
116 template <class Controller, class Base>
117 class FormCB: public Base
121 FormCB(Controller &, string const &, bool allowResize=true);
122 /// The parent controller
123 Controller & controller() const;
127 template <class Controller, class Base>
128 FormCB<Controller, Base>::FormCB(Controller & c, string const & t,
130 : Base(c, t, allowResize)
134 template <class Controller, class Base>
135 Controller & FormCB<Controller, Base>::controller() const
137 return static_cast<Controller &>(controller_);
138 //return dynamic_cast<Controller &>(controller_);