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 GdkRGBA structure is used to represent a (possibly translucent) color, 
  26. --  in a way that is compatible with cairos notion of color. 
  27. -- 
  28. --  </description> 
  29. pragma Ada_2005; 
  30.  
  31. pragma Warnings (Off, "*is already use-visible*"); 
  32. with Glib;        use Glib; 
  33. with Glib.Object; use Glib.Object; 
  34. with Glib.Values; use Glib.Values; 
  35.  
  36. package Gdk.RGBA is 
  37.  
  38.    type Gdk_RGBA is record 
  39.       Red : Gdouble; 
  40.       Green : Gdouble; 
  41.       Blue : Gdouble; 
  42.       Alpha : Gdouble; 
  43.    end record; 
  44.    pragma Convention (C, Gdk_RGBA); 
  45.  
  46.    function From_Object_Free (B : access Gdk_RGBA) return Gdk_RGBA; 
  47.    pragma Inline (From_Object_Free); 
  48.    --  The GdkRGBA structure is used to represent a (possibly translucent) 
  49.    --  color, in a way that is compatible with cairos notion of color. 
  50.  
  51.    ------------------ 
  52.    -- Constructors -- 
  53.    ------------------ 
  54.  
  55.    function Get_Type return Glib.GType; 
  56.    pragma Import (C, Get_Type, "gdk_rgba_get_type"); 
  57.  
  58.    ------------- 
  59.    -- Methods -- 
  60.    ------------- 
  61.  
  62.    function Copy (Self : Gdk_RGBA) return Gdk_RGBA; 
  63.    pragma Import (C, Copy, "gdk_rgba_copy"); 
  64.    --  Makes a copy of a Gdk.RGBA.Gdk_RGBA structure. 
  65.    --  The result must be freed through Gdk.RGBA.Free. 
  66.    --  Since: gtk+ 3.0 
  67.  
  68.    function Equal (Self : Gdk_RGBA; P2 : Gdk_RGBA) return Boolean; 
  69.    --  Compares two RGBA colors. 
  70.    --  Since: gtk+ 3.0 
  71.    --  "p2": another Gdk.RGBA.Gdk_RGBA pointer 
  72.  
  73.    procedure Free (Self : Gdk_RGBA); 
  74.    pragma Import (C, Free, "gdk_rgba_free"); 
  75.    --  Frees a Gdk.RGBA.Gdk_RGBA struct created with Gdk.RGBA.Copy 
  76.    --  Since: gtk+ 3.0 
  77.  
  78.    function Hash (Self : Gdk_RGBA) return Guint; 
  79.    pragma Import (C, Hash, "gdk_rgba_hash"); 
  80.    --  A hash function suitable for using for a hash table that stores 
  81.    --  Gdk_RGBAs. 
  82.    --  Since: gtk+ 3.0 
  83.  
  84.    procedure Parse 
  85.       (Self    : out Gdk_RGBA; 
  86.        Spec    : UTF8_String; 
  87.        Success : out Boolean); 
  88.    --  Parses a textual representation of a color, filling in the 
  89.    --  <structfield>red</structfield>, <structfield>green</structfield>, 
  90.    --  <structfield>blue</structfield> and <structfield>alpha</structfield> 
  91.    --  fields of the Rgba struct. 
  92.    --  The string can be either one of: 
  93.    --     * A standard name (Taken from the X11 rgb.txt file). 
  94.    --     * A hex value in the form '&num;rgb' '&num;rrggbb' '&num;rrrgggbbb' 
  95.    --  or '&num;rrrrggggbbbb' 
  96.    --     * A RGB color in the form 'rgb(r,g,b)' (In this case the color will 
  97.    --  have full opacity) 
  98.    --     * A RGBA color in the form 'rgba(r,g,b,a)' 
  99.    --  Where 'r', 'g', 'b' and 'a' are respectively the red, green, blue and 
  100.    --  alpha color values. In the last two cases, r g and b are either integers 
  101.    --  in the range 0 to 255 or precentage values in the range 0% to 100%, and 
  102.    --  a is a floating point value in the range 0 to 1. 
  103.    --  Since: gtk+ 3.0 
  104.    --  "spec": the string specifying the color 
  105.  
  106.    function To_String (Self : Gdk_RGBA) return UTF8_String; 
  107.    --  Returns a textual specification of Rgba in the form 'rgb (r, g, b)' or 
  108.    --  'rgba (r, g, b, a)', where 'r', 'g', 'b' and 'a' represent the red, 
  109.    --  green, blue and alpha values respectively. r, g, and b are represented 
  110.    --  as integers in the range 0 to 255, and a is represented as floating 
  111.    --  point value in the range 0 to 1. 
  112.    --  These string forms are string forms those supported by the CSS3 colors 
  113.    --  module, and can be parsed by Gdk.RGBA.Parse. 
  114.    --  Note that this string representation may loose some precision, since r, 
  115.    --  g and b are represented as 8-bit integers. If this is a concern, you 
  116.    --  should use a different representation. 
  117.    --  Since: gtk+ 3.0 
  118.  
  119.    ---------------------- 
  120.    -- GtkAda additions -- 
  121.    ---------------------- 
  122.  
  123.    type array_of_Gdk_RGBA is array (Natural range <>) of Gdk_RGBA; 
  124.  
  125.    Null_RGBA  : constant Gdk_RGBA := (0.0, 0.0, 0.0, 0.0); 
  126.    Black_RGBA : constant Gdk_RGBA := (0.0, 0.0, 0.0, 1.0); 
  127.    White_RGBA : constant Gdk_RGBA := (1.0, 1.0, 1.0, 1.0); 
  128.  
  129.    type Property_RGBA is new Glib.Property; 
  130.    procedure Set_Property 
  131.      (Object : access Glib.Object.GObject_Record'Class; 
  132.       Name   : Property_RGBA; 
  133.       Value  : Gdk_RGBA); 
  134.    function Get_Property 
  135.      (Object : access Glib.Object.GObject_Record'Class; 
  136.       Name   : Property_RGBA) return Gdk_RGBA; 
  137.  
  138.    function Gdk_RGBA_Or_Null (Val : System.Address) return System.Address; 
  139.    --  Used for the GtkAda binding itself. 
  140.    --  Return either a Null_Address or a pointer to Val, depending on 
  141.    --  whether Val is the null value for the type. 
  142.    --  In all cases, Val is supposed to be an access to the type mentioned in 
  143.    --  the name of the subprogram. 
  144.    --  In Ada2012, these could be replaced with expression functions instead. 
  145.  
  146.    procedure Set_Value (Value : out Glib.Values.GValue; Val : Gdk_RGBA); 
  147.    function  Get_Value (Value : Glib.Values.GValue) return Gdk_RGBA; 
  148.    --  Conversion functions for storing a Gdk_RGBA as a GValue. 
  149.  
  150. end Gdk.RGBA;