From ff6f7298179da580b1f5232e5d9ab31dd0d50b2c Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Wed, 13 Mar 2002 11:26:36 +0000 Subject: [PATCH] iThe cursor now behaves properly in the dialogs... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3740 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/xforms/ChangeLog | 15 ++++++++++++++ src/frontends/xforms/FormBase.C | 7 +++++++ src/frontends/xforms/FormBaseDeprecated.C | 7 +++++++ src/frontends/xforms/FormPreferences.C | 5 +---- src/frontends/xforms/Tooltips.C | 23 ++++++++++++++------- src/frontends/xforms/xforms_helpers.C | 25 +++++++++++++++-------- src/frontends/xforms/xforms_helpers.h | 5 +++++ 7 files changed, 67 insertions(+), 20 deletions(-) diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 1a17454c9c..96d459e490 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,18 @@ +2002-03-13 Angus Leeming + + * FormBase.C (show): + * FormBaseDeprecated.C (show): set the initial state of the cursor. + + * FormPreferences.C (Colors::apply()): use the helper function + setCursorColor. + + * Tooltips.C (toggleTooltips): proper fix for those Bad Window messages. + Can only set the cursor if the dialog is visible. + + * xforms_helpers.[Ch] (setCursorColor): new helper function to set the + color of all cursors used by LyX. + (XformsColor::read): use it. + 2002-03-12 Angus Leeming * forms/*.fd (except form_filedialog.fd which is v. scary :-(): diff --git a/src/frontends/xforms/FormBase.C b/src/frontends/xforms/FormBase.C index 420c85d456..b637b5fb65 100644 --- a/src/frontends/xforms/FormBase.C +++ b/src/frontends/xforms/FormBase.C @@ -101,6 +101,13 @@ void FormBase::show() (controller_.IconifyWithMain() ? FL_TRANSIENT : 0), title_.c_str()); } + + // Set the initial state of the cursor + if (form()->visible) { + int const cursor = Tooltips::enabled() ? + XC_question_arrow : FL_DEFAULT_CURSOR; + fl_set_cursor(form()->window, cursor); + } } diff --git a/src/frontends/xforms/FormBaseDeprecated.C b/src/frontends/xforms/FormBaseDeprecated.C index 0ab52cee51..e5735d0712 100644 --- a/src/frontends/xforms/FormBaseDeprecated.C +++ b/src/frontends/xforms/FormBaseDeprecated.C @@ -121,6 +121,13 @@ void FormBaseDeprecated::show() (lyxrc.dialogs_iconify_with_main ? FL_TRANSIENT : 0), title_.c_str()); } + + // Set the initial state of the cursor + if (form()->visible) { + int const cursor = Tooltips::enabled() ? + XC_question_arrow : FL_DEFAULT_CURSOR; + fl_set_cursor(form()->window, cursor); + } } diff --git a/src/frontends/xforms/FormPreferences.C b/src/frontends/xforms/FormPreferences.C index 1a2dc14586..821943c1c1 100644 --- a/src/frontends/xforms/FormPreferences.C +++ b/src/frontends/xforms/FormPreferences.C @@ -425,10 +425,7 @@ void FormPreferences::Colors::apply() if (cit->colorID == GUI_COLOR_CURSOR) { fl_mapcolor(GUI_COLOR_CURSOR, 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); + setCursorColor(GUI_COLOR_CURSOR); } } Dialogs::redrawGUI(); diff --git a/src/frontends/xforms/Tooltips.C b/src/frontends/xforms/Tooltips.C index 4328bab6ee..c1aa13cc47 100644 --- a/src/frontends/xforms/Tooltips.C +++ b/src/frontends/xforms/Tooltips.C @@ -70,16 +70,21 @@ void Tooltips::toggleTooltips() 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; + + // The dialog is not visible + if (!ob->form->window) + return; + + // Set the cursor to a question mark or back to the default. int const cursor = enabled_ ? XC_question_arrow : FL_DEFAULT_CURSOR; - fl_set_cursor(FL_ObjWin(ob), cursor); + fl_set_cursor(ob->form->window, cursor); } void Tooltips::initTooltip(FL_OBJECT * ob, string const & tip) { - lyx::Assert(ob); + lyx::Assert(ob && ob->form); // Paranoia check! TooltipsMap::const_iterator it = tooltipsMap.find(ob); @@ -152,16 +157,21 @@ void Tooltips::toggleTooltips() // 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; + + // The dialog is not visible + if (!ob->form->window) + return; + + // Set the cursor to a question mark or back to the default. int const cursor = enabled_ ? XC_question_arrow : FL_DEFAULT_CURSOR; - fl_set_cursor(FL_ObjWin(ob), cursor); + fl_set_cursor(ob->form->window, cursor); } void Tooltips::initTooltip(FL_OBJECT * ob, string const & tip) { - lyx::Assert(ob); + lyx::Assert(ob && ob->form); // Paranoia check! TooltipsMap::const_iterator it = tooltipsMap.find(ob); @@ -176,7 +186,6 @@ void Tooltips::initTooltip(FL_OBJECT * ob, string const & tip) tooltipsMap[ob] = formatted(_(str), 400); if (!tooltip_timer_) { - lyx::Assert(ob->form); if (fl_current_form && ob->form != fl_current_form) fl_end_form(); diff --git a/src/frontends/xforms/xforms_helpers.C b/src/frontends/xforms/xforms_helpers.C index 70a3bcb99d..54668d8c06 100644 --- a/src/frontends/xforms/xforms_helpers.C +++ b/src/frontends/xforms/xforms_helpers.C @@ -19,13 +19,13 @@ #include "xforms_helpers.h" #include "lyxlex.h" -#include "support/FileInfo.h" -#include "support/filetools.h" -#include "support/lstrings.h" // frontStrip, strip #include "gettext.h" -#include "support/LAssert.h" #include "lyxlength.h" #include "lyxgluelength.h" +#include "support/LAssert.h" +#include "support/FileInfo.h" +#include "support/filetools.h" +#include "support/lstrings.h" // frontStrip, strip using std::ofstream; using std::pair; @@ -364,6 +364,16 @@ string formatted(string const & sin, int w, int size, int style) } +void setCursorColor(int color) +{ + fl_set_cursor_color(FL_DEFAULT_CURSOR, color, FL_WHITE); + fl_set_cursor_color(XC_question_arrow, color, FL_WHITE); + fl_set_cursor_color(XC_xterm, color, FL_WHITE); + fl_set_cursor_color(XC_watch, color, FL_WHITE); + fl_set_cursor_color(XC_sb_right_arrow, color, FL_WHITE); +} + + namespace { // sorted by hand to prevent LyXLex from complaining on read(). @@ -420,13 +430,10 @@ bool XformsColor::read(string const & filename) 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); + setCursorColor(FL_FREE_COL16); } } - + return true; } diff --git a/src/frontends/xforms/xforms_helpers.h b/src/frontends/xforms/xforms_helpers.h index aba58c48ea..44bafe5484 100644 --- a/src/frontends/xforms/xforms_helpers.h +++ b/src/frontends/xforms/xforms_helpers.h @@ -81,6 +81,11 @@ void updateWidgetsFromLength(FL_OBJECT * input, FL_OBJECT * choice, LyXLength const & len, string const & default_unit); + +/// Called from Preferences when the cursor color is changed. +void setCursorColor(int color); + + /// struct holding xform-specific colors struct XformsColor : public NamedColor { int colorID; -- 2.39.2