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