Add accessors for underling wxTextCtrl GTK widgets

Allow retrieving GtkTextBuffer or GtkEditable used for multi- and
single-line controls respectively.

Closes #23829.
This commit is contained in:
Blake-Madden 2023-08-27 07:57:53 -04:00 committed by Vadim Zeitlin
parent 13aa094ea6
commit e4388d4f87
2 changed files with 43 additions and 0 deletions

View file

@ -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();

View file

@ -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 GTKs 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.