Xfce Foundation Classes
Main Page | Index | Namespace List | Alphabetical List | Class List | File List

# Xfc::Gtk::Entry Class Reference

A GtkEntry C++ wrapper class. More...

`#include <xfc/gtk/entry.hh>`

Inheritance diagram for Xfc::Gtk::Entry:

List of all members.

## Signal Prototypes

- const PopulatePopupSignalType populate_popup_signal
    Populate popup signal (see signal_populate_popup()).
- const ActviateSignalType activate_signal
    Actviate signal (see signal_activate()).
- const InsertAtCursorSignalType insert_at_cursor_signal
    Insert at cursor signal (see signal_insert_at_cursor()).

## Public Member Functions

Constructors

- Entry ()
    Construct a new Entry.
- Entry (int max_length)
    Construct a new Entry that accepts at most max_length characters.
- virtual ~Entry ()
    Destructor.

Accessors

- GtkEntry * gtk_entry () const
    Get a pointer to the GtkEntry structure.
- operator GtkEntry * () const
    Conversion operator; safely converts an Entry to a GtkEntry pointer.
- String get_text () const
    Retrieves the contents of the widget (see also Gtk::Editable::get_chars()).
- bool get_visibility () const
    Returns true if the text in the widget is visible (see set_visibility()).
- G::Unichar 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()).
- bool get_has_frame () const
    Returns true if the entry has a beveled frame (see set_has_frame()).
- bool get_activates_default () const
    Returns true if the entry will activate the default widget (see set_activates_default()).
- int get_width_chars () const
    Retrieves the number of chars to request space for, or negative if unset (see set_width_chars()).
- int get_max_length () const
    Returns the maximum allowed length of the text in the Entry, or 0 if there is no maximum (see set_max_length()).
- Pango::Layout * get_layout () const
    Gets the Pango::Layout used to display the entry.
- void get_layout_offsets (int *x, int *y) const
    Obtains the position of the Pango::Layout used to render text in the entry, in widget coordinates.
- float get_alignment () const
    Gets the value set by set_alignment().
- EntryCompletion * get_completion () const
    Gets the auxiliary completion object currently in use by the entry.

Methods

- EntryCompletion * create_completion (TreeModel &model)
    Convenience method that creates an EntryCompletion object using the specified model and sets it to be the auxillary completion object for the entry.
- void set_completion (EntryCompletion *completion)
    Sets completion to be the auxiliary completion object to use with the entry.
- int layout_index_to_text_index (int layout_index)
    Converts from a position in the entry contents (returned by get_text()) to a position in the entry's PangoLayout (returned by get_layout(), with text retrieved via Pango::Layout::get_text()).
- int text_index_to_layout_index (int text_index)
    Converts from a position in the entry's Pango::Layout (returned by get_layout()) to a position in the entry contents (returned by get_text()).
- void set_visibility (bool visible)
    Sets whether the contents of the entry are visible or not.
- void set_invisible_char (G::Unichar ch)
    Sets the character to use in place of the actual text when set_visibility() has been called to set text visibility to false.
- void set_has_frame (bool setting)
    Sets whether the entry has a beveled frame around it.
- void set_max_length (int max)
    Sets the maximum allowed length of the contents of the widget.
- void set_text (const String &text)
    Sets the text in the widget to the given value, replacing the current contents.
- void set_alignment (float xalign)
    Sets the alignment for the contents of the entry.
- void set_activates_default (bool setting)
    If setting is true, pressing Enter in the entry will activate the default widget for the window containing the entry.
- void set_width_chars (int n_chars)
    Changes the size request of the entry to be about the right size for n_chars characters.

Signal Proxies

- const PopulatePopupSignalProxy signal_populate_popup ()
    Connect to the populate_popup_signal; emitted when the Entry displays its context-sensitive menu.
- const ActviateSignalProxy signal_activate ()
    Connect to the activate_signal; emitted when the Entry is activated by pressing the enter key.
- const InsertAtCursorSignalProxy signal_insert_at_cursor ()
    Connect to the insert_at_cursor_signal; emitted when text is inserted into the Entry at the current cursor position.

## Protected Member Functions

Constructors

- Entry (GtkEntry *entry, bool owns_reference=false)
    Construct a new Entry from an existing GtkEntry.

## Detailed Description

A GtkEntry C++ wrapper class.

The 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. Entry implements the Editable and CellEditable interfaces

See also: the Entry Widget HOWTO and example.

## Constructor & Destructor Documentation

Xfc::Gtk::Entry::Entry | ( | GtkEntry * | entry,
|  | bool | owns_reference = `false`
| ) | `[explicit, protected]`

  | Construct a new Entry from an existing GtkEntry. Parameters:
  | entry | A pointer to a GtkEntry.
  | owns_reference | Set false if the initial reference count is floating, set true if it's not.
The entry can be a newly created GtkEntry or an existing GtkEntry (see G::Object::Object).

Xfc::Gtk::Entry::Entry | ( | int | max_length | ) | `[explicit]`

  | Construct a new Entry that accepts at most max_length characters. Parameters:
  | max_length | The maximum length of the entry, or 0 for no maximum.
The value passed max_length in will be clamped to the range 0-65536.

## Member Function Documentation

EntryCompletion* Xfc::Gtk::Entry::create_completion | ( | TreeModel & | model | ) |

  | Convenience method that creates an EntryCompletion object using the specified model and sets it to be the auxillary completion object for the entry. Parameters:
  | model | The model for the entry completion.
Returns: The new EntryCompletion object. The returned completion object is owned by the entry widget and should not be unreferenced. Calling this method is equivalent to creating an entry completion yourself and calling set_completion().

float Xfc::Gtk::Entry::get_alignment | ( |  | ) | const

| Gets the value set by set_alignment(). Returns: The alignment.

EntryCompletion* Xfc::Gtk::Entry::get_completion | ( |  | ) | const

| Gets the auxiliary completion object currently in use by the entry. Returns: The auxiliary completion object currently in use by entry.

G::Unichar Xfc::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.

Pango::Layout* Xfc::Gtk::Entry::get_layout | ( |  | ) | const

| Gets the Pango::Layout used to display the entry. Returns: The PangoLayout for this 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 and must not be unreferenced by the caller.

void Xfc::Gtk::Entry::get_layout_offsets | ( | int * | x,
|  | int * | y
| ) | const

  | Obtains the position of the Pango::Layout used to render text in the entry, in widget coordinates. Parameters:
  | x | The location to store the X offset of the layout, or null.
  | y | The location to store the Y offset of the layout, or null.
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.

String Xfc::Gtk::Entry::get_text | ( |  | ) | const

| Retrieves the contents of the widget (see also Gtk::Editable::get_chars()). Returns: A String that contains the contents of the widget.

int Xfc::Gtk::Entry::layout_index_to_text_index | ( | int | layout_index | ) |

  | Converts from a position in the entry contents (returned by get_text()) to a position in the entry's PangoLayout (returned by get_layout(), with text retrieved via Pango::Layout::get_text()). Parameters:
  | layout_index | The byte index into the entry layout text.
Returns: The byte index into the entry contents.

void Xfc::Gtk::Entry::set_activates_default | ( | bool | setting | ) |

  | If setting is true, pressing Enter in the entry will activate the default widget for the window containing the entry. Parameters:
  | setting | true to activate the default widget on Enter keypress.
If setting is true, this usually means that the dialog box containing the entry will be closed, since the default widget is usually one of the dialog buttons.

void Xfc::Gtk::Entry::set_alignment | ( | float | xalign | ) |

  | Sets the alignment for the contents of the entry. Parameters:
  | xalign | The horizontal alignment, from 0 (left) to 1 (right).
This controls the horizontal positioning of the contents when the displayed text is shorter than the width of the entry. The alignment is reversed for RTL layouts.

void Xfc::Gtk::Entry::set_completion | ( | EntryCompletion * | completion | ) |

  | Sets completion to be the auxiliary completion object to use with the entry. Parameters:
  | completion | The EntryCompletion.
All further configuration of the completion mechanism is done on completion using the Gtk::EntryCompletion API.

void Xfc::Gtk::Entry::set_has_frame | ( | bool | setting | ) |

  | Sets whether the entry has a beveled frame around it. Parameters:
  | setting | The new value.

void Xfc::Gtk::Entry::set_invisible_char | ( | G::Unichar | ch | ) |

  | Sets the character to use in place of the actual text when set_visibility() has been called to set text visibility to false. Parameters:
  | ch | A Unicode character.
The ch character is 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.

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

  | Sets the maximum allowed length of the contents of the widget. Parameters:
  | max | The maximum length of the entry, or 0 for no maximum.
The value passed in will be clamped to the range 0-65536. If the current contents are longer than the given length, then they will be truncated to fit.

void Xfc::Gtk::Entry::set_text | ( | const String & | text | ) |

  | Sets the text in the widget to the given value, replacing the current contents. Parameters:
  | text | The new text.

void Xfc::Gtk::Entry::set_visibility | ( | bool | visible | ) |

  | Sets whether the contents of the entry are visible or not. Parameters:
  | visible | true if the contents of the entry are displayed as plain text.
When visibility is set to false, characters are displayed as the invisible char, and will also appear that way when the text in the entry widget is copied elsewhere. The default invisible char is the asterisk '*', but it can be changed with set_invisible_char().

void Xfc::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. Parameters:
  | n_chars | The width in chars.
Note that this method 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.

int Xfc::Gtk::Entry::text_index_to_layout_index | ( | int | text_index | ) |

  | Converts from a position in the entry's Pango::Layout (returned by get_layout()) to a position in the entry contents (returned by get_text()). Parameters:
  | text_index | The byte index into the entry contents.
Returns: The byte index into the entry layout text.

## Member Data Documentation

const ActviateSignalType Xfc::Gtk::Entry::activate_signal`[static, protected]`

| Actviate signal (see signal_activate()). Calls a slot with the signature:
                 void function();

const InsertAtCursorSignalType Xfc::Gtk::Entry::insert_at_cursor_signal`[static, protected]`

| Insert at cursor signal (see signal_insert_at_cursor()). Calls a slot with the signature:
                 void function(const String& text);
                 // text: The new text to insert.

const PopulatePopupSignalType Xfc::Gtk::Entry::populate_popup_signal`[static, protected]`

| Populate popup signal (see signal_populate_popup()). Calls a slot with the signature:
                 void function(Gtk::Menu& menu);
                 // menu: The popup menu.

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

- entry.hh

Xfce Foundation Classes

Copyright © 2004-2005 The XFC Development Team | XFC 4.3