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