gtkmm: Gtk::EntryBuffer Class Reference

gtkmm 4.16.0

Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Symbols | List of all members
Gtk::EntryBuffer Class Reference

A Text buffer for the Entry widget. More...

`#include <gtkmm/entrybuffer.h>`

Inheritance diagram for Gtk::EntryBuffer:
[legend]

## Public Member Functions
| EntryBuffer (EntryBuffer && src) noexcept
EntryBuffer & | operator= (EntryBuffer && src) noexcept
| ~EntryBuffer () noexcept override
GtkEntryBuffer * | gobj ()
| Provides access to the underlying C GObject.
const GtkEntryBuffer * | gobj () const
| Provides access to the underlying C GObject.
GtkEntryBuffer * | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
gsize | get_bytes () const
| Retrieves the length in bytes of the buffer.
guint | get_length () const
| Retrieves the length in characters of the buffer.
Glib::ustring | get_text () const
| Retrieves the contents of the buffer.
void | set_text (const Glib::ustring & text)
| Sets the text in the buffer.
void | set_max_length (int max_length)
| Sets the maximum allowed length of the contents of the buffer.
int | get_max_length () const
| Retrieves the maximum allowed length of the text in buffer.
guint | insert_text (guint position, const Glib::ustring & text)
| Inserts text into the contents of the buffer, at position position.
guint | delete_text (guint position, int n_chars)
| Deletes a sequence of characters from the buffer.
void | emit_inserted_text (guint position, const Glib::ustring & text)
| Used when deriving from EntryBuffer.
void | emit_deleted_text (guint position, guint n_chars)
| Used when subclassing `Gtk::EntryBuffer`.
Glib::SignalProxy< void(guint, const char *, guint)> | signal_inserted_text ()
Glib::SignalProxy< void(guint, guint)> | signal_deleted_text ()
Glib::PropertyProxy< Glib::ustring > | property_text ()
| The contents of the buffer.
Glib::PropertyProxy_ReadOnly< Glib::ustring > | property_text () const
| The contents of the buffer.
Glib::PropertyProxy_ReadOnly< guint > | property_length () const
| The length (in characters) of the text in buffer.
Glib::PropertyProxy< int > | property_max_length ()
| The maximum length (in characters) of the text in the buffer.
Glib::PropertyProxy_ReadOnly< int > | property_max_length () const
| The maximum length (in characters) of the text in the buffer.
Public Member Functions inherited from Glib::Object
| Object (const Object &)=delete
Object & | operator= (const Object &)=delete
| Object (Object &&src) noexcept
Object & | operator= (Object &&src) noexcept
void * | get_data (const QueryQuark &key)
void | set_data (const Quark &key, void *data)
void | set_data_with_c_callback (const Quark &key, void *data, GDestroyNotify notify)
void | set_data (const Quark &key, void *data, DestroyNotify notify)
void | remove_data (const QueryQuark &quark)
void * | steal_data (const QueryQuark &quark)
Glib::RefPtr< Glib::Object > | wrap (GObject *object, bool take_copy=false)
Public Member Functions inherited from Glib::ObjectBase
| ObjectBase (const ObjectBase &)=delete
ObjectBase & | operator= (const ObjectBase &)=delete
void | set_property_value (const Glib::ustring &property_name, const Glib::ValueBase &value)
void | get_property_value (const Glib::ustring &property_name, Glib::ValueBase &value) const
void | set_property (const Glib::ustring &property_name, const PropertyType &value)
void | get_property (const Glib::ustring &property_name, PropertyType &value) const
PropertyType | get_property (const Glib::ustring &property_name) const
sigc::connection | connect_property_changed (const Glib::ustring &property_name, const sigc::slot< void()> &slot)
sigc::connection | connect_property_changed (const Glib::ustring &property_name, sigc::slot< void()> &&slot)
void | freeze_notify ()
void | thaw_notify ()
virtual void | reference () const
virtual void | unreference () const
GObject * | gobj ()
const GObject * | gobj () const
GObject * | gobj_copy () const

## Static Public Member Functions
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system.
static Glib::RefPtr< EntryBuffer > | create ()
| Create a new EntryBuffer object with no text.
static Glib::RefPtr< EntryBuffer > | create (const Glib::ustring & text)
| Create a new EntryBuffer object.

## Protected Member Functions
| EntryBuffer ()
| Create a new EntryBuffer object with no text.
| EntryBuffer (const Glib::ustring & text)
| Create a new EntryBuffer object.
virtual void | on_inserted_text (guint position, const char * chars, guint n_chars)
| This is a default handler for the signal signal_inserted_text().
virtual void | on_deleted_text (guint position, guint n_chars)
| This is a default handler for the signal signal_deleted_text().
Protected Member Functions inherited from Glib::Object
| Object ()
| Object (const Glib::ConstructParams &construct_params)
| Object (GObject *castitem)
| ~Object () noexcept override
Protected Member Functions inherited from Glib::ObjectBase
| ObjectBase ()
| ObjectBase (const char *custom_type_name)
| ObjectBase (const std::type_info &custom_type_info)
| ObjectBase (ObjectBase &&src) noexcept
ObjectBase & | operator= (ObjectBase &&src) noexcept
virtual | ~ObjectBase () noexcept=0
void | initialize (GObject *castitem)
void | initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)

## Related Symbols
(Note that these are not member symbols.)
Glib::RefPtr< Gtk::EntryBuffer > | wrap (GtkEntryBuffer * object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Additional Inherited Members
Public Types inherited from Glib::Object
typedef void(*)(gpointer data) | DestroyNotify

## Detailed Description

A Text buffer for the Entry widget.

The EntryBuffer class contains the actual text displayed in an Entry widget.

A single EntryBuffer object can be shared by multiple Entry widgets which will then share the same text content, but not the cursor position, visibility attributes, icon etc.

EntryBuffer may be derived from. Such a derived class might allow text to be stored in an alternate location, such as non-pageable memory, useful in the case of important passwords. Or a derived class could integrate with an application's concept of undo/redo.

Since gtkmm 2.20

## Constructor & Destructor Documentation

## ◆ EntryBuffer() [1/3]

Gtk::EntryBuffer::EntryBuffer | ( | EntryBuffer && | src | ) |
| noexcept

## ◆ ~EntryBuffer()

Gtk::EntryBuffer::~EntryBuffer | ( |  | ) |
| overridenoexcept

## ◆ EntryBuffer() [2/3]

Gtk::EntryBuffer::EntryBuffer | ( |  | ) |
| protected

Create a new EntryBuffer object with no text.

## ◆ EntryBuffer() [3/3]

Gtk::EntryBuffer::EntryBuffer | ( | const Glib::ustring & | text | ) |
| explicitprotected

Create a new EntryBuffer object.

Parameters

  text | Initial buffer text.

## Member Function Documentation

## ◆ create() [1/2]

static Glib::RefPtr< EntryBuffer > Gtk::EntryBuffer::create | ( |  | ) |
| static

Create a new EntryBuffer object with no text.

## ◆ create() [2/2]

static Glib::RefPtr< EntryBuffer > Gtk::EntryBuffer::create | ( | const Glib::ustring & | text | ) |
| static

Create a new EntryBuffer object.

Parameters

  text | Initial buffer text.

## ◆ delete_text()

guint Gtk::EntryBuffer::delete_text | ( | guint | position,
|  | int | n_chars )

Deletes a sequence of characters from the buffer.

n_chars characters are deleted starting at position. If n_chars is negative, then all characters until the end of the text are deleted.

If position or n_chars are out of bounds, then they are coerced to sane values.

Note that the positions are specified in characters, not bytes.

Parameters

  position | Position at which to delete text.
  n_chars | Number of characters to delete.

Returns
  The number of characters deleted.

## ◆ emit_deleted_text()

void Gtk::EntryBuffer::emit_deleted_text | ( | guint | position,
|  | guint | n_chars )

Used when subclassing `Gtk::EntryBuffer`.

Parameters

  position | Position at which text was deleted.
  n_chars | Number of characters deleted.

## ◆ emit_inserted_text()

void Gtk::EntryBuffer::emit_inserted_text | ( | guint | position,
|  | const Glib::ustring & | text )

Used when deriving from EntryBuffer.

Parameters

  position | Position at which text was inserted.
  text | Text that was inserted.

## ◆ get_bytes()

gsize Gtk::EntryBuffer::get_bytes | ( |  | ) | const

Retrieves the length in bytes of the buffer.

See get_length().

Returns
  The byte length of the buffer.

## ◆ get_length()

guint Gtk::EntryBuffer::get_length | ( |  | ) | const

Retrieves the length in characters of the buffer.

Returns
  The number of characters in the buffer.

## ◆ get_max_length()

int Gtk::EntryBuffer::get_max_length | ( |  | ) | const

Retrieves the maximum allowed length of the text in buffer.

Returns
  The maximum allowed number of characters in `Gtk::EntryBuffer`, or 0 if there is no maximum.

## ◆ get_text()

Glib::ustring Gtk::EntryBuffer::get_text | ( |  | ) | const

Retrieves the contents of the buffer.

The memory pointer returned by this call will not change unless this object emits a signal, or is finalized.

Returns
  A pointer to the contents of the widget as a string. This string points to internally allocated storage in the buffer and must not be freed, modified or stored.

## ◆ get_type()

static GType Gtk::EntryBuffer::get_type | ( |  | ) |
| static

Get the GType for this class, for use with the underlying GObject type system.

## ◆ gobj() [1/2]

GtkEntryBuffer * Gtk::EntryBuffer::gobj | ( |  | ) |
| inline

Provides access to the underlying C GObject.

## ◆ gobj() [2/2]

const GtkEntryBuffer * Gtk::EntryBuffer::gobj | ( |  | ) | const
| inline

Provides access to the underlying C GObject.

## ◆ gobj_copy()

GtkEntryBuffer * Gtk::EntryBuffer::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

## ◆ insert_text()

guint Gtk::EntryBuffer::insert_text | ( | guint | position,
|  | const Glib::ustring & | text )

Inserts text into the contents of the buffer, at position position.

Parameters

  position | The position at which to insert text.
  text | The text to insert into the buffer.

Returns
  The number of characters actually inserted.

## ◆ on_deleted_text()

virtual void Gtk::EntryBuffer::on_deleted_text | ( | guint | position,
|  | guint | n_chars )
| protectedvirtual

This is a default handler for the signal signal_deleted_text().

## ◆ on_inserted_text()

virtual void Gtk::EntryBuffer::on_inserted_text | ( | guint | position,
|  | const char * | chars,
|  | guint | n_chars )
| protectedvirtual

This is a default handler for the signal signal_inserted_text().

## ◆ operator=()

EntryBuffer & Gtk::EntryBuffer::operator= | ( | EntryBuffer && | src | ) |
| noexcept

## ◆ property_length()

Glib::PropertyProxy_ReadOnly< guint > Gtk::EntryBuffer::property_length | ( |  | ) | const

The length (in characters) of the text in buffer.

Default value: 0

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_max_length() [1/2]

Glib::PropertyProxy< int > Gtk::EntryBuffer::property_max_length | ( |  | ) |

The maximum length (in characters) of the text in the buffer.

Default value: 0

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## ◆ property_max_length() [2/2]

Glib::PropertyProxy_ReadOnly< int > Gtk::EntryBuffer::property_max_length | ( |  | ) | const

The maximum length (in characters) of the text in the buffer.

Default value: 0

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_text() [1/2]

Glib::PropertyProxy< Glib::ustring > Gtk::EntryBuffer::property_text | ( |  | ) |

The contents of the buffer.

Default value: ""

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## ◆ property_text() [2/2]

Glib::PropertyProxy_ReadOnly< Glib::ustring > Gtk::EntryBuffer::property_text | ( |  | ) | const

The contents of the buffer.

Default value: ""

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ set_max_length()

void Gtk::EntryBuffer::set_max_length | ( | int | max_length | ) |

Sets the maximum allowed length of the contents of the buffer.

If the current contents are longer than the given length, then they will be truncated to fit.

Parameters

  max_length | The maximum length of the entry buffer, or 0 for no maximum. (other than the maximum length of entries.) The value passed in will be clamped to the range 0-65536.

## ◆ set_text()

void Gtk::EntryBuffer::set_text | ( | const Glib::ustring & | text | ) |

Sets the text in the buffer.

This is roughly equivalent to calling delete_text() and insert_text().

Parameters

  text | The text to set in the buffer.

## ◆ signal_deleted_text()

Glib::SignalProxy< void(guint, guint)> Gtk::EntryBuffer::signal_deleted_text | ( |  | ) |

Slot Prototype:
  `void on_my_deleted_text(guint position, guint n_chars)`

Flags: Run Last

The text is altered in the default handler for this signal.

If you want access to the text after the text has been modified, use connect(..., true).

Parameters

  position | The position the text was deleted at.
  n_chars | The number of characters that were deleted.

## ◆ signal_inserted_text()

Glib::SignalProxy< void(guint, const char *, guint)> Gtk::EntryBuffer::signal_inserted_text | ( |  | ) |

Slot Prototype:
  `void on_my_inserted_text(guint position, const char* chars, guint n_chars)`

Flags: Run First

This signal is emitted after text is inserted into the buffer.

Parameters

  position | The position the text was inserted at.
  chars | The text that was inserted.
  n_chars | The number of characters that were inserted.

## Friends And Related Symbol Documentation

## ◆ wrap()

Glib::RefPtr< Gtk::EntryBuffer > wrap | ( | GtkEntryBuffer * | object,
|  | bool | take_copy = false )
| related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.