Merge branch 'gtk-text-changed-coalesce'
Harmonize wxEVT_TEXT events in wxGTK with other ports. Also use IME for wxComboBox in wxGTK too. See https://github.com/wxWidgets/wxWidgets/pull/1400
This commit is contained in:
@@ -145,13 +145,16 @@ protected:
|
||||
virtual GtkEntry *GetEntry() const wxOVERRIDE
|
||||
{ return m_entry; }
|
||||
|
||||
virtual int GTKIMFilterKeypress(GdkEventKey* event) const wxOVERRIDE
|
||||
{ return GTKEntryIMFilterKeypress(event); }
|
||||
|
||||
|
||||
GtkEntry* m_entry;
|
||||
|
||||
private:
|
||||
// From wxTextEntry:
|
||||
virtual wxWindow *GetEditableWindow() wxOVERRIDE { return this; }
|
||||
virtual GtkEditable *GetEditable() const wxOVERRIDE;
|
||||
virtual void EnableTextChangedEvents(bool enable) wxOVERRIDE;
|
||||
|
||||
void Init();
|
||||
|
||||
|
@@ -142,6 +142,8 @@ public:
|
||||
static wxVisualAttributes
|
||||
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
|
||||
|
||||
void GTKOnTextChanged() wxOVERRIDE;
|
||||
|
||||
protected:
|
||||
// overridden wxWindow virtual methods
|
||||
virtual wxSize DoGetBestSize() const wxOVERRIDE;
|
||||
@@ -182,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();
|
||||
@@ -196,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);
|
||||
|
@@ -15,6 +15,7 @@ typedef struct _GtkEditable GtkEditable;
|
||||
typedef struct _GtkEntry GtkEntry;
|
||||
|
||||
class wxTextAutoCompleteData; // private class used only by wxTextEntry itself
|
||||
class wxTextCoalesceData; // another private class
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTextEntry: roughly corresponds to GtkEditable
|
||||
@@ -62,6 +63,16 @@ public:
|
||||
bool GTKEntryOnInsertText(const char* text);
|
||||
bool GTKIsUpperCase() const { return m_isUpperCase; }
|
||||
|
||||
// Called from "changed" signal handler (or, possibly, slightly later, when
|
||||
// coalescing several "changed" signals into a single event) for GtkEntry.
|
||||
//
|
||||
// By default just generates a wxEVT_TEXT, but overridden to do more things
|
||||
// in wxTextCtrl.
|
||||
virtual void GTKOnTextChanged() { SendTextUpdatedEvent(); }
|
||||
|
||||
// Helper functions only used internally.
|
||||
wxTextCoalesceData* GTKGetCoalesceData() const { return m_coalesceData; }
|
||||
|
||||
protected:
|
||||
// This method must be called from the derived class Create() to connect
|
||||
// the handlers for the clipboard (cut/copy/paste) events.
|
||||
@@ -70,6 +81,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;
|
||||
@@ -81,11 +96,24 @@ protected:
|
||||
virtual bool DoAutoCompleteStrings(const wxArrayString& choices) wxOVERRIDE;
|
||||
virtual bool DoAutoCompleteCustom(wxTextCompleter *completer) wxOVERRIDE;
|
||||
|
||||
// Override the base class method to use GtkEntry IM context.
|
||||
virtual int GTKIMFilterKeypress(GdkEventKey* event) const;
|
||||
// Call this from the overridden wxWindow::GTKIMFilterKeypress() to use
|
||||
// GtkEntry IM context.
|
||||
int GTKEntryIMFilterKeypress(GdkEventKey* event) const;
|
||||
|
||||
// If GTKEntryIMFilterKeypress() is not called (as multiline wxTextCtrl
|
||||
// uses its own IM), call this method instead to still notify wxTextEntry
|
||||
// about the key press events in the given widget.
|
||||
void GTKEntryOnKeypress(GtkWidget* widget) const;
|
||||
|
||||
|
||||
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
|
||||
@@ -94,6 +122,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;
|
||||
@@ -101,6 +135,10 @@ private:
|
||||
// It needs to call our GetEntry() method.
|
||||
friend class wxTextAutoCompleteData;
|
||||
|
||||
// Data used for coalescing "changed" events resulting from a single user
|
||||
// action.
|
||||
mutable wxTextCoalesceData* m_coalesceData;
|
||||
|
||||
bool m_isUpperCase;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user