3 * \file FormDialogView.h
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.
15 #ifndef FORMDIALOGVIEW_H
16 #define FORMDIALOGVIEW_H
20 #include "ButtonPolicies.h"
21 #include "forms_fwd.h"
23 #include <X11/Xlib.h> // for Pixmap
29 /** This class is an XForms GUI base class.
31 class FormDialogView : public Dialog::View {
34 FormDialogView(Dialog &, string const &, bool allowResize);
36 virtual ~FormDialogView();
38 /** Input callback function.
39 * Invoked only by the xforms callback interface
41 void InputCB(FL_OBJECT *, long);
43 /** Message callback function.
44 * Invoked only by the xforms callback interface
46 void MessageCB(FL_OBJECT *, int event);
48 /** Prehandler callback function.
49 * Invoked only by the xforms callback interface
51 void PrehandlerCB(FL_OBJECT * ob, int event, int key);
54 Tooltips & tooltips();
58 virtual void build() = 0;
61 /// Create the dialog if necessary, update it and display it.
64 virtual bool isVisible() const;
66 /** Prepare the way to:
67 * 1. display feedback as the mouse moves over ob. This feedback will
68 * typically be rather more verbose than just a tooltip.
69 * 2. activate the button controller after a paste with the middle
72 static void setPrehandler(FL_OBJECT * ob);
74 /** Pass the class a pointer to the message_widget so that it can
76 void setMessageWidget(FL_OBJECT * message_widget);
78 /** Send the warning message from the daughter class to the
79 message_widget direct. The message will persist till the mouse
80 movesto a new object. */
81 void postWarning(string const & warning);
82 /// Reset the message_widget_
89 /// Pointer to the actual instantiation of xform's form
90 virtual FL_FORM * form() const = 0;
91 /// Filter the inputs on callback from xforms
92 virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
94 /** Redraw the form (on receipt of a Signal indicating, for example,
95 * that the xform colors have been re-mapped).
97 virtual void redraw();
99 /** Called on the first show() request, initialising various bits and
102 void prepare_to_show();
104 /** Get the feedback message for ob.
105 Called if warning_posted_ == false. */
106 virtual string const getFeedback(FL_OBJECT * /* ob */)
109 /// Post the feedback message for ob to message_widget_
110 void postMessage(string const & message);
112 /** Variable used to decide whether to remove the existing feedback
113 message or not (if it is in fact a warning) */
114 bool warning_posted_;
115 /// The widget to display the feedback
116 FL_OBJECT * message_widget_;
118 /// The dialog's minimum allowable dimensions.
122 /// Can the dialog be resized after it has been created?
124 /// Passed to the window manager to give a pretty little symbol ;-)
129 Tooltips * tooltips_;
133 template <class FL_dialog>
134 class FormView: public FormDialogView {
137 FormView(Dialog &, string const &, bool allowResize=true);
138 /// Pointer to the actual instantiation of xform's form
139 virtual FL_FORM * form() const;
140 /// Real GUI implementation.
141 boost::scoped_ptr<FL_dialog> dialog_;
145 template <class FL_dialog>
146 FormView<FL_dialog>::FormView(Dialog & parent, string const & t,
148 : FormDialogView(parent, t, allowResize)
152 template <class FL_dialog>
153 FL_FORM * FormView<FL_dialog>::form() const
155 return dialog_.get() ? dialog_->form : 0;
159 template <class Controller, class Base>
160 class FormController: public Base {
162 /// The parent controller
163 Controller & controller();
165 Controller const & controller() const;
169 FormController(Dialog &, string const &, bool allowResize = true);
173 template <class Controller, class Base>
174 FormController<Controller, Base>::FormController(Dialog & p,
175 string const & t, bool resize)
180 template <class Controller, class Base>
181 Controller & FormController<Controller, Base>::controller()
183 return static_cast<Controller &>(this->getController());
187 template <class Controller, class Base>
188 Controller const & FormController<Controller, Base>::controller() const
190 return static_cast<Controller const &>(this->getController());
194 #endif // FORMDIALOGVIEW_H