Reference Manual

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# Inti::Gtk::Editable Class Reference

A GtkDrawingArea C++ wrapper class. More...

`#include <inti/gtk/editable.h>`

Inheritance diagram for Inti::Gtk::Editable:

List of all members.

## Public Member Functions

Accessors

- GtkEditable * gtk_editable () const
    Get a pointer to the GtkEditable structure.
- GtkEditableClass * gtk_editable_class () const
    Get a pointer to the GtkEditableClass structure.
- operator GtkEditable * () const
    Conversion operator; safely converts an Editable to a GtkEditable pointer.
- bool get_selection_bounds (int *start, int *end) const
    Gets the current selection bounds, if there is a selection.
- String get_chars (int start_pos, int end_pos) const
    Retrieves a sequence of characters.
- int get_position () const
    Retrieves the current cursor position.
- bool get_editable () const
    Retrieves whether the Editable is editable (see set_editable()).

Methods

- void select_region (int start, int end)
    Selects a region of text.
- void insert_text (const String &new_text, int &position)
    Inserts text at a given position.
- void delete_text (int start_pos, int end_pos)
    Deletes a sequence of characters.
- void cut_clipboard ()
    Causes the characters in the current selection to be copied to the clipboard and then deleted from the widget.
- void copy_clipboard ()
    Causes the characters in the current selection to be copied to the clipboard.
- void paste_clipboard ()
    Causes the contents of the clipboard to be pasted into the given widget at the current cursor position.
- void delete_selection ()
    Deletes the current contents of the widget's selection and disclaims the selection.
- void set_position (int position)
    Sets the cursor position.
- void set_editable (bool is_editable)
    Determines if the user can edit the text in the editable widget or not.

Signal Proxies

- const InsertTextSignalProxy sig_insert_text ()
    Connect to the insert_text_signal; emitted when text is inserted into the widget by the user.
- const DeleteTextSignalProxy sig_delete_text ()
    Connect to the delete_text_signal; emitted when text is deleted from the widget by the user.
- const ChangedSignalProxy sig_changed ()
    Connect to the changed_signal; emitted when the user changes the contents of the widget.

## Protected Member Functions

Constructors

- virtual ~Editable ()=0
    Destructor.

Signal Handlers

- virtual void on_insert_text (const String &text, int *position)
    Called when text is inserted into the widget by the user.
- virtual void on_delete_text (int start_pos, int end_pos)
    Called when text is deleted from the widget by the user.
- virtual void on_changed ()
    Called when the user changes the contents of the widget.

## Detailed Description

A GtkDrawingArea C++ wrapper class.

The Editable class is a base interface class for widgets editing text, such as Entry. It cannot be instantiated by itself. The editable class contains methods 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.

As an example of the latter usage, by connecting the following handler to "insert_text", an application can convert all entry into a widget into uppercase.

Example: Forcing entry to uppercase.

        #include <inti/main.h>
        #include <inti/core.h>
        #include <inti/gtk/entry.h>

        using namespace Inti;

        class EntryWindow : public Gtk::Window
        {
            Gtk::Entry *entry;
            Connection connection;
        protected:
            void on_entry_insert_text(const char* text, int length, int* position);
        public:
            EntryWindow();
        };

        EntryWindow::EntryWindow()
        {
            set_title("Entry");
            set_size_request(200, 100);

            entry = new Gtk::Entry;
            connection = entry->sig_insert_text().connect(slot(this, &EntryWindow::on_entry_insert_text));
            entry->set_text("hello world");
            entry->select_region(0, entry->gtk_entry()->text_length);
            add(*entry);
            entry->show();
        }

        void
        EntryWindow::on_entry_insert_text(const char* text, int length, int* position)
        {
            String s(text, length);
            connection.block();
            entry->insert_text(s.upper().c_str(), *position);
            connection.unblock();
            entry->stop_emission_by_name("insert_text");
        }

        int main(int argc, char *argv[])
        {
            using namespace Main;

            init(&argc, &argv);

            EntryWindow window;
            window.sig_destroy().connect(slot(&Inti::Main::quit));
            window.show();

            run();
            return 0;
        }

## Member Function Documentation

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

  | Deletes a sequence of characters. Parameters:
  start_pos | The starting position.
  end_pos | The end position.
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 the characters deleted will be those characters from start_pos to the end of the text.

String Inti::Gtk::Editable::get_chars | ( | int | start_pos,
|  | int | end_pos
| ) | const

  | Retrieves a sequence of characters. Parameters:
  start_pos | The starting position.
  end_pos | The end position.
Returns: The characters in the indicated region. 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 the characters retrieved will be those characters from start_pos to the end of the text.

bool Inti::Gtk::Editable::get_editable | ( |  | ) | const

| Retrieves whether the Editable is editable (see set_editable()). Returns: true if the editable is editable.

int Inti::Gtk::Editable::get_position | ( |  | ) | const

| Retrieves the current cursor position. Returns: The position of the cursor. The cursor is displayed before the character with the given (zero-based) index in the widget. The value will be less than or equal to the number of characters in the widget. Note that this position is in characters, not in bytes.

bool Inti::Gtk::Editable::get_selection_bounds | ( | int * | start,
|  | int * | end
| ) | const

  | Gets the current selection bounds, if there is a selection. Parameters:
  start | The location to store the starting position, or null.
  end | The location to store the end position, or null.
Returns: true if there is a selection.

void Inti::Gtk::Editable::insert_text | ( | const String & | new_text,
|  | int & | position
| ) |

  | Inserts text at a given position. Parameters:
  new_text | The text to insert.
  position | An in/out parameter.
The caller initializes position to the position at which to insert the text. After the call it points at the position after the newly inserted text.

virtual void Inti::Gtk::Editable::on_delete_text | ( | int | start_pos,
|  | int | end_pos
| ) | `[protected, virtual]`

  | Called when text is deleted from the widget by the user. Parameters:
  start_pos | The starting position.
  end_pos | The end position.
The default handler for this signal will normally be responsible for deleting the text, so by overriding this method and either calling or not calling the parent class method, it is possible to modify the deleted text, or prevent it from being deleted entirely. The start_pos and end_pos parameters are interpreted as for delete_text()

virtual void Inti::Gtk::Editable::on_insert_text | ( | const String & | text,
|  | int * | position
| ) | `[protected, virtual]`

  | Called when text is inserted into the widget by the user. Parameters:
  text | The new text to insert.
  position | The position at which to insert the new text.
Position is an in-out paramter. After the signal emission is finished, it should point after the newly inserted text. The default handler for this signal will normally be responsible for inserting the text, so by overriding this method and either calling or not calling the parent class method, it is possible to modify the inserted text, or prevent it from being inserted entirely.

void Inti::Gtk::Editable::select_region | ( | int | start,
|  | int | end
| ) |

  | Selects a region of text. Parameters:
  start | The starting position.
  end | The end position.
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 the characters selected will be those characters from start_pos to the end of the text.

void Inti::Gtk::Editable::set_editable | ( | bool | is_editable | ) |

  | Determines if the user can edit the text in the editable widget or not. Parameters:
  is_editable | true if the user is allowed to edit the text in the widget.

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

  | Sets the cursor position. Parameters:
  position | The position of the cursor.
The cursor is displayed before the character with the given (zero-baseed) index in the widget. The value must be less than or equal to the number of characters in the widget. A value of -1 indicates that the position should be set after the last character in the entry. Note that this position is in characters, not in bytes.

const DeleteTextSignalProxy Inti::Gtk::Editable::sig_delete_text | ( |  | ) | `[inline]`

| Connect to the delete_text_signal; 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 G::Object::stop_emission_by_name(), it is possible to modify the deleted text, or prevent it from being deleted entirely. The start_pos and end_pos parameters are interpreted as for delete_text().

const InsertTextSignalProxy Inti::Gtk::Editable::sig_insert_text | ( |  | ) | `[inline]`

| Connect to the insert_text_signal; emitted when text is inserted into the widget by the user. The default handler for this signal will normally be responsible for inserting the text, so by connecting to this signal and then stopping the signal with G::Object::stop_emission_by_name(), it is possible to modify the inserted text, or prevent it from being inserted entirely.

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

- editable.h

Main Page - Footer