X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fxforms%2FFeedbackController.C;h=01dcc2bf29e083844916663ace4b0bc1942ad734;hb=ce708d095c65866617424f940c1dac6b7e236d61;hp=d4aaa523e13c8967688360da862dcc60b11cfb32;hpb=f7c9b1176d2cb36a3f9ad12e6d57295bf600ddcb;p=lyx.git diff --git a/src/frontends/xforms/FeedbackController.C b/src/frontends/xforms/FeedbackController.C index d4aaa523e1..01dcc2bf29 100644 --- a/src/frontends/xforms/FeedbackController.C +++ b/src/frontends/xforms/FeedbackController.C @@ -1,15 +1,17 @@ /** * \file FeedbackController.C - * Copyright 2002 the LyX Team - * Read the file COPYING + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. * - * \author Angus Leeming, a.leeming@ic.ac.uk + * \author Angus Leeming + * + * Full author contact details are available in file CREDITS */ /* A common interface for posting feedback messages to a message widget in * xforms. * Derive FormBase and FormBaseDeprecated from it, so daughter classes of - * either can interface tooltips in the same way. + * either can use the same interface. */ #include @@ -22,6 +24,7 @@ #include "gettext.h" // _() #include "xforms_helpers.h" // formatted #include "support/LAssert.h" +#include FORMS_H_LOCATION FeedbackController::FeedbackController() : warning_posted_(false), message_widget_(0) @@ -34,8 +37,9 @@ FeedbackController::~FeedbackController() void FeedbackController::setMessageWidget(FL_OBJECT * ob) { - lyx::Assert(ob && ob->objclass == FL_TEXT); + lyx::Assert(ob && ob->objclass == FL_TEXT); message_widget_ = ob; + fl_set_object_lsize(message_widget_, FL_SMALL_SIZE); } @@ -46,13 +50,19 @@ void FeedbackController::MessageCB(FL_OBJECT * ob, int event) switch (event) { case FL_ENTER: + { + string const feedback = getFeedback(ob); + if (feedback.empty() && warning_posted_) + break; + warning_posted_ = false; postMessage(getFeedback(ob)); break; + } case FL_LEAVE: if (!warning_posted_) - fl_set_object_label(message_widget_, ""); + clearMessage(); break; default: @@ -63,10 +73,29 @@ void FeedbackController::MessageCB(FL_OBJECT * ob, int event) void FeedbackController::PrehandlerCB(FL_OBJECT * ob, int event, int key) { - if (event == FL_PUSH && key == 2 && ob->objclass == FL_INPUT) { + lyx::Assert(ob); + + if (ob->objclass == FL_INPUT && event == FL_PUSH && key == 2) { // Trigger an input event when pasting in an xforms input object // using the middle mouse button. InputCB(ob, 0); + + } else if (ob->objclass == FL_TABFOLDER && + (event == FL_ENTER || event == FL_LEAVE)) { + // This prehandler is used to work-around an xforms bug and + // ensures that the form->x, form->y coords of the active + // tabfolder are up to date. + + // The tabfolder itself can be very narrow, being just + // the visible border to the tabs. + // We thus use both FL_ENTER and FL_LEAVE as flags, + // in case the FL_ENTER event is not caught. + + FL_FORM * const folder = fl_get_active_folder(ob); + if (folder && folder->window) { + fl_get_winorigin(folder->window, + &(folder->x), &(folder->y)); + } } else if (message_widget_ && (event == FL_ENTER || event == FL_LEAVE)) { @@ -80,9 +109,24 @@ void FeedbackController::PrehandlerCB(FL_OBJECT * ob, int event, int key) void FeedbackController::postWarning(string const & warning) { warning_posted_ = true; + postMessage(warning); +} - string const str = _("WARNING! ") + warning; - postMessage(str); + +void FeedbackController::clearMessage() +{ + lyx::Assert(message_widget_); + + warning_posted_ = false; + + string const existing = message_widget_->label + ? message_widget_->label : string(); + if (existing.empty()) + return; + + // This trick is needed to get xforms to clear the label... + fl_set_object_label(message_widget_, ""); + fl_hide_object(message_widget_); } @@ -90,9 +134,18 @@ void FeedbackController::postMessage(string const & message) { lyx::Assert(message_widget_); - string const str = formatted(message, - message_widget_->w-10, FL_SMALL_SIZE); + string str; + if (warning_posted_) + str = _("WARNING! ") + message; + else + str = message; + + str = formatted(str, message_widget_->w-10, FL_SMALL_SIZE); fl_set_object_label(message_widget_, str.c_str()); - fl_set_object_lsize(message_widget_, FL_SMALL_SIZE); + FL_COLOR const label_color = warning_posted_ ? FL_TOMATO : FL_BLACK; + fl_set_object_lcol(message_widget_, label_color); + + if (!message_widget_->visible) + fl_show_object(message_widget_); }