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"
31 /** This class is an XForms GUI base class.
33 class FormBase : public ViewBC<xformsBC>, public SigC::Object
44 FormBase(ControlButtons &, string const &, bool allowResize);
48 /** input callback function.
49 Invoked only by C_FormBaseInputCB and by C_FormBasePrehandler */
50 void InputCB(FL_OBJECT *, long);
51 /// feedback callback function, invoked only by C_FormBasePrehandler
52 void FeedbackCB(FL_OBJECT *, int event);
54 /** Return the tooltip dependent on the value of tooltip_level_
55 currently non-const becuase it gets connected to a SigC::slot */
56 string getTooltip(FL_OBJECT const *);
60 virtual void build() = 0;
63 /// Create the dialog if necessary, update it and display it.
66 /// Prepare the way to produce a tooltip when the mouse is over ob.
67 void setTooltipHandler(FL_OBJECT * ob);
69 /** Prepare the way to:
70 1. display feedback as the mouse moves over ob. This feedback will
71 typically be rather more verbose than just a tooltip.
72 2. activate the button controller after a paste with the middle
74 void setPrehandler(FL_OBJECT * ob);
76 /** Flag that the message is a warning and should not be removed
77 when the mouse is no longer over the object.
78 Used in conjunction with setPrehandler(ob) and with feedback(ob),
80 void setWarningPosted(bool);
82 /** Fill the tooltips chooser with the standard descriptions
83 and set it to the tooltips_level_ */
84 void fillTooltipChoice(FL_OBJECT *);
85 /// Set tooltips_level_ from the chooser.
86 void setTooltipLevel(FL_OBJECT *);
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). */
96 virtual void redraw();
98 /// These methods can be overridden in the daughter classes.
99 virtual string const getMinimalTooltip(FL_OBJECT const *) const
101 virtual string const getVerboseTooltip(FL_OBJECT const *) const
104 /// Post feedback for ob. Defaults to nothing
105 virtual void feedback(FL_OBJECT * /* ob */) {}
106 /// clear the feedback message
107 virtual void clear_feedback() {}
109 /// The dialog's minimum allowable dimensions.
113 /// Can the dialog be resized after it has been created?
115 /// dialog title, displayed by WM.
117 /** Variable used to decide whether to remove the existing feedback
118 message or not (if it is infact a warning) */
119 bool warning_posted_;
122 /// How verbose are the tooltips?
123 TooltipLevel tooltip_level_;
127 template <class Dialog>
128 class FormDB: public FormBase
132 FormDB(ControlButtons &, string const &, bool allowResize=true);
133 /// Pointer to the actual instantiation of xform's form
134 virtual FL_FORM * form() const;
135 /// Real GUI implementation.
136 boost::scoped_ptr<Dialog> dialog_;
140 template <class Dialog>
141 FormDB<Dialog>::FormDB(ControlButtons & c, string const & t, bool allowResize)
142 : FormBase(c, t, allowResize)
146 template <class Dialog>
147 FL_FORM * FormDB<Dialog>::form() const
149 if (dialog_.get()) return dialog_->form;
154 template <class Controller, class Base>
155 class FormCB: public Base
159 FormCB(ControlButtons &, string const &, bool allowResize=true);
160 /// The parent controller
161 Controller & controller() const;
165 template <class Controller, class Base>
166 FormCB<Controller, Base>::FormCB(ControlButtons & c, string const & t,
168 : Base(c, t, allowResize)
172 template <class Controller, class Base>
173 Controller & FormCB<Controller, Base>::controller() const
175 return static_cast<Controller &>(controller_);
176 //return dynamic_cast<Controller &>(controller_);