]> git.lyx.org Git - lyx.git/commitdiff
iThe cursor now behaves properly in the dialogs...
authorAngus Leeming <leeming@lyx.org>
Wed, 13 Mar 2002 11:26:36 +0000 (11:26 +0000)
committerAngus Leeming <leeming@lyx.org>
Wed, 13 Mar 2002 11:26:36 +0000 (11:26 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3740 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/xforms/ChangeLog
src/frontends/xforms/FormBase.C
src/frontends/xforms/FormBaseDeprecated.C
src/frontends/xforms/FormPreferences.C
src/frontends/xforms/Tooltips.C
src/frontends/xforms/xforms_helpers.C
src/frontends/xforms/xforms_helpers.h

index 1a17454c9c84faa915da62972082548e34ae2477..96d459e490e0c3da0d8e47849be5bebad9671a32 100644 (file)
@@ -1,3 +1,18 @@
+2002-03-13  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * 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  <a.leeming@ic.ac.uk>
 
        * forms/*.fd (except form_filedialog.fd which is v. scary :-():
index 420c85d4563791d8801bc2c649b03a7f2e3532a9..b637b5fb65fa5c6cb512f4dff091f2c5e9f2713e 100644 (file)
@@ -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);
+       }
 }
 
 
index 0ab52cee51c4edf2edabf675c2de32d14e0d86c3..e5735d07128874e62979435c4ce86e1ad93ce317 100644 (file)
@@ -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);
+       }
 }
 
 
index 1a2dc1458694001a89a97886740f9f14b3148966..821943c1c1cb509c3961807f91a5c4d1a53145f9 100644 (file)
@@ -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();
index 4328bab6eeee1d6f9956b2c37493b6020be1d0b6..c1aa13cc4784cf257320c4d648084029d0272ad1 100644 (file)
@@ -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();
 
index 70a3bcb99d214a92610ede2c0e713ce59bf1a683..54668d8c0611d1196ff6ba44c7ce9de38f300ec6 100644 (file)
  
 #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;
 }
 
index aba58c48ea5ebde17f927c065ff7970ec5746437..44bafe54849ea5e973e413505c254088356e1a4f 100644 (file)
@@ -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;