Use the same "changed" GTK callback for wxComboBox and wxTextCtrl

And reuse EnableTextChangedEvents() between these classes as well.

No real changes so far, this is just a refactoring to centralize the
code in a single place before modifying it.
This commit is contained in:
Vadim Zeitlin
2019-07-08 16:04:24 +02:00
parent c024944d78
commit 5c766c0b8b
6 changed files with 53 additions and 68 deletions

View File

@@ -151,7 +151,6 @@ private:
// From wxTextEntry:
virtual wxWindow *GetEditableWindow() wxOVERRIDE { return this; }
virtual GtkEditable *GetEditable() const wxOVERRIDE;
virtual void EnableTextChangedEvents(bool enable) wxOVERRIDE;
void Init();

View File

@@ -184,7 +184,6 @@ private:
// overridden wxTextEntry virtual methods
virtual GtkEditable *GetEditable() const wxOVERRIDE;
virtual GtkEntry *GetEntry() const wxOVERRIDE;
virtual void EnableTextChangedEvents(bool enable) wxOVERRIDE;
// change the font for everything in this control
void ChangeFontGlobally();
@@ -198,7 +197,7 @@ private:
// returns either m_text or m_buffer depending on whether the control is
// single- or multi-line; convenient for the GTK+ functions which work with
// both
void *GetTextObject() const
void *GetTextObject() const wxOVERRIDE
{
return IsMultiLine() ? static_cast<void *>(m_buffer)
: static_cast<void *>(m_text);

View File

@@ -76,6 +76,10 @@ protected:
// And this one to connect "insert-text" signal.
void GTKConnectInsertTextSignal(GtkEntry* entry);
// Finally this one connects to the "changed" signal on the object returned
// by GetTextObject().
void GTKConnectChangedSignal();
virtual void DoSetValue(const wxString& value, int flags) wxOVERRIDE;
virtual wxString DoGetValue() const wxOVERRIDE;
@@ -92,6 +96,12 @@ protected:
static int GTKGetEntryTextLength(GtkEntry* entry);
// Block/unblock the corresponding GTK signal.
//
// Note that we make it protected in wxGTK as it is called from wxComboBox
// currently.
virtual void EnableTextChangedEvents(bool enable) wxOVERRIDE;
private:
// implement this to return the associated GtkEntry or another widget
// implementing GtkEditable
@@ -100,6 +110,12 @@ private:
// implement this to return the associated GtkEntry
virtual GtkEntry *GetEntry() const = 0;
// This one exists in order to be overridden by wxTextCtrl which uses
// either GtkEditable or GtkTextBuffer depending on whether it is single-
// or multi-line.
virtual void *GetTextObject() const { return GetEntry(); }
// Various auto-completion-related stuff, only used if any of AutoComplete()
// methods are called.
wxTextAutoCompleteData *m_autoCompleteData;