Merge branch 'textctrl-spellcheck'

Add wxTextCtrl::EnableProofCheck() to use native spell checking support.

See https://github.com/wxWidgets/wxWidgets/pull/2473
This commit is contained in:
Vadim Zeitlin
2021-08-27 21:58:32 +02:00
27 changed files with 650 additions and 16 deletions

View File

@@ -447,6 +447,14 @@
// Recommended setting: 1 (but may be safely disabled if you don't use it)
#define wxUSE_SECRETSTORE 1
// Allow the use of the OS built-in spell checker in wxTextCtrl.
//
// Default is 1, the corresponding wxTextCtrl functions simply won't do
// anything if the functionality is not supported by the current platform.
//
// Recommended setting: 1 unless you want to save a tiny bit of code.
#define wxUSE_SPELLCHECK 1
// Use wxStandardPaths class which allows to retrieve some standard locations
// in the file system
//

View File

@@ -282,6 +282,14 @@
# endif
#endif /* !defined(wxUSE_SECRETSTORE) */
#ifndef wxUSE_SPELLCHECK
# ifdef wxABORT_ON_CONFIG_ERROR
# error "wxUSE_SPELLCHECK must be defined, please read comment near the top of this file."
# else
# define wxUSE_SPELLCHECK 1
# endif
#endif /* !defined(wxUSE_SPELLCHECK) */
#ifndef wxUSE_STDPATHS
# ifdef wxABORT_ON_CONFIG_ERROR
# error "wxUSE_STDPATHS must be defined, please read comment near the top of this file."

View File

@@ -448,6 +448,14 @@
// Recommended setting: 1 (but may be safely disabled if you don't use it)
#define wxUSE_SECRETSTORE 1
// Allow the use of the OS built-in spell checker in wxTextCtrl.
//
// Default is 1, the corresponding wxTextCtrl functions simply won't do
// anything if the functionality is not supported by the current platform.
//
// Recommended setting: 1 unless you want to save a tiny bit of code.
#define wxUSE_SPELLCHECK 1
// Use wxStandardPaths class which allows to retrieve some standard locations
// in the file system
//

View File

@@ -96,6 +96,13 @@ public:
// Overridden wxWindow methods
virtual void SetWindowStyleFlag( long style ) wxOVERRIDE;
#if wxUSE_SPELLCHECK && defined(__WXGTK3__)
// Use native spelling and grammar checking functions.
virtual bool EnableProofCheck(const wxTextProofOptions& options
= wxTextProofOptions::Default()) wxOVERRIDE;
virtual wxTextProofOptions GetProofCheckOptions() const wxOVERRIDE;
#endif // wxUSE_SPELLCHECK && __WXGTK3__
// Implementation from now on
void OnDropFiles( wxDropFilesEvent &event );
void OnChar( wxKeyEvent &event );

View File

@@ -448,6 +448,14 @@
// Recommended setting: 1 (but may be safely disabled if you don't use it)
#define wxUSE_SECRETSTORE 1
// Allow the use of the OS built-in spell checker in wxTextCtrl.
//
// Default is 1, the corresponding wxTextCtrl functions simply won't do
// anything if the functionality is not supported by the current platform.
//
// Recommended setting: 1 unless you want to save a tiny bit of code.
#define wxUSE_SPELLCHECK 1
// Use wxStandardPaths class which allows to retrieve some standard locations
// in the file system
//

View File

@@ -448,6 +448,14 @@
// Recommended setting: 1 (but may be safely disabled if you don't use it)
#define wxUSE_SECRETSTORE 1
// Allow the use of the OS built-in spell checker in wxTextCtrl.
//
// Default is 1, the corresponding wxTextCtrl functions simply won't do
// anything if the functionality is not supported by the current platform.
//
// Recommended setting: 1 unless you want to save a tiny bit of code.
#define wxUSE_SPELLCHECK 1
// Use wxStandardPaths class which allows to retrieve some standard locations
// in the file system
//

View File

@@ -111,6 +111,14 @@ public:
bool ShowNativeCaret(bool show = true);
bool HideNativeCaret() { return ShowNativeCaret(false); }
#if wxUSE_RICHEDIT && wxUSE_SPELLCHECK
// Use native spelling and grammar checking functions.
// This is only available in wxTE_RICH2 controls.
virtual bool EnableProofCheck(const wxTextProofOptions& options
= wxTextProofOptions::Default()) wxOVERRIDE;
virtual wxTextProofOptions GetProofCheckOptions() const wxOVERRIDE;
#endif // wxUSE_RICHEDIT && wxUSE_SPELLCHECK
// Implementation from now on
// --------------------------

View File

@@ -127,7 +127,10 @@ public:
virtual bool HasOwnContextMenu() const wxOVERRIDE { return true; }
virtual void CheckSpelling(bool check) wxOVERRIDE;
#if wxUSE_SPELLCHECK
virtual void CheckSpelling(const wxTextProofOptions& options) wxOVERRIDE;
virtual wxTextProofOptions GetCheckingOptions() const wxOVERRIDE;
#endif // wxUSE_SPELLCHECK
virtual void EnableAutomaticQuoteSubstitution(bool enable) wxOVERRIDE;
virtual void EnableAutomaticDashSubstitution(bool enable) wxOVERRIDE;

View File

@@ -77,6 +77,8 @@ WXDLLIMPEXP_BASE CFURLRef wxOSXCreateURLFromFileSystemPath( const wxString& path
#include "wx/bitmap.h"
#include "wx/window.h"
class wxTextProofOptions;
class WXDLLIMPEXP_CORE wxMacCGContextStateSaver
{
wxDECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver);
@@ -737,7 +739,10 @@ public :
virtual void ShowPosition(long pos) ;
virtual int GetLineLength(long lineNo) const ;
virtual wxString GetLineText(long lineNo) const ;
virtual void CheckSpelling(bool WXUNUSED(check)) { }
#if wxUSE_SPELLCHECK
virtual void CheckSpelling(const wxTextProofOptions& WXUNUSED(options)) { }
virtual wxTextProofOptions GetCheckingOptions() const;
#endif // wxUSE_SPELLCHECK
virtual void EnableAutomaticQuoteSubstitution(bool WXUNUSED(enable)) {}
virtual void EnableAutomaticDashSubstitution(bool WXUNUSED(enable)) {}

View File

@@ -71,7 +71,6 @@ public:
virtual bool HasOwnContextMenu() const { return true; }
virtual void CheckSpelling(bool check);
virtual wxSize GetBestSize() const;
protected:

View File

@@ -454,6 +454,14 @@
// Recommended setting: 1 (but may be safely disabled if you don't use it)
#define wxUSE_SECRETSTORE 1
// Allow the use of the OS built-in spell checker in wxTextCtrl.
//
// Default is 1, the corresponding wxTextCtrl functions simply won't do
// anything if the functionality is not supported by the current platform.
//
// Recommended setting: 1 unless you want to save a tiny bit of code.
#define wxUSE_SPELLCHECK 1
// Use wxStandardPaths class which allows to retrieve some standard locations
// in the file system
//

View File

@@ -97,6 +97,13 @@ public:
virtual void Cut() wxOVERRIDE;
virtual void Paste() wxOVERRIDE;
#if wxUSE_SPELLCHECK
// Use native spelling and grammar checking functions (multiline only).
virtual bool EnableProofCheck(const wxTextProofOptions& options
= wxTextProofOptions::Default()) wxOVERRIDE;
virtual wxTextProofOptions GetProofCheckOptions() const wxOVERRIDE;
#endif // wxUSE_SPELLCHECK
// Implementation
// --------------
virtual void Command(wxCommandEvent& event) wxOVERRIDE;
@@ -130,7 +137,11 @@ public:
virtual void MacVisibilityChanged() wxOVERRIDE;
virtual void MacSuperChangedPosition() wxOVERRIDE;
virtual void MacCheckSpelling(bool check);
// Use portable EnableProofCheck() instead now.
#if WXWIN_COMPATIBILITY_3_0 && wxUSE_SPELLCHECK
wxDEPRECATED( virtual void MacCheckSpelling(bool check) );
#endif // WXWIN_COMPATIBILITY_3_0 && wxUSE_SPELLCHECK
void OSXEnableAutomaticQuoteSubstitution(bool enable);
void OSXEnableAutomaticDashSubstitution(bool enable);

View File

@@ -444,6 +444,14 @@
// Recommended setting: 1 (but may be safely disabled if you don't use it)
#define wxUSE_SECRETSTORE 1
// Allow the use of the OS built-in spell checker in wxTextCtrl.
//
// Default is 1, the corresponding wxTextCtrl functions simply won't do
// anything if the functionality is not supported by the current platform.
//
// Recommended setting: 1 unless you want to save a tiny bit of code.
#define wxUSE_SPELLCHECK 1
// Use wxStandardPaths class which allows to retrieve some standard locations
// in the file system
//

View File

@@ -126,6 +126,76 @@ enum wxTextCtrlHitTestResult
};
// ... the character returned
#if wxUSE_SPELLCHECK
// ----------------------------------------------------------------------------
// This object can be passed to wxTextCtrl::EnableProofCheck() to configure the
// proofing options for this control.
// ----------------------------------------------------------------------------
class wxTextProofOptions
{
public:
// Return the object corresponding to the default options: current
// language, spell checking enabled, grammar checking disabled.
static wxTextProofOptions Default()
{
wxTextProofOptions opts;
return opts.SpellCheck(true);
}
// Return the object with all checks disabled.
static wxTextProofOptions Disable()
{
return wxTextProofOptions();
}
// Default copy ctor, assignment operator and dtor are ok
// Methods that can be used to set the various options.
wxTextProofOptions& SpellCheck(bool enable = true)
{
m_EnableSpellCheck = enable;
return *this;
}
wxTextProofOptions& GrammarCheck(bool enable = true)
{
m_EnableGrammarCheck = enable;
return *this;
}
wxTextProofOptions& Language(const wxString& lang)
{
m_lang = lang;
return *this;
}
// And the corresponding accessors.
bool IsSpellCheckEnabled() const { return m_EnableSpellCheck; }
bool IsGrammarCheckEnabled() const { return m_EnableGrammarCheck; }
const wxString& GetLang() const { return m_lang; }
bool AnyChecksEnabled() const
{
return IsSpellCheckEnabled() || IsGrammarCheckEnabled();
}
private:
// Ctor is private, use static factory methods to create objects of this
// class.
wxTextProofOptions()
{
m_EnableSpellCheck =
m_EnableGrammarCheck = false;
}
wxString m_lang;
bool m_EnableSpellCheck;
bool m_EnableGrammarCheck;
};
#endif // wxUSE_SPELLCHECK
// ----------------------------------------------------------------------------
// Types for wxTextAttr
// ----------------------------------------------------------------------------
@@ -758,6 +828,19 @@ public:
virtual const wxTextEntry* WXGetTextEntry() const wxOVERRIDE { return this; }
#if wxUSE_SPELLCHECK
// Use native spelling and grammar checking functions.
virtual bool EnableProofCheck(const wxTextProofOptions& WXUNUSED(options)
= wxTextProofOptions::Default())
{
return false;
}
virtual wxTextProofOptions GetProofCheckOptions() const
{
return wxTextProofOptions::Disable();
}
#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

View File

@@ -447,6 +447,14 @@
// Recommended setting: 1 (but may be safely disabled if you don't use it)
#define wxUSE_SECRETSTORE 1
// Allow the use of the OS built-in spell checker in wxTextCtrl.
//
// Default is 1, the corresponding wxTextCtrl functions simply won't do
// anything if the functionality is not supported by the current platform.
//
// Recommended setting: 1 unless you want to save a tiny bit of code.
#define wxUSE_SPELLCHECK 1
// Use wxStandardPaths class which allows to retrieve some standard locations
// in the file system
//