// -*- C++ -*-
-/* This file is part of
- * ======================================================
+/**
+ * \file FormBase.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * LyX, The Document Processor
+ * \author Angus Leeming
*
- * Copyright 2000-2001 The LyX Team.
- *
- * ======================================================
- *
- * \author Angus Leeming <a.leeming@ic.ac.uk>
+ * Full author contact details are available in file CREDITS.
+ */
+
+/* A base class for the MCV-ed xforms dialogs.
*/
#ifndef FORMBASE_H
#define FORMBASE_H
-#include <boost/smart_ptr.hpp>
-#include FORMS_H_LOCATION // Can't forward-declare FL_FORM
-
-#ifdef __GNUG__
-#pragma interface
-#endif
#include "ViewBase.h"
-#include "LString.h"
#include "ButtonPolicies.h"
+#include "forms_fwd.h"
+
+#include <boost/scoped_ptr.hpp>
+#include <X11/Xlib.h> // for Pixmap
class xformsBC;
+class Tooltips;
/** This class is an XForms GUI base class.
*/
-class FormBase : public ViewBC<xformsBC>
+class FormBase : public ViewBase
{
public:
///
- FormBase(ControlButtons &, string const &, bool allowResize);
+ FormBase(std::string const &, bool allowResize);
///
- virtual ~FormBase() {}
+ virtual ~FormBase();
- /** input callback function.
- Invoked only by C_FormBaseInputCB and by C_FormBasePrehandler */
+ /** Input callback function.
+ * Invoked only by the xforms callback interface
+ */
void InputCB(FL_OBJECT *, long);
- /// feedback callback function, invoked only by C_FormBasePrehandler
- void FeedbackCB(FL_OBJECT *, int event);
-#if FL_REVISION < 89
- /// invoked only by TooltipTimerCB
- string const getTooltipCB(FL_OBJECT *);
-#endif
+ /** Message callback function.
+ * Invoked only by the xforms callback interface
+ */
+ void MessageCB(FL_OBJECT *, int event);
+
+ /** Prehandler callback function.
+ * Invoked only by the xforms callback interface
+ */
+ void PrehandlerCB(FL_OBJECT * ob, int event, int key);
+
+ ///
+ Tooltips & tooltips();
protected:
/// Build the dialog
virtual void build() = 0;
/// Hide the dialog.
- void hide();
+ virtual void hide();
/// Create the dialog if necessary, update it and display it.
- void show();
-
- /// Prepare the way to produce a tooltip when the mouse is over ob.
- void setTooltipHandler(FL_OBJECT * ob);
+ virtual void show();
+ ///
+ virtual bool isVisible() const;
/** Prepare the way to:
- 1. display feedback as the mouse moves over ob. This feedback will
- typically be rather more verbose than just a tooltip.
- 2. activate the button controller after a paste with the middle
- mouse button */
- void setPrehandler(FL_OBJECT * ob);
-
- /** Flag that the message is a warning and should not be removed
- when the mouse is no longer over the object.
- Used in conjunction with setPrehandler(ob) and with feedback(ob),
- clear_feedback(). */
- void setWarningPosted(bool);
+ * 1. display feedback as the mouse moves over ob. This feedback will
+ * typically be rather more verbose than just a tooltip.
+ * 2. activate the button controller after a paste with the middle
+ * mouse button.
+ */
+ static void setPrehandler(FL_OBJECT * ob);
+
+ /** Pass the class a pointer to the message_widget so that it can
+ post the message */
+ void setMessageWidget(FL_OBJECT * message_widget);
+
+ /** Send the warning message from the daughter class to the
+ message_widget direct. The message will persist till the mouse
+ movesto a new object. */
+ void postWarning(std::string const & warning);
+ /// Reset the message_widget_
+ void clearMessage();
+
+ ///
+ xformsBC & bcview();
private:
/// Pointer to the actual instantiation of xform's form
virtual FL_FORM * form() const = 0;
- /// Filter the inputs on callback from xforms
+ /// Filter the inputs on callback from xforms
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
/** Redraw the form (on receipt of a Signal indicating, for example,
- that the xform colors have been re-mapped). */
+ * that the xform colors have been re-mapped).
+ */
virtual void redraw();
- ///
- virtual string const getTooltip(FL_OBJECT *) { return string(); }
+ /** Called on the first show() request, initialising various bits and
+ * pieces.
+ */
+ void prepare_to_show();
+
+ /** Get the feedback message for ob.
+ Called if warning_posted_ == false. */
+ virtual std::string const getFeedback(FL_OBJECT * /* ob */)
+ { return std::string(); }
+
+ /// Post the feedback message for ob to message_widget_
+ void postMessage(std::string const & message);
- /// post feedback for ob. Defaults to nothing
- virtual void feedback(FL_OBJECT * /* ob */) {}
- /// clear the feedback message
- virtual void clear_feedback() {}
+ /** Variable used to decide whether to remove the existing feedback
+ message or not (if it is in fact a warning) */
+ bool warning_posted_;
+ /// The widget to display the feedback
+ FL_OBJECT * message_widget_;
/// The dialog's minimum allowable dimensions.
int minw_;
int minh_;
/// Can the dialog be resized after it has been created?
bool allow_resize_;
- /// dialog title, displayed by WM.
- string title_;
- /** Variable used to decide whether to remove the existing feedback
- message or not (if it is infact a warning) */
- bool warning_posted_;
- /// Enables tooltips for crappy GUI libraries...
-#if FL_REVISION < 89
- FL_OBJECT * tooltip_timer_;
-#endif
+ /// Passed to the window manager to give a pretty little symbol ;-)
+ Pixmap icon_pixmap_;
+ ///
+ Pixmap icon_mask_;
+ ///
+ Tooltips * tooltips_;
};
{
protected:
///
- FormDB(ControlButtons &, string const &, bool allowResize=true);
+ FormDB(std::string const &, bool allowResize=true);
/// Pointer to the actual instantiation of xform's form
virtual FL_FORM * form() const;
/// Real GUI implementation.
template <class Dialog>
-FormDB<Dialog>::FormDB(ControlButtons & c, string const & t, bool allowResize)
- : FormBase(c, t, allowResize)
+FormDB<Dialog>::FormDB(std::string const & t, bool allowResize)
+ : FormBase(t, allowResize)
{}
template <class Dialog>
FL_FORM * FormDB<Dialog>::form() const
{
- if (dialog_.get()) return dialog_->form;
- return 0;
+ return dialog_.get() ? dialog_->form : 0;
}
template <class Controller, class Base>
class FormCB: public Base
{
+public:
+ /// The parent controller
+ Controller & controller();
+ ///
+ Controller const & controller() const;
+
protected:
///
- FormCB(ControlButtons &, string const &, bool allowResize=true);
- /// The parent controller
- Controller & controller() const;
+ FormCB(std::string const &, bool allowResize = true);
};
template <class Controller, class Base>
-FormCB<Controller, Base>::FormCB(ControlButtons & c, string const & t,
- bool allowResize)
- : Base(c, t, allowResize)
+FormCB<Controller, Base>::FormCB(std::string const & t, bool allowResize)
+ : Base(t, allowResize)
{}
template <class Controller, class Base>
-Controller & FormCB<Controller, Base>::controller() const
+Controller & FormCB<Controller, Base>::controller()
+{
+ return static_cast<Controller &>(this->getController());
+}
+
+
+template <class Controller, class Base>
+Controller const & FormCB<Controller, Base>::controller() const
{
- return static_cast<Controller &>(controller_);
- //return dynamic_cast<Controller &>(controller_);
+ return static_cast<Controller const &>(this->getController());
}