gtkmm 3.24.7
Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions | List of all members
Gtk::Editable Class Reference

Base class for text-editing widgets. More...

#include <gtkmm/editable.h>

Inheritance diagram for Gtk::Editable:
Inheritance graph
[legend]

Public Member Functions

 Editable (Editable && src) noexcept
 
Editableoperator= (Editable && src) noexcept
 
 ~Editable () noexcept override
 
GtkEditable * gobj ()
 Provides access to the underlying C GObject. More...
 
const GtkEditable * gobj () const
 Provides access to the underlying C GObject. More...
 
void cut_clipboard ()
 Removes the contents of the currently selected content in the editable and puts it on the clipboard. More...
 
void copy_clipboard ()
 Copies the contents of the currently selected content in the editable and puts it on the clipboard. More...
 
void paste_clipboard ()
 Pastes the content of the clipboard to the current position of the cursor in the editable. More...
 
void delete_selection ()
 Deletes the currently selected text of the editable. More...
 
void set_editable (bool is_editable=true)
 Determines if the user can edit the text in the editable widget or not. More...
 
bool get_editable () const
 Retrieves whether editable is editable. More...
 
void insert_text (const Glib::ustring & new_text, int new_text_length, int & position)
 Inserts new_text_length bytes of new_text into the contents of the widget, at position position. More...
 
void delete_text (int start_pos, int end_pos)
 Deletes a sequence of characters. More...
 
Glib::ustring get_chars (int start_pos, int end_pos) const
 Retrieves a sequence of characters. More...
 
void select_region (int start_pos, int end_pos)
 Selects a region of text. More...
 
bool get_selection_bounds (int & start_pos, int & end_pos) const
 Retrieves the selection bound of the editable. More...
 
void set_position (int position)
 Sets the cursor position in the editable to the given value. More...
 
int get_position () const
 Retrieves the current position of the cursor relative to the start of the content of the editable. More...
 
Glib::SignalProxy< void, const Glib::ustring &, int * > signal_insert_text ()
 
Glib::SignalProxy< void, int, int > signal_delete_text ()
 
Glib::SignalProxy< void > signal_changed ()
 

Static Public Member Functions

static void add_interface (GType gtype_implementer)
 
static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...
 

Protected Member Functions

 Editable ()
 You should derive from this class to use it. More...
 
virtual void delete_text_vfunc (int start_pos, int end_pos)
 
virtual Glib::ustring get_chars_vfunc (int start_pos, int end_pos) const
 
virtual void select_region_vfunc (int start_pos, int end_pos)
 
virtual bool get_selection_bounds_vfunc (int & start_pos, int & end_pos) const
 
virtual void set_position_vfunc (int position)
 
virtual int get_position_vfunc () const
 
virtual void insert_text_vfunc (const Glib::ustring & text, int & position)
 
virtual void on_insert_text (const Glib::ustring & text, int * position)
 This is a default handler for the signal signal_insert_text(). More...
 
virtual void on_delete_text (int start_pos, int end_pos)
 This is a default handler for the signal signal_delete_text(). More...
 
virtual void on_changed ()
 This is a default handler for the signal signal_changed(). More...
 

Related Functions

(Note that these are not member functions.)

Glib::RefPtr< Gtk::Editablewrap (GtkEditable * object, bool take_copy=false)
 A Glib::wrap() method for this object. More...
 

Detailed Description

Base class for text-editing widgets.

The Gtk::Editable class is a base class for widgets for editing text, such as Gtk::Entry. It cannot be instantiated by itself. The editable class contains functions for generically manipulating an editable widget, a large number of action signals used for key bindings, and several signals that an application can connect to to modify the behavior of a widget.

Constructor & Destructor Documentation

◆ Editable() [1/2]

Gtk::Editable::Editable ( )
protected

You should derive from this class to use it.

◆ Editable() [2/2]

Gtk::Editable::Editable ( Editable &&  src)
noexcept

◆ ~Editable()

Gtk::Editable::~Editable ( )
overridenoexcept

Member Function Documentation

◆ add_interface()

static void Gtk::Editable::add_interface ( GType  gtype_implementer)
static

◆ copy_clipboard()

void Gtk::Editable::copy_clipboard ( )

Copies the contents of the currently selected content in the editable and puts it on the clipboard.

◆ cut_clipboard()

void Gtk::Editable::cut_clipboard ( )

Removes the contents of the currently selected content in the editable and puts it on the clipboard.

◆ delete_selection()

void Gtk::Editable::delete_selection ( )

Deletes the currently selected text of the editable.

This call doesn’t do anything if there is no selected text.

◆ delete_text()

void Gtk::Editable::delete_text ( int  start_pos,
int  end_pos 
)

Deletes a sequence of characters.

The characters that are deleted are those characters at positions from start_pos up to, but not including end_pos. If end_pos is negative, then the characters deleted are those from start_pos to the end of the text.

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

Parameters
start_posStart position.
end_posEnd position.

◆ delete_text_vfunc()

virtual void Gtk::Editable::delete_text_vfunc ( int  start_pos,
int  end_pos 
)
protectedvirtual

◆ get_chars()

Glib::ustring Gtk::Editable::get_chars ( int  start_pos,
int  end_pos 
) const

Retrieves a sequence of characters.

The characters that are retrieved are those characters at positions from start_pos up to, but not including end_pos. If end_pos is negative, then the characters retrieved are those characters from start_pos to the end of the text.

Note that positions are specified in characters, not bytes.

Parameters
start_posStart of text.
end_posEnd of text.
Returns
A pointer to the contents of the widget as a string. This string is allocated by the Gtk::Editable implementation and should be freed by the caller.

◆ get_chars_vfunc()

virtual Glib::ustring Gtk::Editable::get_chars_vfunc ( int  start_pos,
int  end_pos 
) const
protectedvirtual

◆ get_editable()

bool Gtk::Editable::get_editable ( ) const

Retrieves whether editable is editable.

See set_editable().

Returns
true if editable is editable.

◆ get_position()

int Gtk::Editable::get_position ( ) const

Retrieves the current position of the cursor relative to the start of the content of the editable.

Note that this position is in characters, not in bytes.

Returns
The cursor position.

◆ get_position_vfunc()

virtual int Gtk::Editable::get_position_vfunc ( ) const
protectedvirtual

◆ get_selection_bounds()

bool Gtk::Editable::get_selection_bounds ( int &  start_pos,
int &  end_pos 
) const

Retrieves the selection bound of the editable.

start_pos will be filled with the start of the selection and end_pos with end. If no text was selected both will be identical and false will be returned.

Note that positions are specified in characters, not bytes.

Parameters
start_posLocation to store the starting position, or nullptr.
end_posLocation to store the end position, or nullptr.
Returns
true if an area is selected, false otherwise.

◆ get_selection_bounds_vfunc()

virtual bool Gtk::Editable::get_selection_bounds_vfunc ( int &  start_pos,
int &  end_pos 
) const
protectedvirtual

◆ get_type()

static GType Gtk::Editable::get_type ( )
static

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

◆ gobj() [1/2]

GtkEditable * Gtk::Editable::gobj ( )
inline

Provides access to the underlying C GObject.

◆ gobj() [2/2]

const GtkEditable * Gtk::Editable::gobj ( ) const
inline

Provides access to the underlying C GObject.

◆ insert_text()

void Gtk::Editable::insert_text ( const Glib::ustring &  new_text,
int  new_text_length,
int &  position 
)

Inserts new_text_length bytes of new_text into the contents of the widget, at position position.

Note that the position is in characters, not in bytes. The function updates position to point after the newly inserted text.

Parameters
new_textThe text to append.
new_text_lengthThe length of the text in bytes, or -1.
positionLocation of the position text will be inserted at.

◆ insert_text_vfunc()

virtual void Gtk::Editable::insert_text_vfunc ( const Glib::ustring &  text,
int &  position 
)
protectedvirtual

◆ on_changed()

virtual void Gtk::Editable::on_changed ( )
protectedvirtual

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

◆ on_delete_text()

virtual void Gtk::Editable::on_delete_text ( int  start_pos,
int  end_pos 
)
protectedvirtual

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

◆ on_insert_text()

virtual void Gtk::Editable::on_insert_text ( const Glib::ustring &  text,
int *  position 
)
protectedvirtual

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

◆ operator=()

Editable & Gtk::Editable::operator= ( Editable &&  src)
noexcept

◆ paste_clipboard()

void Gtk::Editable::paste_clipboard ( )

Pastes the content of the clipboard to the current position of the cursor in the editable.

◆ select_region()

void Gtk::Editable::select_region ( int  start_pos,
int  end_pos 
)

Selects a region of text.

The characters that are selected are those characters at positions from start_pos up to, but not including end_pos. If end_pos is negative, then the characters selected are those characters from start_pos to the end of the text.

Note that positions are specified in characters, not bytes.

Parameters
start_posStart of region.
end_posEnd of region.

◆ select_region_vfunc()

virtual void Gtk::Editable::select_region_vfunc ( int  start_pos,
int  end_pos 
)
protectedvirtual

◆ set_editable()

void Gtk::Editable::set_editable ( bool  is_editable = true)

Determines if the user can edit the text in the editable widget or not.

Parameters
is_editabletrue if the user is allowed to edit the text in the widget.

◆ set_position()

void Gtk::Editable::set_position ( int  position)

Sets the cursor position in the editable to the given value.

The cursor is displayed before the character with the given (base 0) index in the contents of the editable. The value must be less than or equal to the number of characters in the editable. A value of -1 indicates that the position should be set after the last character of the editable. Note that position is in characters, not in bytes.

Parameters
positionThe position of the cursor.

◆ set_position_vfunc()

virtual void Gtk::Editable::set_position_vfunc ( int  position)
protectedvirtual

◆ signal_changed()

Glib::SignalProxy< void > Gtk::Editable::signal_changed ( )
Slot Prototype:
void on_my_changed()

Flags: Run Last

The signal_changed() signal is emitted at the end of a single user-visible operation on the contents of the Gtk::Editable.

E.g., a paste operation that replaces the contents of the selection will cause only one signal emission (even though it is implemented by first deleting the selection, then inserting the new content, and may cause multiple ::notify::text signals to be emitted).

◆ signal_delete_text()

Glib::SignalProxy< void, int, int > Gtk::Editable::signal_delete_text ( )
Slot Prototype:
void on_my_delete_text(int start_pos, int end_pos)

Flags: Run Last

This signal is emitted when text is deleted from the widget by the user. The default handler for this signal will normally be responsible for deleting the text, so by connecting to this signal and then stopping the signal with Glib::signal_stop_emission(), it is possible to modify the range of deleted text, or prevent it from being deleted entirely. The start_pos and end_pos parameters are interpreted as for Gtk::Editable::delete_text().

Parameters
start_posThe starting position.
end_posThe end position.

◆ signal_insert_text()

Glib::SignalProxy< void, const Glib::ustring &, int * > Gtk::Editable::signal_insert_text ( )

Friends And Related Function Documentation

◆ wrap()

Glib::RefPtr< Gtk::Editable > wrap ( GtkEditable *  object,
bool  take_copy = false 
)
related

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

Parameters
objectThe C instance.
take_copyFalse 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.