Implement support for grammar checking in wxOSX
Use native support for grammar checking in NSTextView. As we're not passing wxTextProofOptions to the lower level function, this functionality now depends on wxUSE_SPELLCHECK, meaning that even the previously existing MacCheckSpelling() function is not defined any more when wxUSE_SPELLCHECK is set to 0. This is not completely backwards-compatible, but hopefully shouldn't be a problem in practice and shouldn't break any existing applications which can't disable the just added wxUSE_SPELLCHECK.
This commit is contained in:
@@ -127,8 +127,10 @@ public:
|
|||||||
|
|
||||||
virtual bool HasOwnContextMenu() const wxOVERRIDE { return true; }
|
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;
|
virtual bool IsSpellingCheckEnabled() const wxOVERRIDE;
|
||||||
|
#endif // wxUSE_SPELLCHECK
|
||||||
virtual void EnableAutomaticQuoteSubstitution(bool enable) wxOVERRIDE;
|
virtual void EnableAutomaticQuoteSubstitution(bool enable) wxOVERRIDE;
|
||||||
virtual void EnableAutomaticDashSubstitution(bool enable) wxOVERRIDE;
|
virtual void EnableAutomaticDashSubstitution(bool enable) wxOVERRIDE;
|
||||||
|
|
||||||
|
@@ -77,6 +77,8 @@ WXDLLIMPEXP_BASE CFURLRef wxOSXCreateURLFromFileSystemPath( const wxString& path
|
|||||||
#include "wx/bitmap.h"
|
#include "wx/bitmap.h"
|
||||||
#include "wx/window.h"
|
#include "wx/window.h"
|
||||||
|
|
||||||
|
class wxTextProofOptions;
|
||||||
|
|
||||||
class WXDLLIMPEXP_CORE wxMacCGContextStateSaver
|
class WXDLLIMPEXP_CORE wxMacCGContextStateSaver
|
||||||
{
|
{
|
||||||
wxDECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver);
|
wxDECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver);
|
||||||
@@ -737,8 +739,10 @@ public :
|
|||||||
virtual void ShowPosition(long pos) ;
|
virtual void ShowPosition(long pos) ;
|
||||||
virtual int GetLineLength(long lineNo) const ;
|
virtual int GetLineLength(long lineNo) const ;
|
||||||
virtual wxString GetLineText(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; }
|
virtual bool IsSpellingCheckEnabled() const { return false; }
|
||||||
|
#endif // wxUSE_SPELLCHECK
|
||||||
virtual void EnableAutomaticQuoteSubstitution(bool WXUNUSED(enable)) {}
|
virtual void EnableAutomaticQuoteSubstitution(bool WXUNUSED(enable)) {}
|
||||||
virtual void EnableAutomaticDashSubstitution(bool WXUNUSED(enable)) {}
|
virtual void EnableAutomaticDashSubstitution(bool WXUNUSED(enable)) {}
|
||||||
|
|
||||||
|
@@ -71,8 +71,10 @@ public:
|
|||||||
|
|
||||||
virtual bool HasOwnContextMenu() const { return true; }
|
virtual bool HasOwnContextMenu() const { return true; }
|
||||||
|
|
||||||
virtual void CheckSpelling(bool check);
|
#if wxUSE_SPELLCHECK
|
||||||
|
virtual void CheckSpelling(const wxTextProofOptions& options);
|
||||||
virtual bool IsSpellingCheckEnabled() const;
|
virtual bool IsSpellingCheckEnabled() const;
|
||||||
|
#endif // wxUSE_SPELLCHECK
|
||||||
|
|
||||||
virtual wxSize GetBestSize() const;
|
virtual wxSize GetBestSize() const;
|
||||||
|
|
||||||
|
@@ -139,9 +139,9 @@ public:
|
|||||||
virtual void MacSuperChangedPosition() wxOVERRIDE;
|
virtual void MacSuperChangedPosition() wxOVERRIDE;
|
||||||
|
|
||||||
// Use portable EnableProofCheck() instead now.
|
// Use portable EnableProofCheck() instead now.
|
||||||
#if WXWIN_COMPATIBILITY_3_0
|
#if WXWIN_COMPATIBILITY_3_0 && wxUSE_SPELLCHECK
|
||||||
wxDEPRECATED( virtual void MacCheckSpelling(bool check) );
|
wxDEPRECATED( virtual void MacCheckSpelling(bool check) );
|
||||||
#endif // WXWIN_COMPATIBILITY_3_0
|
#endif // WXWIN_COMPATIBILITY_3_0 && wxUSE_SPELLCHECK
|
||||||
|
|
||||||
void OSXEnableAutomaticQuoteSubstitution(bool enable);
|
void OSXEnableAutomaticQuoteSubstitution(bool enable);
|
||||||
void OSXEnableAutomaticDashSubstitution(bool enable);
|
void OSXEnableAutomaticDashSubstitution(bool enable);
|
||||||
|
@@ -1033,7 +1033,8 @@ class WXDLLIMPEXP_CORE wxTextProofOptions
|
|||||||
/**
|
/**
|
||||||
Enable / disable grammar checking for this control.
|
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)
|
wxTextProofOptions& GrammarCheck(bool enable = true)
|
||||||
|
|
||||||
|
@@ -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)
|
wxCHECK_RET( m_textView, "control must be created first" );
|
||||||
[m_textView setContinuousSpellCheckingEnabled: check];
|
|
||||||
|
m_textView.continuousSpellCheckingEnabled = options.IsSpellCheckingEnabled();
|
||||||
|
m_textView.grammarCheckingEnabled = options.IsGrammarCheckingEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxNSTextViewControl::IsSpellingCheckEnabled() const
|
bool wxNSTextViewControl::IsSpellingCheckEnabled() const
|
||||||
@@ -1288,6 +1292,8 @@ bool wxNSTextViewControl::IsSpellingCheckEnabled() const
|
|||||||
return m_textView && m_textView.continuousSpellCheckingEnabled;
|
return m_textView && m_textView.continuousSpellCheckingEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_SPELLCHECK
|
||||||
|
|
||||||
void wxNSTextViewControl::EnableAutomaticQuoteSubstitution(bool enable)
|
void wxNSTextViewControl::EnableAutomaticQuoteSubstitution(bool enable)
|
||||||
{
|
{
|
||||||
if (m_textView)
|
if (m_textView)
|
||||||
|
@@ -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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_SPELLCHECK
|
||||||
|
|
||||||
wxSize wxUITextViewControl::GetBestSize() const
|
wxSize wxUITextViewControl::GetBestSize() const
|
||||||
{
|
{
|
||||||
wxRect r;
|
wxRect r;
|
||||||
|
@@ -124,12 +124,13 @@ void wxTextCtrl::MacVisibilityChanged()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#if WXWIN_COMPATIBILITY_3_0
|
#if WXWIN_COMPATIBILITY_3_0 && wxUSE_SPELLCHECK
|
||||||
void wxTextCtrl::MacCheckSpelling(bool check)
|
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)
|
void wxTextCtrl::OSXEnableAutomaticQuoteSubstitution(bool enable)
|
||||||
{
|
{
|
||||||
@@ -346,7 +347,7 @@ void wxTextCtrl::Paste()
|
|||||||
|
|
||||||
bool wxTextCtrl::EnableProofCheck(const wxTextProofOptions& options)
|
bool wxTextCtrl::EnableProofCheck(const wxTextProofOptions& options)
|
||||||
{
|
{
|
||||||
GetTextPeer()->CheckSpelling(options.IsSpellCheckingEnabled());
|
GetTextPeer()->CheckSpelling(options);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user