Add support for using native spell checking in wxTextCtrl

Add wxTextCtrl::EnableSpellCheck() and implement it for wxMSW and
wxGTK3.

Closes #17544.
This commit is contained in:
iwbnwif
2021-08-18 21:17:04 +01:00
committed by Vadim Zeitlin
parent d6ba8eafc5
commit 472aec2d7e
19 changed files with 575 additions and 4 deletions

View File

@@ -126,6 +126,45 @@ enum wxTextCtrlHitTestResult
};
// ... the character returned
#if wxUSE_SPELLCHECK
// ----------------------------------------------------------------------------
// wxTextCtrl proof options object
// Passed to ::EnableProofCheck() to configure the proofing options for
// this control
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxTextProofOptions
{
public:
wxTextProofOptions(const wxString& lang = wxEmptyString)
: m_lang(lang)
{
m_EnableSpellCheck = true;
m_EnableGrammarCheck = false;
}
wxTextProofOptions& SpellCheck(bool enable = true)
{
m_EnableSpellCheck = enable;
return *this;
}
wxTextProofOptions& GrammarCheck(bool enable = true)
{
m_EnableGrammarCheck = enable;
return *this;
}
const wxString& GetLang() const { return m_lang; }
private:
wxString m_lang;
bool m_EnableSpellCheck;
bool m_EnableGrammarCheck;
};
#endif // wxUSE_SPELLCHECK
// ----------------------------------------------------------------------------
// Types for wxTextAttr
// ----------------------------------------------------------------------------
@@ -758,6 +797,15 @@ public:
virtual const wxTextEntry* WXGetTextEntry() const wxOVERRIDE { return this; }
#if wxUSE_SPELLCHECK
// Use native spelling and grammar checking functions.
virtual bool EnableProofCheck(bool WXUNUSED(enable) = true,
const wxTextProofOptions& WXUNUSED(options) =
wxTextProofOptions())
{ return false; }
virtual bool IsProofCheckEnabled() const { return false; }
#endif // wxUSE_SPELLCHECK
protected:
// Override wxEvtHandler method to check for a common problem of binding
// wxEVT_TEXT_ENTER to a control without wxTE_PROCESS_ENTER style, which is