2 * \file FeedbackController.C
3 * Copyright 2002 the LyX Team
4 * Read the file COPYING
6 * \author Angus Leeming, a.leeming@ic.ac.uk
8 * A common interface for posting feedback messages to a message widget in
10 * Derive FormBase and FormBaseDeprecated from it, so daughter classes of
11 * either can interface tooltips in the same way.
17 #pragma implementation
20 #include "FeedbackController.h"
21 #include "gettext.h" // _()
22 #include "xforms_helpers.h" // formatted
23 #include "support/LAssert.h"
25 FeedbackController::FeedbackController()
26 : warning_posted_(false)
30 FeedbackController::~FeedbackController()
34 void FeedbackController::setMessageWidget(FL_OBJECT * ob)
36 lyx::Assert(ob && ob->objclass == FL_TEXT);
41 // preemptive handler for feedback messages
42 void FeedbackController::MessageCB(FL_OBJECT * ob, int event)
44 lyx::Assert(ob && message_widget_);
48 warning_posted_ = false;
49 postMessage(getFeedback(ob));
54 fl_set_object_label(message_widget_, "");
63 void FeedbackController::PrehandlerCB(FL_OBJECT * ob, int event, int key)
65 if (event == FL_PUSH && key == 2 && ob->objclass == FL_INPUT) {
66 // Trigger an input event when pasting in an xforms input object
67 // using the middle mouse button.
70 } else if (event == FL_ENTER || event == FL_LEAVE){
71 // Post feedback as the mouse enters the object,
72 // remove it as the mouse leaves.
78 void FeedbackController::postWarning(string const & warning)
80 lyx::Assert(message_widget_);
82 warning_posted_ = true;
84 string const str = _("WARNING! ") + warning;
89 void FeedbackController::postMessage(string const & message)
91 string const str = formatted(message,
92 message_widget_->w-10, FL_SMALL_SIZE);
94 fl_set_object_label(message_widget_, str.c_str());
95 fl_set_object_lsize(message_widget_, FL_SMALL_SIZE);