Reference Manual
Inti Logo
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:

Inti::G::TypeInterface Inti::G::TypeInstance Inti::ReferencedBase Inti::Gtk::Entry Inti::Gtk::SpinButton List of all members.

Public Member Functions

Accessors
Methods
Signal Proxies

Protected Member Functions

Constructors
Signal Handlers

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: Main Page - Footer


Generated on Sun Sep 14 20:08:15 2003 for Inti by doxygen 1.3.2 written by Dimitri van Heesch, © 1997-2002