diff --git a/include/wx/gtk/textctrl.h b/include/wx/gtk/textctrl.h index 390e27987f..b4d6e6b595 100644 --- a/include/wx/gtk/textctrl.h +++ b/include/wx/gtk/textctrl.h @@ -100,7 +100,7 @@ public: // Use native spelling and grammar checking functions. virtual bool EnableProofCheck(const wxTextProofOptions& options = wxTextProofOptions::Default()) wxOVERRIDE; - virtual bool IsProofCheckEnabled() const wxOVERRIDE; + virtual wxTextProofOptions GetProofCheckOptions() const wxOVERRIDE; #endif // wxUSE_SPELLCHECK && __WXGTK3__ // Implementation from now on diff --git a/include/wx/msw/textctrl.h b/include/wx/msw/textctrl.h index 1383120402..08ff22bbf4 100644 --- a/include/wx/msw/textctrl.h +++ b/include/wx/msw/textctrl.h @@ -116,7 +116,7 @@ public: // This is only available in wxTE_RICH2 controls. virtual bool EnableProofCheck(const wxTextProofOptions& options = wxTextProofOptions::Default()) wxOVERRIDE; - virtual bool IsProofCheckEnabled() const wxOVERRIDE; + virtual wxTextProofOptions GetProofCheckOptions() const wxOVERRIDE; #endif // wxUSE_RICHEDIT && wxUSE_SPELLCHECK // Implementation from now on diff --git a/include/wx/osx/cocoa/private/textimpl.h b/include/wx/osx/cocoa/private/textimpl.h index 2984375992..c6b57b5a6a 100644 --- a/include/wx/osx/cocoa/private/textimpl.h +++ b/include/wx/osx/cocoa/private/textimpl.h @@ -129,7 +129,7 @@ public: #if wxUSE_SPELLCHECK virtual void CheckSpelling(const wxTextProofOptions& options) wxOVERRIDE; - virtual bool IsSpellingCheckEnabled() const wxOVERRIDE; + virtual wxTextProofOptions GetCheckingOptions() 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 4dd3074b7c..db904c8207 100644 --- a/include/wx/osx/core/private.h +++ b/include/wx/osx/core/private.h @@ -741,7 +741,7 @@ public : virtual wxString GetLineText(long lineNo) const ; #if wxUSE_SPELLCHECK virtual void CheckSpelling(const wxTextProofOptions& WXUNUSED(options)) { } - virtual bool IsSpellingCheckEnabled() const { return false; } + virtual wxTextProofOptions GetCheckingOptions() const; #endif // wxUSE_SPELLCHECK virtual void EnableAutomaticQuoteSubstitution(bool WXUNUSED(enable)) {} virtual void EnableAutomaticDashSubstitution(bool WXUNUSED(enable)) {} diff --git a/include/wx/osx/textctrl.h b/include/wx/osx/textctrl.h index b528ee0887..6e6a40817c 100644 --- a/include/wx/osx/textctrl.h +++ b/include/wx/osx/textctrl.h @@ -101,7 +101,7 @@ public: // Use native spelling and grammar checking functions (multiline only). virtual bool EnableProofCheck(const wxTextProofOptions& options = wxTextProofOptions::Default()) wxOVERRIDE; - virtual bool IsProofCheckEnabled() const wxOVERRIDE; + virtual wxTextProofOptions GetProofCheckOptions() const wxOVERRIDE; #endif // wxUSE_SPELLCHECK // Implementation diff --git a/include/wx/textctrl.h b/include/wx/textctrl.h index 12553337c0..b2db92f48e 100644 --- a/include/wx/textctrl.h +++ b/include/wx/textctrl.h @@ -171,10 +171,15 @@ public: } // And the corresponding accessors. - bool IsSpellCheckingEnabled() const { return m_EnableSpellCheck; } - bool IsGrammarCheckingEnabled() const { return m_EnableGrammarCheck; } + 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. @@ -830,7 +835,10 @@ public: { return false; } - virtual bool IsProofCheckEnabled() const { return false; } + virtual wxTextProofOptions GetProofCheckOptions() const + { + return wxTextProofOptions::Disable(); + } #endif // wxUSE_SPELLCHECK protected: diff --git a/interface/wx/textctrl.h b/interface/wx/textctrl.h index 6dd7216e03..40d26da191 100644 --- a/interface/wx/textctrl.h +++ b/interface/wx/textctrl.h @@ -1004,7 +1004,7 @@ public: constructor, so its objects can only be created using the static factory methods Default() or Disable(). - @see wxTextCtrl::EnableProofCheck(), wxTextCtrl::IsProofCheckEnabled(). + @see wxTextCtrl::EnableProofCheck(), wxTextCtrl::GetProofCheckOptions(). @since 3.1.6 */ @@ -1039,10 +1039,13 @@ class WXDLLIMPEXP_CORE wxTextProofOptions wxTextProofOptions& GrammarCheck(bool enable = true) /// Return true if spell checking is enabled. - bool IsSpellCheckingEnabled() const; + bool IsSpellCheckEnabled() const; /// Return true if grammar checking is enabled. - bool IsGrammarCheckingEnabled() const; + bool IsGrammarCheckEnabled() const; + + /// Returns true if any checks are enabled. + bool AnyChecksEnabled() const }; /** @@ -1570,15 +1573,16 @@ public: bool IsSingleLine() const; /** - Returns @true if proof (spell) checking is currently active on this - control, @false otherwise. + Returns the current text proofing options. This function is implemented for the same platforms as - EnableProofCheck() and returns @false for the other ones. + EnableProofCheck() and returns wxTextProofOptions with all checks + disabled, i.e. such that wxTextProofOptions::AnyChecksEnabled() returns + @false. @since 3.1.6 */ - virtual bool IsProofCheckEnabled(); + virtual wxTextProofOptions GetProofCheckOptions(); /** Loads and displays the named file, if it exists. diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 3c5f5e8427..b279d1a817 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -1036,7 +1036,7 @@ bool wxTextCtrl::EnableProofCheck(const wxTextProofOptions& options) GtkSpellChecker *spell = gtk_spell_checker_get_from_text_view(textview); - if ( options.IsSpellCheckingEnabled() ) + if ( options.IsSpellCheckEnabled() ) { if ( !spell ) { @@ -1057,19 +1057,22 @@ bool wxTextCtrl::EnableProofCheck(const wxTextProofOptions& options) gtk_spell_checker_detach(spell); } - return IsProofCheckEnabled(); + return GetProofCheckOptions().IsSpellCheckEnabled(); } -bool wxTextCtrl::IsProofCheckEnabled() const +wxTextProofOptions wxTextCtrl::GetProofCheckOptions() const { + wxTextProofOptions opts = wxTextProofOptions::Disable(); + GtkTextView *textview = GTK_TEXT_VIEW(m_text); - if ( !IsMultiLine() || textview == NULL ) - return false; + if ( IsMultiLine() && textview ) + { + if ( gtk_spell_checker_get_from_text_view(textview) ) + opts.SpellCheck(); + } - GtkSpellChecker *spell = gtk_spell_checker_get_from_text_view(textview); - - return (spell != NULL); + return opts; } #endif // wxUSE_SPELLCHECK && __WXGTK3__ diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index d2a9082a9d..4e06cff953 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -846,21 +846,26 @@ bool wxTextCtrl::EnableProofCheck(const wxTextProofOptions& options) LRESULT langOptions = ::SendMessage(GetHwnd(), EM_GETLANGOPTIONS, 0, 0); - if ( options.IsSpellCheckingEnabled() ) + if ( options.IsSpellCheckEnabled() ) langOptions |= IMF_SPELLCHECKING; else langOptions &= ~IMF_SPELLCHECKING; ::SendMessage(GetHwnd(), EM_SETLANGOPTIONS, 0, langOptions); - return IsProofCheckEnabled(); + return GetProofCheckOptions().IsSpellCheckEnabled(); } -bool wxTextCtrl::IsProofCheckEnabled() const +wxTextProofOptions wxTextCtrl::GetProofCheckOptions() const { + wxTextProofOptions opts = wxTextProofOptions::Disable(); + LRESULT langOptions = ::SendMessage(GetHwnd(), EM_GETLANGOPTIONS, 0, 0); - return (langOptions & IMF_SPELLCHECKING); + if (langOptions & IMF_SPELLCHECKING) + opts.SpellCheck(); + + return opts; } #endif // wxUSE_SPELLCHECK diff --git a/src/osx/cocoa/textctrl.mm b/src/osx/cocoa/textctrl.mm index 23f9b95ce0..d756dc09d4 100644 --- a/src/osx/cocoa/textctrl.mm +++ b/src/osx/cocoa/textctrl.mm @@ -1283,13 +1283,20 @@ void wxNSTextViewControl::CheckSpelling(const wxTextProofOptions& options) { wxCHECK_RET( m_textView, "control must be created first" ); - m_textView.continuousSpellCheckingEnabled = options.IsSpellCheckingEnabled(); - m_textView.grammarCheckingEnabled = options.IsGrammarCheckingEnabled(); + m_textView.continuousSpellCheckingEnabled = options.IsSpellCheckEnabled(); + m_textView.grammarCheckingEnabled = options.IsGrammarCheckEnabled(); } -bool wxNSTextViewControl::IsSpellingCheckEnabled() const +wxTextProofOptions wxNSTextViewControl::GetCheckingOptions() const { - return m_textView && m_textView.continuousSpellCheckingEnabled; + wxTextProofOptions opts = wxTextProofOptions::Disable(); + if ( m_textView ) + { + opts.SpellCheck(m_textView.continuousSpellCheckingEnabled); + opts.GrammarCheck(m_textView.grammarCheckingEnabled); + } + + return opts; } #endif // wxUSE_SPELLCHECK diff --git a/src/osx/textctrl_osx.cpp b/src/osx/textctrl_osx.cpp index 969e6a9d48..670e4859e2 100644 --- a/src/osx/textctrl_osx.cpp +++ b/src/osx/textctrl_osx.cpp @@ -352,9 +352,9 @@ bool wxTextCtrl::EnableProofCheck(const wxTextProofOptions& options) return true; } -bool wxTextCtrl::IsProofCheckEnabled() const +wxTextProofOptions wxTextCtrl::GetProofCheckOptions() const { - return GetTextPeer()->IsSpellingCheckEnabled(); + return GetTextPeer()->GetCheckingOptions(); } #endif // wxUSE_SPELLCHECK @@ -827,6 +827,15 @@ int wxTextWidgetImpl::GetLineLength(long lineNo) const return -1 ; } +#if wxUSE_SPELLCHECK + +wxTextProofOptions wxTextWidgetImpl::GetCheckingOptions() const +{ + return wxTextProofOptions::Disable(); +} + +#endif // wxUSE_SPELLCHECK + void wxTextWidgetImpl::SetJustification() { }