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. -- -- -- -- -- -- -- -- -- -- -- --
  23. ----------------------------------------------------------------------- 
  24.  
  25. --  <description> 
  26. --  This widget is an abstract widget designed to support the common 
  27. --  functionalities of all widgets for editing text. It provides general 
  28. --  services to manipulate an editable widget, a large number of action 
  29. --  signals used for key bindings, and several signals that an 
  30. --  application can connect to to modify the behavior of a widget. 
  31. --  </description> 
  32. --  <c_version>2.8.17</c_version> 
  33. --  <group>Numeric/Text Data Entry</group> 
  34.  
  35. with Gtk.Widget; 
  36.  
  37. package Gtk.Editable is 
  38.  
  39.    type Gtk_Editable_Record is new Gtk.Widget.Gtk_Widget_Record with private; 
  40.    type Gtk_Editable is access all Gtk_Editable_Record'Class; 
  41.    --  Gtk_Editable is now an interface, not an object per se. 
  42.  
  43.    function Get_Type return Glib.GType; 
  44.    --  Return the internal value associated with a Gtk_Editable. 
  45.  
  46.    procedure Select_Region 
  47.      (Editable : access Gtk_Editable_Record; 
  48.       Start    : Gint; 
  49.       The_End  : Gint := -1); 
  50.    --  Select the region of text from Start to The_End. 
  51.    --  The characters that are selected are those characters at positions 
  52.    --  from Start up to, but not including The_End. If The_End_Pos is 
  53.    --  negative, then the characters selected will be those characters 
  54.    --  from Start to the end of the text. 
  55.  
  56.    procedure Get_Selection_Bounds 
  57.      (Widget    : access Gtk_Editable_Record; 
  58.       Success   : out Boolean; 
  59.       Start_Pos : out Guint; 
  60.       End_Pos   : out Guint); 
  61.    --  Return the position of the start and end of the current selection. 
  62.    --  If success is false, Start_Pos and End_Pos are not modified. 
  63.  
  64.    procedure Insert_Text 
  65.      (Editable : access Gtk_Editable_Record; 
  66.       New_Text : UTF8_String; 
  67.       Position : in out Gint); 
  68.    --  Insert the given string at the given position. 
  69.    --  Position is set to the new cursor position. If Position is -1, the 
  70.    --  text is appended at the end. 
  71.  
  72.    procedure Delete_Text 
  73.      (Editable  : access Gtk_Editable_Record; 
  74.       Start_Pos : Gint := 0; 
  75.       End_Pos   : Gint := -1); 
  76.    --  Delete the characters from Start_Pos to End_Pos. 
  77.    --  If End_Pos is negative, the characters are deleted from Start_Pos to the 
  78.    --  end of the text. 
  79.  
  80.    function Get_Chars 
  81.      (Editable  : access Gtk_Editable_Record; 
  82.       Start_Pos : Gint := 0; 
  83.       End_Pos   : Gint := -1) return UTF8_String; 
  84.    --  Get the text from Start_Pos to End_Pos. 
  85.    --  If End_Pos is negative, the text from Start_Pos to the end is returned. 
  86.  
  87.    procedure Cut_Clipboard (Editable : access Gtk_Editable_Record); 
  88.    --  Copy the characters in the current selection to the clipboard. 
  89.    --  The selection is then deleted. 
  90.  
  91.    procedure Copy_Clipboard (Editable : access Gtk_Editable_Record); 
  92.    --  Copy the characters in the current selection to the clipboard. 
  93.  
  94.    procedure Paste_Clipboard (Editable : access Gtk_Editable_Record); 
  95.    --  The contents of the clipboard is pasted into the given widget at 
  96.    --  the current cursor position. 
  97.  
  98.    procedure Delete_Selection (Editable : access Gtk_Editable_Record); 
  99.    --  Disclaim and delete the current selection. 
  100.  
  101.    procedure Set_Position 
  102.      (Editable : access Gtk_Editable_Record; 
  103.       Position : Gint); 
  104.    function Get_Position (Editable : access Gtk_Editable_Record) return Gint; 
  105.    --  Change the position of the cursor in the entry. 
  106.    --  The cursor is displayed before the character with the given 
  107.    --  index in the widget (the first character has index 0). The 
  108.    --  value must be less than or equal to the number of characters in the 
  109.    --  widget. A value of -1 indicates that the position 
  110.    --  should be set after the last character in the entry. 
  111.    --  Note that this position is in characters, not in bytes. 
  112.  
  113.    procedure Set_Editable 
  114.      (Widget   : access Gtk_Editable_Record; 
  115.       Editable : Boolean := True); 
  116.    function Get_Editable 
  117.      (Editable : access Gtk_Editable_Record) return Boolean; 
  118.    --  Set the editable status of the entry. 
  119.    --  If Editable is False, the user can not modify the contents of the entry. 
  120.    --  This does not affect the user of the insertion functions above. 
  121.  
  122.    ---------------- 
  123.    -- Properties -- 
  124.    ---------------- 
  125.  
  126.    --  <properties> 
  127.    --  The following properties are defined for this widget. See 
  128.    --  Glib.Properties for more information on properties. 
  129.    -- 
  130.    --  </properties> 
  131.  
  132.    --------------- 
  133.    --  Signals  -- 
  134.    --------------- 
  135.  
  136.    --  <signals> 
  137.    --  The following new signals are defined for this widget: 
  138.    -- 
  139.    --  - "insert_text" 
  140.    --    procedure Handler (Widget   : access Gtk_Editable_Record'Class; 
  141.    --                       Text     : in UTF8_String; 
  142.    --                       Length   : in Gint; 
  143.    --                       Position : in Gint_Access); 
  144.    -- 
  145.    --    Emitted when some text is inserted inside the widget by the 
  146.    --    user. The default handler inserts the text into the widget. 
  147.    --    By connecting a handler to this signal, and then by stopping 
  148.    --    the signal with Gtk.Handlers.Emit_Stop_By_Name, it is possible 
  149.    --    to modify the inserted text, or even prevent it from being 
  150.    --    inserted. 
  151.    --    Position.all should be modified by the callback, and indicates 
  152.    --    the new position of the cursor after the text has been inserted. 
  153.    -- 
  154.    --  - "delete_text" 
  155.    --    procedure Handler (Widget    : access Gtk_Editable_Record'Class; 
  156.    --                       Start_Pos : in Gint; 
  157.    --                       End_Pos   : in Gint); 
  158.    -- 
  159.    --    Emitted when some text is deleted by the user. As for the 
  160.    --    "insert-text" handler, it is possible to override the default 
  161.    --    behavior by connecting a handler to this signal, and then 
  162.    --    stopping the signal. 
  163.    -- 
  164.    --  - "changed" 
  165.    --    procedure Handler (Widget : access Gtk_Editable_Record'Class); 
  166.    -- 
  167.    --    Called when the contents of Widget has changed 
  168.    --  </signals> 
  169.  
  170.    Signal_Changed     : constant Glib.Signal_Name := "changed"; 
  171.    Signal_Delete_Text : constant Glib.Signal_Name := "delete_text"; 
  172.    Signal_Insert_Text : constant Glib.Signal_Name := "insert_text"; 
  173.  
  174. private 
  175.    type Gtk_Editable_Record is new Gtk.Widget.Gtk_Widget_Record 
  176.      with null record; 
  177.    pragma Import (C, Get_Type, "gtk_editable_get_type"); 
  178. end Gtk.Editable;