Xfce Foundation Classes
Main Page  | IndexNamespace List  |  Alphabetical List  |  Class List  |  File List


Xfc::Gtk::Editable Class Reference

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

#include <xfc/gtk/editable.hh>

Inheritance diagram for Xfc::Gtk::Editable:

Xfc::G::TypeInterface Xfc::G::TypeInstance Xfc::Trackable Xfc::Gtk::Entry Xfc::Gtk::SpinButton List of all members.

Signal Prototypes

Public Member Functions

Accessors
Methods
Signal Proxies

Protected Member Functions

Constructors

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 <xfc/main.h>
    #include <xfc/core.h>
    #include <xfc/gtk/entry.h>
   
    using namespace Xfc;
   
    class EntryWindow : public Gtk::Window
    {
        Gtk::Entry *entry;
        Connection connection;
    protected:
        void on_entry_insert_text(const String& text, int* position);
    public:
        EntryWindow();
    };
   
    EntryWindow::EntryWindow()
    {
        set_title("Entry");
        set_size_request(200, 100);
   
        entry = new Gtk::Entry;
        connection = entry->signal_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 String& text, int* position)
    {
        connection.block();
        entry->insert_text(s.upper(), *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.signal_destroy().connect(slot(&Xfc::Main::quit));
        window.show();
   
        run();
        return 0;
    }


Member Function Documentation

void Xfc::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 Xfc::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 Xfc::Gtk::Editable::get_editable  )  const
 

Retrieves whether the Editable is editable (see set_editable()).

Returns:
true if the editable is editable.

int Xfc::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 Xfc::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 Xfc::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.

void Xfc::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 Xfc::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 Xfc::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 Xfc::Gtk::Editable::signal_delete_text  ) 
 

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 Xfc::Gtk::Editable::signal_insert_text  ) 
 

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.


Member Data Documentation

const ChangedSignalType Xfc::Gtk::Editable::changed_signal [static, protected]
 

Changed signal (see signal_changed()).

Calls a slot with the signature:

             void function();

const DeleteTextSignalType Xfc::Gtk::Editable::delete_text_signal [static, protected]
 

Delete text signal (see signal_delete_text()).

Calls a slot with the signature:

             void function(int start_pos, int end_pos);
             // start_pos: The starting position.
             // end_pos: The end position.

const InsertTextSignalType Xfc::Gtk::Editable::insert_text_signal [static, protected]
 

Insert text signal (see signal_insert_text()).

Calls a slot with the signature:

             void function(const String& text, int *position);
             // text: The new text to insert.
             // position: The position at which to insert the new text.


The documentation for this class was generated from the following file: Xfce Foundation Classes
Copyright © 2004-2005 The XFC Development Team XFC 4.3