2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000-2001 The LyX Team.
9 * ======================================================
11 * \author Angus Leeming <a.leeming@ic.ac.uk>
17 #include <boost/smart_ptr.hpp>
18 #include FORMS_H_LOCATION // Can't forward-declare FL_FORM
26 #include "ButtonPolicies.h"
27 #include "FeedbackController.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
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). */
72 virtual void redraw();
74 /// The dialog's minimum allowable dimensions.
78 /// Can the dialog be resized after it has been created?
80 /// dialog title, displayed by WM.
87 template <class Dialog>
88 class FormDB: public FormBase
92 FormDB(ControlButtons &, string const &, bool allowResize=true);
93 /// Pointer to the actual instantiation of xform's form
94 virtual FL_FORM * form() const;
95 /// Real GUI implementation.
96 boost::scoped_ptr<Dialog> dialog_;
100 template <class Dialog>
101 FormDB<Dialog>::FormDB(ControlButtons & c, string const & t, bool allowResize)
102 : FormBase(c, t, allowResize)
106 template <class Dialog>
107 FL_FORM * FormDB<Dialog>::form() const
109 if (dialog_.get()) return dialog_->form;
114 template <class Controller, class Base>
115 class FormCB: public Base
119 FormCB(Controller &, string const &, bool allowResize=true);
120 /// The parent controller
121 Controller & controller() const;
125 template <class Controller, class Base>
126 FormCB<Controller, Base>::FormCB(Controller & c, string const & t,
128 : Base(c, t, allowResize)
132 template <class Controller, class Base>
133 Controller & FormCB<Controller, Base>::controller() const
135 return static_cast<Controller &>(controller_);
136 //return dynamic_cast<Controller &>(controller_);