having broken Rob's word count update, I guess I should fix it too ;-)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5749 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2002-11-29 12:47:33 +00:00
parent 9068fa3b33
commit 8daf842ccd
4 changed files with 53 additions and 51 deletions

View File

@ -1,5 +1,10 @@
2002-11-29 Angus Leeming <leeming@lyx.org> 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 * FormPreferences.C (apply): if controller().isClosing() (ie, if the
"save" button has been pressed), then save any modified gui colors. "save" button has been pressed), then save any modified gui colors.

View File

@ -14,12 +14,14 @@
#pragma implementation #pragma implementation
#endif #endif
#include "Tooltips.h"
#include "xformsBC.h" #include "xformsBC.h"
#include "xforms_helpers.h"
#include "ControlSpellchecker.h" #include "ControlSpellchecker.h"
#include "FormSpellchecker.h" #include "FormSpellchecker.h"
#include "forms/form_spellchecker.h" #include "forms/form_spellchecker.h"
#include "forms_gettext.h"
#include "Tooltips.h"
#include "xforms_helpers.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include FORMS_H_LOCATION #include FORMS_H_LOCATION
@ -28,7 +30,7 @@ typedef FormCB<ControlSpellchecker, FormDB<FD_spellchecker> > base_class;
FormSpellchecker::FormSpellchecker() FormSpellchecker::FormSpellchecker()
: base_class(_("Spellchecker")), state_(STOP) : base_class(_("Spellchecker")), state_(STOPPED)
{} {}
@ -80,15 +82,27 @@ void FormSpellchecker::build()
void FormSpellchecker::updateState(State state) void FormSpellchecker::updateState(State state)
{ {
switch (state) { switch (state) {
case START: case READY_TO_START:
fl_set_slider_value(dialog_->slider_progress, 0.0); fl_set_slider_value(dialog_->slider_progress, 0.0);
fl_set_object_label(dialog_->slider_progress, "0 %"); fl_set_object_label(dialog_->slider_progress, "0 %");
break; 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(); int const progress = controller().getProgress();
if (progress == 0) if (progress == 0)
break; break;
@ -103,7 +117,7 @@ void FormSpellchecker::updateState(State state)
break; break;
} }
case STOP: case STOPPED:
{ {
controller().stop(); controller().stop();
@ -122,24 +136,24 @@ void FormSpellchecker::updateState(State state)
if (!state_change) if (!state_change)
return; return;
bool const set_running = (state == RUNNING); bool const running = (state == STARTED || state == CHECKING);
string const label = set_running ? _("Stop") : _("Start"); string const label = running ? _("Stop|#S") : _("Start|#S");
fl_set_object_label(dialog_->button_start, label.c_str()); fl_set_object_label(dialog_->button_start, idex(label).c_str());
fl_set_button_shortcut(dialog_->button_start, "#S", 1); fl_set_button_shortcut(dialog_->button_start, scex(label).c_str(), 1);
fl_redraw_object(dialog_->button_start); fl_redraw_object(dialog_->button_start);
string const tip = set_running ? string const tip = running ?
_("Stop the spellingchecker.") : _("Stop the spellingchecker.") :
_("Start the spellingchecker."); _("Start the spellingchecker.");
tooltips().init(dialog_->button_start, tip); tooltips().init(dialog_->button_start, tip);
setEnabled(dialog_->button_replace, set_running); setEnabled(dialog_->button_replace, running);
setEnabled(dialog_->button_ignore, set_running); setEnabled(dialog_->button_ignore, running);
setEnabled(dialog_->button_accept, set_running); setEnabled(dialog_->button_accept, running);
setEnabled(dialog_->button_add, set_running); setEnabled(dialog_->button_add, running);
setEnabled(dialog_->browser_suggestions, set_running); setEnabled(dialog_->browser_suggestions, running);
setEnabled(dialog_->input_replacement, set_running); setEnabled(dialog_->input_replacement, running);
} }
@ -151,14 +165,15 @@ void FormSpellchecker::update()
fl_clear_browser(dialog_->browser_suggestions); fl_clear_browser(dialog_->browser_suggestions);
// reset dialog and buttons into start condition // reset dialog and buttons into start condition
updateState(START); updateState(READY_TO_START);
} }
ButtonPolicy::SMInput FormSpellchecker::input(FL_OBJECT * ob, long ob_value) ButtonPolicy::SMInput FormSpellchecker::input(FL_OBJECT * ob, long ob_value)
{ {
if (ob == dialog_->button_start) { if (ob == dialog_->button_start) {
updateState(RUNNING); updateState(STARTED);
controller().check();
} else if (ob == dialog_->button_replace) { } else if (ob == dialog_->button_replace) {
string const tmp = getString(dialog_->input_replacement); string const tmp = getString(dialog_->input_replacement);
@ -200,21 +215,12 @@ void FormSpellchecker::partialUpdate(int id)
{ {
switch (id) { switch (id) {
case 1: case 1:
{
// Set suggestions. // Set suggestions.
string w = controller().getWord(); updateState(CHECKING);
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());
}
break; break;
}
case 2: case 2:
// End of spell checking. // End of spell checking.
updateState(STOP); updateState(STOPPED);
break; break;
} }
} }

View File

@ -23,7 +23,8 @@ struct FD_spellchecker;
/** This class provides an XForms implementation of the FormSpellchecker Dialog. /** 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: public:
/// ///
FormSpellchecker(); FormSpellchecker();
@ -43,9 +44,10 @@ private:
/// ///
enum State { enum State {
START, READY_TO_START,
RUNNING, STARTED,
STOP CHECKING,
STOPPED
}; };
/// ///
void updateState(State state); void updateState(State state);

View File

@ -52,12 +52,10 @@ void Tooltips::toggleEnabled()
void Tooltips::set() void Tooltips::set()
{ {
if (tooltipsMap.empty()) 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; return;
TooltipsMap::iterator it = tooltipsMap.begin(); TooltipsMap::const_iterator it = tooltipsMap.begin();
TooltipsMap::iterator end = tooltipsMap.end(); TooltipsMap::const_iterator end = tooltipsMap.end();
for (; it != end; ++it) { for (; it != end; ++it) {
FL_OBJECT * const ob = it->first; FL_OBJECT * const ob = it->first;
char const * const c_str = enabled_ ? it->second.c_str() : 0; 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); 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 // Store the tooltip string
str = formatted(str, 400); string const str = formatted(trim(tip), 400);
tooltipsMap[ob] = str; tooltipsMap[ob] = str;
// Set the tooltip // Set the tooltip