Main Page Widgets Namespaces Book

# Gtk::Entry Class Reference
[Widgets]

Inheritance diagram for Gtk::Entry:

[legend]
List of all members.

## Detailed Description

A single line text entry field.

The Gtk::Entry widget is a single line text entry widget. A fairly large set of key bindings are supported by default. If the entered text is longer than the allocation of the widget, the widget will scroll so that the cursor position is visible.

## Public Member Functions

virtual | ~Entry ()
GtkEntry* | gobj ()
| Provides access to the underlying C GtkObject.
const GtkEntry* | gobj () const
| Provides access to the underlying C GtkObject.
| Entry ()
void | set_visibility (bool visible=true)
bool | get_visibility () const
| Retrieves whether the text in entry is visible.
void | set_invisible_char (gunichar ch)
| Sets the character to use in place of the actual text when set_visibility() has been called to set text visibility to `false`.
gunichar | get_invisible_char () const
| Retrieves the character displayed in place of the real characters for entries with visisbility set to false.
void | set_has_frame (bool setting=true)
| Sets whether the entry has a beveled frame around it.
bool | get_has_frame () const
| Gets the value set by set_has_frame().
void | set_max_length (int max)
| Sets the maximum allowed length of the contents of the widget.
int | get_max_length () const
| Retrieves the maximum allowed length of the text in entry .
void | set_activates_default (bool setting=true)
| If setting is `true`, pressing Enter in the entry will activate the default widget for the window containing the entry.
gboolean | get_activates_default () const
| Retrieves the value set by set_activates_default().
void | set_width_chars (int n_chars)
| Changes the size request of the entry to be about the right size for n_chars characters.
int | get_width_chars () const
| Gets the value set by set_width_chars().
void | set_text (const Glib::ustring& text)
Glib::ustring | get_text () const
| Retrieves the contents of the entry widget.
Glib::RefPtr<Pango::Layout> | get_layout ()
| Gets the Pango::Layout used to display the entry.
void | get_layout_offsets (int& x, int& y)
| Obtains the position of the Pango::Layout used to render text in the entry, in widget coordinates.
guint16 | get_text_length () const
Glib::SignalProxy1< void, Menu* > | signal_populate_popup ()
Glib::SignalProxy0<void> | signal_activate ()
Glib::SignalProxy3< void, MovementStep, int, bool > | signal_move_cursor ()
Glib::SignalProxy1< void, const Glib::ustring& > | signal_insert_at_cursor ()
Glib::SignalProxy2< void, DeleteType, int > | signal_delete_from_cursor ()
Glib::SignalProxy0<void> | signal_cut_clipboard ()
Glib::SignalProxy0<void> | signal_copy_clipboard ()
Glib::SignalProxy0<void> | signal_paste_clipboard ()
Glib::SignalProxy0<void> | signal_toggle_overwrite ()
Glib::PropertyProxy_ReadOnly< int > | property_cursor_position ()
| You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy_ReadOnly< int > | property_selection_bound ()
| You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy<bool> | property_editable ()
| You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy<int> | property_max_length ()
| You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy<bool> | property_visibility ()
| You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy<bool> | property_has_frame ()
| You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy<gunichar> | property_invisible_char ()
| You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy<bool> | property_activates_default ()
| You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy<int> | property_width_chars ()
| You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy_ReadOnly< int > | property_scroll_offset ()
| You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy<Glib::ustring> | property_text ()
| You rarely need to use properties because there are get_ and set_ methods for almost all of them.

## Protected Member Functions

virtual void | on_populate_popup (Menu* menu)
virtual void | on_activate ()
virtual void | on_move_cursor (MovementStep step, int count, bool extend_selection)
virtual void | on_insert_at_cursor (const Glib::ustring& str)
virtual void | on_delete_from_cursor (DeleteType type, int count)
virtual void | on_cut_clipboard ()
virtual void | on_copy_clipboard ()
virtual void | on_paste_clipboard ()
virtual void | on_toggle_overwrite ()

## Related Functions

(Note that these are not member functions.)
Gtk::Entry* | wrap (GtkEntry* object, bool take_copy=false)

## Constructor & Destructor Documentation

virtual Gtk::Entry::~Entry | ( |  | ) | `[virtual]`

Gtk::Entry::Entry | ( |  | ) |

## Member Function Documentation

gboolean Gtk::Entry::get_activates_default | ( |  | ) | const

Retrieves the value set by set_activates_default().

Returns:
  `true` if the entry will activate the default widget.

bool Gtk::Entry::get_has_frame | ( |  | ) | const

Gets the value set by set_has_frame().

Returns:
  Whether the entry has a beveled frame.

gunichar Gtk::Entry::get_invisible_char | ( |  | ) | const

Retrieves the character displayed in place of the real characters for entries with visisbility set to false.

See set_invisible_char().

Returns:
  The current invisible char, or 0, if the entry does not show invisible text at all.

Glib::RefPtr<Pango::Layout> Gtk::Entry::get_layout | ( |  | ) |

Gets the Pango::Layout used to display the entry.

The layout is useful to e.g. convert text positions to pixel positions, in combination with get_layout_offsets(). The returned layout is owned by the entry so need not be freed by the caller.

Keep in mind that the layout text may contain a preedit string, so gtk_entry_layout_index_to_text_index() and gtk_entry_text_index_to_layout_index() are needed to convert byte indices in the layout to byte indices in the entry contents.

Returns:
  The Pango::Layout for this entry.

void Gtk::Entry::get_layout_offsets | ( | int& | x,
|  | int& | y
| ) |

Obtains the position of the Pango::Layout used to render text in the entry, in widget coordinates.

Useful if you want to line up the text in an entry with some other text, e.g. when using the entry to implement editable cells in a sheet widget.

Also useful to convert mouse events into coordinates inside the Pango::Layout, e.g. to take some action if some part of the entry text is clicked.

Note that as the user scrolls around in the entry the offsets will change; you'll need to connect to the "notify::scroll_offset" signal to track this. Remember when using the Pango::Layout functions you need to convert to and from pixels using PANGO_PIXELS() or Pango::SCALE.

Keep in mind that the layout text may contain a preedit string, so gtk_entry_layout_index_to_text_index() and gtk_entry_text_index_to_layout_index() are needed to convert byte indices in the layout to byte indices in the entry contents.

Parameters:

  x | Location to store X offset of layout, or `0`.
  y | Location to store Y offset of layout, or `0`.

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

Retrieves the maximum allowed length of the text in entry .

See set_max_length().

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

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

Retrieves the contents of the entry widget.

See also gtk_editable_get_chars().

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

guint16 Gtk::Entry::get_text_length | ( |  | ) | const

bool Gtk::Entry::get_visibility | ( |  | ) | const

Retrieves whether the text in entry is visible.

See set_visibility().

Returns:
  `true` if the text is currently visible.

int Gtk::Entry::get_width_chars | ( |  | ) | const

Gets the value set by set_width_chars().

Returns:
  Number of chars to request space for, or negative if unset.

const GtkEntry* Gtk::Entry::gobj | ( |  | ) | const`[inline]`

| Provides access to the underlying C GtkObject. Reimplemented from Gtk::CellEditable. Reimplemented in Gtk::SpinButton.

GtkEntry* Gtk::Entry::gobj | ( |  | ) | `[inline]`

| Provides access to the underlying C GtkObject. Reimplemented from Gtk::CellEditable. Reimplemented in Gtk::SpinButton.

virtual void Gtk::Entry::on_activate | ( |  | ) | `[protected, virtual]`

virtual void Gtk::Entry::on_copy_clipboard | ( |  | ) | `[protected, virtual]`

virtual void Gtk::Entry::on_cut_clipboard | ( |  | ) | `[protected, virtual]`

virtual void Gtk::Entry::on_delete_from_cursor | ( | DeleteType | type,
|  | int | count
| ) | `[protected, virtual]`

virtual void Gtk::Entry::on_insert_at_cursor | ( | const Glib::ustring& | str | ) | `[protected, virtual]`

virtual void Gtk::Entry::on_move_cursor | ( | MovementStep | step,
|  | int | count,
|  | bool | extend_selection
| ) | `[protected, virtual]`

virtual void Gtk::Entry::on_paste_clipboard | ( |  | ) | `[protected, virtual]`

virtual void Gtk::Entry::on_populate_popup | ( | Menu* | menu | ) | `[protected, virtual]`

virtual void Gtk::Entry::on_toggle_overwrite | ( |  | ) | `[protected, virtual]`

Glib::PropertyProxy<bool> Gtk::Entry::property_activates_default | ( |  | ) |

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

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

Glib::PropertyProxy_ReadOnly<int> Gtk::Entry::property_cursor_position | ( |  | ) |

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

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

Glib::PropertyProxy<bool> Gtk::Entry::property_editable | ( |  | ) |

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

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

Glib::PropertyProxy<bool> Gtk::Entry::property_has_frame | ( |  | ) |

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

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

Glib::PropertyProxy<gunichar> Gtk::Entry::property_invisible_char | ( |  | ) |

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

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

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

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

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

Glib::PropertyProxy_ReadOnly<int> Gtk::Entry::property_scroll_offset | ( |  | ) |

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

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

Glib::PropertyProxy_ReadOnly<int> Gtk::Entry::property_selection_bound | ( |  | ) |

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

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

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

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

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

Glib::PropertyProxy<bool> Gtk::Entry::property_visibility | ( |  | ) |

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

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

Glib::PropertyProxy<int> Gtk::Entry::property_width_chars | ( |  | ) |

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

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

void Gtk::Entry::set_activates_default | ( | bool | setting = true | ) |

If setting is `true`, pressing Enter in the entry will activate the default widget for the window containing the entry.

This usually means that the dialog box containing the entry will be closed, since the default widget is usually one of the dialog buttons.

(For experts: if setting is `true`, the entry calls Gtk::Window::activate_default() on the window containing the entry, in the default handler for the "activate" signal.)

Parameters:

  setting | `true` to activate window's default widget on Enter keypress.

void Gtk::Entry::set_has_frame | ( | bool | setting = true | ) |

Sets whether the entry has a beveled frame around it.

Parameters:

  setting | New value.

void Gtk::Entry::set_invisible_char | ( | gunichar | ch | ) |

Sets the character to use in place of the actual text when set_visibility() has been called to set text visibility to `false`.

i.e. this is the character used in "password mode" to show the user how many characters have been typed. The default invisible char is an asterisk ('*'). If you set the invisible char to 0, then the user will get no feedback at all; there will be no text on the screen as they type.

Parameters:

  ch | A Unicode character.

void Gtk::Entry::set_max_length | ( | int | max | ) |

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

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

Parameters:

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

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

void Gtk::Entry::set_visibility | ( | bool | visible = true | ) |

void Gtk::Entry::set_width_chars | ( | int | n_chars | ) |

Changes the size request of the entry to be about the right size for n_chars characters.

Note that it changes the size request, the size can still be affected by how you pack the widget into containers. If n_chars is -1, the size reverts to the default entry size.

Parameters:

  n_chars | Width in chars.

Glib::SignalProxy0<void> Gtk::Entry::signal_activate | ( |  | ) |

Prototype:
  `void activate()`

Glib::SignalProxy0<void> Gtk::Entry::signal_copy_clipboard | ( |  | ) |

Prototype:
  `void copy_clipboard()`

Glib::SignalProxy0<void> Gtk::Entry::signal_cut_clipboard | ( |  | ) |

Prototype:
  `void cut_clipboard()`

Glib::SignalProxy2<void,DeleteType,int> Gtk::Entry::signal_delete_from_cursor | ( |  | ) |

Prototype:
  `void delete_from_cursor(DeleteType type, int count)`

Glib::SignalProxy1<void,const Glib::ustring&> Gtk::Entry::signal_insert_at_cursor | ( |  | ) |

Prototype:
  `void insert_at_cursor(const Glib::ustring& str)`

Glib::SignalProxy3<void,MovementStep,int,bool> Gtk::Entry::signal_move_cursor | ( |  | ) |

Prototype:
  `void move_cursor(MovementStep step, int count, bool extend_selection)`

Glib::SignalProxy0<void> Gtk::Entry::signal_paste_clipboard | ( |  | ) |

Prototype:
  `void paste_clipboard()`

Glib::SignalProxy1<void,Menu*> Gtk::Entry::signal_populate_popup | ( |  | ) |

Prototype:
  `void populate_popup(Menu* menu)`

Glib::SignalProxy0<void> Gtk::Entry::signal_toggle_overwrite | ( |  | ) |

Prototype:
  `void toggle_overwrite()`

## Friends And Related Function Documentation

Gtk::Entry* wrap | ( | GtkEntry* | object,
|  | bool | take_copy = false
| ) | `[related]`

The documentation for this class was generated from the following file:

- entry.h