/* $Id: editable.gen_h,v 1.46 2002/04/14 15:28:30 murrayc Exp $ */ /* editable.h * * Copyright (C) 1998-1999 The Gtk-- Development Team * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <gtk--/widget.h> #include <gtk/gtkeditable.h> namespace Gtk { //: Base class for text-editing widgets. //- The {\class Gtk::Editable} class is a base class for widgets for editing //- text, such as {\class Gtk::Entry} and {\class Gtk::Text}. It cannot be //- instantiated by itself. The editable class contains functions 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. class Editable : public Widget { public: typedef Editable CppObjectType; typedef GtkEditable BaseObjectType; public: //: Returns the underlaying gtk+ object. GtkEditable* gtkobj(); const GtkEditable* gtkobj() const; //: Returns true if object is this type. static bool isA(Gtk::Object *object); virtual ~Editable(); private: public: Editable(); //: Indicates that the user has changed the contents of the widget. emitable signal void changed(); //: Indicates that the user has activated the widget in some fashion. //- Generally, this will be done with a keystroke. (The default binding //- for this action is Return for {\class Gtk::Entry} and Control-Return //- for {\class Gtk::Text}.) signal void activate(); //: This signal is 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, it is possible to modify the //- inserted text, or prevent it from being inserted entirely. emitable signal void insert_text(const gchar*,gint,gint*); //: This signal is 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, 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()}. emitable signal void delete_text(gint,gint); //:Determines if the user can edit the text in the editable widget or not. //- This is meant to be overriden by child classes and should not generally useful to applications. emitable signal void set_editable(gboolean); //: An action signal. Move the cursor position. signal void move_cursor(gint,gint); //: An action signal. Move the cursor by words. signal void move_word(gint); //: An action signal. Move the cursor by pages. signal void move_page(gint,gint); //: An action signal. Move the cursor to the given row. signal void move_to_row(gint); //: An action signal. Move the cursor to the given column. signal void move_to_column(gint); //: An action signal. Delete a single character. signal void kill_char(gint); //: An action signal. Delete a single word. signal void kill_word(gint); //: An action signal. Delete a single line. signal void kill_line(gint); //: An action signal. Causes the characters in the current selection to be copied to the clipboard //: and then deleted from the widget. emitable signal void cut_clipboard(); //: An action signal. Causes the characters in the current selection to be copied to the clipboard. emitable signal void copy_clipboard(); //: An action signal. Causes the contents of the clipboard to be pasted into the editable widget //: at the current cursor position. emitable signal void paste_clipboard(); //SIGNAL_SPEC("get_chars",vfunc,gchar* get_chars(gint,gint),gtk_editable_get_chars); //: Selects a region of text. //- 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. //- //- start: The starting position. //- //- end: The end position. void select_region(gint start,gint end); /* no function for 1.1, we'll use signal instead */ //: Retrieves the current cursor position. //- Returns : the position of the cursor. The cursor is displayed before //- the character with the given (base 0) 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. gint get_position() const; //: Retrieves a sequence of characters. //- 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. //- //- start_pos: The starting position. //- //- end_pos: The end position. //- //- Returns: The characters in the indicated region. string get_chars (int start_pos = 0, int end_pos = - 1) const; //: Claim or disclaim ownership of the PRIMARY X selection. //- claim: If TRUE, claim the selection, otherwise, disclaim it. //- //- time: The timestamp for claiming the selection. void claim_selection(gboolean claim,guint32 time); //: Deletes the current contents of the widgets selection and disclaims the selection. void delete_selection(); guint get_selection_start_pos() const { return gtkobj()->selection_start_pos; } guint get_selection_end_pos() const { return gtkobj()->selection_end_pos; } bool has_selection() const { return gtkobj()->has_selection; } protected: // impl functions virtual void changed_impl(); virtual void activate_impl(); virtual void insert_text_impl(const gchar* p0,gint p1,gint* p2); virtual void delete_text_impl(gint p0,gint p1); virtual void set_editable_impl(gboolean p0); virtual void move_cursor_impl(gint p0,gint p1); virtual void move_word_impl(gint p0); virtual void move_page_impl(gint p0,gint p1); virtual void move_to_row_impl(gint p0); virtual void move_to_column_impl(gint p0); virtual void kill_char_impl(gint p0); virtual void kill_word_impl(gint p0); virtual void kill_line_impl(gint p0); virtual void cut_clipboard_impl(); virtual void copy_clipboard_impl(); virtual void paste_clipboard_impl(); }; //+ PROPERTIES(Gtk_Editable) //. name: current_pos //. type: guint //. get: //. set: //. desc: //. name: selection_start_pos //. type: guint //. get: //. set: //. desc: //. name: selection_end_pos //. type: guint //. get: //. set: //. desc: //. name: has_selection //. type: guint:1 //. get: //. set: //. desc: //. name: editable //. type: guint:1 //. get: //. set: //. desc: //. name: ic //. type: GdkIC* //. get: //. set: //. desc: //. name: ic_attr //. type: GdkICAttr* //. get: //. set: //. desc: //. name: clipboard_text //. type: string //. get: //. set: //. desc: }