]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlSpellchecker.h
Add support for the jurabib package (www.jurabib.org), a package for elegant BibTeX...
[lyx.git] / src / frontends / controllers / ControlSpellchecker.h
1 // -*- C++ -*-
2 /**
3  * \file ControlSpellchecker.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Edwin Leuven
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef CONTROLSPELLCHECKER_H
13 #define CONTROLSPELLCHECKER_H
14
15 #include <boost/scoped_ptr.hpp>
16
17 #include "ControlDialog_impl.h"
18 #include "WordLangTuple.h"
19
20 class SpellBase;
21
22 /** A controller for Spellchecker dialogs.
23  */
24 class ControlSpellchecker : public ControlDialogBD {
25 public:
26         enum State {
27                 SPELL_PROGRESSED, //< update progress bar
28                 SPELL_FOUND_WORD //< found a bad word
29         };
30
31         ControlSpellchecker(LyXView &, Dialogs &);
32
33         ~ControlSpellchecker();
34
35         /// replace word with replacement
36         void replace(std::string const &);
37
38         /// replace all occurances of word
39         void replaceAll(std::string const &);
40
41         /// insert word in personal dictionary
42         void insert();
43
44         /// ignore all occurances of word
45         void ignoreAll();
46
47         /// check text until next misspelled/unknown word
48         /// returns true when finished
49         void check();
50
51         /// get suggestion
52         std::string const getSuggestion() const;
53
54         /// get word
55         std::string const getWord() const;
56
57         /// returns progress value
58         int getProgress() const { return oldval_; }
59
60         /// returns word count
61         int getCount()  const { return count_; }
62
63 private:
64         /// give error message is spellchecker dies
65         bool checkAlive();
66
67         /// start a spell-checking session
68         void startSession();
69
70         /// end a spell-checking session
71         void endSession();
72
73         /// show count of checked words at normal exit
74         void showSummary();
75
76         /// set the params before show or update
77         void setParams();
78         /// clean-up on hide.
79         void clearParams();
80
81         /// not needed.
82         virtual void apply() {}
83
84         /// current word being checked and lang code
85         WordLangTuple word_;
86
87         /// values for progress
88         int oldval_;
89         int newvalue_;
90
91         /// word count
92         int count_;
93
94         /// The actual spellchecker object
95         boost::scoped_ptr<SpellBase> speller_;
96 };
97
98 #endif // CONTROLSPELLCHECKER_H