diff --git a/include/wx/gtk/textctrl.h b/include/wx/gtk/textctrl.h index 802ff28fed..743e3db31a 100644 --- a/include/wx/gtk/textctrl.h +++ b/include/wx/gtk/textctrl.h @@ -11,6 +11,8 @@ #define _WX_GTK_TEXTCTRL_H_ typedef struct _GtkTextMark GtkTextMark; +typedef struct _GTKGetTextBuffer GTKGetTextBuffer; +typedef struct _GTKGetEditable GTKGetEditable; //----------------------------------------------------------------------------- // wxTextCtrl @@ -186,6 +188,11 @@ protected: void GTKSetWrapMode(); void GTKSetJustification(); + // get the underlying text buffer for multi-line controls, or null otherwise + GtkTextBuffer *GTKGetTextBuffer() { return IsMultiLine() ? m_buffer : nullptr; } + // get the underlying text control + GtkEditable *GTKGetEditable() const { return GetEditable(); } + private: void Init(); diff --git a/interface/wx/textctrl.h b/interface/wx/textctrl.h index 7b60ebaf3e..046052d953 100644 --- a/interface/wx/textctrl.h +++ b/interface/wx/textctrl.h @@ -1791,6 +1791,42 @@ public: ///@} + /** + @name Gtk-specific functions + */ + ///@{ + + /** + Gets the underlying text buffer for multi-line controls. + + This function returns the underlying GTK object for multiline text + controls, i.e. those with wxTE_MULTILINE style, and @NULL for single + line text controls. + + Having direct access to the `GtkTextBuffer` allows to use GTK API + directly if necessary, but beware that doing it may interfere with the + normal wxTextCtrl operation. + + @onlyfor{wxgtk} + + @since 3.3 + */ + GtkTextBuffer *GTKGetTextBuffer(); + + /** + Gets the underlying text control that can be uses with GTK’s API. + + This function can only be called for single-line text controls, i.e. + those without wxTE_MULTILINE style. + + @onlyfor{wxgtk} + + @since 3.3 + */ + GtkEditable *GTKGetEditable(); + + ///@} + ///@{ /** Operator definitions for appending to a text control.