4 * Read the file COPYING
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS
11 /* A base class for the MCV-ed xforms dialogs.
23 #include "ButtonPolicies.h"
24 #include "FeedbackController.h"
26 #include <boost/scoped_ptr.hpp>
28 #include "forms_fwd.h"
34 /** This class is an XForms GUI base class.
36 class FormBase : public ViewBase, public FeedbackController
40 FormBase(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);
71 /// Pointer to the actual instantiation of xform's form
72 virtual FL_FORM * form() const = 0;
73 /// Filter the inputs on callback from xforms
74 virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
76 /** Redraw the form (on receipt of a Signal indicating, for example,
77 * that the xform colors have been re-mapped).
79 virtual void redraw();
81 /// The dialog's minimum allowable dimensions.
85 /// Can the dialog be resized after it has been created?
87 /// dialog title, displayed by WM.
94 template <class Dialog>
95 class FormDB: public FormBase
99 FormDB(string const &, bool allowResize=true);
100 /// Pointer to the actual instantiation of xform's form
101 virtual FL_FORM * form() const;
102 /// Real GUI implementation.
103 boost::scoped_ptr<Dialog> dialog_;
107 template <class Dialog>
108 FormDB<Dialog>::FormDB(string const & t, bool allowResize)
109 : FormBase(t, allowResize)
113 template <class Dialog>
114 FL_FORM * FormDB<Dialog>::form() const
116 if (dialog_.get()) return dialog_->form;
121 template <class Controller, class Base>
122 class FormCB: public Base
126 FormCB(string const &, bool allowResize = true);
127 /// The parent controller
128 Controller & controller();
130 Controller const & controller() const;
134 template <class Controller, class Base>
135 FormCB<Controller, Base>::FormCB(string const & t, bool allowResize)
136 : Base(t, allowResize)
140 template <class Controller, class Base>
141 Controller & FormCB<Controller, Base>::controller()
143 return static_cast<Controller &>(getController());
147 template <class Controller, class Base>
148 Controller const & FormCB<Controller, Base>::controller() const
150 return static_cast<Controller const &>(getController());