]> git.lyx.org Git - lyx.git/commitdiff
having broken Rob's word count update, I guess I should fix it too ;-)
authorAngus Leeming <leeming@lyx.org>
Fri, 29 Nov 2002 12:47:33 +0000 (12:47 +0000)
committerAngus Leeming <leeming@lyx.org>
Fri, 29 Nov 2002 12:47:33 +0000 (12:47 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5749 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/xforms/ChangeLog
src/frontends/xforms/FormSpellchecker.C
src/frontends/xforms/FormSpellchecker.h
src/frontends/xforms/Tooltips.C

index 605169f722e308b1ff1929347504631bcd835da7..bfab9e118ef228e36878138cb1f85999925980e8 100644 (file)
@@ -1,5 +1,10 @@
 2002-11-29  Angus Leeming  <leeming@lyx.org>
 
+       * Tooltips.C (init): allow tooltips to be reset.
+
+       * FormSpellchecker.C: having broken Rob's word count update, I guess
+       I should fix it too ;-)
+
        * FormPreferences.C (apply): if controller().isClosing() (ie, if the
        "save" button has been pressed), then save any modified gui colors.
 
index 7590294d0384ea64dfe818b4314a007aa59fc142..2d441c31bee17aee02e00bc1459a30aa026c77b2 100644 (file)
 #pragma implementation
 #endif
 
-#include "Tooltips.h"
 #include "xformsBC.h"
-#include "xforms_helpers.h"
 #include "ControlSpellchecker.h"
 #include "FormSpellchecker.h"
 #include "forms/form_spellchecker.h"
+
+#include "forms_gettext.h"
+#include "Tooltips.h"
+#include "xforms_helpers.h"
 #include "support/lstrings.h"
 
 #include FORMS_H_LOCATION
@@ -28,7 +30,7 @@ typedef FormCB<ControlSpellchecker, FormDB<FD_spellchecker> > base_class;
 
 
 FormSpellchecker::FormSpellchecker()
-       : base_class(_("Spellchecker")), state_(STOP)
+       : base_class(_("Spellchecker")), state_(STOPPED)
 {}
 
 
@@ -80,15 +82,27 @@ void FormSpellchecker::build()
 void FormSpellchecker::updateState(State state)
 {
        switch (state) {
-       case START:
+       case READY_TO_START:
                fl_set_slider_value(dialog_->slider_progress, 0.0);
                fl_set_object_label(dialog_->slider_progress, "0 %");
                break;
 
-       case RUNNING: 
+       case CHECKING:
        {
-               controller().check();
+               // Set suggestions.
+               string w = controller().getWord();
+               fl_set_input(dialog_->input_replacement, w.c_str());
+               fl_set_object_label(dialog_->text_unknown, w.c_str());
+               fl_clear_browser(dialog_->browser_suggestions);
+               while (!(w = controller().getSuggestion()).empty()) {
+                       fl_add_browser_line(dialog_->browser_suggestions,
+                                           w.c_str());
+               }
+               // Fall through...
+       }
 
+       case STARTED:
+       {
                int const progress = controller().getProgress();
                if (progress == 0)
                        break;
@@ -103,7 +117,7 @@ void FormSpellchecker::updateState(State state)
                break;
        }
 
-       case STOP
+       case STOPPED:
        {
                controller().stop();
 
@@ -122,24 +136,24 @@ void FormSpellchecker::updateState(State state)
        if (!state_change)
                return;
 
-       bool const set_running = (state == RUNNING);
-       string const label = set_running ? _("Stop") : _("Start");
-       
-       fl_set_object_label(dialog_->button_start, label.c_str());      
-       fl_set_button_shortcut(dialog_->button_start, "#S", 1);
+       bool const running = (state == STARTED || state == CHECKING);
+       string const label = running ? _("Stop|#S") : _("Start|#S");
+
+       fl_set_object_label(dialog_->button_start, idex(label).c_str());
+       fl_set_button_shortcut(dialog_->button_start, scex(label).c_str(), 1);
        fl_redraw_object(dialog_->button_start);
 
-       string const tip = set_running ?
+       string const tip = running ?
                _("Stop the spellingchecker.") :
                _("Start the spellingchecker.");
        tooltips().init(dialog_->button_start, tip);
-       
-       setEnabled(dialog_->button_replace,      set_running);
-       setEnabled(dialog_->button_ignore,       set_running);
-       setEnabled(dialog_->button_accept,       set_running);
-       setEnabled(dialog_->button_add,          set_running);
-       setEnabled(dialog_->browser_suggestions, set_running);
-       setEnabled(dialog_->input_replacement,   set_running);
+
+       setEnabled(dialog_->button_replace,      running);
+       setEnabled(dialog_->button_ignore,       running);
+       setEnabled(dialog_->button_accept,       running);
+       setEnabled(dialog_->button_add,          running);
+       setEnabled(dialog_->browser_suggestions, running);
+       setEnabled(dialog_->input_replacement,   running);
 }
 
 
@@ -151,14 +165,15 @@ void FormSpellchecker::update()
        fl_clear_browser(dialog_->browser_suggestions);
 
        // reset dialog and buttons into start condition
-       updateState(START);
+       updateState(READY_TO_START);
 }
 
 
 ButtonPolicy::SMInput FormSpellchecker::input(FL_OBJECT * ob, long ob_value)
 {
        if (ob == dialog_->button_start) {
-               updateState(RUNNING);
+               updateState(STARTED);
+               controller().check();
 
        } else if (ob == dialog_->button_replace) {
                string const tmp = getString(dialog_->input_replacement);
@@ -200,21 +215,12 @@ void FormSpellchecker::partialUpdate(int id)
 {
        switch (id) {
        case 1:
-       {
                // Set suggestions.
-               string w = controller().getWord();
-               fl_set_input(dialog_->input_replacement, w.c_str());
-               fl_set_object_label(dialog_->text_unknown, w.c_str());
-               fl_clear_browser(dialog_->browser_suggestions);
-               while (!(w = controller().getSuggestion()).empty()) {
-                       fl_add_browser_line(dialog_->browser_suggestions,
-                                           w.c_str());
-               }
+               updateState(CHECKING);
                break;
-       }
        case 2:
                // End of spell checking.
-               updateState(STOP);
+               updateState(STOPPED);
                break;
        }
 }
index 3f45a2d26cece93e99821a5577cc1507f63ee18e..0150cd29d74fa589d02070e3e9fc6b8d78ee7c8f 100644 (file)
@@ -23,7 +23,8 @@ struct FD_spellchecker;
 
 /** This class provides an XForms implementation of the FormSpellchecker Dialog.
  */
-class FormSpellchecker : public FormCB<ControlSpellchecker, FormDB<FD_spellchecker> > {
+class FormSpellchecker
+       : public FormCB<ControlSpellchecker, FormDB<FD_spellchecker> > {
 public:
        ///
        FormSpellchecker();
@@ -43,9 +44,10 @@ private:
 
        ///
        enum State {
-               START,
-               RUNNING,
-               STOP
+               READY_TO_START,
+               STARTED,
+               CHECKING,
+               STOPPED
        };
        ///
        void updateState(State state);
index 3bcc3e6fee5d160ca3fedf9bb0d81b3f34ec2efe..d5e3defd6f807d3b3d9517f8844809151067f5cb 100644 (file)
@@ -52,12 +52,10 @@ void Tooltips::toggleEnabled()
 void Tooltips::set()
 {
        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();
+       TooltipsMap::const_iterator it  = tooltipsMap.begin();
+       TooltipsMap::const_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;
@@ -70,17 +68,8 @@ void Tooltips::init(FL_OBJECT * ob, string const & tip)
 {
        lyx::Assert(ob && ob->form);
 
-       // Paranoia check!
-       TooltipsMap::const_iterator it = tooltipsMap.find(ob);
-       if (it != tooltipsMap.end())
-               return;
-
-       string str = trim(tip);
-       if (str.empty())
-               return;
-
        // Store the tooltip string
-       str = formatted(str, 400);
+       string const str = formatted(trim(tip), 400);
        tooltipsMap[ob] = str;
 
        // Set the tooltip