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. pragma Ada_2005; 
  25.  
  26. pragma Warnings (Off, "*is already use-visible*"); 
  27. with Glib;        use Glib; 
  28. with Pango.Enums; use Pango.Enums; 
  29.  
  30. package Pango.Attributes is 
  31.  
  32.    type Pango_Attribute is private; 
  33.    function From_Object_Free (B : access Pango_Attribute) return Pango_Attribute; 
  34.    pragma Inline (From_Object_Free); 
  35.  
  36.  
  37.    type Pango_Attr_List is new Glib.C_Boxed with null record; 
  38.    Null_Pango_Attr_List : constant Pango_Attr_List; 
  39.  
  40.    function From_Object (Object : System.Address) return Pango_Attr_List; 
  41.    function From_Object_Free (B : access Pango_Attr_List'Class) return Pango_Attr_List; 
  42.    pragma Inline (From_Object_Free, From_Object); 
  43.  
  44.    --------------- 
  45.    -- Callbacks -- 
  46.    --------------- 
  47.  
  48.    type Pango_Attr_Filter_Func is access function (Attribute : Pango_Attribute) return Boolean; 
  49.    --  Type of a function filtering a list of attributes. 
  50.    --  "attribute": a Pango attribute 
  51.  
  52.    ------------------ 
  53.    -- Constructors -- 
  54.    ------------------ 
  55.  
  56.    procedure Gdk_New (Self : out Pango_Attr_List); 
  57.    --  Create a new empty attribute list with a reference count of one. 
  58.  
  59.    function Pango_Attr_List_New return Pango_Attr_List; 
  60.    --  Create a new empty attribute list with a reference count of one. 
  61.  
  62.    function Get_Type return Glib.GType; 
  63.    pragma Import (C, Get_Type, "pango_attr_list_get_type"); 
  64.  
  65.    ------------- 
  66.    -- Methods -- 
  67.    ------------- 
  68.  
  69.    function Copy (Self : Pango_Attribute) return Pango_Attribute; 
  70.    pragma Import (C, Copy, "pango_attribute_copy"); 
  71.    --  Make a copy of an attribute. 
  72.  
  73.    function Copy (Self : Pango_Attr_List) return Pango_Attr_List; 
  74.    --  Copy List and return an identical new list. 
  75.  
  76.    procedure Destroy (Self : Pango_Attribute); 
  77.    pragma Import (C, Destroy, "pango_attribute_destroy"); 
  78.    --  Destroy a Pango.Attributes.Pango_Attribute and free all associated 
  79.    --  memory. 
  80.  
  81.    function Equal 
  82.       (Self  : Pango_Attribute; 
  83.        Attr2 : Pango_Attribute) return Boolean; 
  84.    --  Compare two attributes for equality. This compares only the actual 
  85.    --  value of the two attributes and not the ranges that the attributes apply 
  86.    --  to. 
  87.    --  "attr2": another Pango.Attributes.Pango_Attribute 
  88.  
  89.    procedure Change (Self : Pango_Attr_List; Attr : Pango_Attribute); 
  90.    --  Insert the given attribute into the Pango.Attributes.Pango_Attr_List. 
  91.    --  It will replace any attributes of the same type on that segment and be 
  92.    --  merged with any adjoining attributes that are identical. 
  93.    --  This function is slower than Pango.Attributes.Insert for creating a 
  94.    --  attribute list in order (potentially much slower for large lists). 
  95.    --  However, Pango.Attributes.Insert is not suitable for continually 
  96.    --  changing a set of attributes since it never removes or combines existing 
  97.    --  attributes. 
  98.    --  "attr": the attribute to insert. Ownership of this value is assumed by 
  99.    --  the list. 
  100.  
  101.    function Filter 
  102.       (Self : Pango_Attr_List; 
  103.        Func : Pango_Attr_Filter_Func) return Pango_Attr_List; 
  104.    --  Given a Pango.Attributes.Pango_Attr_List and callback function, removes 
  105.    --  any elements of List for which Func returns True and inserts them into a 
  106.    --  new list. 
  107.    --  Since: gtk+ 1.2 
  108.    --  "func": callback function; returns True if an attribute should be 
  109.    --  filtered out. 
  110.  
  111.    generic 
  112.       type User_Data_Type (<>) is private; 
  113.       with procedure Destroy (Data : in out User_Data_Type) is null; 
  114.    package Filter_User_Data is 
  115.  
  116.       type Pango_Attr_Filter_Func is access function 
  117.         (Attribute : Pango.Attributes.Pango_Attribute; 
  118.          User_Data : User_Data_Type) return Boolean; 
  119.       --  Type of a function filtering a list of attributes. 
  120.       --  "attribute": a Pango attribute 
  121.       --  "user_data": user data passed to the function 
  122.  
  123.       function Filter 
  124.          (Self : Pango.Attributes.Pango_Attr_List; 
  125.           Func : Pango_Attr_Filter_Func; 
  126.           Data : User_Data_Type) return Pango.Attributes.Pango_Attr_List; 
  127.       --  Given a Pango.Attributes.Pango_Attr_List and callback function, 
  128.       --  removes any elements of List for which Func returns True and inserts 
  129.       --  them into a new list. 
  130.       --  Since: gtk+ 1.2 
  131.       --  "func": callback function; returns True if an attribute should be 
  132.       --  filtered out. 
  133.       --  "data": Data to be passed to Func 
  134.  
  135.    end Filter_User_Data; 
  136.  
  137.    procedure Insert (Self : Pango_Attr_List; Attr : Pango_Attribute); 
  138.    --  Insert the given attribute into the Pango.Attributes.Pango_Attr_List. 
  139.    --  It will be inserted after all other attributes with a matching 
  140.    --  Start_Index. 
  141.    --  "attr": the attribute to insert. Ownership of this value is assumed by 
  142.    --  the list. 
  143.  
  144.    procedure Insert_Before (Self : Pango_Attr_List; Attr : Pango_Attribute); 
  145.    --  Insert the given attribute into the Pango.Attributes.Pango_Attr_List. 
  146.    --  It will be inserted before all other attributes with a matching 
  147.    --  Start_Index. 
  148.    --  "attr": the attribute to insert. Ownership of this value is assumed by 
  149.    --  the list. 
  150.  
  151.    function Ref (Self : Pango_Attr_List) return Pango_Attr_List; 
  152.    --  Increase the reference count of the given attribute list by one. 
  153.    --  Since: gtk+ 1.10 
  154.  
  155.    procedure Splice 
  156.       (Self  : Pango_Attr_List; 
  157.        Other : Pango_Attr_List; 
  158.        Pos   : Gint; 
  159.        Len   : Gint); 
  160.    --  This function opens up a hole in List, fills it in with attributes from 
  161.    --  the left, and then merges Other on top of the hole. 
  162.    --  This operation is equivalent to stretching every attribute that applies 
  163.    --  at position Pos in List by an amount Len, and then calling 
  164.    --  Pango.Attributes.Change with a copy of each attribute in Other in 
  165.    --  sequence (offset in position by Pos). 
  166.    --  This operation proves useful for, for instance, inserting a pre-edit 
  167.    --  string in the middle of an edit buffer. 
  168.    --  "other": another Pango.Attributes.Pango_Attr_List 
  169.    --  "pos": the position in List at which to insert Other 
  170.    --  "len": the length of the spliced segment. (Note that this must be 
  171.    --  specified since the attributes in Other may only be present at some 
  172.    --  subsection of this range) 
  173.  
  174.    procedure Unref (Self : Pango_Attr_List); 
  175.    --  Decrease the reference count of the given attribute list by one. If the 
  176.    --  result is zero, free the attribute list and the attributes it contains. 
  177.  
  178.    --------------- 
  179.    -- Functions -- 
  180.    --------------- 
  181.  
  182.    function Attr_Underline_New 
  183.       (Underline : Pango.Enums.Underline) return Pango_Attribute; 
  184.    pragma Import (C, Attr_Underline_New, "pango_attr_underline_new"); 
  185.    --  Create a new underline-style attribute. 
  186.    --  "underline": the underline style. 
  187.  
  188.    function Attr_Background_New 
  189.       (Red   : Guint16; 
  190.        Green : Guint16; 
  191.        Blue  : Guint16) return Pango_Attribute; 
  192.    pragma Import (C, Attr_Background_New, "pango_attr_background_new"); 
  193.    --  Create a new background color attribute. 
  194.    --  "red": the red value (ranging from 0 to 65535) 
  195.    --  "green": the green value 
  196.    --  "blue": the blue value 
  197.  
  198.    function Attr_Foreground_New 
  199.       (Red   : Guint16; 
  200.        Green : Guint16; 
  201.        Blue  : Guint16) return Pango_Attribute; 
  202.    pragma Import (C, Attr_Foreground_New, "pango_attr_foreground_new"); 
  203.    --  Create a new foreground color attribute. 
  204.    --  "red": the red value (ranging from 0 to 65535) 
  205.    --  "green": the green value 
  206.    --  "blue": the blue value 
  207.  
  208.    function Attr_Family_New (Family : UTF8_String) return Pango_Attribute; 
  209.    --  Create a new font family attribute. 
  210.    --  "family": the family or comma separated list of families 
  211.  
  212.    function Attr_Strikethrough_New 
  213.       (Strikethrough : Boolean) return Pango_Attribute; 
  214.    --  Create a new strike-through attribute. 
  215.    --  "strikethrough": True if the text should be struck-through. 
  216.  
  217.    function Attr_Variant_New 
  218.       (Variant : Pango.Enums.Variant) return Pango_Attribute; 
  219.    pragma Import (C, Attr_Variant_New, "pango_attr_variant_new"); 
  220.    --  Create a new font variant attribute (normal or small caps) 
  221.    --  "variant": the variant 
  222.  
  223.    function Attr_Weight_New 
  224.       (Weight : Pango.Enums.Weight) return Pango_Attribute; 
  225.    pragma Import (C, Attr_Weight_New, "pango_attr_weight_new"); 
  226.    --  Create a new font weight attribute. 
  227.    --  "weight": the weight 
  228.  
  229.    function Attr_Stretch_New 
  230.       (Stretch : Pango.Enums.Stretch) return Pango_Attribute; 
  231.    pragma Import (C, Attr_Stretch_New, "pango_attr_stretch_new"); 
  232.    --  Create a new font stretch attribute 
  233.    --  "stretch": the stretch 
  234.  
  235.    function Attr_Scale_New (Scale_Factor : Gdouble) return Pango_Attribute; 
  236.    pragma Import (C, Attr_Scale_New, "pango_attr_scale_new"); 
  237.    --  Create a new font size scale attribute. The base font for the affected 
  238.    --  text will have its size multiplied by Scale_Factor. 
  239.    --  "scale_factor": factor to scale the font 
  240.  
  241.    function Attr_Rise_New (Rise : Gint) return Pango_Attribute; 
  242.    pragma Import (C, Attr_Rise_New, "pango_attr_rise_new"); 
  243.    --  Create a new baseline displacement attribute. 
  244.    --  "rise": the amount that the text should be displaced vertically, in 
  245.    --  Pango units. Positive values displace the text upwards. 
  246.  
  247.    function Attr_Gravity_New 
  248.       (Gravity : Pango.Enums.Gravity) return Pango_Attribute; 
  249.    pragma Import (C, Attr_Gravity_New, "pango_attr_gravity_new"); 
  250.    --  Create a new gravity attribute. 
  251.    --  Since: gtk+ 1.16 
  252.    --  "gravity": the gravity value; should not be 
  253.    --  Pango.Enums.Pango_Gravity_Auto. 
  254.  
  255. private 
  256. type Pango_Attribute is record 
  257.    Klass : access Pango_Attr_Class; 
  258.    Start_Index : Guint; 
  259.    End_Index : Guint; 
  260. end record; 
  261. pragma Convention (C, Pango_Attribute); 
  262.  
  263.  
  264.    Null_Pango_Attr_List : constant Pango_Attr_List := (Glib.C_Boxed with null record); 
  265.  
  266. end Pango.Attributes;