]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormBase.h
Introduce LFUN_PRINT.
[lyx.git] / src / frontends / xforms / FormBase.h
index d578803b4fcf1069714f54687f4dab8d66df526a..3ed7cf1d2db552f1d90d469ebc119e8ee8806344 100644 (file)
@@ -4,9 +4,9 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author Angus Leeming 
+ * \author Angus Leeming
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 /* A base class for the MCV-ed xforms dialogs.
 #ifndef FORMBASE_H
 #define FORMBASE_H
 
-#ifdef __GNUG__
-#pragma interface
-#endif
 
 #include "ViewBase.h"
 #include "ButtonPolicies.h"
-#include "FeedbackController.h"
 #include "forms_fwd.h"
 
-#include "LString.h"
 #include <boost/scoped_ptr.hpp>
 #include <X11/Xlib.h> // for Pixmap
 
@@ -34,28 +29,41 @@ class Tooltips;
 
 /** This class is an XForms GUI base class.
  */
-class FormBase : public ViewBase, public FeedbackController
+class FormBase : public ViewBase
 {
 public:
        ///
-       FormBase(string const &, bool allowResize);
+       FormBase(std::string const &, bool allowResize);
        ///
        virtual ~FormBase();
 
-       /** input callback function. invoked only by the xforms callback
-        *  interface
+       /** Input callback function.
+        *  Invoked only by the xforms callback interface
         */
        void InputCB(FL_OBJECT *, long);
 
+       /** 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();
+       virtual void show();
+       ///
+       virtual bool isVisible() const;
 
        /** Prepare the way to:
         *  1. display feedback as the mouse moves over ob. This feedback will
@@ -65,8 +73,19 @@ protected:
         */
        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 & bc();
+       xformsBC & bcview();
 
 private:
        /// Pointer to the actual instantiation of xform's form
@@ -84,14 +103,26 @@ private:
         */
        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);
+
+       /** 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 the window manager.
-       string title_;
        /// Passed to the window manager to give a pretty little symbol ;-)
        Pixmap icon_pixmap_;
        ///
@@ -106,7 +137,7 @@ class FormDB: public FormBase
 {
 protected:
        ///
-       FormDB(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.
@@ -115,7 +146,7 @@ protected:
 
 
 template <class Dialog>
-FormDB<Dialog>::FormDB(string const & t, bool allowResize)
+FormDB<Dialog>::FormDB(std::string const & t, bool allowResize)
        : FormBase(t, allowResize)
 {}
 
@@ -123,26 +154,27 @@ FormDB<Dialog>::FormDB(string const & t, bool 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
 {
-protected:
-       ///
-       FormCB(string const &, bool allowResize = true);
+public:
        /// The parent controller
        Controller & controller();
        ///
        Controller const & controller() const;
+
+protected:
+       ///
+       FormCB(std::string const &, bool allowResize = true);
 };
 
 
 template <class Controller, class Base>
-FormCB<Controller, Base>::FormCB(string const & t, bool allowResize)
+FormCB<Controller, Base>::FormCB(std::string const & t, bool allowResize)
        : Base(t, allowResize)
 {}
 
@@ -150,14 +182,14 @@ FormCB<Controller, Base>::FormCB(string const & t, bool allowResize)
 template <class Controller, class Base>
 Controller & FormCB<Controller, Base>::controller()
 {
-       return static_cast<Controller &>(getController());
+       return static_cast<Controller &>(this->getController());
 }
 
 
 template <class Controller, class Base>
 Controller const & FormCB<Controller, Base>::controller() const
 {
-       return static_cast<Controller const &>(getController());
+       return static_cast<Controller const &>(this->getController());
 }