From 4fff14150128dcf569ac291f28ab60f11fbab5b4 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Mon, 11 Mar 2002 09:54:42 +0000 Subject: [PATCH] Give people a rational basis to describe what they dislike about tooltips!!! git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3703 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/ChangeLog | 4 + lib/ui/default.ui | 1 + src/ChangeLog | 8 + src/LyXAction.C | 1 + src/commandtags.h | 1 + src/frontends/ChangeLog | 5 + src/frontends/Dialogs.C | 4 + src/frontends/Dialogs.h | 6 + src/frontends/xforms/ChangeLog | 41 +++ src/frontends/xforms/Dialogs.C | 8 + src/frontends/xforms/FeedbackController.C | 96 ++++++ src/frontends/xforms/FeedbackController.h | 72 ++++ src/frontends/xforms/FormBase.C | 171 ++-------- src/frontends/xforms/FormBase.h | 60 +--- src/frontends/xforms/FormBaseDeprecated.C | 164 +++++---- src/frontends/xforms/FormBaseDeprecated.h | 38 ++- src/frontends/xforms/FormBibtex.C | 77 +---- src/frontends/xforms/FormBibtex.h | 4 - src/frontends/xforms/FormCitation.C | 175 +++------- src/frontends/xforms/FormCitation.h | 4 - src/frontends/xforms/FormForks.C | 44 +-- src/frontends/xforms/FormForks.h | 3 +- src/frontends/xforms/FormPreferences.C | 357 ++++++++------------ src/frontends/xforms/FormPreferences.h | 30 +- src/frontends/xforms/FormSendto.C | 39 +-- src/frontends/xforms/FormSendto.h | 3 - src/frontends/xforms/FormTexinfo.C | 101 ++---- src/frontends/xforms/FormTexinfo.h | 4 - src/frontends/xforms/Makefile.am | 4 +- src/frontends/xforms/Toolbar_pimpl.C | 89 +---- src/frontends/xforms/Toolbar_pimpl.h | 10 +- src/frontends/xforms/Tooltips.C | 160 ++++++++- src/frontends/xforms/Tooltips.h | 54 ++- src/frontends/xforms/form_bibtex.C | 7 - src/frontends/xforms/form_bibtex.h | 1 - src/frontends/xforms/form_citation.C | 9 +- src/frontends/xforms/form_citation.h | 1 - src/frontends/xforms/form_sendto.C | 10 +- src/frontends/xforms/form_sendto.h | 1 - src/frontends/xforms/form_texinfo.C | 13 +- src/frontends/xforms/form_texinfo.h | 1 - src/frontends/xforms/forms/form_bibtex.fd | 20 +- src/frontends/xforms/forms/form_citation.fd | 22 +- src/frontends/xforms/forms/form_sendto.fd | 22 +- src/frontends/xforms/forms/form_texinfo.fd | 26 +- src/frontends/xforms/xforms_helpers.C | 28 +- src/lyxfunc.C | 8 + 47 files changed, 910 insertions(+), 1097 deletions(-) create mode 100644 src/frontends/xforms/FeedbackController.C create mode 100644 src/frontends/xforms/FeedbackController.h diff --git a/lib/ChangeLog b/lib/ChangeLog index c381a934e0..d3f993296c 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,7 @@ +2002-03-08 Angus Leeming + + * ui/default.ui: add a toggle-tooltips item to the Help menu. + 2002-03-08 Jean-Marc Lasgouttes * tex/ejour2.cls: diff --git a/lib/ui/default.ui b/lib/ui/default.ui index 6480fbf27b..6d2ccd6a23 100644 --- a/lib/ui/default.ui +++ b/lib/ui/default.ui @@ -325,6 +325,7 @@ Menuset # HELP MENU # Menu "help" + Item "What's This|W" "toggle-tooltips" Item "Introduction|I" "help-open Intro" Item "Tutorial|T" "help-open Tutorial" Item "User's Guide|U" "help-open UserGuide" diff --git a/src/ChangeLog b/src/ChangeLog index 85c7809ffc..3371aead3a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2002-03-08 Angus Leeming + + * commandtags.h: + * LyXAction.C: add LFUN_TOOLTIPS_TOGGLE, "toggle-tooltips" + * lyxfunc.C (getStatus(LFUN_TOOLTIPS_TOGGLE)): set flag based on + value of Dialogs::tooltipsEnabled(). + (dispatch(LFUN_TOOLTIPS_TOGGLE)): emit signal Dialogs::toggleTooltips. + 2002-03-08 Juergen Vigna * BufferView_pimpl.C (updateInset): update inset inside inset also diff --git a/src/LyXAction.C b/src/LyXAction.C index b61bf6a85b..ad6b2f3f4e 100644 --- a/src/LyXAction.C +++ b/src/LyXAction.C @@ -437,6 +437,7 @@ void LyXAction::init() N_("Show the processes forked by LyX"), NoBuffer }, { LFUN_FORKS_KILL, "kill-forks", N_("Kill the forked process with this PID"), NoBuffer }, + { LFUN_TOOLTIPS_TOGGLE, "toggle-tooltips", "", NoBuffer }, { LFUN_NOACTION, "", "", Noop } }; diff --git a/src/commandtags.h b/src/commandtags.h index 2c76063fd7..b9042343b8 100644 --- a/src/commandtags.h +++ b/src/commandtags.h @@ -299,6 +299,7 @@ enum kb_action { LFUN_HELP_TEXINFO, // Herbert 20011001 LFUN_FORKS_SHOW, // Angus 16 Feb 2002 LFUN_FORKS_KILL, // Angus 16 Feb 2002 + LFUN_TOOLTIPS_TOGGLE, // Angus 8 Mar 2002 LFUN_LASTACTION /* this marks the end of the table */ }; diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index 23febc64bd..06069bc438 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,8 @@ +2002-03-08 Angus Leeming + + * Dialogs.[Ch]: add static signal toggleTooltips and + static method tooltipsEnabled. + 2002-03-04 Angus Leeming * Dialogs.h: diff --git a/src/frontends/Dialogs.C b/src/frontends/Dialogs.C index da2e1a581c..120c1ceb10 100644 --- a/src/frontends/Dialogs.C +++ b/src/frontends/Dialogs.C @@ -27,6 +27,10 @@ // E.g., when the GUI colours have been remapped. SigC::Signal0 Dialogs::redrawGUI; + +// toggle tooltips on/off in all dialogs. +SigC::Signal0 Dialogs::toggleTooltips; + void Dialogs::add(DialogBase * ptr) { lyx::Assert(ptr); diff --git a/src/frontends/Dialogs.h b/src/frontends/Dialogs.h index 06d7e8dcf4..84c1297abe 100644 --- a/src/frontends/Dialogs.h +++ b/src/frontends/Dialogs.h @@ -67,6 +67,12 @@ public: have been re-mapped. */ static SigC::Signal0 redrawGUI; + /// Toggle tooltips on/off in all dialogs. + static SigC::Signal0 toggleTooltips; + + /// Are the tooltips on or off? + static bool tooltipsEnabled(); + /**@name Global Hide and Update Signals */ //@{ /// Hide all visible dialogs diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 582fbe6176..99d4fc8007 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,44 @@ +2002-03-08 Angus Leeming + + * FeedbackController.[Ch]: new files, providing a standard interface to + the feedback and warning messages. Created by stripping code out of + FormBase. + + * FormBase.[Ch]: strip out all the feedback code and simplify yet + further the tooltips code. + + * FormBase.[Ch]: + * FormBaseDeprecated.[Ch]: Add a Tooltips pointer. + Derive both classes from FeedbackController so daughter classes each + have a common interface for same. + + * Toolbar_pimpl.[Ch]: strip out all the tooltip code and use the + Tooltips wrapper class. + + * Tooltips.[Ch]: work out how to update tooltips when using + xforms 0.89's fl_set_object_helper. Can now toggle tooltips with both + xforms 0.88 and 0.89. Change the cursor to a "?" when in query mode + and when the dialog has some tooltips. + + * FormPreferences.[Ch]: strip out all the feedback code and use + the FeedbackController. + + * xforms_helpers.C: save the color of the gui pointer. + + * FormBibtex.[Ch]: + * forms/form_bibtex.fd: + * FormCitation.[Ch]: + * forms/form_citation.fd: + * FormForks.[Ch]: + * forms/form_forks.fd: + * FormSendto.[Ch]: + * forms/form_sendto.fd: + * FormTexinfo.[Ch]: + * forms/form_texinfo.fd: remove "Help" button and rejig for much + simplified tooltips code. + + * Makefile.am: add FeedbackController.[Ch]. + 2002-03-08 Juergen Spitzmueller * FormGraphics.C: Tiny stylistic correction. diff --git a/src/frontends/xforms/Dialogs.C b/src/frontends/xforms/Dialogs.C index d8b5cf9a20..de38fe37cc 100644 --- a/src/frontends/xforms/Dialogs.C +++ b/src/frontends/xforms/Dialogs.C @@ -83,6 +83,14 @@ #include "FormPreferences.h" #include "FormTabular.h" +#include "Tooltips.h" + +/// Are the tooltips on or off? +bool Dialogs::tooltipsEnabled() +{ + return Tooltips::enabled(); +} + Dialogs::Dialogs(LyXView * lv) { diff --git a/src/frontends/xforms/FeedbackController.C b/src/frontends/xforms/FeedbackController.C new file mode 100644 index 0000000000..2450ec2ef6 --- /dev/null +++ b/src/frontends/xforms/FeedbackController.C @@ -0,0 +1,96 @@ +/* + * \file FeedbackController.C + * Copyright 2002 the LyX Team + * Read the file COPYING + * + * \author Angus Leeming, a.leeming@ic.ac.uk + * + * 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. + */ + +#include + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "FeedbackController.h" +#include "gettext.h" // _() +#include "xforms_helpers.h" // formatted +#include "support/LAssert.h" + +FeedbackController::FeedbackController() + : warning_posted_(false) +{} + + +FeedbackController::~FeedbackController() +{} + + +void FeedbackController::setMessageWidget(FL_OBJECT * ob) +{ + lyx::Assert(ob && ob->objclass == FL_TEXT); + message_widget_ = ob; +} + + +// preemptive handler for feedback messages +void FeedbackController::MessageCB(FL_OBJECT * ob, int event) +{ + lyx::Assert(ob && message_widget_); + + switch (event) { + case FL_ENTER: + warning_posted_ = false; + postMessage(getFeedback(ob)); + break; + + case FL_LEAVE: + if (!warning_posted_) + fl_set_object_label(message_widget_, ""); + break; + + default: + break; + } +} + + +void FeedbackController::PrehandlerCB(FL_OBJECT * ob, int event, int key) +{ + if (event == FL_PUSH && key == 2 && ob->objclass == FL_INPUT) { + // Trigger an input event when pasting in an xforms input object + // using the middle mouse button. + InputCB(ob, 0); + + } else if (event == FL_ENTER || event == FL_LEAVE){ + // Post feedback as the mouse enters the object, + // remove it as the mouse leaves. + MessageCB(ob, event); + } +} + + +void FeedbackController::postWarning(string const & warning) +{ + lyx::Assert(message_widget_); + + warning_posted_ = true; + + string const str = _("WARNING! ") + warning; + postMessage(str); +} + + +void FeedbackController::postMessage(string const & message) +{ + string const str = formatted(message, + 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); +} diff --git a/src/frontends/xforms/FeedbackController.h b/src/frontends/xforms/FeedbackController.h new file mode 100644 index 0000000000..69aa4a237c --- /dev/null +++ b/src/frontends/xforms/FeedbackController.h @@ -0,0 +1,72 @@ +// -*- C++ -*- +/* + * \file FeedbackController.h + * Copyright 2002 the LyX Team + * Read the file COPYING + * + * \author Angus Leeming, a.leeming@ic.ac.uk + * + * 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. + */ + +#ifndef FEEDBACKCONTROLLER_H +#define FEEDBACKCONTROLLER_H + +#include FORMS_H_LOCATION +#include "LString.h" + +#ifdef __GNUG__ +#pragma interface +#endif + +class FeedbackController +{ +public: + /// + FeedbackController(); + /// + virtual ~FeedbackController(); + + /** Input callback function, invoked only by the xforms callback + interface. Is defined by FormBase, FormBaseDeprecated. */ + virtual void InputCB(FL_OBJECT *, long) = 0; + + /** Message callback function, invoked only by the xforms callback + interface */ + void MessageCB(FL_OBJECT *, int event); + + /** Prehandler callback function, invoked only by the xforms callback + interface */ + void PrehandlerCB(FL_OBJECT * ob, int event, int key); + +protected: + /** Pass the class a pointer to the message_widget so that it can + post the message */ + void setMessageWidget(FL_OBJECT * message_widget); + + /** Send the warning message from the daughter class to the + message_widget direct. The message will persist till the mouse + movesto a new object. */ + void postWarning(string const & warning); + +private: + /** Get the feedback message for ob. + Called if warning_posted_ == false. */ + virtual string const getFeedback(FL_OBJECT * /* ob */) + { return string(); } + + /// Post the feedback message for ob to message_widget_ + void postMessage(string const & message); + + /** Variable used to decide whether to remove the existing feedback + message or not (if it is in fact a warning) */ + bool warning_posted_; + + /// The widget to display the feedback + FL_OBJECT * message_widget_; +}; + +#endif // FEEDBACKCONTROLLER_H diff --git a/src/frontends/xforms/FormBase.C b/src/frontends/xforms/FormBase.C index 814247e298..f311472d43 100644 --- a/src/frontends/xforms/FormBase.C +++ b/src/frontends/xforms/FormBase.C @@ -20,39 +20,39 @@ #include "FormBase.h" #include "xformsBC.h" #include "GUIRunTime.h" -#include "support/LAssert.h" #include "Tooltips.h" -#include "xforms_helpers.h" // formatted +#include "support/LAssert.h" extern "C" { // Callback function invoked by xforms when the dialog is closed by the // window manager -static int C_FormBaseWMHideCB(FL_FORM * form, void *); +static int C_WMHideCB(FL_FORM * form, void *); -// Use this to diaplay feedback messages or to trigger an input event on paste -// with the middle mouse button -static int C_FormBasePrehandler(FL_OBJECT * ob, int event, - FL_Coord, FL_Coord, int key, void *); +// Callback function invoked by the xforms pre- and post-handler routines +static int C_PrehandlerCB(FL_OBJECT *, int, FL_Coord, FL_Coord, int, void *); } // extern "C" FormBase::FormBase(ControlButtons & c, string const & t, bool allowResize) : ViewBC(c), minw_(0), minh_(0), allow_resize_(allowResize), - title_(t), warning_posted_(false), tooltip_level_(NO_TOOLTIP) + title_(t), tooltips_(new Tooltips) +{} + +FormBase::~FormBase() { - tooltip_ = new Tooltips; - tooltip_->getTooltip.connect(SigC::slot(this, &FormBase::getTooltip)); + delete tooltips_; } -FormBase::~FormBase() +Tooltips & FormBase::tooltips() { - delete tooltip_; + return *tooltips_; } + void FormBase::redraw() { if (form() && form()->visible) @@ -75,7 +75,7 @@ void FormBase::show() minw_ = form()->w; minh_ = form()->h; - fl_set_form_atclose(form(), C_FormBaseWMHideCB, 0); + fl_set_form_atclose(form(), C_WMHideCB, 0); } fl_freeze_form(form()); @@ -122,6 +122,13 @@ void FormBase::hide() } +void FormBase::setPrehandler(FL_OBJECT * ob) +{ + lyx::Assert(ob); + fl_set_object_prehandler(ob, C_PrehandlerCB); +} + + void FormBase::InputCB(FL_OBJECT * ob, long data) { // It is possible to set the choice to 0 when using the @@ -140,119 +147,13 @@ ButtonPolicy::SMInput FormBase::input(FL_OBJECT *, long) } -// preemptive handler for feedback messages -void FormBase::FeedbackCB(FL_OBJECT * ob, int event) -{ - lyx::Assert(ob); - - switch (event) { - case FL_ENTER: - warning_posted_ = false; - feedback(ob); - break; - - case FL_LEAVE: - if (!warning_posted_) - clear_feedback(); - break; - - default: - break; - } -} - - -void FormBase::setTooltipHandler(FL_OBJECT * ob) -{ - tooltip_->activateTooltip(ob); -} - - -string FormBase::getTooltip(FL_OBJECT const * ob) -{ - lyx::Assert(ob); - - switch (tooltip_level_) { - case VERBOSE_TOOLTIP: - { - string str = getVerboseTooltip(ob); - if (!str.empty()) - return formatted(_(str), 400); - // else, fall through - } - - case MINIMAL_TOOLTIP: - return getMinimalTooltip(ob); - - case NO_TOOLTIP: - default: - return string(); - } - -} - - -/// Fill the tooltips chooser with the standard descriptions -void FormBase::fillTooltipChoice(FL_OBJECT * ob) -{ - lyx::Assert(ob && ob->objclass == FL_CHOICE); - - fl_clear_choice(ob); - fl_addto_choice(ob, _(" None | Normal | Verbose ")); - - switch (tooltip_level_) { - case NO_TOOLTIP: - fl_set_choice(ob, 1); - break; - case MINIMAL_TOOLTIP: - fl_set_choice(ob, 2); - break; - case VERBOSE_TOOLTIP: - fl_set_choice(ob, 3); - break; - } -} - - -void FormBase::setTooltipLevel(FL_OBJECT * ob) -{ - lyx::Assert(ob && ob->objclass == FL_CHOICE && - fl_get_choice_maxitems(ob) == 3); - - switch (fl_get_choice(ob)) { - case 1: - tooltip_level_ = NO_TOOLTIP; - break; - case 2: - tooltip_level_ = MINIMAL_TOOLTIP; - break; - case 3: - tooltip_level_ = VERBOSE_TOOLTIP; - break; - } -} - - -void FormBase::setPrehandler(FL_OBJECT * ob) -{ - lyx::Assert(ob); - fl_set_object_prehandler(ob, C_FormBasePrehandler); -} - - -void FormBase::setWarningPosted(bool warning) -{ - warning_posted_ = warning; -} - - namespace { FormBase * GetForm(FL_OBJECT * ob) { lyx::Assert(ob && ob->form && ob->form->u_vdata); - FormBase * pre = static_cast(ob->form->u_vdata); - return pre; + FormBase * ptr = static_cast(ob->form->u_vdata); + return ptr; } } // namespace anon @@ -291,18 +192,17 @@ void C_FormBaseInputCB(FL_OBJECT * ob, long d) } -static int C_FormBaseWMHideCB(FL_FORM * form, void *) +static int C_WMHideCB(FL_FORM * form, void *) { // Close the dialog cleanly, even if the WM is used to do so. lyx::Assert(form && form->u_vdata); - FormBase * pre = static_cast(form->u_vdata); - pre->CancelButton(); + FormBase * ptr = static_cast(form->u_vdata); + ptr->CancelButton(); return FL_CANCEL; } - -static int C_FormBasePrehandler(FL_OBJECT * ob, int event, - FL_Coord, FL_Coord, int key, void *) +static int C_PrehandlerCB(FL_OBJECT * ob, int event, + FL_Coord, FL_Coord, int key, void *) { // Note that the return value is important in the pre-emptive handler. // Don't return anything other than 0. @@ -313,19 +213,10 @@ static int C_FormBasePrehandler(FL_OBJECT * ob, int event, //Assert(ob->form); if (!ob->form) return 0; - FormBase * pre = static_cast(ob->form->u_vdata); - if (!pre) return 0; - - if (event == FL_PUSH && key == 2 && ob->objclass == FL_INPUT) { - // Trigger an input event when pasting in an xforms input object - // using the middle mouse button. - pre->InputCB(ob, 0); - - } else if (event == FL_ENTER || event == FL_LEAVE) { - // Post feedback as the mouse enters the object, - // remove it as the mouse leaves. - pre->FeedbackCB(ob, event); - } + FormBase * ptr = static_cast(ob->form->u_vdata); + + if (ptr) + ptr->PrehandlerCB(ob, event, key); return 0; } diff --git a/src/frontends/xforms/FormBase.h b/src/frontends/xforms/FormBase.h index d0b66e6c97..a11ff21b79 100644 --- a/src/frontends/xforms/FormBase.h +++ b/src/frontends/xforms/FormBase.h @@ -24,36 +24,26 @@ #include "ViewBase.h" #include "LString.h" #include "ButtonPolicies.h" +#include "FeedbackController.h" class xformsBC; class Tooltips; /** This class is an XForms GUI base class. */ -class FormBase : public ViewBC, public SigC::Object +class FormBase : public ViewBC, public FeedbackController { public: - /// - enum TooltipLevel { - NO_TOOLTIP, - MINIMAL_TOOLTIP, - VERBOSE_TOOLTIP - }; - /// FormBase(ControlButtons &, string const &, bool allowResize); /// virtual ~FormBase(); - /** input callback function. - Invoked only by C_FormBaseInputCB and by C_FormBasePrehandler */ + /** input callback function. invoked only by the xforms callback + interface */ void InputCB(FL_OBJECT *, long); - /// feedback callback function, invoked only by C_FormBasePrehandler - void FeedbackCB(FL_OBJECT *, int event); - /** Return the tooltip dependent on the value of tooltip_level_ - currently non-const becuase it gets connected to a SigC::slot */ - string getTooltip(FL_OBJECT const *); + Tooltips & tooltips(); protected: /// Build the dialog @@ -63,28 +53,14 @@ protected: /// Create the dialog if necessary, update it and display it. void show(); - /// Prepare the way to produce a tooltip when the mouse is over ob. - void setTooltipHandler(FL_OBJECT * ob); - /** Prepare the way to: 1. display feedback as the mouse moves over ob. This feedback will typically be rather more verbose than just a tooltip. 2. activate the button controller after a paste with the middle - mouse button */ - void setPrehandler(FL_OBJECT * ob); - - /** Flag that the message is a warning and should not be removed - when the mouse is no longer over the object. - Used in conjunction with setPrehandler(ob) and with feedback(ob), - clear_feedback(). */ - void setWarningPosted(bool); - - /** Fill the tooltips chooser with the standard descriptions - and set it to the tooltips_level_ */ - void fillTooltipChoice(FL_OBJECT *); - /// Set tooltips_level_ from the chooser. - void setTooltipLevel(FL_OBJECT *); - + mouse button. + */ + static void setPrehandler(FL_OBJECT * ob); + private: /// Pointer to the actual instantiation of xform's form virtual FL_FORM * form() const = 0; @@ -95,17 +71,6 @@ private: that the xform colors have been re-mapped). */ virtual void redraw(); - /// These methods can be overridden in the daughter classes. - virtual string const getMinimalTooltip(FL_OBJECT const *) const - { return string(); } - virtual string const getVerboseTooltip(FL_OBJECT const *) const - { return string(); } - - /// Post feedback for ob. Defaults to nothing - virtual void feedback(FL_OBJECT * /* ob */) {} - /// clear the feedback message - virtual void clear_feedback() {} - /// The dialog's minimum allowable dimensions. int minw_; /// @@ -114,13 +79,8 @@ private: bool allow_resize_; /// dialog title, displayed by WM. string title_; - /** Variable used to decide whether to remove the existing feedback - message or not (if it is infact a warning) */ - bool warning_posted_; /// - Tooltips * tooltip_; - /// How verbose are the tooltips? - TooltipLevel tooltip_level_; + Tooltips * tooltips_; }; diff --git a/src/frontends/xforms/FormBaseDeprecated.C b/src/frontends/xforms/FormBaseDeprecated.C index cd17667c90..23b1f395ac 100644 --- a/src/frontends/xforms/FormBaseDeprecated.C +++ b/src/frontends/xforms/FormBaseDeprecated.C @@ -18,11 +18,12 @@ #include "Dialogs.h" #include "FormBaseDeprecated.h" -#include "LyXView.h" -#include "GUIRunTime.h" -#include "support/LAssert.h" #include "xformsBC.h" +#include "GUIRunTime.h" +#include "Tooltips.h" +#include "LyXView.h" #include "lyxrc.h" +#include "support/LAssert.h" using SigC::slot; @@ -30,20 +31,36 @@ extern "C" { // Callback function invoked by xforms when the dialog is closed by the // window manager -static int C_FormBaseDeprecatedWMHideCB(FL_FORM *, void *); - +static int C_WMHideCB(FL_FORM *, void *); + +// Callback function invoked by the xforms pre- and post-handler routines +static int C_PrehandlerCB(FL_OBJECT *, int, FL_Coord, FL_Coord, int, void *); + } // extern "C" FormBaseDeprecated::FormBaseDeprecated(LyXView * lv, Dialogs * d, string const & t, bool allowResize) : lv_(lv), d_(d), h_(0), r_(0), title_(t), - minw_(0), minh_(0), allow_resize_(allowResize) + minw_(0), minh_(0), allow_resize_(allowResize), + tooltips_(new Tooltips) { lyx::Assert(lv && d); } +FormBaseDeprecated::~FormBaseDeprecated() +{ + delete tooltips_; +} + + +Tooltips & FormBaseDeprecated::tooltips() +{ + return *tooltips_; +} + + void FormBaseDeprecated::redraw() { if (form() && form()->visible) @@ -76,8 +93,7 @@ void FormBaseDeprecated::show() minw_ = form()->w; minh_ = form()->h; - fl_set_form_atclose(form(), - C_FormBaseDeprecatedWMHideCB, 0); + fl_set_form_atclose(form(), C_WMHideCB, 0); } fl_freeze_form(form()); @@ -130,78 +146,57 @@ void FormBaseDeprecated::hide() } -int FormBaseDeprecated::WMHideCB(FL_FORM * form, void *) +void FormBaseDeprecated::setPrehandler(FL_OBJECT * ob) { - lyx::Assert(form); - // Ensure that the signals (u and h) are disconnected even if the - // window manager is used to close the dialog. - FormBaseDeprecated * pre = - static_cast(form->u_vdata); - lyx::Assert(pre); - pre->hide(); - pre->bc().hide(); - return FL_CANCEL; + lyx::Assert(ob); + fl_set_object_prehandler(ob, C_PrehandlerCB); } -void FormBaseDeprecated::ApplyCB(FL_OBJECT * ob, long) +void FormBaseDeprecated::WMHideCB() { - lyx::Assert(ob && ob->form); - FormBaseDeprecated * pre = - static_cast(ob->form->u_vdata); - lyx::Assert(pre); - pre->apply(); - pre->bc().apply(); + hide(); + bc().hide(); } -void FormBaseDeprecated::OKCB(FL_OBJECT * ob, long) +void FormBaseDeprecated::ApplyCB() { - lyx::Assert(ob && ob->form); - FormBaseDeprecated * pre = - static_cast(ob->form->u_vdata); - lyx::Assert(pre); - pre->ok(); - pre->bc().ok(); + apply(); + bc().apply(); } -void FormBaseDeprecated::CancelCB(FL_OBJECT * ob, long) +void FormBaseDeprecated::OKCB() { - lyx::Assert(ob && ob->form); - FormBaseDeprecated * pre = - static_cast(ob->form->u_vdata); - lyx::Assert(pre); - pre->cancel(); - pre->bc().cancel(); + ok(); + bc().ok(); } -void FormBaseDeprecated::InputCB(FL_OBJECT * ob, long data) +void FormBaseDeprecated::CancelCB() { - lyx::Assert(ob && ob->form); - FormBaseDeprecated * pre = - static_cast(ob->form->u_vdata); - lyx::Assert(pre); + cancel(); + bc().cancel(); +} + +void FormBaseDeprecated::InputCB(FL_OBJECT * ob, long data) +{ // It is possible to set the choice to 0 when using the // keyboard shortcuts. This work-around deals with the problem. if (ob && ob->objclass == FL_CHOICE && fl_get_choice(ob) < 1) { fl_set_choice(ob, 1); } - pre->bc().valid(pre->input(ob, data)); + bc().valid(input(ob, data)); } -void FormBaseDeprecated::RestoreCB(FL_OBJECT * ob, long) +void FormBaseDeprecated::RestoreCB() { - lyx::Assert(ob && ob->form); - FormBaseDeprecated * pre = - static_cast(ob->form->u_vdata); - lyx::Assert(pre); - pre->bc().restore(); - pre->restore(); + bc().restore(); + restore(); } @@ -242,42 +237,79 @@ void FormBaseBD::disconnect() } -extern "C" { - -static int C_FormBaseDeprecatedWMHideCB(FL_FORM * ob, void * d) +namespace { + +FormBaseDeprecated * GetForm(FL_OBJECT * ob) { - return FormBaseDeprecated::WMHideCB(ob, d); + lyx::Assert(ob && ob->form && ob->form->u_vdata); + FormBaseDeprecated * ptr = + static_cast(ob->form->u_vdata); + return ptr; } +} // namespace anon -void C_FormBaseDeprecatedApplyCB(FL_OBJECT * ob, long d) + +extern "C" { + +void C_FormBaseDeprecatedApplyCB(FL_OBJECT * ob, long) { - FormBaseDeprecated::ApplyCB(ob, d); + GetForm(ob)->ApplyCB(); } -void C_FormBaseDeprecatedOKCB(FL_OBJECT * ob, long d) +void C_FormBaseDeprecatedOKCB(FL_OBJECT * ob, long) { - FormBaseDeprecated::OKCB(ob, d); + GetForm(ob)->OKCB(); } -void C_FormBaseDeprecatedCancelCB(FL_OBJECT * ob, long d) +void C_FormBaseDeprecatedCancelCB(FL_OBJECT * ob, long) { - FormBaseDeprecated::CancelCB(ob, d); + GetForm(ob)->CancelCB(); } void C_FormBaseDeprecatedInputCB(FL_OBJECT * ob, long d) { - FormBaseDeprecated::InputCB(ob, d); + GetForm(ob)->InputCB(ob, d); } -void C_FormBaseDeprecatedRestoreCB(FL_OBJECT * ob, long d) +void C_FormBaseDeprecatedRestoreCB(FL_OBJECT * ob, long) { - FormBaseDeprecated::RestoreCB(ob, d); + GetForm(ob)->RestoreCB(); } -} // extern "C" +static int C_WMHideCB(FL_FORM * form, void *) +{ + // Close the dialog cleanly, even if the WM is used to do so. + lyx::Assert(form && form->u_vdata); + FormBaseDeprecated * ptr = + static_cast(form->u_vdata); + ptr->WMHideCB(); + return FL_CANCEL; +} + +static int C_PrehandlerCB(FL_OBJECT * ob, int event, + FL_Coord, FL_Coord, int key, void *) +{ + // Note that the return value is important in the pre-emptive handler. + // Don't return anything other than 0. + lyx::Assert(ob); + + // Don't Assert this one, as it can happen quite naturally when things + // are being deleted in the d-tor. + //Assert(ob->form); + if (!ob->form) return 0; + FormBaseDeprecated * ptr = + static_cast(ob->form->u_vdata); + + if (ptr) + ptr->PrehandlerCB(ob, event, key); + + return 0; +} + +} // extern "C" diff --git a/src/frontends/xforms/FormBaseDeprecated.h b/src/frontends/xforms/FormBaseDeprecated.h index ca29b23a08..67ca32fa35 100644 --- a/src/frontends/xforms/FormBaseDeprecated.h +++ b/src/frontends/xforms/FormBaseDeprecated.h @@ -22,10 +22,12 @@ #include "DialogBase.h" #include "LString.h" #include "xformsBC.h" +#include "FeedbackController.h" class Buffer; class Dialogs; class LyXView; +class Tooltips; /** This class is an XForms GUI base class. It is meant to be used solely as the parent class to FormBaseBI @@ -35,26 +37,30 @@ class LyXView; @author Angus Leeming */ -class FormBaseDeprecated : public DialogBase { +class FormBaseDeprecated : public DialogBase, public FeedbackController +{ public: + /// + FormBaseDeprecated(LyXView *, Dialogs *, string const &, bool); + /// + virtual ~FormBaseDeprecated(); + /// Callback functions - static int WMHideCB(FL_FORM *, void *); + void WMHideCB(); /// - static void ApplyCB(FL_OBJECT *, long); + void ApplyCB(); /// - static void OKCB(FL_OBJECT *, long); + void OKCB(); /// - static void CancelCB(FL_OBJECT *, long); + void CancelCB(); /// - static void InputCB(FL_OBJECT *, long); + void InputCB(FL_OBJECT *, long); /// - static void RestoreCB(FL_OBJECT *, long); + void RestoreCB(); + + Tooltips & tooltips(); protected: // methods - /// - FormBaseDeprecated(LyXView *, Dialogs *, string const &, bool); - /// - virtual ~FormBaseDeprecated() {} /// Pointer to the actual instantiation of the ButtonController. virtual xformsBC & bc() = 0; @@ -102,6 +108,14 @@ protected: // methods /// Pointer to the actual instantiation of xform's form virtual FL_FORM * form() const = 0; + /** Prepare the way to: + 1. display feedback as the mouse moves over ob. This feedback will + typically be rather more verbose than just a tooltip. + 2. activate the button controller after a paste with the middle + mouse button. + */ + static void setPrehandler(FL_OBJECT * ob); + /** Which LyXFunc do we use? We could modify Dialogs to have a visible LyXFunc* instead and save a couple of bytes per dialog. @@ -123,6 +137,8 @@ private: int minh_; /// Can the dialog be resized after it has been created? bool allow_resize_; + /// + Tooltips * tooltips_; }; diff --git a/src/frontends/xforms/FormBibtex.C b/src/frontends/xforms/FormBibtex.C index 6dce7788cf..5b61ad4bd5 100644 --- a/src/frontends/xforms/FormBibtex.C +++ b/src/frontends/xforms/FormBibtex.C @@ -17,10 +17,11 @@ #include "ControlBibtex.h" #include "FormBibtex.h" #include "form_bibtex.h" -#include "gettext.h" -#include "debug.h" +#include "Tooltips.h" #include "xforms_helpers.h" #include "helper_funcs.h" +#include "gettext.h" +#include "debug.h" #include "support/LAssert.h" #include "support/lstrings.h" #include "support/filetools.h" @@ -41,8 +42,6 @@ void FormBibtex::build() { dialog_.reset(build_bibtex()); - // the help choice - fillTooltipChoice(dialog_->choice_help); fl_set_input_return(dialog_->database, FL_RETURN_CHANGED); fl_set_input_return(dialog_->style, FL_RETURN_CHANGED); @@ -56,12 +55,18 @@ void FormBibtex::build() bc().addReadOnly(dialog_->style); bc().addReadOnly(dialog_->radio_bibtotoc); - // set up the help mechanism - setTooltipHandler(dialog_->database_browse); - setTooltipHandler(dialog_->database); - setTooltipHandler(dialog_->style_browse); - setTooltipHandler(dialog_->style); - setTooltipHandler(dialog_->radio_bibtotoc); + // set up the tooltips + string str = N_("The database you want to cite from. Insert it without the default extension \".bib\". If you insert it with the browser, LyX strips the extension. Several databases must be separated by a comma: \"natbib, books\"."); + tooltips().initTooltip(dialog_->database_browse, str); + + str = N_("Browse your directory for BibTeX stylefiles."); + tooltips().initTooltip(dialog_->style_browse, str); + + str = N_("The BibTeX style to use (only one allowed). Insert it without the default extension \".bst\" and without path. Most of the bibstyles are stored in $TEXMF/bibtex/bst. $TEXMF is the root dir of the local TeX tree. In \"Help->TeX Info\" you can list all installed styles."); + tooltips().initTooltip(dialog_->style, str); + + str = N_("Activate this option if you want the bibliography to appear in the Table of Contents (which doesn't happen by default)."); + tooltips().initTooltip(dialog_->radio_bibtotoc, str); } @@ -98,11 +103,6 @@ ButtonPolicy::SMInput FormBibtex::input(FL_OBJECT * ob, long) } } - if (ob == dialog_->choice_help) { - setTooltipLevel(dialog_->choice_help); - return ButtonPolicy::SMI_NOOP; - } - if (!compare(fl_get_input(dialog_->database),"")) { return ButtonPolicy::SMI_NOOP; } @@ -194,50 +194,3 @@ void FormBibtex::apply() controller().params().setOptions(bibstyle); } } - - -string const FormBibtex::getMinimalTooltip(FL_OBJECT const * ob) const -{ - string str; - - if (ob == dialog_->database) { - str = N_("The BibTeX Database"); - - } else if (ob == dialog_->database_browse) { - str = _("Browse for BibTeX databases."); - - } else if (ob == dialog_->style) { - str = _("The BibTeX style to use"); - - } else if (ob == dialog_->style_browse) { - str = _("Browse for BibTeX stylefiles."); - - } else if (ob == dialog_->radio_bibtotoc) { - str = _("Bibliography to Table of Contents"); - } - - return str; -} - -string const FormBibtex::getVerboseTooltip(FL_OBJECT const * ob) const -{ - string str; - - if (ob == dialog_->database) { - str = N_("The database you want to cite from. Insert it without the default extension \".bib\". If you insert it with the browser, LyX strips the extension. Several databases must be separated by a comma: \"natbib, books\"."); - - } else if (ob == dialog_->database_browse) { - str = _("Browse your directory for BibTeX databases."); - - } else if (ob == dialog_->style) { - str = _("The BibTeX style to use (only one allowed). Insert it without the default extension \".bst\" and without path. Most of the bibstyles are stored in $TEXMF/bibtex/bst. $TEXMF is the root dir of the local TeX tree. In \"Help->TeX Info\" you can list all installed styles."); - - } else if (ob == dialog_->style_browse) { - str = _("Browse your directory for BibTeX stylefiles."); - - } else if (ob == dialog_->radio_bibtotoc) { - str = _("Activate this option if you want the bibliography to appear in the Table of Contents (which doesn't happen by default)."); - } - - return str; -} diff --git a/src/frontends/xforms/FormBibtex.h b/src/frontends/xforms/FormBibtex.h index c20ce54d14..66a3241e77 100644 --- a/src/frontends/xforms/FormBibtex.h +++ b/src/frontends/xforms/FormBibtex.h @@ -37,10 +37,6 @@ private: virtual void update(); /// Filter the inputs on callback from xforms virtual ButtonPolicy::SMInput input(FL_OBJECT *, long); - /// tooltips - string const getVerboseTooltip(FL_OBJECT const *) const; - /// - string const getMinimalTooltip(FL_OBJECT const *) const; /// Fdesign generated method FD_form_bibtex * build_bibtex(); diff --git a/src/frontends/xforms/FormCitation.C b/src/frontends/xforms/FormCitation.C index 82b850c37d..449d934f22 100644 --- a/src/frontends/xforms/FormCitation.C +++ b/src/frontends/xforms/FormCitation.C @@ -23,11 +23,12 @@ #include "ControlCitation.h" #include "FormCitation.h" #include "form_citation.h" +#include "Tooltips.h" +#include "helper_funcs.h" +#include "xforms_helpers.h" #include "gettext.h" #include "support/LAssert.h" #include "support/lstrings.h" -#include "helper_funcs.h" -#include "xforms_helpers.h" using std::find; using std::max; @@ -154,8 +155,6 @@ void FormCitation::build() fl_set_button(dialog_->button_search_case, 0); fl_set_button(dialog_->button_search_type, 0); - // the help choice - fillTooltipChoice(dialog_->choice_help); // Manage the ok, apply, restore and cancel/close buttons bc().setOK(dialog_->button_ok); @@ -174,20 +173,50 @@ void FormCitation::build() bc().addReadOnly(dialog_->button_force_uppercase); //set up the tooltip mechanism - setTooltipHandler(dialog_->button_add); - setTooltipHandler(dialog_->button_del); - setTooltipHandler(dialog_->button_up); - setTooltipHandler(dialog_->button_down); - setTooltipHandler(dialog_->choice_style); - setTooltipHandler(dialog_->input_before); - setTooltipHandler(dialog_->input_after); - setTooltipHandler(dialog_->button_full_author_list); - setTooltipHandler(dialog_->button_force_uppercase); - setTooltipHandler(dialog_->input_search); - setTooltipHandler(dialog_->button_search_case); - setTooltipHandler(dialog_->button_search_type); - setTooltipHandler(dialog_->button_previous); - setTooltipHandler(dialog_->button_next); + string str = N_("Add the selected entry to the current citation reference."); + tooltips().initTooltip(dialog_->button_add, str); + + str = N_("Delete the selected entry from the current citation reference."); + tooltips().initTooltip(dialog_->button_del, str); + + str = N_("Move the selected entry upwards (in the current list)."); + tooltips().initTooltip(dialog_->button_up, str); + + str = N_("Move the selected entry downwards (in the current list)."); + tooltips().initTooltip(dialog_->button_down, str); + + str = N_("The entries which will be cited. Select them with the arrow buttons from the right browser window."); + tooltips().initTooltip(dialog_->browser_cite, str); + + str = N_("All entries in the database you have loaded (via \"Insert->Lists&TOC->BibTex Reference\"). Move the ones you want to cite with the arrow buttons into the left browser window."); + tooltips().initTooltip(dialog_->browser_bib, str); + + str = N_("Information about the selected entry"); + tooltips().initTooltip(dialog_->browser_info, str); + + str = N_("Here you may select how the citation label should look inside the text (Natbib)."); + tooltips().initTooltip(dialog_->choice_style, str); + + str = N_("Activate if you want to print all authors in a reference with more than three authors, and not \" et.al.\" (Natbib)."); + tooltips().initTooltip(dialog_->button_full_author_list, str); + + str = N_("Activate if you want to print the first character of the author name as uppercase (\"Van Gogh\", not \"van Gogh\"). Useful at the beginning of sentences (Natbib)."); + tooltips().initTooltip(dialog_->button_force_uppercase, str); + + str = N_("Optional text which appears before the citation reference, e.g. \"see \""); + tooltips().initTooltip(dialog_->input_before, str); + + str = N_("Optional text which appears after the citation reference, e.g. \"pp. 12\""); + tooltips().initTooltip(dialog_->input_after, str); + + str = N_("Search your database (all fields will be searched)."); + tooltips().initTooltip(dialog_->input_search, str); + + str = N_("Activate if you want to have case sensitive search: \"bibtex\" finds \"bibtex\", but not \"BibTeX\"."); + tooltips().initTooltip(dialog_->button_search_case, str); + + str = N_("Activate if you want to enter Regular Expressions."); + tooltips().initTooltip(dialog_->button_search_type, str); } @@ -384,11 +413,6 @@ ButtonPolicy::SMInput FormCitation::input(FL_OBJECT * ob, long) activate = ButtonPolicy::SMI_VALID; } - if (ob == dialog_->choice_help) { - setTooltipLevel(dialog_->choice_help); - return ButtonPolicy::SMI_NOOP; - } - string currentCitekey; if (!citekeys.empty()) currentCitekey = citekeys[0]; @@ -483,108 +507,3 @@ void FormCitation::setCiteButtons(State status) const setEnabled(dialog_->button_up, activate_up); setEnabled(dialog_->button_down, activate_down); } - - -string const FormCitation::getMinimalTooltip(FL_OBJECT const * ob) const -{ - string str; - - if (ob == dialog_->button_add) { - str = N_("Add entry"); - - } else if (ob == dialog_->button_del) { - str = _("Delete entry"); - - } else if (ob == dialog_->button_up) { - str = _("Move entry up"); - - } else if (ob == dialog_->button_down) { - str = _("Move entry down"); - - } else if (ob == dialog_->choice_style) { - str = N_("Natbib Citation Style"); - - } else if (ob == dialog_->button_full_author_list) { - str = N_("List all authors"); - - } else if (ob == dialog_->button_force_uppercase) { - str = N_("Author Name begins with uppercase"); - - } else if (ob == dialog_->input_before) { - str = N_("Optional text before"); - - } else if (ob == dialog_->input_after) { - str = N_("Optional text after"); - - } else if (ob == dialog_->input_search) { - str = N_("Search the database"); - - } else if (ob == dialog_->button_search_case) { - str = N_("Case sensitive search"); - - } else if (ob == dialog_->button_search_type) { - str = N_("Use Regular Expressions."); - - } else if (ob == dialog_->button_previous) { - str = N_("Search Backwards"); - - } else if (ob == dialog_->button_next) { - str = N_("Search Forwards"); - } - - return str; -} - - -string const FormCitation::getVerboseTooltip(FL_OBJECT const * ob) const -{ - string str; - - if (ob == dialog_->button_add) { - str = N_("Add the selected entry to the current citation reference."); - - } else if (ob == dialog_->button_del) { - str = N_("Delete the selected entry from the current citation reference."); - - } else if (ob == dialog_->button_up) { - str = N_("Move the selected entry upwards (in the current list)."); - - } else if (ob == dialog_->button_down) { - str = N_("Move the selected entry downwards (in the current list)."); - - } else if (ob == dialog_->browser_cite) { - str = N_("The entries which will be cited. Select them with the arrow buttons from the right browser window."); - - } else if (ob == dialog_->browser_bib) { - str = N_("All entries in the database you have loaded (via \"Insert->Lists&TOC->BibTex Reference\"). Move the ones you want to cite with the arrow buttons into the left browser window."); - - } else if (ob == dialog_->browser_info) { - str = N_("Information about the selected entry"); - - } else if (ob == dialog_->choice_style) { - str = N_("Here you may select how the citation label should look inside the text (Natbib)."); - - } else if (ob == dialog_->button_full_author_list) { - str = N_("Activate if you want to print all authors in a reference with more than three authors, and not \" et.al.\" (Natbib)."); - - } else if (ob == dialog_->button_force_uppercase) { - str = N_("Activate if you want to print the first character of the author name as uppercase (\"Van Gogh\", not \"van Gogh\"). Useful at the beginning of sentences (Natbib)."); - - } else if (ob == dialog_->input_before) { - str = N_("Optional text which appears before the citation reference, e.g. \"see \""); - - } else if (ob == dialog_->input_after) { - str = N_("Optional text which appears after the citation reference, e.g. \"pp. 12\""); - - } else if (ob == dialog_->input_search) { - str = N_("Search your database (all fields will be searched)."); - - } else if (ob == dialog_->button_search_case) { - str = N_("Activate if you want to have case sensitive search: \"bibtex\" finds \"bibtex\", but not \"BibTeX\"."); - - } else if (ob == dialog_->button_search_type) { - str = N_("Activate if you want to enter Regular Expressions."); - } - - return str; -} diff --git a/src/frontends/xforms/FormCitation.h b/src/frontends/xforms/FormCitation.h index 270f1f5979..cef3dc4edb 100644 --- a/src/frontends/xforms/FormCitation.h +++ b/src/frontends/xforms/FormCitation.h @@ -51,10 +51,6 @@ private: virtual void update(); /// Filter the inputs on callback from xforms virtual ButtonPolicy::SMInput input(FL_OBJECT *, long); - /// tooltips - string const getMinimalTooltip(FL_OBJECT const *) const; - /// - string const getVerboseTooltip(FL_OBJECT const *) const; /// Fdesign generated method FD_form_citation * build_citation(); diff --git a/src/frontends/xforms/FormForks.C b/src/frontends/xforms/FormForks.C index 524c8346cc..9ee34540ea 100644 --- a/src/frontends/xforms/FormForks.C +++ b/src/frontends/xforms/FormForks.C @@ -17,9 +17,10 @@ #include "FormForks.h" #include "ControlForks.h" #include "form_forks.h" -#include "gettext.h" +#include "Tooltips.h" #include "helper_funcs.h" #include "xforms_helpers.h" +#include "gettext.h" #include "support/lstrings.h" using std::vector; @@ -50,11 +51,20 @@ void FormForks::build() { bc().invalid(); // Set up the tooltip mechanism - setTooltipHandler(dialog_->browser_children); - setTooltipHandler(dialog_->browser_kill); - setTooltipHandler(dialog_->button_all); - setTooltipHandler(dialog_->button_add); - setTooltipHandler(dialog_->button_remove); + string str = N_("All currently running child processes forked by LyX."); + tooltips().initTooltip(dialog_->browser_children, str); + + str = N_("A list of all child processes to kill."); + tooltips().initTooltip(dialog_->browser_kill, str); + + str = N_("Add all processes to the list of processes to kill."); + tooltips().initTooltip(dialog_->button_all, str); + + str = N_("Add the currently selected child process to the list of processes to kill."); + tooltips().initTooltip(dialog_->button_add, str); + + str = N_("Remove the currently selected item from the list of processes to kill."); + tooltips().initTooltip(dialog_->button_remove, str); } @@ -399,25 +409,3 @@ ButtonPolicy::SMInput FormForks::input_button_remove() return ButtonPolicy::SMI_VALID; } - - -string const FormForks::getVerboseTooltip(FL_OBJECT const * ob) const -{ - string str; - - if (ob == dialog_->browser_children) { - str = _("All currently running child processes forked by LyX."); - } else if (ob == dialog_->browser_kill) { - str = _("A list of all child processes to kill."); - } else if (ob == dialog_->button_all) { - str = _("Add all processes to the list of processes to kill."); - } else if (ob == dialog_->button_add) { - str = _("Add the currently selected child process to the list of processes to kill."); - } else if (ob == dialog_->button_remove) { - str = _("Remove the currently selected item from the list of processes to kill."); - } - - return str; -} - - diff --git a/src/frontends/xforms/FormForks.h b/src/frontends/xforms/FormForks.h index ebfb25b7b2..74f5b71423 100644 --- a/src/frontends/xforms/FormForks.h +++ b/src/frontends/xforms/FormForks.h @@ -36,8 +36,7 @@ private: virtual void update(); /// Filter the inputs on callback from xforms virtual ButtonPolicy::SMInput input(FL_OBJECT *, long); - /// tooltips - string const getVerboseTooltip(FL_OBJECT const * ob) const; + /// Fdesign generated method FD_form_forks * build_forks(); diff --git a/src/frontends/xforms/FormPreferences.C b/src/frontends/xforms/FormPreferences.C index 6f0cbb43c4..df44136a86 100644 --- a/src/frontends/xforms/FormPreferences.C +++ b/src/frontends/xforms/FormPreferences.C @@ -76,7 +76,6 @@ Converters local_converters; FormPreferences::FormPreferences(LyXView * lv, Dialogs * d) : FormBaseBI(lv, d, _("Preferences"), false), - warningPosted(false), colors_(*this), converters_(*this), inputs_misc_(*this), formats_(*this), interface_(*this), language_(*this), lnf_misc_(*this), outputs_misc_(*this), paths_(*this), @@ -174,6 +173,9 @@ void FormPreferences::build() bc().setCancel(dialog_->button_cancel); bc().setRestore(dialog_->button_restore); + // Allow the base class to control messages + setMessageWidget(dialog_->text_warning); + // build the tab folders converters_tab_.reset(build_inner_tab()); look_n_feel_tab_.reset(build_inner_tab()); @@ -291,7 +293,7 @@ void FormPreferences::apply() } -void FormPreferences::feedback(FL_OBJECT * ob) +string const FormPreferences::getFeedback(FL_OBJECT * ob) { lyx::Assert(ob); @@ -323,10 +325,7 @@ void FormPreferences::feedback(FL_OBJECT * ob) str = spelloptions_.feedback(ob); } - str = formatted(_(str), dialog_->text_warning->w-10, FL_SMALL_SIZE); - - fl_set_object_label(dialog_->text_warning, str.c_str()); - fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE); + return str; } @@ -433,6 +432,8 @@ void FormPreferences::Colors::apply() cit->r, cit->g, cit->b); fl_set_cursor_color(FL_DEFAULT_CURSOR, GUI_COLOR_CURSOR, FL_WHITE); + fl_set_cursor_color(XC_question_arrow, + GUI_COLOR_CURSOR, FL_WHITE); } } Dialogs::redrawGUI(); @@ -494,19 +495,19 @@ void FormPreferences::Colors::build() fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0); fl_set_slider_step(dialog_->slider_blue, 1.0); fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED); - + // set up the feedback mechanism - setPreHandler(dialog_->browser_lyx_objs); - setPreHandler(dialog_->button_color); - setPreHandler(dialog_->button_modify); - setPreHandler(dialog_->dial_hue); - setPreHandler(dialog_->slider_saturation); - setPreHandler(dialog_->slider_value); - setPreHandler(dialog_->slider_red); - setPreHandler(dialog_->slider_green); - setPreHandler(dialog_->slider_blue); - setPreHandler(dialog_->radio_rgb); - setPreHandler(dialog_->radio_hsv); + setPrehandler(dialog_->browser_lyx_objs); + setPrehandler(dialog_->button_color); + setPrehandler(dialog_->button_modify); + setPrehandler(dialog_->dial_hue); + setPrehandler(dialog_->slider_saturation); + setPrehandler(dialog_->slider_value); + setPrehandler(dialog_->slider_red); + setPrehandler(dialog_->slider_green); + setPrehandler(dialog_->slider_blue); + setPrehandler(dialog_->radio_rgb); + setPrehandler(dialog_->radio_hsv); } string const @@ -723,9 +724,6 @@ void FormPreferences::Colors::LoadBrowserLyX() xcol.colorID = FL_BLACK; fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b); - fl_mapcolor(GUI_COLOR_CURSOR, xcol.r, xcol.g, xcol.b); - fl_set_cursor_color(FL_DEFAULT_CURSOR, GUI_COLOR_CURSOR, FL_WHITE); - xformsColorDB.push_back(xcol); xcol.name = _("GUI selection"); @@ -957,13 +955,13 @@ void FormPreferences::Converters::build() fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED); // set up the feedback mechanism - setPreHandler(dialog_->browser_all); - setPreHandler(dialog_->button_delete); - setPreHandler(dialog_->button_add); - setPreHandler(dialog_->input_converter); - setPreHandler(dialog_->choice_from); - setPreHandler(dialog_->choice_to); - setPreHandler(dialog_->input_flags); + setPrehandler(dialog_->browser_all); + setPrehandler(dialog_->button_delete); + setPrehandler(dialog_->button_add); + setPrehandler(dialog_->input_converter); + setPrehandler(dialog_->choice_from); + setPrehandler(dialog_->choice_to); + setPrehandler(dialog_->input_flags); } @@ -1219,14 +1217,14 @@ void FormPreferences::Formats::build() fl_set_input_filter(dialog_->input_format, fl_lowercase_filter); // set up the feedback mechanism - setPreHandler(dialog_->browser_all); - setPreHandler(dialog_->input_format); - setPreHandler(dialog_->input_gui_name); - setPreHandler(dialog_->button_delete); - setPreHandler(dialog_->button_add); - setPreHandler(dialog_->input_extension); - setPreHandler(dialog_->input_viewer); - setPreHandler(dialog_->input_shrtcut); + setPrehandler(dialog_->browser_all); + setPrehandler(dialog_->input_format); + setPrehandler(dialog_->input_gui_name); + setPrehandler(dialog_->button_delete); + setPrehandler(dialog_->button_add); + setPrehandler(dialog_->input_extension); + setPrehandler(dialog_->input_viewer); + setPrehandler(dialog_->input_shrtcut); } @@ -1365,7 +1363,7 @@ bool FormPreferences::Formats::erase() string const name = fl_get_input(dialog_->input_format); if (local_converters.formatIsUsed(name)) { - parent_.printWarning(_("Cannot remove a Format used by a Converter. Remove the converter first.")); + parent_.postWarning(_("Cannot remove a Format used by a Converter. Remove the converter first.")); setEnabled(dialog_->button_delete, false); return false; } @@ -1439,7 +1437,7 @@ void FormPreferences::InputsMisc::build() fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED); // set up the feedback mechanism - setPreHandler(dialog_->input_date_format); + setPrehandler(dialog_->input_date_format); } @@ -1498,14 +1496,14 @@ void FormPreferences::Interface::build() fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED); // set up the feedback mechanism - setPreHandler(dialog_->input_popup_normal_font); - setPreHandler(dialog_->input_popup_bold_font); - setPreHandler(dialog_->input_popup_font_encoding); - setPreHandler(dialog_->input_bind_file); - setPreHandler(dialog_->button_bind_file_browse); - setPreHandler(dialog_->input_ui_file); - setPreHandler(dialog_->button_ui_file_browse); - setPreHandler(dialog_->check_override_x_dead_keys); + setPrehandler(dialog_->input_popup_normal_font); + setPrehandler(dialog_->input_popup_bold_font); + setPrehandler(dialog_->input_popup_font_encoding); + setPrehandler(dialog_->input_bind_file); + setPrehandler(dialog_->button_bind_file_browse); + setPrehandler(dialog_->input_ui_file); + setPrehandler(dialog_->button_ui_file_browse); + setPrehandler(dialog_->check_override_x_dead_keys); } @@ -1663,26 +1661,26 @@ void FormPreferences::Language::build() fl_unfreeze_form(dialog_->form); // set up the feedback mechanism - setPreHandler(dialog_->input_package); - setPreHandler(dialog_->check_use_kbmap); + setPrehandler(dialog_->input_package); + setPrehandler(dialog_->check_use_kbmap); // This is safe, as nothing is done to the pointer, other than // to use its address in a block-if statement. // No it's not! Leads to crash. - // setPreHandler( + // setPrehandler( // reinterpret_cast(combo_default_lang), // C_FormPreferencesFeedbackCB); - setPreHandler(dialog_->input_kbmap1); - setPreHandler(dialog_->input_kbmap2); - setPreHandler(dialog_->check_rtl_support); - setPreHandler(dialog_->check_mark_foreign); - setPreHandler(dialog_->check_auto_begin); - setPreHandler(dialog_->check_auto_end); - setPreHandler(dialog_->check_use_babel); - setPreHandler(dialog_->check_global_options); - setPreHandler(dialog_->input_command_begin); - setPreHandler(dialog_->input_command_end); + setPrehandler(dialog_->input_kbmap1); + setPrehandler(dialog_->input_kbmap2); + setPrehandler(dialog_->check_rtl_support); + setPrehandler(dialog_->check_mark_foreign); + setPrehandler(dialog_->check_auto_begin); + setPrehandler(dialog_->check_auto_end); + setPrehandler(dialog_->check_use_babel); + setPrehandler(dialog_->check_global_options); + setPrehandler(dialog_->input_command_begin); + setPrehandler(dialog_->input_command_end); // Activate/Deactivate the input fields dependent on the state of the // buttons. @@ -1866,19 +1864,19 @@ void FormPreferences::LnFmisc::build() fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED); // set up the feedback mechanism - setPreHandler(dialog_->check_banner); - setPreHandler(dialog_->check_auto_region_delete); - setPreHandler(dialog_->check_exit_confirm); - setPreHandler(dialog_->check_display_shrtcuts); - setPreHandler(dialog_->counter_autosave); - setPreHandler(dialog_->check_ask_new_file); - setPreHandler(dialog_->check_cursor_follows_scrollbar); - setPreHandler(dialog_->check_dialogs_iconify_with_main); - setPreHandler(dialog_->counter_wm_jump); - setPreHandler(dialog_->radio_display_monochrome); - setPreHandler(dialog_->radio_display_grayscale); - setPreHandler(dialog_->radio_display_color); - setPreHandler(dialog_->radio_no_display); + setPrehandler(dialog_->check_banner); + setPrehandler(dialog_->check_auto_region_delete); + setPrehandler(dialog_->check_exit_confirm); + setPrehandler(dialog_->check_display_shrtcuts); + setPrehandler(dialog_->counter_autosave); + setPrehandler(dialog_->check_ask_new_file); + setPrehandler(dialog_->check_cursor_follows_scrollbar); + setPrehandler(dialog_->check_dialogs_iconify_with_main); + setPrehandler(dialog_->counter_wm_jump); + setPrehandler(dialog_->radio_display_monochrome); + setPrehandler(dialog_->radio_display_grayscale); + setPrehandler(dialog_->radio_display_color); + setPrehandler(dialog_->radio_no_display); } @@ -1986,13 +1984,13 @@ void FormPreferences::OutputsMisc::build() _(" default | US letter | legal | executive | A3 | A4 | A5 | B5 ")); // set up the feedback mechanism - setPreHandler(dialog_->counter_line_len); - setPreHandler(dialog_->input_tex_encoding); - setPreHandler(dialog_->choice_default_papersize); - setPreHandler(dialog_->input_ascii_roff); - setPreHandler(dialog_->input_checktex); - setPreHandler(dialog_->input_paperoption); - setPreHandler(dialog_->check_autoreset_classopt); + setPrehandler(dialog_->counter_line_len); + setPrehandler(dialog_->input_tex_encoding); + setPrehandler(dialog_->choice_default_papersize); + setPrehandler(dialog_->input_ascii_roff); + setPrehandler(dialog_->input_checktex); + setPrehandler(dialog_->input_paperoption); + setPrehandler(dialog_->check_autoreset_classopt); } @@ -2099,16 +2097,16 @@ void FormPreferences::Paths::build() fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED); // set up the feedback mechanism - setPreHandler(dialog_->input_default_path); - setPreHandler(dialog_->counter_lastfiles); - setPreHandler(dialog_->input_template_path); - setPreHandler(dialog_->check_last_files); - setPreHandler(dialog_->input_lastfiles); - setPreHandler(dialog_->check_make_backups); - setPreHandler(dialog_->input_backup_path); - setPreHandler(dialog_->input_serverpipe); - setPreHandler(dialog_->input_temp_dir); - setPreHandler(dialog_->check_use_temp_dir); + setPrehandler(dialog_->input_default_path); + setPrehandler(dialog_->counter_lastfiles); + setPrehandler(dialog_->input_template_path); + setPrehandler(dialog_->check_last_files); + setPrehandler(dialog_->input_lastfiles); + setPrehandler(dialog_->check_make_backups); + setPrehandler(dialog_->input_backup_path); + setPrehandler(dialog_->input_serverpipe); + setPrehandler(dialog_->input_temp_dir); + setPrehandler(dialog_->check_use_temp_dir); } @@ -2168,7 +2166,7 @@ bool FormPreferences::Paths::input(FL_OBJECT const * const ob) if (!ob || ob == dialog_->input_default_path) { string const name = fl_get_input(dialog_->input_default_path); if (!name.empty() && !RWInfo::WriteableDir(name)) { - parent_.printWarning(RWInfo::ErrorMessage()); + parent_.postWarning(RWInfo::ErrorMessage()); return false; } } @@ -2176,7 +2174,7 @@ bool FormPreferences::Paths::input(FL_OBJECT const * const ob) if (!ob || ob == dialog_->input_template_path) { string const name = fl_get_input(dialog_->input_template_path); if (!name.empty() && !RWInfo::ReadableDir(name)) { - parent_.printWarning(RWInfo::ErrorMessage()); + parent_.postWarning(RWInfo::ErrorMessage()); return false; } } @@ -2186,7 +2184,7 @@ bool FormPreferences::Paths::input(FL_OBJECT const * const ob) if (fl_get_button(dialog_->check_make_backups) && !name.empty() && !RWInfo::WriteableDir(name)) { - parent_.printWarning(RWInfo::ErrorMessage()); + parent_.postWarning(RWInfo::ErrorMessage()); return false; } } @@ -2196,7 +2194,7 @@ bool FormPreferences::Paths::input(FL_OBJECT const * const ob) if (fl_get_button(dialog_->check_make_backups) && !name.empty() && !RWInfo::WriteableDir(name)) { - parent_.printWarning(RWInfo::ErrorMessage()); + parent_.postWarning(RWInfo::ErrorMessage()); return false; } } @@ -2206,7 +2204,7 @@ bool FormPreferences::Paths::input(FL_OBJECT const * const ob) if (fl_get_button(dialog_->check_last_files) && !name.empty() && !RWInfo::WriteableFile(name)) { - parent_.printWarning(RWInfo::ErrorMessage()); + parent_.postWarning(RWInfo::ErrorMessage()); return false; } } @@ -2217,11 +2215,11 @@ bool FormPreferences::Paths::input(FL_OBJECT const * const ob) // strip off the extension string const str = ChangeExtension(name, ""); if (!RWInfo::WriteableFile(str + ".in")) { - parent_.printWarning(RWInfo::ErrorMessage()); + parent_.postWarning(RWInfo::ErrorMessage()); return false; } if (!RWInfo::WriteableFile(str + ".out")) { - parent_.printWarning(RWInfo::ErrorMessage()); + parent_.postWarning(RWInfo::ErrorMessage()); return false; } } @@ -2399,24 +2397,24 @@ void FormPreferences::Printer::build() fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED); // set up the feedback mechanism - setPreHandler(dialog_->input_command); - setPreHandler(dialog_->input_page_range); - setPreHandler(dialog_->input_copies); - setPreHandler(dialog_->input_reverse); - setPreHandler(dialog_->input_to_printer); - setPreHandler(dialog_->input_file_extension); - setPreHandler(dialog_->input_spool_command); - setPreHandler(dialog_->input_paper_type); - setPreHandler(dialog_->input_even_pages); - setPreHandler(dialog_->input_odd_pages); - setPreHandler(dialog_->input_collated); - setPreHandler(dialog_->input_landscape); - setPreHandler(dialog_->input_to_file); - setPreHandler(dialog_->input_extra_options); - setPreHandler(dialog_->input_spool_prefix); - setPreHandler(dialog_->input_paper_size); - setPreHandler(dialog_->input_name); - setPreHandler(dialog_->check_adapt_output); + setPrehandler(dialog_->input_command); + setPrehandler(dialog_->input_page_range); + setPrehandler(dialog_->input_copies); + setPrehandler(dialog_->input_reverse); + setPrehandler(dialog_->input_to_printer); + setPrehandler(dialog_->input_file_extension); + setPrehandler(dialog_->input_spool_command); + setPrehandler(dialog_->input_paper_type); + setPrehandler(dialog_->input_even_pages); + setPrehandler(dialog_->input_odd_pages); + setPrehandler(dialog_->input_collated); + setPrehandler(dialog_->input_landscape); + setPrehandler(dialog_->input_to_file); + setPrehandler(dialog_->input_extra_options); + setPrehandler(dialog_->input_spool_prefix); + setPrehandler(dialog_->input_paper_size); + setPrehandler(dialog_->input_name); + setPrehandler(dialog_->check_adapt_output); } @@ -2624,23 +2622,23 @@ void FormPreferences::ScreenFonts::build() fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter); // set up the feedback mechanism - setPreHandler(dialog_->input_roman); - setPreHandler(dialog_->input_sans); - setPreHandler(dialog_->input_typewriter); - setPreHandler(dialog_->counter_zoom); - setPreHandler(dialog_->counter_dpi); - setPreHandler(dialog_->check_scalable); - setPreHandler(dialog_->input_screen_encoding); - setPreHandler(dialog_->input_tiny); - setPreHandler(dialog_->input_script); - setPreHandler(dialog_->input_footnote); - setPreHandler(dialog_->input_small); - setPreHandler(dialog_->input_large); - setPreHandler(dialog_->input_larger); - setPreHandler(dialog_->input_largest); - setPreHandler(dialog_->input_normal); - setPreHandler(dialog_->input_huge); - setPreHandler(dialog_->input_huger); + setPrehandler(dialog_->input_roman); + setPrehandler(dialog_->input_sans); + setPrehandler(dialog_->input_typewriter); + setPrehandler(dialog_->counter_zoom); + setPrehandler(dialog_->counter_dpi); + setPrehandler(dialog_->check_scalable); + setPrehandler(dialog_->input_screen_encoding); + setPrehandler(dialog_->input_tiny); + setPrehandler(dialog_->input_script); + setPrehandler(dialog_->input_footnote); + setPrehandler(dialog_->input_small); + setPrehandler(dialog_->input_large); + setPrehandler(dialog_->input_larger); + setPrehandler(dialog_->input_largest); + setPrehandler(dialog_->input_normal); + setPrehandler(dialog_->input_huge); + setPrehandler(dialog_->input_huger); } @@ -2725,7 +2723,7 @@ bool FormPreferences::ScreenFonts::input() } if (!activate) - parent_.printWarning(str); + parent_.postWarning(str); return activate; } @@ -2858,16 +2856,16 @@ void FormPreferences::SpellOptions::build() fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED); // set up the feedback mechanism - setPreHandler(dialog_->choice_spell_command); - setPreHandler(dialog_->check_alt_lang); - setPreHandler(dialog_->input_alt_lang); - setPreHandler(dialog_->check_escape_chars); - setPreHandler(dialog_->input_escape_chars); - setPreHandler(dialog_->check_personal_dict); - setPreHandler(dialog_->input_personal_dict); - setPreHandler(dialog_->button_personal_dict); - setPreHandler(dialog_->check_compound_words); - setPreHandler(dialog_->check_input_enc); + setPrehandler(dialog_->choice_spell_command); + setPrehandler(dialog_->check_alt_lang); + setPrehandler(dialog_->input_alt_lang); + setPrehandler(dialog_->check_escape_chars); + setPrehandler(dialog_->input_escape_chars); + setPrehandler(dialog_->check_personal_dict); + setPrehandler(dialog_->input_personal_dict); + setPrehandler(dialog_->button_personal_dict); + setPrehandler(dialog_->check_compound_words); + setPrehandler(dialog_->check_input_enc); } @@ -3002,18 +3000,6 @@ void FormPreferences::SpellOptions::update() } -void FormPreferences::printWarning(string const & warning) -{ - warningPosted = true; - - string str = _("WARNING!") + string(" ") + warning; - str = formatted(str, dialog_->text_warning->w-10, FL_SMALL_SIZE); - - fl_set_object_label(dialog_->text_warning, str.c_str()); - fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE); -} - - void FormPreferences::browse(FL_OBJECT * inpt, string const & title, string const & pattern, @@ -3033,66 +3019,3 @@ void FormPreferences::browse(FL_OBJECT * inpt, input(inpt, 0); } } - - -// C function wrapper, required by xforms. -extern "C" { - - static - int C_FormPreferencesFeedbackCB(FL_OBJECT * ob, int event, - FL_Coord mx, FL_Coord my, - int key, void * xev) - { - return FormPreferences::FeedbackCB(ob, event, - mx, my, key, xev); - } - -} - - -int FormPreferences::FeedbackCB(FL_OBJECT * ob, int event, - FL_Coord, FL_Coord, int, void *) -{ - // Note that the return value is important in the pre-emptive handler. - // Don't return anything other than 0. - - lyx::Assert(ob); - // Don't Assert this one, as it can happen quite reasonably when things - // are being deleted in the d-tor. - //Assert(ob->form); - if (!ob->form) return 0; - - FormPreferences * pre = - static_cast(ob->form->u_vdata); - pre->Feedback(ob, event); - return 0; -} - - -// preemptive handler for feedback messages -void FormPreferences::Feedback(FL_OBJECT * ob, int event) -{ - lyx::Assert(ob); - - switch (event) { - case FL_ENTER: - warningPosted = false; - feedback(ob); - break; - - case FL_LEAVE: - if (!warningPosted) - fl_set_object_label(dialog_->text_warning, ""); - break; - - default: - break; - } -} - - -void FormPreferences::setPreHandler(FL_OBJECT * ob) -{ - lyx::Assert(ob); - fl_set_object_prehandler(ob, C_FormPreferencesFeedbackCB); -} diff --git a/src/frontends/xforms/FormPreferences.h b/src/frontends/xforms/FormPreferences.h index 2dcb6c4190..a26c1e896a 100644 --- a/src/frontends/xforms/FormPreferences.h +++ b/src/frontends/xforms/FormPreferences.h @@ -53,11 +53,8 @@ struct FD_form_spelloptions; */ class FormPreferences : public FormBaseBI { public: - /// #FormPreferences x(LyXFunc ..., Dialogs ...);# - FormPreferences(LyXView *, Dialogs *); /// - static int FeedbackCB(FL_OBJECT *, int, - FL_Coord, FL_Coord, int, void *); + FormPreferences(LyXView *, Dialogs *); private: /// Pointer to the actual instantiation of the ButtonController. @@ -81,18 +78,9 @@ private: virtual void build(); /// Pointer to the actual instantiation of the xforms form. virtual FL_FORM * form() const; - /// control which feedback message is output - void feedback(FL_OBJECT *); - - /// Set the preemptive handler for each FL_OBJECT. - static void setPreHandler(FL_OBJECT *); - /// The preemptive handler for feedback messages. - void Feedback(FL_OBJECT *, int); - /// Print a warning message and set warning flag. - void printWarning(string const &); - /** Launch a file dialog and modify input if it returns a new file. - For an explanation of the various parameters, see xforms_helpers.h. - */ + /// control which feedback message is output + string const getFeedback(FL_OBJECT *); + /// void browse(FL_OBJECT * input, string const & title, string const & pattern, std::pair const & dir1= std::make_pair(string(),string()), @@ -140,10 +128,6 @@ private: /// Spellchecker, language stuff, etc boost::scoped_ptr lang_opts_tab_; - /** Flag whether a warning has been posted to the text window. - If so, don't redraw the window when the mouse leaves an object. */ - bool warningPosted; - /** Each tab folder is encapsulated in its own class. */ @@ -151,9 +135,9 @@ private: public: /// enum GuiColors { - GUI_COLOR_CHOICE = FL_FREE_COL1, - GUI_COLOR_HUE_DIAL = FL_FREE_COL2, - GUI_COLOR_CURSOR = FL_FREE_COL3 + GUI_COLOR_CHOICE = FL_FREE_COL14, + GUI_COLOR_HUE_DIAL = FL_FREE_COL15, + GUI_COLOR_CURSOR = FL_FREE_COL16 }; /// Colors(FormPreferences & p); diff --git a/src/frontends/xforms/FormSendto.C b/src/frontends/xforms/FormSendto.C index fa4a9e8845..7d305d2c8e 100644 --- a/src/frontends/xforms/FormSendto.C +++ b/src/frontends/xforms/FormSendto.C @@ -16,6 +16,7 @@ #include "form_sendto.h" #include "ControlSendto.h" #include "xformsBC.h" +#include "Tooltips.h" #include "xforms_helpers.h" #include "converter.h" #include "gettext.h" @@ -35,17 +36,17 @@ void FormSendto::build() fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED); - // The help choice - fillTooltipChoice(dialog_->choice_help); - - // Set up the tooltip mechanism - setTooltipHandler(dialog_->browser_formats); - setTooltipHandler(dialog_->input_command); - // Manage the ok, apply, restore and cancel/close buttons bc().setOK(dialog_->button_ok); bc().setApply(dialog_->button_apply); bc().setCancel(dialog_->button_cancel); + + // Set up the tooltip mechanism + string str = N_("Export the buffer to this format before running the command below on it."); + tooltips().initTooltip(dialog_->browser_formats, str); + + str = N_("Run this command on the buffer exported to the chosen format. $$FName will be replaced by the name of this file."); + tooltips().initTooltip(dialog_->input_command, str); } @@ -64,7 +65,7 @@ void FormSendto::update() for (; it != end; ++it, ++result) { *result = (*it)->prettyname(); } - + vector const browser_keys = getVectorFromBrowser(dialog_->browser_formats); @@ -83,13 +84,8 @@ void FormSendto::update() } -ButtonPolicy::SMInput FormSendto::input(FL_OBJECT * ob, long) +ButtonPolicy::SMInput FormSendto::input(FL_OBJECT *, long) { - if (ob == dialog_->choice_help) { - setTooltipLevel(dialog_->choice_help); - return ButtonPolicy::SMI_NOOP; - } - int const line = fl_get_browser(dialog_->browser_formats); if (line < 1 || line > fl_get_browser_maxline(dialog_->browser_formats)) return ButtonPolicy::SMI_INVALID; @@ -114,18 +110,3 @@ void FormSendto::apply() controller().setFormat(all_formats_[line-1]); controller().setCommand(cmd); } - - -string const FormSendto::getVerboseTooltip(FL_OBJECT const * ob) const -{ - string str; - - if (ob == dialog_->browser_formats) { - str = N_("Export the buffer to this format before running the command below on it."); - - } else if (ob == dialog_->input_command) { - str = N_("Run this command on the buffer exported to the chosen format. $$FName will be replaced by the name of this file."); - } - - return str; -} diff --git a/src/frontends/xforms/FormSendto.h b/src/frontends/xforms/FormSendto.h index 7798f1bc46..a4f59bbd7d 100644 --- a/src/frontends/xforms/FormSendto.h +++ b/src/frontends/xforms/FormSendto.h @@ -38,9 +38,6 @@ private: /// Filter the inputs on callback from xforms virtual ButtonPolicy::SMInput input(FL_OBJECT *, long); - /// tooltips - string const getVerboseTooltip(FL_OBJECT const *) const; - /// Fdesign generated method FD_form_sendto * build_sendto(); diff --git a/src/frontends/xforms/FormTexinfo.C b/src/frontends/xforms/FormTexinfo.C index 75b32d911c..fc06713813 100644 --- a/src/frontends/xforms/FormTexinfo.C +++ b/src/frontends/xforms/FormTexinfo.C @@ -17,6 +17,7 @@ #include "xformsBC.h" #include "FormTexinfo.h" #include "form_texinfo.h" +#include "Tooltips.h" #include "gettext.h" #include "debug.h" #include "xforms_helpers.h" @@ -38,18 +39,27 @@ void FormTexinfo::build() { fl_set_button(dialog_->button_fullPath, 1); updateStyles(ControlTexinfo::cls); - // the help choice - fillTooltipChoice(dialog_->choice_help); - - // setting up the help mechanism - setTooltipHandler(dialog_->button_rescan); - setTooltipHandler(dialog_->button_view); - setTooltipHandler(dialog_->button_texhash); - setTooltipHandler(dialog_->button_fullPath); - setTooltipHandler(dialog_->browser); - setTooltipHandler(dialog_->radio_cls); - setTooltipHandler(dialog_->radio_sty); - setTooltipHandler(dialog_->radio_bst); + // set up the tooltips + string str = N_("Runs the script \"TexFiles.sh\" to build new file lists."); + tooltips().initTooltip(dialog_->button_rescan, str); + + str = N_("Shows the contents of the marked file. Only possible in full path mode."); + tooltips().initTooltip(dialog_->button_view, str); + + str = N_("Runs the script \"texhash\" which builds the a new LaTeX tree. Needed if you install a new TeX class or style. To execute it, you need the write permissions for the tex-dirs, often /var/lib/texmf and other."); + tooltips().initTooltip(dialog_->button_texhash, str); + + str = N_("View full path or only file name. Full path is needed to view the contents of a file."); + tooltips().initTooltip(dialog_->button_fullPath, str); + + str = N_("Shows the installed LaTeX Document classes. Remember, that these classes are only available in LyX if a corresponding LyX layout file exists!"); + tooltips().initTooltip(dialog_->radio_cls, str); + + str = N_("Shows the installed LaTeX style files, which are available in LyX by default, like \"babel\" or through \\usepackage{} in LaTeX preamble."); + tooltips().initTooltip(dialog_->radio_sty, str); + + str = N_("Shows the installed style files for BibTeX. They can be loaded through insert->Lists&Toc->BibTeX Reference->Style."); + tooltips().initTooltip(dialog_->radio_bst, str); } @@ -91,11 +101,6 @@ ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long) { } } - if (ob == dialog_->choice_help) { - setTooltipLevel(dialog_->choice_help); - return ButtonPolicy::SMI_NOOP; - } - return ButtonPolicy::SMI_VALID; } @@ -111,65 +116,3 @@ void FormTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle) activeStyle = whichStyle; } - - -string const FormTexinfo::getMinimalTooltip(FL_OBJECT const * ob) const -{ - string str; - - if (ob == dialog_->radio_cls) { - str = N_("Available LaTeX Classes"); - - } else if (ob == dialog_->radio_sty) { - str = _("Available LaTeX Styles"); - - } else if (ob == dialog_->radio_bst) { - str = _("Available BibTeX Styles"); - - } else if (ob == dialog_->button_rescan) { - str = _("Rescan File List"); - - } else if (ob == dialog_->button_fullPath) { - str = _("Show Full Path or not"); - - } else if (ob == dialog_->button_texhash) { - str = _("Execute Script \"Texhash\""); - - } else if (ob == dialog_->button_view) { - str = N_("View Content of the File"); - - } - - return str; -} - - -string const FormTexinfo::getVerboseTooltip(FL_OBJECT const * ob) const -{ - string str; - - if (ob == dialog_->radio_cls) { - str = N_("Shows the installed LaTeX Document classes. Remember, that these classes are only available in LyX if a corresponding LyX layout file exists!"); - - } else if (ob == dialog_->radio_sty) { - str = _("Shows the installed LaTeX style files, which are available in LyX by default, like \"babel\" or through \\usepackage{} in LaTeX preamble."); - - } else if (ob == dialog_->radio_bst) { - str = _("Shows the installed style files for BibTeX. They can be loaded through insert->Lists&Toc->BibTeX Reference->Style."); - - } else if (ob == dialog_->button_rescan) { - str = _("Runs the script \"TexFiles.sh\" to build new file lists."); - - } else if (ob == dialog_->button_fullPath) { - str = _("View full path or only file name. Full path is needed to view the contents of a file."); - - } else if (ob == dialog_->button_texhash) { - str = _("Runs the script \"texhash\" which builds the a new LaTeX tree. Needed if you install a new TeX class or style. To execute it, you need the write permissions for the tex-dirs, often /var/lib/texmf and other."); - - } else if (ob == dialog_->button_view) { - str = N_("Shows the contents of the marked file. Only possible in full path mode."); - - } - - return str; -} diff --git a/src/frontends/xforms/FormTexinfo.h b/src/frontends/xforms/FormTexinfo.h index 1bf5af0bb8..012da2b0a0 100644 --- a/src/frontends/xforms/FormTexinfo.h +++ b/src/frontends/xforms/FormTexinfo.h @@ -34,10 +34,6 @@ private: /// Filter the inputs on callback from xforms virtual ButtonPolicy::SMInput input(FL_OBJECT *, long); /// - string const getMinimalTooltip(FL_OBJECT const *) const; - /// - string const getVerboseTooltip(FL_OBJECT const *) const; - /// void updateStyles(ControlTexinfo::texFileSuffix); /// Fdesign generated method FD_form_texinfo * build_texinfo(); diff --git a/src/frontends/xforms/Makefile.am b/src/frontends/xforms/Makefile.am index 8e6dd34795..49a368d4c6 100644 --- a/src/frontends/xforms/Makefile.am +++ b/src/frontends/xforms/Makefile.am @@ -30,12 +30,13 @@ libxforms_la_SOURCES = \ Dialogs.C \ DropDown.h \ DropDown.C \ + FeedbackController.C \ + FeedbackController.h \ FileDialog.C \ FormFiledialog.h \ FormFiledialog.C \ form_filedialog.C \ form_filedialog.h \ - GUIRunTime.C \ FormAboutlyx.C \ FormAboutlyx.h \ form_aboutlyx.C \ @@ -194,6 +195,7 @@ libxforms_la_SOURCES = \ form_url.h \ FormVCLog.C \ FormVCLog.h \ + GUIRunTime.C \ input_validators.C \ input_validators.h \ MathsSymbols.C \ diff --git a/src/frontends/xforms/Toolbar_pimpl.C b/src/frontends/xforms/Toolbar_pimpl.C index 3785955688..0337e93e6d 100644 --- a/src/frontends/xforms/Toolbar_pimpl.C +++ b/src/frontends/xforms/Toolbar_pimpl.C @@ -30,7 +30,9 @@ #include "LyXAction.h" #include "MathsSymbols.h" #include "gettext.h" +#include "Tooltips.h" +#include "support/LAssert.h" #include "support/filetools.h" #include "support/lstrings.h" @@ -90,74 +92,15 @@ Toolbar::Pimpl::Pimpl(LyXView * o, int x, int y) : owner(static_cast(o)), sxpos(x), sypos(y) { combox = 0; -#if FL_REVISION < 89 - bubble_timer = 0; -#endif + tooltip_ = new Tooltips(); } -namespace { - -#if FL_REVISION < 89 -// timer-cb for bubble-help (Matthias) -void BubbleTimerCB(FL_OBJECT *, long data) -{ - FL_OBJECT * ob = reinterpret_cast(data); - // The trick we use to get the help text is to read the - // argument of the callback that has been registered for - // ToolBarCB. (JMarc) - string help = _(lyxaction.helpText(ob->argument)); - fl_show_oneliner(help.c_str(), ob->form->x + ob->x, - ob->form->y + ob->y + ob->h); -} - - -extern "C" { - -static -void C_Toolbar_BubbleTimerCB(FL_OBJECT * ob, long data) +Toolbar::Pimpl::~Pimpl() { - BubbleTimerCB(ob, data); -} - -} - -// post_handler for bubble-help (Matthias) -int BubblePost(FL_OBJECT *ob, int event, - FL_Coord /*mx*/, FL_Coord /*my*/, - int /*key*/, void * /*xev*/) -{ - FL_OBJECT * bubble_timer = reinterpret_cast(ob->u_cdata); - - // We do not test for empty help here, since this can never happen - if (event == FL_ENTER) { - fl_set_object_callback(bubble_timer, - C_Toolbar_BubbleTimerCB, - reinterpret_cast(ob)); - fl_set_timer(bubble_timer, 1); - } - else if (event != FL_MOTION) { - fl_set_timer(bubble_timer, 0); - fl_hide_oneliner(); - } - return 0; -} - - -extern "C" { - -static -int C_Toolbar_BubblePost(FL_OBJECT * ob, int event, - FL_Coord /*mx*/, FL_Coord /*my*/, - int key, void * xev) -{ - return BubblePost(ob, event, 0, 0, key, xev); -} - + clean(); + delete tooltip_; } -#endif - -} // namespace anon void Toolbar::Pimpl::activate() @@ -377,13 +320,6 @@ void Toolbar::Pimpl::set(bool doingmain) fl_addto_form(owner->getForm()); } -#if FL_REVISION < 89 - // add the time if it don't exist - if (bubble_timer == 0) - bubble_timer = fl_add_timer(FL_HIDDEN_TIMER, - xpos, ypos, 0, 0, "Timer"); -#endif - ToolbarList::iterator item = toollist.begin(); ToolbarList::iterator end = toollist.end(); for (; item != end; ++item) { @@ -420,15 +356,10 @@ void Toolbar::Pimpl::set(bool doingmain) // Remove the blue feedback rectangle fl_set_pixmapbutton_focus_outline(obj, 0); - // Set the tooltip -#if FL_REVISION >= 89 - string const help(_(lyxaction.helpText(item->action))); - fl_set_object_helper(obj, help.c_str()); -#else - fl_set_object_posthandler(obj, C_Toolbar_BubblePost); - obj->u_cdata = reinterpret_cast(bubble_timer); -#endif - + // initialise the tooltip + string const tip = _(lyxaction.helpText(obj->argument)); + tooltip_->initTooltip(obj, tip); + // The view that this object belongs to. obj->u_vdata = owner; diff --git a/src/frontends/xforms/Toolbar_pimpl.h b/src/frontends/xforms/Toolbar_pimpl.h index 5bdaba476b..4ec1e070ef 100644 --- a/src/frontends/xforms/Toolbar_pimpl.h +++ b/src/frontends/xforms/Toolbar_pimpl.h @@ -28,6 +28,7 @@ #endif class XFormsView; +class Tooltips; /** The LyX xforms toolbar class */ @@ -37,11 +38,8 @@ public: static void layoutSelectedCB(int, void *, Combox *); /// Pimpl(LyXView * o, int x, int y); - /// - ~Pimpl() { - clean(); - } + ~Pimpl(); /// (re)sets the toolbar void set(bool doingmain = false); @@ -95,10 +93,8 @@ public: ToolbarList toollist; /// XFormsView * owner; -#if FL_REVISION < 89 /// - FL_OBJECT * bubble_timer; -#endif + Tooltips * tooltip_; /// Combox * combox; /// Starting position diff --git a/src/frontends/xforms/Tooltips.C b/src/frontends/xforms/Tooltips.C index 0227775044..ee80e05586 100644 --- a/src/frontends/xforms/Tooltips.C +++ b/src/frontends/xforms/Tooltips.C @@ -18,26 +18,85 @@ #endif #include "Tooltips.h" +#include "Dialogs.h" +#include "xforms_helpers.h" // formatted +#include "gettext.h" +#include "support/lstrings.h" #include "support/LAssert.h" -//#if FL_REVISION >= 89 -// Usually, this is all that is needed for xforms 0.89 -// However, I can't see an easy way to change Tooltips on the fly -// with this method, so for now use the jiggery pokery below. ;-) -// Angus 6 Feb 2002 +using SigC::slot; -/* -void Tooltips::activateTooltip(FL_OBJECT * ob) + +bool Tooltips::enabled_ = false; + +SigC::Signal0 Tooltips::tooltipsToggled; + + +#if FL_REVISION >= 89 + +Tooltips::Tooltips() +{ + static bool first = true; + if (first) { + first = false; + Dialogs::toggleTooltips.connect(slot(&Tooltips::toggleEnabled)); + } + tooltipsToggled.connect(slot(this, &Tooltips::toggleTooltips)); +} + + +void Tooltips::toggleEnabled() +{ + enabled_ = !enabled_; + tooltipsToggled(); +} + + +void Tooltips::toggleTooltips() +{ + if (tooltipsMap.empty()) + // There are no objects with tooltips in this dialog, so + // just go away. Don't change the cursor to a question mark. + return; + + TooltipsMap::iterator it = tooltipsMap.begin(); + TooltipsMap::iterator end = tooltipsMap.end(); + for (; it != end; ++it) { + FL_OBJECT * const ob = it->first; + char const * const c_str = enabled_ ? it->second.c_str() : 0; + fl_set_object_helper(ob, c_str); + } + + // Set the cursor to a question mark or back to the default. + FL_OBJECT * const ob = tooltipsMap.begin()->first; + int const cursor = enabled_ ? XC_question_arrow : FL_DEFAULT_CURSOR; + fl_set_cursor(FL_ObjWin(ob), cursor); +} + + +void Tooltips::initTooltip(FL_OBJECT * ob, string const & tip) { lyx::Assert(ob); - string const help(getTooltip(ob)); - if (!help.empty()) - fl_set_object_helper(ob, help.c_str()); + // Paranoia check! + TooltipsMap::const_iterator it = tooltipsMap.find(ob); + if (it != tooltipsMap.end()) + return; + + string const str = strip(frontStrip(tip)); + if (str.empty()) + return; + + // Store the tooltip string + tooltipsMap[ob] = formatted(_(str), 400); + + // Set the initial state of the tooltips + char const * const c_str = enabled_ ? str.c_str() : 0; + fl_set_object_helper(ob, c_str); } -*/ -//#else // if FL_REVISION < 89 + +#else // if FL_REVISION < 89 namespace { @@ -64,15 +123,68 @@ static void C_TooltipTimerCB(FL_OBJECT * ob, long data) } -void Tooltips::activateTooltip(FL_OBJECT * ob) +Tooltips::Tooltips() + : tooltip_timer_(0) +{ + static bool first = true; + if (first) { + first = false; + Dialogs::toggleTooltips.connect(slot(&Tooltips::toggleEnabled)); + } + tooltipsToggled.connect(slot(this, &Tooltips::toggleTooltips)); +} + + +void Tooltips::toggleEnabled() +{ + enabled_ = !enabled_; + tooltipsToggled(); +} + + +void Tooltips::toggleTooltips() +{ + if (tooltipsMap.empty()) + // There are no objects with tooltips in this dialog, so + // just go away. Don't change the cursor to a question mark. + return; + + // Set the cursor to a question mark or back to the default. + FL_OBJECT * const ob = tooltipsMap.begin()->first; + int const cursor = enabled_ ? XC_question_arrow : FL_DEFAULT_CURSOR; + fl_set_cursor(FL_ObjWin(ob), cursor); +} + + +void Tooltips::initTooltip(FL_OBJECT * ob, string const & tip) { lyx::Assert(ob); + // Paranoia check! + TooltipsMap::const_iterator it = tooltipsMap.find(ob); + if (it != tooltipsMap.end()) + return; + + string const str = strip(frontStrip(tip)); + if (str.empty()) + return; + + // Store the tooltip string + tooltipsMap[ob] = formatted(_(str), 400); + if (!tooltip_timer_) { lyx::Assert(ob->form); - fl_addto_form(ob->form); + if (fl_current_form && ob->form != fl_current_form) + fl_end_form(); + + bool const open_form = !fl_current_form; + if (open_form) + fl_addto_form(ob->form); + tooltip_timer_ = fl_add_timer(FL_HIDDEN_TIMER, 0, 0, 0, 0, ""); - fl_end_form(); + + if (open_form) + fl_end_form(); } fl_set_object_posthandler(ob, C_TooltipHandler); @@ -81,6 +193,15 @@ void Tooltips::activateTooltip(FL_OBJECT * ob) } +string const Tooltips::getTooltip(FL_OBJECT * ob) const +{ + TooltipsMap::const_iterator it = tooltipsMap.find(ob); + if (it == tooltipsMap.end()) + return string(); + return it->second; +} + + namespace { void TooltipTimerCB(FL_OBJECT * timer, long data) @@ -99,9 +220,12 @@ void TooltipTimerCB(FL_OBJECT * timer, long data) } -// post_handler for bubble-help (Matthias) -int TooltipHandler(FL_OBJECT *ob, int event) +// post_handler for tooltip help +int TooltipHandler(FL_OBJECT * ob, int event) { + if (!Tooltips::enabled()) + return 0; + lyx::Assert(ob); FL_OBJECT * timer = reinterpret_cast(ob->u_cdata); lyx::Assert(timer); @@ -122,4 +246,4 @@ int TooltipHandler(FL_OBJECT *ob, int event) } // namespace anon -//#endif // FL_REVISION < 89 +#endif // FL_REVISION >= 89 diff --git a/src/frontends/xforms/Tooltips.h b/src/frontends/xforms/Tooltips.h index 36d2f8b8ac..6e461db570 100644 --- a/src/frontends/xforms/Tooltips.h +++ b/src/frontends/xforms/Tooltips.h @@ -19,31 +19,57 @@ #include #include #include FORMS_H_LOCATION // Can't forward-declare FL_OBJECT +#include #ifdef __GNUG__ #pragma interface #endif -class Tooltips : boost::noncopyable { +class Tooltips : boost::noncopyable, public SigC::Object { public: - /// Activate tooltips for this ob - void activateTooltip(FL_OBJECT * ob); - /** Connect this signal to the function returning the tooltip for ob - Eg, string FormBase::getTooltip(FL_OBJECT const *) - Note that SigC is unable to create a Signal1 returning string const - or to connect it to a const method. - */ - SigC::Signal1 getTooltip; + Tooltips(); + + /// Initialise a tooltip for this ob + void initTooltip(FL_OBJECT * ob, string const & tip); + + /// Are the tooltips on or off? + static bool enabled() { return enabled_; } + +#if FL_REVISION < 89 - // We use the old method because we want to change tooltips on the fly -//#if FL_REVISION < 89 - /// - Tooltips() : tooltip_timer_(0) {} + /// Return the tooltip associated with this object + string const getTooltip(FL_OBJECT *) const; + +#endif private: + /// Are the tooltips on or off? + static bool enabled_; + + /** This method is connected to Dialogs::toggleTooltips and toggles + * the state of enabled_ + */ + static void toggleEnabled(); + + /** Once enabled_ is changed, then this signal is emitted to update + * all the tooltips. + */ + static SigC::Signal0 tooltipsToggled; + + /// This method is connected to the tooltipsToggled signal. + void toggleTooltips(); + + /// The tooltips are stored so that they can be turned on and off + typedef std::map TooltipsMap; + + TooltipsMap tooltipsMap; + +#if FL_REVISION < 89 + FL_OBJECT * tooltip_timer_; -//#endif + +#endif // FL_REVISION >= 89 }; #endif // TOOLTIPS_H diff --git a/src/frontends/xforms/form_bibtex.C b/src/frontends/xforms/form_bibtex.C index 2bd9126a1c..323083324f 100644 --- a/src/frontends/xforms/form_bibtex.C +++ b/src/frontends/xforms/form_bibtex.C @@ -67,13 +67,6 @@ FD_form_bibtex * FormBibtex::build_bibtex() fl_set_button_shortcut(obj, scex(_(dummy)), 1); } fl_set_object_callback(obj, C_FormBaseInputCB, 0); - { - char const * const dummy = N_("Help:|#H"); - fdui->choice_help = obj = fl_add_choice(FL_NORMAL_CHOICE, 89, 120, 136, 29, idex(_(dummy))); - fl_set_button_shortcut(obj, scex(_(dummy)), 1); - } - fl_set_object_boxtype(obj, FL_FRAME_BOX); - fl_set_object_callback(obj, C_FormBaseInputCB, 0); fl_end_form(); fdui->form->fdui = fdui; diff --git a/src/frontends/xforms/form_bibtex.h b/src/frontends/xforms/form_bibtex.h index 6753fa766f..4ec2b78783 100644 --- a/src/frontends/xforms/form_bibtex.h +++ b/src/frontends/xforms/form_bibtex.h @@ -22,7 +22,6 @@ struct FD_form_bibtex { FL_OBJECT *database_browse; FL_OBJECT *style_browse; FL_OBJECT *radio_bibtotoc; - FL_OBJECT *choice_help; }; #endif /* FD_form_bibtex_h_ */ diff --git a/src/frontends/xforms/form_citation.C b/src/frontends/xforms/form_citation.C index b96d165b27..3f1cf3aec3 100644 --- a/src/frontends/xforms/form_citation.C +++ b/src/frontends/xforms/form_citation.C @@ -164,7 +164,7 @@ FD_form_citation * FormCitation::build_citation() fl_set_object_callback(obj, C_FormBaseInputCB, 0); { char const * const dummy = N_("Restore|#R"); - fdui->button_restore = obj = fl_add_button(FL_NORMAL_BUTTON, 220, 400, 100, 30, idex(_(dummy))); + fdui->button_restore = obj = fl_add_button(FL_NORMAL_BUTTON, 10, 400, 100, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } fl_set_object_lsize(obj, FL_NORMAL_SIZE); @@ -190,13 +190,6 @@ FD_form_citation * FormCitation::build_citation() fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); fl_set_object_callback(obj, C_FormBaseCancelCB, 0); - { - char const * const dummy = N_("Help:|#H"); - fdui->choice_help = obj = fl_add_choice(FL_NORMAL_CHOICE, 80, 400, 130, 30, idex(_(dummy))); - fl_set_button_shortcut(obj, scex(_(dummy)), 1); - } - fl_set_object_boxtype(obj, FL_FRAME_BOX); - fl_set_object_callback(obj, C_FormBaseInputCB, 0); fl_end_form(); fdui->form->fdui = fdui; diff --git a/src/frontends/xforms/form_citation.h b/src/frontends/xforms/form_citation.h index 2bd6f4ff97..828287e8d6 100644 --- a/src/frontends/xforms/form_citation.h +++ b/src/frontends/xforms/form_citation.h @@ -41,7 +41,6 @@ struct FD_form_citation { FL_OBJECT *button_ok; FL_OBJECT *button_apply; FL_OBJECT *button_cancel; - FL_OBJECT *choice_help; }; #endif /* FD_form_citation_h_ */ diff --git a/src/frontends/xforms/form_sendto.C b/src/frontends/xforms/form_sendto.C index 393b33e5d9..5d553f7008 100644 --- a/src/frontends/xforms/form_sendto.C +++ b/src/frontends/xforms/form_sendto.C @@ -27,7 +27,7 @@ FD_form_sendto * FormSendto::build_sendto() obj = fl_add_box(FL_UP_BOX, 0, 0, 360, 410, ""); { char const * const dummy = N_("Export format|#E"); - fdui->browser_formats = obj = fl_add_browser(FL_HOLD_BROWSER, 15, 30, 145, 250, idex(_(dummy))); + fdui->browser_formats = obj = fl_add_browser(FL_HOLD_BROWSER, 105, 30, 145, 250, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } fl_set_object_lsize(obj, FL_NORMAL_SIZE); @@ -43,14 +43,6 @@ FD_form_sendto * FormSendto::build_sendto() fl_set_object_lalign(obj, FL_ALIGN_TOP_LEFT); fl_set_object_gravity(obj, FL_SouthWest, FL_SouthEast); fl_set_object_callback(obj, C_FormBaseInputCB, 0); - { - char const * const dummy = N_("Help:|#H"); - fdui->choice_help = obj = fl_add_choice(FL_NORMAL_CHOICE, 215, 250, 130, 30, idex(_(dummy))); - fl_set_button_shortcut(obj, scex(_(dummy)), 1); - } - fl_set_object_boxtype(obj, FL_FRAME_BOX); - fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fl_set_object_callback(obj, C_FormBaseInputCB, 0); fdui->button_ok = obj = fl_add_button(FL_RETURN_BUTTON, 65, 370, 90, 30, _("OK")); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); diff --git a/src/frontends/xforms/form_sendto.h b/src/frontends/xforms/form_sendto.h index e20d60bf7e..e7e48f9f01 100644 --- a/src/frontends/xforms/form_sendto.h +++ b/src/frontends/xforms/form_sendto.h @@ -18,7 +18,6 @@ struct FD_form_sendto { FL_FORM *form; FL_OBJECT *browser_formats; FL_OBJECT *input_command; - FL_OBJECT *choice_help; FL_OBJECT *button_ok; FL_OBJECT *button_apply; FL_OBJECT *button_cancel; diff --git a/src/frontends/xforms/form_texinfo.C b/src/frontends/xforms/form_texinfo.C index 2b8705d271..9ac82d0b4e 100644 --- a/src/frontends/xforms/form_texinfo.C +++ b/src/frontends/xforms/form_texinfo.C @@ -22,9 +22,9 @@ FD_form_texinfo * FormTexinfo::build_texinfo() FL_OBJECT *obj; FD_form_texinfo *fdui = new FD_form_texinfo; - fdui->form = fl_bgn_form(FL_NO_BOX, 513, 353); + fdui->form = fl_bgn_form(FL_NO_BOX, 513, 312); fdui->form->u_vdata = this; - obj = fl_add_box(FL_UP_BOX, 0, 0, 513, 353, ""); + obj = fl_add_box(FL_UP_BOX, 0, 0, 513, 312, ""); fl_set_object_lstyle(obj, FL_FIXED_STYLE); fdui->browser = obj = fl_add_browser(FL_HOLD_BROWSER, 15, 12, 324, 241, ""); fl_set_object_lalign(obj, FL_ALIGN_TOP); @@ -102,19 +102,12 @@ FD_form_texinfo * FormTexinfo::build_texinfo() fl_set_object_callback(obj, C_FormBaseInputCB, 0); { char const * const dummy = N_("Close|^[^M"); - fdui->button_close = obj = fl_add_button(FL_NORMAL_BUTTON, 409, 313, 90, 30, idex(_(dummy))); + fdui->button_close = obj = fl_add_button(FL_NORMAL_BUTTON, 409, 270, 90, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); fl_set_object_callback(obj, C_FormBaseCancelCB, 0); - { - char const * const dummy = N_("Help:|#H"); - fdui->choice_help = obj = fl_add_choice(FL_NORMAL_CHOICE, 344, 270, 155, 29, idex(_(dummy))); - fl_set_button_shortcut(obj, scex(_(dummy)), 1); - } - fl_set_object_boxtype(obj, FL_FRAME_BOX); - fl_set_object_callback(obj, C_FormBaseInputCB, 0); fl_end_form(); fdui->form->fdui = fdui; diff --git a/src/frontends/xforms/form_texinfo.h b/src/frontends/xforms/form_texinfo.h index 293ba72e8d..30c9024b57 100644 --- a/src/frontends/xforms/form_texinfo.h +++ b/src/frontends/xforms/form_texinfo.h @@ -23,7 +23,6 @@ struct FD_form_texinfo { FL_OBJECT *button_fullPath; FL_OBJECT *button_texhash; FL_OBJECT *button_close; - FL_OBJECT *choice_help; }; #endif /* FD_form_texinfo_h_ */ diff --git a/src/frontends/xforms/forms/form_bibtex.fd b/src/frontends/xforms/forms/form_bibtex.fd index 850c5dd8d6..53a1cf0ade 100644 --- a/src/frontends/xforms/forms/form_bibtex.fd +++ b/src/frontends/xforms/forms/form_bibtex.fd @@ -11,7 +11,7 @@ SnapGrid: 1 Name: form_bibtex Width: 450 Height: 160 -Number of Objects: 9 +Number of Objects: 8 -------------------- class: FL_BOX @@ -157,23 +157,5 @@ name: radio_bibtotoc callback: C_FormBaseInputCB argument: 0 --------------------- -class: FL_CHOICE -type: NORMAL_CHOICE -box: 89 120 136 29 -boxtype: FL_FRAME_BOX -colors: FL_COL1 FL_BLACK -alignment: FL_ALIGN_LEFT -style: FL_NORMAL_STYLE -size: FL_DEFAULT_SIZE -lcol: FL_BLACK -label: Help:|#H -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity -name: choice_help -callback: C_FormBaseInputCB -argument: 0 - ============================== create_the_forms diff --git a/src/frontends/xforms/forms/form_citation.fd b/src/frontends/xforms/forms/form_citation.fd index cdc3fa3362..9a9bd92762 100644 --- a/src/frontends/xforms/forms/form_citation.fd +++ b/src/frontends/xforms/forms/form_citation.fd @@ -10,7 +10,7 @@ Unit of measure: FL_COORD_PIXEL Name: form_citation Width: 680 Height: 440 -Number of Objects: 26 +Number of Objects: 25 -------------------- class: FL_BOX @@ -393,7 +393,7 @@ argument: 0 -------------------- class: FL_BUTTON type: NORMAL_BUTTON -box: 220 400 100 30 +box: 10 400 100 30 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -462,23 +462,5 @@ name: button_cancel callback: C_FormBaseCancelCB argument: 0 --------------------- -class: FL_CHOICE -type: NORMAL_CHOICE -box: 80 400 130 30 -boxtype: FL_FRAME_BOX -colors: FL_COL1 FL_BLACK -alignment: FL_ALIGN_LEFT -style: FL_NORMAL_STYLE -size: FL_DEFAULT_SIZE -lcol: FL_BLACK -label: Help:|#H -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity -name: choice_help -callback: C_FormBaseInputCB -argument: 0 - ============================== create_the_forms diff --git a/src/frontends/xforms/forms/form_sendto.fd b/src/frontends/xforms/forms/form_sendto.fd index 551c703554..604e19fb01 100644 --- a/src/frontends/xforms/forms/form_sendto.fd +++ b/src/frontends/xforms/forms/form_sendto.fd @@ -10,7 +10,7 @@ Unit of measure: FL_COORD_PIXEL Name: form_sendto Width: 360 Height: 410 -Number of Objects: 7 +Number of Objects: 6 -------------------- class: FL_BOX @@ -33,7 +33,7 @@ argument: -------------------- class: FL_BROWSER type: HOLD_BROWSER -box: 15 30 145 250 +box: 105 30 145 250 boxtype: FL_DOWN_BOX colors: FL_COL1 FL_YELLOW alignment: FL_ALIGN_TOP_LEFT @@ -66,24 +66,6 @@ name: input_command callback: C_FormBaseInputCB argument: 0 --------------------- -class: FL_CHOICE -type: NORMAL_CHOICE -box: 215 250 130 30 -boxtype: FL_FRAME_BOX -colors: FL_COL1 FL_BLACK -alignment: FL_ALIGN_LEFT -style: FL_NORMAL_STYLE -size: FL_NORMAL_SIZE -lcol: FL_BLACK -label: Help:|#H -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity -name: choice_help -callback: C_FormBaseInputCB -argument: 0 - -------------------- class: FL_BUTTON type: RETURN_BUTTON diff --git a/src/frontends/xforms/forms/form_texinfo.fd b/src/frontends/xforms/forms/form_texinfo.fd index a303e1b3b6..0530fd2a76 100644 --- a/src/frontends/xforms/forms/form_texinfo.fd +++ b/src/frontends/xforms/forms/form_texinfo.fd @@ -10,13 +10,13 @@ SnapGrid: 1 =============== FORM =============== Name: form_texinfo Width: 513 -Height: 353 -Number of Objects: 13 +Height: 312 +Number of Objects: 12 -------------------- class: FL_BOX type: UP_BOX -box: 0 0 513 353 +box: 0 0 513 312 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -215,7 +215,7 @@ argument: 0 -------------------- class: FL_BUTTON type: NORMAL_BUTTON -box: 409 313 90 30 +box: 409 270 90 30 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -230,23 +230,5 @@ name: button_close callback: C_FormBaseCancelCB argument: 0 --------------------- -class: FL_CHOICE -type: NORMAL_CHOICE -box: 344 270 155 29 -boxtype: FL_FRAME_BOX -colors: FL_COL1 FL_BLACK -alignment: FL_ALIGN_LEFT -style: FL_NORMAL_STYLE -size: FL_DEFAULT_SIZE -lcol: FL_BLACK -label: Help:|#H -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity -name: choice_help -callback: C_FormBaseInputCB -argument: 0 - ============================== create_the_form diff --git a/src/frontends/xforms/xforms_helpers.C b/src/frontends/xforms/xforms_helpers.C index 2edbb87f75..422440ed3a 100644 --- a/src/frontends/xforms/xforms_helpers.C +++ b/src/frontends/xforms/xforms_helpers.C @@ -363,15 +363,16 @@ namespace { // sorted by hand to prevent LyXLex from complaining on read(). keyword_item xformTags[] = { - { "\\gui_background", FL_COL1 }, + { "\\gui_background", FL_COL1 }, { "\\gui_buttonbottom", FL_BOTTOM_BCOL }, - { "\\gui_buttonleft", FL_LEFT_BCOL }, - { "\\gui_buttonright", FL_RIGHT_BCOL }, - { "\\gui_buttontop", FL_TOP_BCOL }, - { "\\gui_inactive", FL_INACTIVE }, - { "\\gui_push_button", FL_YELLOW }, - { "\\gui_selected", FL_MCOL }, - { "\\gui_text", FL_BLACK } + { "\\gui_buttonleft", FL_LEFT_BCOL }, + { "\\gui_buttonright", FL_RIGHT_BCOL }, + { "\\gui_buttontop", FL_TOP_BCOL }, + { "\\gui_inactive", FL_INACTIVE }, + { "\\gui_pointer", FL_FREE_COL16 }, + { "\\gui_push_button", FL_YELLOW }, + { "\\gui_selected", FL_MCOL }, + { "\\gui_text", FL_BLACK } }; @@ -398,6 +399,8 @@ bool XformsColor::read(string const & filename) default: break; } + string const tag = lexrc.getString(); + RGBColor col; if (!lexrc.next()) break; @@ -410,6 +413,13 @@ bool XformsColor::read(string const & filename) col.b = lexrc.getInteger(); fl_mapcolor(le, col.r, col.g, col.b); + + if (tag == "\\gui_pointer") { + fl_set_cursor_color(FL_DEFAULT_CURSOR, + FL_FREE_COL16, FL_WHITE); + fl_set_cursor_color(XC_question_arrow, + FL_FREE_COL16, FL_WHITE); + } } return true; @@ -427,7 +437,7 @@ bool XformsColor::write(string const & filename) << "### LyX, The Document Processor\n" << "###\n" << "### Copyright 1995 Matthias Ettrich\n" - << "### Copyright 1995-2001 The LyX Team.\n" + << "### Copyright 1995-2002 The LyX Team.\n" << "###\n" << "### ========================================================\n" << "\n" diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 25b90bc5fd..0857b261b3 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -674,6 +674,10 @@ FuncStatus LyXFunc::getStatus(kb_action action, // A few general toggles switch (action) { + case LFUN_TOOLTIPS_TOGGLE: + flag.setOnOff(owner->getDialogs()->tooltipsEnabled()); + break; + case LFUN_READ_ONLY_TOGGLE: flag.setOnOff(buf->isReadonly()); break; @@ -1648,6 +1652,10 @@ string const LyXFunc::dispatch(kb_action action, string argument) break; } + case LFUN_TOOLTIPS_TOGGLE: + owner->getDialogs()->toggleTooltips(); + break; + default: // Then if it was none of the above // Trying the BufferView::pimpl dispatch: -- 2.39.2