]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FeedbackController.h
Make more use of the feedback controller routines.
[lyx.git] / src / frontends / xforms / FeedbackController.h
1 // -*- C++ -*-
2 /*
3  * \file FeedbackController.h
4  * Copyright 2002 the LyX Team
5  * Read the file COPYING
6  *
7  * \author Angus Leeming, a.leeming@ic.ac.uk
8  **/
9
10 /* A common interface for posting feedback messages to a message widget in
11  * xforms.
12  * Derive FormBase and FormBaseDeprecated from it, so daughter classes of
13  * either can interface tooltips in the same way.
14  */
15
16 #ifndef FEEDBACKCONTROLLER_H
17 #define FEEDBACKCONTROLLER_H
18
19 #include FORMS_H_LOCATION
20 #include "LString.h"
21
22 #ifdef __GNUG__
23 #pragma interface
24 #endif
25
26 class FeedbackController
27 {
28 public:
29         ///
30         FeedbackController();
31         ///
32         virtual ~FeedbackController();
33
34         /** Input callback function, invoked only by the xforms callback
35             interface. Is defined by FormBase, FormBaseDeprecated. */
36         virtual void InputCB(FL_OBJECT *, long) = 0;
37
38         /** Message callback function, invoked only by the xforms callback
39             interface */
40         void MessageCB(FL_OBJECT *, int event);
41
42         /** Prehandler callback function, invoked only by the xforms callback
43             interface */
44         void PrehandlerCB(FL_OBJECT * ob, int event, int key);
45
46 protected:
47         /** Pass the class a pointer to the message_widget so that it can
48             post the message */
49         void setMessageWidget(FL_OBJECT * message_widget);
50
51         /** Send the warning message from the daughter class to the
52             message_widget direct. The message will persist till the mouse
53             movesto a new object. */
54         void postWarning(string const & warning);
55         /// Reset the message_widget_
56         void clearMessage();
57
58 private:
59         /** Get the feedback message for ob.
60             Called if warning_posted_ == false. */
61         virtual string const getFeedback(FL_OBJECT * /* ob */)
62                 { return string(); }
63
64         /// Post the feedback message for ob to message_widget_
65         void postMessage(string const & message);
66
67         /** Variable used to decide whether to remove the existing feedback
68             message or not (if it is in fact a warning) */
69         bool warning_posted_;
70
71         /// The widget to display the feedback
72         FL_OBJECT * message_widget_;
73 };
74
75 #endif // FEEDBACKCONTROLLER_H