4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS
12 /* A base class for the MCV-ed xforms dialogs.
23 #include "ButtonPolicies.h"
24 #include "FeedbackController.h"
25 #include "forms_fwd.h"
28 #include <boost/scoped_ptr.hpp>
29 #include <X11/Xlib.h> // for Pixmap
35 /** This class is an XForms GUI base class.
37 class FormBase : public ViewBase, public FeedbackController
41 FormBase(string const &, bool allowResize);
45 /** input callback function. invoked only by the xforms callback
48 void InputCB(FL_OBJECT *, long);
50 Tooltips & tooltips();
54 virtual void build() = 0;
57 /// Create the dialog if necessary, update it and display it.
60 /** Prepare the way to:
61 * 1. display feedback as the mouse moves over ob. This feedback will
62 * typically be rather more verbose than just a tooltip.
63 * 2. activate the button controller after a paste with the middle
66 static void setPrehandler(FL_OBJECT * ob);
72 /// Pointer to the actual instantiation of xform's form
73 virtual FL_FORM * form() const = 0;
74 /// Filter the inputs on callback from xforms
75 virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
77 /** Redraw the form (on receipt of a Signal indicating, for example,
78 * that the xform colors have been re-mapped).
80 virtual void redraw();
82 /** Called on the first show() request, initialising various bits and
85 void prepare_to_show();
87 /// The dialog's minimum allowable dimensions.
91 /// Can the dialog be resized after it has been created?
93 /// dialog title, displayed by the window manager.
95 /// Passed to the window manager to give a pretty little symbol ;-)
100 Tooltips * tooltips_;
104 template <class Dialog>
105 class FormDB: public FormBase
109 FormDB(string const &, bool allowResize=true);
110 /// Pointer to the actual instantiation of xform's form
111 virtual FL_FORM * form() const;
112 /// Real GUI implementation.
113 boost::scoped_ptr<Dialog> dialog_;
117 template <class Dialog>
118 FormDB<Dialog>::FormDB(string const & t, bool allowResize)
119 : FormBase(t, allowResize)
123 template <class Dialog>
124 FL_FORM * FormDB<Dialog>::form() const
126 if (dialog_.get()) return dialog_->form;
131 template <class Controller, class Base>
132 class FormCB: public Base
136 FormCB(string const &, bool allowResize = true);
137 /// The parent controller
138 Controller & controller();
140 Controller const & controller() const;
144 template <class Controller, class Base>
145 FormCB<Controller, Base>::FormCB(string const & t, bool allowResize)
146 : Base(t, allowResize)
150 template <class Controller, class Base>
151 Controller & FormCB<Controller, Base>::controller()
153 return static_cast<Controller &>(getController());
157 template <class Controller, class Base>
158 Controller const & FormCB<Controller, Base>::controller() const
160 return static_cast<Controller const &>(getController());