1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --   Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet   -- 
  5. --                Copyright (C) 2000-2007 AdaCore                    -- 
  6. --                                                                   -- 
  7. -- This library is free software; you can redistribute it and/or     -- 
  8. -- modify it under the terms of the GNU General Public               -- 
  9. -- License as published by the Free Software Foundation; either      -- 
  10. -- version 2 of the License, or (at your option) any later version.  -- 
  11. --                                                                   -- 
  12. -- This library is distributed in the hope that it will be useful,   -- 
  13. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  14. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  15. -- General Public License for more details.                          -- 
  16. --                                                                   -- 
  17. -- You should have received a copy of the GNU General Public         -- 
  18. -- License along with this library; if not, write to the             -- 
  19. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  20. -- Boston, MA 02111-1307, USA.                                       -- 
  21. --                                                                   -- 
  22. -- As a special exception, if other files instantiate generics from  -- 
  23. -- this unit, or you link this unit with other files to produce an   -- 
  24. -- executable, this  unit  does not  by itself cause  the resulting  -- 
  25. -- executable to be covered by the GNU General Public License. This  -- 
  26. -- exception does not however invalidate any other reasons why the   -- 
  27. -- executable file  might be covered by the  GNU Public License.     -- 
  28. ----------------------------------------------------------------------- 
  29.  
  30. --  <description> 
  31. --  This widget is an abstract widget designed to support the common 
  32. --  functionalities of all widgets for editing text. It provides general 
  33. --  services to manipulate an editable widget, a large number of action 
  34. --  signals used for key bindings, and several signals that an 
  35. --  application can connect to to modify the behavior of a widget. 
  36. --  </description> 
  37. --  <c_version>2.8.17</c_version> 
  38. --  <group>Numeric/Text Data Entry</group> 
  39.  
  40. with Gtk.Widget; 
  41.  
  42. package Gtk.Editable is 
  43.  
  44.    type Gtk_Editable_Record is new Gtk.Widget.Gtk_Widget_Record with private; 
  45.    type Gtk_Editable is access all Gtk_Editable_Record'Class; 
  46.    --  Gtk_Editable is now an interface, not an object per se. 
  47.  
  48.    function Get_Type return Glib.GType; 
  49.    --  Return the internal value associated with a Gtk_Editable. 
  50.  
  51.    procedure Select_Region 
  52.      (Editable : access Gtk_Editable_Record; 
  53.       Start    : Gint; 
  54.       The_End  : Gint := -1); 
  55.    --  Select the region of text from Start to The_End. 
  56.    --  The characters that are selected are those characters at positions 
  57.    --  from Start up to, but not including The_End. If The_End_Pos is 
  58.    --  negative, then the characters selected will be those characters 
  59.    --  from Start to the end of the text. 
  60.  
  61.    procedure Get_Selection_Bounds 
  62.      (Widget    : access Gtk_Editable_Record; 
  63.       Success   : out Boolean; 
  64.       Start_Pos : out Guint; 
  65.       End_Pos   : out Guint); 
  66.    --  Return the position of the start and end of the current selection. 
  67.    --  If success is false, Start_Pos and End_Pos are not modified. 
  68.  
  69.    procedure Insert_Text 
  70.      (Editable : access Gtk_Editable_Record; 
  71.       New_Text : UTF8_String; 
  72.       Position : in out Gint); 
  73.    --  Insert the given string at the given position. 
  74.    --  Position is set to the new cursor position. If Position is -1, the 
  75.    --  text is appended at the end. 
  76.  
  77.    procedure Delete_Text 
  78.      (Editable  : access Gtk_Editable_Record; 
  79.       Start_Pos : Gint := 0; 
  80.       End_Pos   : Gint := -1); 
  81.    --  Delete the characters from Start_Pos to End_Pos. 
  82.    --  If End_Pos is negative, the characters are deleted from Start_Pos to the 
  83.    --  end of the text. 
  84.  
  85.    function Get_Chars 
  86.      (Editable  : access Gtk_Editable_Record; 
  87.       Start_Pos : Gint := 0; 
  88.       End_Pos   : Gint := -1) return UTF8_String; 
  89.    --  Get the text from Start_Pos to End_Pos. 
  90.    --  If End_Pos is negative, the text from Start_Pos to the end is returned. 
  91.  
  92.    procedure Cut_Clipboard (Editable : access Gtk_Editable_Record); 
  93.    --  Copy the characters in the current selection to the clipboard. 
  94.    --  The selection is then deleted. 
  95.  
  96.    procedure Copy_Clipboard (Editable : access Gtk_Editable_Record); 
  97.    --  Copy the characters in the current selection to the clipboard. 
  98.  
  99.    procedure Paste_Clipboard (Editable : access Gtk_Editable_Record); 
  100.    --  The contents of the clipboard is pasted into the given widget at 
  101.    --  the current cursor position. 
  102.  
  103.    procedure Delete_Selection (Editable : access Gtk_Editable_Record); 
  104.    --  Disclaim and delete the current selection. 
  105.  
  106.    procedure Set_Position 
  107.      (Editable : access Gtk_Editable_Record; 
  108.       Position : Gint); 
  109.    function Get_Position (Editable : access Gtk_Editable_Record) return Gint; 
  110.    --  Change the position of the cursor in the entry. 
  111.    --  The cursor is displayed before the character with the given 
  112.    --  index in the widget (the first character has index 0). The 
  113.    --  value must be less than or equal to the number of characters in the 
  114.    --  widget. A value of -1 indicates that the position 
  115.    --  should be set after the last character in the entry. 
  116.    --  Note that this position is in characters, not in bytes. 
  117.  
  118.    procedure Set_Editable 
  119.      (Widget   : access Gtk_Editable_Record; 
  120.       Editable : Boolean := True); 
  121.    function Get_Editable 
  122.      (Editable : access Gtk_Editable_Record) return Boolean; 
  123.    --  Set the editable status of the entry. 
  124.    --  If Editable is False, the user can not modify the contents of the entry. 
  125.    --  This does not affect the user of the insertion functions above. 
  126.  
  127.    ---------------- 
  128.    -- Properties -- 
  129.    ---------------- 
  130.  
  131.    --  <properties> 
  132.    --  The following properties are defined for this widget. See 
  133.    --  Glib.Properties for more information on properties. 
  134.    -- 
  135.    --  </properties> 
  136.  
  137.    --------------- 
  138.    --  Signals  -- 
  139.    --------------- 
  140.  
  141.    --  <signals> 
  142.    --  The following new signals are defined for this widget: 
  143.    -- 
  144.    --  - "insert_text" 
  145.    --    procedure Handler (Widget   : access Gtk_Editable_Record'Class; 
  146.    --                       Text     : in UTF8_String; 
  147.    --                       Length   : in Gint; 
  148.    --                       Position : in Gint_Access); 
  149.    -- 
  150.    --    Emitted when some text is inserted inside the widget by the 
  151.    --    user. The default handler inserts the text into the widget. 
  152.    --    By connecting a handler to this signal, and then by stopping 
  153.    --    the signal with Gtk.Handlers.Emit_Stop_By_Name, it is possible 
  154.    --    to modify the inserted text, or even prevent it from being 
  155.    --    inserted. 
  156.    --    Position.all should be modified by the callback, and indicates 
  157.    --    the new position of the cursor after the text has been inserted. 
  158.    -- 
  159.    --  - "delete_text" 
  160.    --    procedure Handler (Widget    : access Gtk_Editable_Record'Class; 
  161.    --                       Start_Pos : in Gint; 
  162.    --                       End_Pos   : in Gint); 
  163.    -- 
  164.    --    Emitted when some text is deleted by the user. As for the 
  165.    --    "insert-text" handler, it is possible to override the default 
  166.    --    behavior by connecting a handler to this signal, and then 
  167.    --    stopping the signal. 
  168.    -- 
  169.    --  - "changed" 
  170.    --    procedure Handler (Widget : access Gtk_Editable_Record'Class); 
  171.    -- 
  172.    --    Called when the contents of Widget has changed 
  173.    --  </signals> 
  174.  
  175.    Signal_Changed     : constant Glib.Signal_Name := "changed"; 
  176.    Signal_Delete_Text : constant Glib.Signal_Name := "delete_text"; 
  177.    Signal_Insert_Text : constant Glib.Signal_Name := "insert_text"; 
  178.  
  179. private 
  180.    type Gtk_Editable_Record is new Gtk.Widget.Gtk_Widget_Record 
  181.      with null record; 
  182.    pragma Import (C, Get_Type, "gtk_editable_get_type"); 
  183. end Gtk.Editable;