diff --git a/include/wx/osx/cocoa/private/textimpl.h b/include/wx/osx/cocoa/private/textimpl.h index 9c6b5f884a..2984375992 100644 --- a/include/wx/osx/cocoa/private/textimpl.h +++ b/include/wx/osx/cocoa/private/textimpl.h @@ -127,8 +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 bool IsSpellingCheckEnabled() const wxOVERRIDE; +#endif // wxUSE_SPELLCHECK virtual void EnableAutomaticQuoteSubstitution(bool enable) wxOVERRIDE; virtual void EnableAutomaticDashSubstitution(bool enable) wxOVERRIDE; diff --git a/include/wx/osx/core/private.h b/include/wx/osx/core/private.h index 326e6e963f..4dd3074b7c 100644 --- a/include/wx/osx/core/private.h +++ b/include/wx/osx/core/private.h @@ -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,8 +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 bool IsSpellingCheckEnabled() const { return false; } +#endif // wxUSE_SPELLCHECK virtual void EnableAutomaticQuoteSubstitution(bool WXUNUSED(enable)) {} virtual void EnableAutomaticDashSubstitution(bool WXUNUSED(enable)) {} diff --git a/include/wx/osx/iphone/private/textimpl.h b/include/wx/osx/iphone/private/textimpl.h index c9beb7818a..1a2876e4fe 100644 --- a/include/wx/osx/iphone/private/textimpl.h +++ b/include/wx/osx/iphone/private/textimpl.h @@ -71,8 +71,10 @@ public: virtual bool HasOwnContextMenu() const { return true; } - virtual void CheckSpelling(bool check); +#if wxUSE_SPELLCHECK + virtual void CheckSpelling(const wxTextProofOptions& options); virtual bool IsSpellingCheckEnabled() const; +#endif // wxUSE_SPELLCHECK virtual wxSize GetBestSize() const; diff --git a/include/wx/osx/textctrl.h b/include/wx/osx/textctrl.h index 0bc924713d..b528ee0887 100644 --- a/include/wx/osx/textctrl.h +++ b/include/wx/osx/textctrl.h @@ -139,9 +139,9 @@ public: virtual void MacSuperChangedPosition() wxOVERRIDE; // Use portable EnableProofCheck() instead now. -#if WXWIN_COMPATIBILITY_3_0 +#if WXWIN_COMPATIBILITY_3_0 && wxUSE_SPELLCHECK wxDEPRECATED( virtual void MacCheckSpelling(bool check) ); -#endif // WXWIN_COMPATIBILITY_3_0 +#endif // WXWIN_COMPATIBILITY_3_0 && wxUSE_SPELLCHECK void OSXEnableAutomaticQuoteSubstitution(bool enable); void OSXEnableAutomaticDashSubstitution(bool enable); diff --git a/interface/wx/textctrl.h b/interface/wx/textctrl.h index 73122f5444..6dd7216e03 100644 --- a/interface/wx/textctrl.h +++ b/interface/wx/textctrl.h @@ -1033,7 +1033,8 @@ class WXDLLIMPEXP_CORE wxTextProofOptions /** Enable / disable grammar checking for this control. - This option is not currently supported and is ignored. + This option is currently only supported under macOS and is ignored under + the other platforms. */ wxTextProofOptions& GrammarCheck(bool enable = true) diff --git a/src/osx/cocoa/textctrl.mm b/src/osx/cocoa/textctrl.mm index 91e62092b2..23f9b95ce0 100644 --- a/src/osx/cocoa/textctrl.mm +++ b/src/osx/cocoa/textctrl.mm @@ -1277,10 +1277,14 @@ void wxNSTextViewControl::SetStyle(long start, } } -void wxNSTextViewControl::CheckSpelling(bool check) +#if wxUSE_SPELLCHECK + +void wxNSTextViewControl::CheckSpelling(const wxTextProofOptions& options) { - if (m_textView) - [m_textView setContinuousSpellCheckingEnabled: check]; + wxCHECK_RET( m_textView, "control must be created first" ); + + m_textView.continuousSpellCheckingEnabled = options.IsSpellCheckingEnabled(); + m_textView.grammarCheckingEnabled = options.IsGrammarCheckingEnabled(); } bool wxNSTextViewControl::IsSpellingCheckEnabled() const @@ -1288,6 +1292,8 @@ bool wxNSTextViewControl::IsSpellingCheckEnabled() const return m_textView && m_textView.continuousSpellCheckingEnabled; } +#endif // wxUSE_SPELLCHECK + void wxNSTextViewControl::EnableAutomaticQuoteSubstitution(bool enable) { if (m_textView) diff --git a/src/osx/iphone/textctrl.mm b/src/osx/iphone/textctrl.mm index 9be4a74c09..889cf3c676 100644 --- a/src/osx/iphone/textctrl.mm +++ b/src/osx/iphone/textctrl.mm @@ -500,7 +500,9 @@ void wxUITextViewControl::SetStyle(long start, } } -void wxUITextViewControl::CheckSpelling(bool check) +#if wxUSE_SPELLCHECK + +void wxUITextViewControl::CheckSpelling(const wxTextProofOptions& WXUNUSED(options)) { } @@ -509,6 +511,8 @@ bool wxUITextViewControl::IsSpellingCheckEnabled() const return false; } +#endif // wxUSE_SPELLCHECK + wxSize wxUITextViewControl::GetBestSize() const { wxRect r; diff --git a/src/osx/textctrl_osx.cpp b/src/osx/textctrl_osx.cpp index 1af21da2ca..969e6a9d48 100644 --- a/src/osx/textctrl_osx.cpp +++ b/src/osx/textctrl_osx.cpp @@ -124,12 +124,13 @@ void wxTextCtrl::MacVisibilityChanged() { } -#if WXWIN_COMPATIBILITY_3_0 +#if WXWIN_COMPATIBILITY_3_0 && wxUSE_SPELLCHECK void wxTextCtrl::MacCheckSpelling(bool check) { - GetTextPeer()->CheckSpelling(check); + GetTextPeer()->CheckSpelling(check ? wxTextProofOptions::Default() + : wxTextProofOptions::Disable()); } -#endif // WXWIN_COMPATIBILITY_3_0 +#endif // WXWIN_COMPATIBILITY_3_0 && wxUSE_SPELLCHECK void wxTextCtrl::OSXEnableAutomaticQuoteSubstitution(bool enable) { @@ -346,7 +347,7 @@ void wxTextCtrl::Paste() bool wxTextCtrl::EnableProofCheck(const wxTextProofOptions& options) { - GetTextPeer()->CheckSpelling(options.IsSpellCheckingEnabled()); + GetTextPeer()->CheckSpelling(options); return true; }