1. ------------------------------------------------------------------------------ 
  2. --                                                                          -- 
  3. --      Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet       -- 
  4. --                     Copyright (C) 2000-2014, AdaCore                     -- 
  5. --                                                                          -- 
  6. -- This library is free software;  you can redistribute it and/or modify it -- 
  7. -- under terms of the  GNU General Public License  as published by the Free -- 
  8. -- Software  Foundation;  either version 3,  or (at your  option) any later -- 
  9. -- version. This library is distributed in the hope that it will be useful, -- 
  10. -- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- -- 
  11. -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            -- 
  12. --                                                                          -- 
  13. -- As a special exception under Section 7 of GPL version 3, you are granted -- 
  14. -- additional permissions described in the GCC Runtime Library Exception,   -- 
  15. -- version 3.1, as published by the Free Software Foundation.               -- 
  16. --                                                                          -- 
  17. -- You should have received a copy of the GNU General Public License and    -- 
  18. -- a copy of the GCC Runtime Library Exception along with this program;     -- 
  19. -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    -- 
  20. -- <http://www.gnu.org/licenses/>.                                          -- 
  21. --                                                                          -- 
  22. ------------------------------------------------------------------------------ 
  23.  
  24. --  <description> 
  25. --  The Gtk.Entry_Buffer.Gtk_Entry_Buffer class contains the actual text 
  26. --  displayed in a Gtk.GEntry.Gtk_Entry widget. 
  27. -- 
  28. --  A single Gtk.Entry_Buffer.Gtk_Entry_Buffer object can be shared by 
  29. --  multiple Gtk.GEntry.Gtk_Entry widgets which will then share the same text 
  30. --  content, but not the cursor position, visibility attributes, icon etc. 
  31. -- 
  32. --  Gtk.Entry_Buffer.Gtk_Entry_Buffer may be derived from. Such a derived 
  33. --  class might allow text to be stored in an alternate location, such as 
  34. --  non-pageable memory, useful in the case of important passwords. Or a 
  35. --  derived class could integrate with an application's concept of undo/redo. 
  36. -- 
  37. --  </description> 
  38. pragma Ada_2005; 
  39.  
  40. pragma Warnings (Off, "*is already use-visible*"); 
  41. with Glib;            use Glib; 
  42. with Glib.Object;     use Glib.Object; 
  43. with Glib.Properties; use Glib.Properties; 
  44.  
  45. package Gtk.Entry_Buffer is 
  46.  
  47.    type Gtk_Entry_Buffer_Record is new GObject_Record with null record; 
  48.    type Gtk_Entry_Buffer is access all Gtk_Entry_Buffer_Record'Class; 
  49.  
  50.    ------------------ 
  51.    -- Constructors -- 
  52.    ------------------ 
  53.  
  54.    procedure Gtk_New 
  55.       (Self            : out Gtk_Entry_Buffer; 
  56.        Initial_Chars   : UTF8_String := ""; 
  57.        N_Initial_Chars : Gint); 
  58.    procedure Initialize 
  59.       (Self            : not null access Gtk_Entry_Buffer_Record'Class; 
  60.        Initial_Chars   : UTF8_String := ""; 
  61.        N_Initial_Chars : Gint); 
  62.    --  Create a new GtkEntryBuffer object. 
  63.    --  Optionally, specify initial text to set in the buffer. 
  64.    --  Since: gtk+ 2.18 
  65.    --  "initial_chars": initial buffer text, or null 
  66.    --  "n_initial_chars": number of characters in Initial_Chars, or -1 
  67.  
  68.    function Gtk_Entry_Buffer_New 
  69.       (Initial_Chars   : UTF8_String := ""; 
  70.        N_Initial_Chars : Gint) return Gtk_Entry_Buffer; 
  71.    --  Create a new GtkEntryBuffer object. 
  72.    --  Optionally, specify initial text to set in the buffer. 
  73.    --  Since: gtk+ 2.18 
  74.    --  "initial_chars": initial buffer text, or null 
  75.    --  "n_initial_chars": number of characters in Initial_Chars, or -1 
  76.  
  77.    function Get_Type return Glib.GType; 
  78.    pragma Import (C, Get_Type, "gtk_entry_buffer_get_type"); 
  79.  
  80.    ------------- 
  81.    -- Methods -- 
  82.    ------------- 
  83.  
  84.    function Delete_Text 
  85.       (Self     : not null access Gtk_Entry_Buffer_Record; 
  86.        Position : Guint; 
  87.        N_Chars  : Gint) return Guint; 
  88.    --  Deletes a sequence of characters from the buffer. N_Chars characters 
  89.    --  are deleted starting at Position. If N_Chars is negative, then all 
  90.    --  characters until the end of the text are deleted. 
  91.    --  If Position or N_Chars are out of bounds, then they are coerced to sane 
  92.    --  values. 
  93.    --  Note that the positions are specified in characters, not bytes. 
  94.    --  Since: gtk+ 2.18 
  95.    --  "position": position at which to delete text 
  96.    --  "n_chars": number of characters to delete 
  97.  
  98.    procedure Emit_Deleted_Text 
  99.       (Self     : not null access Gtk_Entry_Buffer_Record; 
  100.        Position : Guint; 
  101.        N_Chars  : Guint); 
  102.    --  Used when subclassing Gtk.Entry_Buffer.Gtk_Entry_Buffer 
  103.    --  Since: gtk+ 2.18 
  104.    --  "position": position at which text was deleted 
  105.    --  "n_chars": number of characters deleted 
  106.  
  107.    procedure Emit_Inserted_Text 
  108.       (Self     : not null access Gtk_Entry_Buffer_Record; 
  109.        Position : Guint; 
  110.        Chars    : UTF8_String; 
  111.        N_Chars  : Guint); 
  112.    --  Used when subclassing Gtk.Entry_Buffer.Gtk_Entry_Buffer 
  113.    --  Since: gtk+ 2.18 
  114.    --  "position": position at which text was inserted 
  115.    --  "chars": text that was inserted 
  116.    --  "n_chars": number of characters inserted 
  117.  
  118.    function Get_Bytes 
  119.       (Self : not null access Gtk_Entry_Buffer_Record) return Gsize; 
  120.    --  Retrieves the length in bytes of the buffer. See 
  121.    --  Gtk.Entry_Buffer.Get_Length. 
  122.    --  Since: gtk+ 2.18 
  123.  
  124.    function Get_Length 
  125.       (Self : not null access Gtk_Entry_Buffer_Record) return Guint; 
  126.    --  Retrieves the length in characters of the buffer. 
  127.    --  Since: gtk+ 2.18 
  128.  
  129.    function Get_Max_Length 
  130.       (Self : not null access Gtk_Entry_Buffer_Record) return Gint; 
  131.    --  Retrieves the maximum allowed length of the text in Buffer. See 
  132.    --  Gtk.Entry_Buffer.Set_Max_Length. 
  133.    --  Since: gtk+ 2.18 
  134.  
  135.    procedure Set_Max_Length 
  136.       (Self       : not null access Gtk_Entry_Buffer_Record; 
  137.        Max_Length : Gint); 
  138.    --  Sets the maximum allowed length of the contents of the buffer. If the 
  139.    --  current contents are longer than the given length, then they will be 
  140.    --  truncated to fit. 
  141.    --  Since: gtk+ 2.18 
  142.    --  "max_length": the maximum length of the entry buffer, or 0 for no 
  143.    --  maximum. (other than the maximum length of entries.) The value passed in 
  144.    --  will be clamped to the range 0-65536. 
  145.  
  146.    function Get_Text 
  147.       (Self : not null access Gtk_Entry_Buffer_Record) return UTF8_String; 
  148.    --  Retrieves the contents of the buffer. 
  149.    --  The memory pointer returned by this call will not change unless this 
  150.    --  object emits a signal, or is finalized. 
  151.    --  Since: gtk+ 2.18 
  152.  
  153.    procedure Set_Text 
  154.       (Self    : not null access Gtk_Entry_Buffer_Record; 
  155.        Chars   : UTF8_String; 
  156.        N_Chars : Gint); 
  157.    --  Sets the text in the buffer. 
  158.    --  This is roughly equivalent to calling Gtk.Entry_Buffer.Delete_Text and 
  159.    --  Gtk.Entry_Buffer.Insert_Text. 
  160.    --  Note that N_Chars is in characters, not in bytes. 
  161.    --  Since: gtk+ 2.18 
  162.    --  "chars": the new text 
  163.    --  "n_chars": the number of characters in Text, or -1 
  164.  
  165.    function Insert_Text 
  166.       (Self     : not null access Gtk_Entry_Buffer_Record; 
  167.        Position : Guint; 
  168.        Chars    : UTF8_String; 
  169.        N_Chars  : Gint) return Guint; 
  170.    --  Inserts N_Chars characters of Chars into the contents of the buffer, at 
  171.    --  position Position. 
  172.    --  If N_Chars is negative, then characters from chars will be inserted 
  173.    --  until a null-terminator is found. If Position or N_Chars are out of 
  174.    --  bounds, or the maximum buffer text length is exceeded, then they are 
  175.    --  coerced to sane values. 
  176.    --  Note that the position and length are in characters, not in bytes. 
  177.    --  Since: gtk+ 2.18 
  178.    --  "position": the position at which to insert text. 
  179.    --  "chars": the text to insert into the buffer. 
  180.    --  "n_chars": the length of the text in characters, or -1 
  181.  
  182.    ---------------- 
  183.    -- Properties -- 
  184.    ---------------- 
  185.    --  The following properties are defined for this widget. See 
  186.    --  Glib.Properties for more information on properties) 
  187.  
  188.    Length_Property : constant Glib.Properties.Property_Uint; 
  189.    --  The length (in characters) of the text in buffer. 
  190.  
  191.    Max_Length_Property : constant Glib.Properties.Property_Int; 
  192.    --  The maximum length (in characters) of the text in the buffer. 
  193.  
  194.    Text_Property : constant Glib.Properties.Property_String; 
  195.    --  The contents of the buffer. 
  196.  
  197.    ------------- 
  198.    -- Signals -- 
  199.    ------------- 
  200.  
  201.    type Cb_Gtk_Entry_Buffer_Guint_Guint_Void is not null access procedure 
  202.      (Self     : access Gtk_Entry_Buffer_Record'Class; 
  203.       Position : Guint; 
  204.       N_Chars  : Guint); 
  205.  
  206.    type Cb_GObject_Guint_Guint_Void is not null access procedure 
  207.      (Self     : access Glib.Object.GObject_Record'Class; 
  208.       Position : Guint; 
  209.       N_Chars  : Guint); 
  210.  
  211.    Signal_Deleted_Text : constant Glib.Signal_Name := "deleted-text"; 
  212.    procedure On_Deleted_Text 
  213.       (Self  : not null access Gtk_Entry_Buffer_Record; 
  214.        Call  : Cb_Gtk_Entry_Buffer_Guint_Guint_Void; 
  215.        After : Boolean := False); 
  216.    procedure On_Deleted_Text 
  217.       (Self  : not null access Gtk_Entry_Buffer_Record; 
  218.        Call  : Cb_GObject_Guint_Guint_Void; 
  219.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  220.        After : Boolean := False); 
  221.    --  This signal is emitted after text is deleted from the buffer. 
  222.    --  
  223.    --  Callback parameters: 
  224.    --    --  "position": the position the text was deleted at. 
  225.    --    --  "n_chars": The number of characters that were deleted. 
  226.  
  227.    type Cb_Gtk_Entry_Buffer_Guint_UTF8_String_Guint_Void is not null access procedure 
  228.      (Self     : access Gtk_Entry_Buffer_Record'Class; 
  229.       Position : Guint; 
  230.       Chars    : UTF8_String; 
  231.       N_Chars  : Guint); 
  232.  
  233.    type Cb_GObject_Guint_UTF8_String_Guint_Void is not null access procedure 
  234.      (Self     : access Glib.Object.GObject_Record'Class; 
  235.       Position : Guint; 
  236.       Chars    : UTF8_String; 
  237.       N_Chars  : Guint); 
  238.  
  239.    Signal_Inserted_Text : constant Glib.Signal_Name := "inserted-text"; 
  240.    procedure On_Inserted_Text 
  241.       (Self  : not null access Gtk_Entry_Buffer_Record; 
  242.        Call  : Cb_Gtk_Entry_Buffer_Guint_UTF8_String_Guint_Void; 
  243.        After : Boolean := False); 
  244.    procedure On_Inserted_Text 
  245.       (Self  : not null access Gtk_Entry_Buffer_Record; 
  246.        Call  : Cb_GObject_Guint_UTF8_String_Guint_Void; 
  247.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  248.        After : Boolean := False); 
  249.    --  This signal is emitted after text is inserted into the buffer. 
  250.    --  
  251.    --  Callback parameters: 
  252.    --    --  "position": the position the text was inserted at. 
  253.    --    --  "chars": The text that was inserted. 
  254.    --    --  "n_chars": The number of characters that were inserted. 
  255.  
  256. private 
  257.    Text_Property : constant Glib.Properties.Property_String := 
  258.      Glib.Properties.Build ("text"); 
  259.    Max_Length_Property : constant Glib.Properties.Property_Int := 
  260.      Glib.Properties.Build ("max-length"); 
  261.    Length_Property : constant Glib.Properties.Property_Uint := 
  262.      Glib.Properties.Build ("length"); 
  263. end Gtk.Entry_Buffer;