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. --  You may wish to begin by reading the <link linkend="TextWidget">text 
  26. --  widget conceptual overview</link> which gives an overview of all the 
  27. --  objects and data types related to the text widget and how they work 
  28. --  together. 
  29. -- 
  30. --  == GtkTextTagTables as GtkBuildable == 
  31. -- 
  32. --  The GtkTextTagTable implementation of the GtkBuildable interface supports 
  33. --  adding tags by specifying "tag" as the "type" attribute of a <child> 
  34. --  element. 
  35. -- 
  36. --  == A UI definition fragment specifying tags == 
  37. -- 
  38. --    <object class="GtkTextTagTable"> 
  39. --    <child type="tag"> 
  40. --    <object class="GtkTextTag"/> 
  41. --    </child> 
  42. --    </object> 
  43. --  </description> 
  44. pragma Ada_2005; 
  45.  
  46. pragma Warnings (Off, "*is already use-visible*"); 
  47. with Glib;          use Glib; 
  48. with Glib.Object;   use Glib.Object; 
  49. with Glib.Types;    use Glib.Types; 
  50. with Gtk.Buildable; use Gtk.Buildable; 
  51. with Gtk.Text_Tag;  use Gtk.Text_Tag; 
  52.  
  53. package Gtk.Text_Tag_Table is 
  54.  
  55.    type Gtk_Text_Tag_Table_Record is new GObject_Record with null record; 
  56.    type Gtk_Text_Tag_Table is access all Gtk_Text_Tag_Table_Record'Class; 
  57.  
  58.    --------------- 
  59.    -- Callbacks -- 
  60.    --------------- 
  61.  
  62.    type Gtk_Text_Tag_Table_Foreach is access procedure 
  63.      (Tag : not null access Gtk.Text_Tag.Gtk_Text_Tag_Record'Class); 
  64.  
  65.    ------------------ 
  66.    -- Constructors -- 
  67.    ------------------ 
  68.  
  69.    procedure Gtk_New (Table : out Gtk_Text_Tag_Table); 
  70.    procedure Initialize 
  71.       (Table : not null access Gtk_Text_Tag_Table_Record'Class); 
  72.    --  Creates a new Gtk.Text_Tag_Table.Gtk_Text_Tag_Table. The table contains 
  73.    --  no tags by default. 
  74.  
  75.    function Gtk_Text_Tag_Table_New return Gtk_Text_Tag_Table; 
  76.    --  Creates a new Gtk.Text_Tag_Table.Gtk_Text_Tag_Table. The table contains 
  77.    --  no tags by default. 
  78.  
  79.    function Get_Type return Glib.GType; 
  80.    pragma Import (C, Get_Type, "gtk_text_tag_table_get_type"); 
  81.  
  82.    ------------- 
  83.    -- Methods -- 
  84.    ------------- 
  85.  
  86.    procedure Add 
  87.       (Table : not null access Gtk_Text_Tag_Table_Record; 
  88.        Tag   : not null access Gtk.Text_Tag.Gtk_Text_Tag_Record'Class); 
  89.    --  Add a tag to the table. The tag is assigned the highest priority in the 
  90.    --  table. 
  91.    --  Tag must not be in a tag table already, and may not have the same name 
  92.    --  as an already-added tag. 
  93.    --  "tag": a Gtk.Text_Tag.Gtk_Text_Tag 
  94.  
  95.    procedure Foreach 
  96.       (Table : not null access Gtk_Text_Tag_Table_Record; 
  97.        Func  : Gtk_Text_Tag_Table_Foreach); 
  98.    --  Calls Func on each tag in Table, with user data Data. Note that the 
  99.    --  table may not be modified while iterating over it (you can't add/remove 
  100.    --  tags). 
  101.    --  "func": a function to call on each tag 
  102.  
  103.    generic 
  104.       type User_Data_Type (<>) is private; 
  105.       with procedure Destroy (Data : in out User_Data_Type) is null; 
  106.    package Foreach_User_Data is 
  107.  
  108.       type Gtk_Text_Tag_Table_Foreach is access procedure 
  109.         (Tag  : not null access Gtk.Text_Tag.Gtk_Text_Tag_Record'Class; 
  110.          Data : User_Data_Type); 
  111.  
  112.       procedure Foreach 
  113.          (Table : not null access Gtk.Text_Tag_Table.Gtk_Text_Tag_Table_Record'Class; 
  114.           Func  : Gtk_Text_Tag_Table_Foreach; 
  115.           Data  : User_Data_Type); 
  116.       --  Calls Func on each tag in Table, with user data Data. Note that the 
  117.       --  table may not be modified while iterating over it (you can't 
  118.       --  add/remove tags). 
  119.       --  "func": a function to call on each tag 
  120.       --  "data": user data 
  121.  
  122.    end Foreach_User_Data; 
  123.  
  124.    function Get_Size 
  125.       (Table : not null access Gtk_Text_Tag_Table_Record) return Gint; 
  126.    --  Returns the size of the table (number of tags) 
  127.  
  128.    function Lookup 
  129.       (Table : not null access Gtk_Text_Tag_Table_Record; 
  130.        Name  : UTF8_String) return Gtk.Text_Tag.Gtk_Text_Tag; 
  131.    --  Look up a named tag. 
  132.    --  "name": name of a tag 
  133.  
  134.    procedure Remove 
  135.       (Table : not null access Gtk_Text_Tag_Table_Record; 
  136.        Tag   : not null access Gtk.Text_Tag.Gtk_Text_Tag_Record'Class); 
  137.    --  Remove a tag from the table. This will remove the table's reference to 
  138.    --  the tag, so be careful - the tag will end up destroyed if you don't have 
  139.    --  a reference to it. 
  140.    --  "tag": a Gtk.Text_Tag.Gtk_Text_Tag 
  141.  
  142.    ------------- 
  143.    -- Signals -- 
  144.    ------------- 
  145.  
  146.    type Cb_Gtk_Text_Tag_Table_Gtk_Text_Tag_Void is not null access procedure 
  147.      (Self : access Gtk_Text_Tag_Table_Record'Class; 
  148.       Tag  : not null access Gtk.Text_Tag.Gtk_Text_Tag_Record'Class); 
  149.  
  150.    type Cb_GObject_Gtk_Text_Tag_Void is not null access procedure 
  151.      (Self : access Glib.Object.GObject_Record'Class; 
  152.       Tag  : not null access Gtk.Text_Tag.Gtk_Text_Tag_Record'Class); 
  153.  
  154.    Signal_Tag_Added : constant Glib.Signal_Name := "tag-added"; 
  155.    procedure On_Tag_Added 
  156.       (Self  : not null access Gtk_Text_Tag_Table_Record; 
  157.        Call  : Cb_Gtk_Text_Tag_Table_Gtk_Text_Tag_Void; 
  158.        After : Boolean := False); 
  159.    procedure On_Tag_Added 
  160.       (Self  : not null access Gtk_Text_Tag_Table_Record; 
  161.        Call  : Cb_GObject_Gtk_Text_Tag_Void; 
  162.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  163.        After : Boolean := False); 
  164.  
  165.    type Cb_Gtk_Text_Tag_Table_Gtk_Text_Tag_Boolean_Void is not null access procedure 
  166.      (Self         : access Gtk_Text_Tag_Table_Record'Class; 
  167.       Tag          : not null access Gtk.Text_Tag.Gtk_Text_Tag_Record'Class; 
  168.       Size_Changed : Boolean); 
  169.  
  170.    type Cb_GObject_Gtk_Text_Tag_Boolean_Void is not null access procedure 
  171.      (Self         : access Glib.Object.GObject_Record'Class; 
  172.       Tag          : not null access Gtk.Text_Tag.Gtk_Text_Tag_Record'Class; 
  173.       Size_Changed : Boolean); 
  174.  
  175.    Signal_Tag_Changed : constant Glib.Signal_Name := "tag-changed"; 
  176.    procedure On_Tag_Changed 
  177.       (Self  : not null access Gtk_Text_Tag_Table_Record; 
  178.        Call  : Cb_Gtk_Text_Tag_Table_Gtk_Text_Tag_Boolean_Void; 
  179.        After : Boolean := False); 
  180.    procedure On_Tag_Changed 
  181.       (Self  : not null access Gtk_Text_Tag_Table_Record; 
  182.        Call  : Cb_GObject_Gtk_Text_Tag_Boolean_Void; 
  183.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  184.        After : Boolean := False); 
  185.    --  
  186.    --  Callback parameters: 
  187.    --    --  "tag": the changed tag. 
  188.    --    --  "size_changed": whether the size has been changed. 
  189.  
  190.    Signal_Tag_Removed : constant Glib.Signal_Name := "tag-removed"; 
  191.    procedure On_Tag_Removed 
  192.       (Self  : not null access Gtk_Text_Tag_Table_Record; 
  193.        Call  : Cb_Gtk_Text_Tag_Table_Gtk_Text_Tag_Void; 
  194.        After : Boolean := False); 
  195.    procedure On_Tag_Removed 
  196.       (Self  : not null access Gtk_Text_Tag_Table_Record; 
  197.        Call  : Cb_GObject_Gtk_Text_Tag_Void; 
  198.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  199.        After : Boolean := False); 
  200.  
  201.    ---------------- 
  202.    -- Interfaces -- 
  203.    ---------------- 
  204.    --  This class implements several interfaces. See Glib.Types 
  205.    -- 
  206.    --  - "Buildable" 
  207.  
  208.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  209.      (Gtk.Buildable.Gtk_Buildable, Gtk_Text_Tag_Table_Record, Gtk_Text_Tag_Table); 
  210.    function "+" 
  211.      (Widget : access Gtk_Text_Tag_Table_Record'Class) 
  212.    return Gtk.Buildable.Gtk_Buildable 
  213.    renames Implements_Gtk_Buildable.To_Interface; 
  214.    function "-" 
  215.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  216.    return Gtk_Text_Tag_Table 
  217.    renames Implements_Gtk_Buildable.To_Object; 
  218.  
  219. end Gtk.Text_Tag_Table;