------------------------------------------------------------------------------
--                                                                          --
--                An Ada2005 binding to the Qt C++ framework                --
--                                                                          --
------------------------------------------------------------------------------
--                                                                          --
-- Copyright © 2008-2010 Vadim Godunko <vgodunko@gmail.com>                 --
--                                                                          --
-- QtAda is free software;  you can  redistribute it and/or modify it under --
-- terms of the  GNU General Public License as published  by the Free Soft- --
-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
-- sion. QtAda is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
-- for  more details.  You should have  received  a copy of the GNU General --
-- Public License distributed with QtAda;  see file COPYING.  If not, write --
-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
-- Boston, MA 02110-1301, USA.                                              --
--                                                                          --
-- As a special exception,  if other files  instantiate  generics from this --
-- unit, or you link  this unit with other files  to produce an executable, --
-- this  unit  does not  by itself cause  the resulting  executable  to  be --
-- covered  by the  GNU  General  Public  License.  This exception does not --
-- however invalidate  any other reasons why  the executable file  might be --
-- covered by the  GNU Public License.                                      --
--                                                                          --
------------------------------------------------------------------------------
--  $Revision: 3764 $ $Date: 2010-10-23 23:13:39 +0400 (Sat, 23 Oct 2010) $
------------------------------------------------------------------------------
private with Ada.Finalization;
with Interfaces.C;

with Qt4.Rgbs;
with Qt4.Strings;
private with Qt_Ada.Internals.Value_Class_Sizes;

package Qt4.Colors is

   --  QColor::Spec

   type Color_Spec is
    (Invalid,
     Rgb,
     Hsv,
     Cmyk);
   pragma Convention (C, Color_Spec);
   for Color_Spec'Size use Interfaces.C.unsigned'Size;

   type Q_Color is tagged private;

   function Create
    (R : Qt4.Q_Integer;
     G : Qt4.Q_Integer;
     B : Qt4.Q_Integer;
     A : Qt4.Q_Integer
       := 255)
       return Q_Color;

   function Create
    (Color : Qt4.Rgbs.Q_Rgb)
       return Q_Color;

   function Create
    (Name : Qt4.Strings.Q_String'Class)
       return Q_Color;

   function Create
    (Color : Qt4.Global_Color)
       return Q_Color;

   function Alpha
    (Self : Q_Color'Class)
       return Qt4.Q_Integer;

   function Alpha_F
    (Self : Q_Color'Class)
       return Qt4.Q_Real;

   function Black
    (Self : Q_Color'Class)
       return Qt4.Q_Integer;

   function Black_F
    (Self : Q_Color'Class)
       return Qt4.Q_Real;

   function Blue
    (Self : Q_Color'Class)
       return Qt4.Q_Integer;

   function Blue_F
    (Self : Q_Color'Class)
       return Qt4.Q_Real;

   function Convert_To
    (Self : Q_Color'Class;
     Spec : Color_Spec)
       return Q_Color;

   function Cyan
    (Self : Q_Color'Class)
       return Qt4.Q_Integer;

   function Cyan_F
    (Self : Q_Color'Class)
       return Qt4.Q_Real;

   function Darker
    (Self : Q_Color'Class;
     F : Qt4.Q_Integer
       := 200)
       return Q_Color;

   function Green
    (Self : Q_Color'Class)
       return Qt4.Q_Integer;

   function Green_F
    (Self : Q_Color'Class)
       return Qt4.Q_Real;

   function Hue
    (Self : Q_Color'Class)
       return Qt4.Q_Integer;

   function Hue_F
    (Self : Q_Color'Class)
       return Qt4.Q_Real;

   function Is_Valid
    (Self : Q_Color'Class)
       return Boolean;

   function Lighter
    (Self : Q_Color'Class;
     F : Qt4.Q_Integer
       := 150)
       return Q_Color;

   function Magenta
    (Self : Q_Color'Class)
       return Qt4.Q_Integer;

   function Magenta_F
    (Self : Q_Color'Class)
       return Qt4.Q_Real;

   function Name
    (Self : Q_Color'Class)
       return Qt4.Strings.Q_String;

   function Red
    (Self : Q_Color'Class)
       return Qt4.Q_Integer;

   function Red_F
    (Self : Q_Color'Class)
       return Qt4.Q_Real;

   function Rgb
    (Self : Q_Color'Class)
       return Qt4.Rgbs.Q_Rgb;

   function Rgba
    (Self : Q_Color'Class)
       return Qt4.Rgbs.Q_Rgb;

   function Saturation
    (Self : Q_Color'Class)
       return Qt4.Q_Integer;

   function Saturation_F
    (Self : Q_Color'Class)
       return Qt4.Q_Real;

   procedure Set_Alpha
    (Self : in out Q_Color'Class;
     Alpha : Qt4.Q_Integer);

   procedure Set_Alpha_F
    (Self : in out Q_Color'Class;
     Alpha : Qt4.Q_Real);

   procedure Set_Blue
    (Self : in out Q_Color'Class;
     Blue : Qt4.Q_Integer);

   procedure Set_Blue_F
    (Self : in out Q_Color'Class;
     Blue : Qt4.Q_Real);

   procedure Set_Cmyk
    (Self : in out Q_Color'Class;
     C : Qt4.Q_Integer;
     M : Qt4.Q_Integer;
     Y : Qt4.Q_Integer;
     K : Qt4.Q_Integer;
     A : Qt4.Q_Integer
       := 255);

   procedure Set_Cmyk_F
    (Self : in out Q_Color'Class;
     C : Qt4.Q_Real;
     M : Qt4.Q_Real;
     Y : Qt4.Q_Real;
     K : Qt4.Q_Real;
     A : Qt4.Q_Real);

   procedure Set_Green
    (Self : in out Q_Color'Class;
     Green : Qt4.Q_Integer);

   procedure Set_Green_F
    (Self : in out Q_Color'Class;
     Green : Qt4.Q_Real);

   procedure Set_Hsv
    (Self : in out Q_Color'Class;
     H : Qt4.Q_Integer;
     S : Qt4.Q_Integer;
     V : Qt4.Q_Integer;
     A : Qt4.Q_Integer
       := 255);

   procedure Set_Hsv_F
    (Self : in out Q_Color'Class;
     H : Qt4.Q_Real;
     S : Qt4.Q_Real;
     V : Qt4.Q_Real;
     A : Qt4.Q_Real);

   procedure Set_Named_Color
    (Self : in out Q_Color'Class;
     Name : Qt4.Strings.Q_String'Class);

   procedure Set_Red
    (Self : in out Q_Color'Class;
     Red : Qt4.Q_Integer);

   procedure Set_Red_F
    (Self : in out Q_Color'Class;
     Red : Qt4.Q_Real);

   procedure Set_Rgb
    (Self : in out Q_Color'Class;
     R : Qt4.Q_Integer;
     G : Qt4.Q_Integer;
     B : Qt4.Q_Integer;
     A : Qt4.Q_Integer
       := 255);

   procedure Set_Rgb
    (Self : in out Q_Color'Class;
     Rgb : Qt4.Rgbs.Q_Rgb);

   procedure Set_Rgb_F
    (Self : in out Q_Color'Class;
     R : Qt4.Q_Real;
     G : Qt4.Q_Real;
     B : Qt4.Q_Real;
     A : Qt4.Q_Real);

   procedure Set_Rgba
    (Self : in out Q_Color'Class;
     Rgba : Qt4.Rgbs.Q_Rgb);

   function Spec
    (Self : Q_Color'Class)
       return Color_Spec;

   function To_Cmyk
    (Self : Q_Color'Class)
       return Q_Color;

   function To_Hsv
    (Self : Q_Color'Class)
       return Q_Color;

   function To_Rgb
    (Self : Q_Color'Class)
       return Q_Color;

   function Value
    (Self : Q_Color'Class)
       return Qt4.Q_Integer;

   function Value_F
    (Self : Q_Color'Class)
       return Qt4.Q_Real;

   function Yellow
    (Self : Q_Color'Class)
       return Qt4.Q_Integer;

   function Yellow_F
    (Self : Q_Color'Class)
       return Qt4.Q_Real;

   overriding
   function "="
    (Self : Q_Color;
     Color : Q_Color)
       return Boolean;

   function From_Cmyk
    (C : Qt4.Q_Integer;
     M : Qt4.Q_Integer;
     Y : Qt4.Q_Integer;
     K : Qt4.Q_Integer;
     A : Qt4.Q_Integer
       := 255)
       return Q_Color;

   function From_Cmyk_F
    (C : Qt4.Q_Real;
     M : Qt4.Q_Real;
     Y : Qt4.Q_Real;
     K : Qt4.Q_Real;
     A : Qt4.Q_Real
       := 1.0)
       return Q_Color;

   function From_Hsv
    (H : Qt4.Q_Integer;
     S : Qt4.Q_Integer;
     V : Qt4.Q_Integer;
     A : Qt4.Q_Integer
       := 255)
       return Q_Color;

   function From_Hsv_F
    (H : Qt4.Q_Real;
     S : Qt4.Q_Real;
     V : Qt4.Q_Real;
     A : Qt4.Q_Real
       := 1.0)
       return Q_Color;

   function From_Rgb
    (Rgb : Qt4.Rgbs.Q_Rgb)
       return Q_Color;

   function From_Rgb
    (R : Qt4.Q_Integer;
     G : Qt4.Q_Integer;
     B : Qt4.Q_Integer;
     A : Qt4.Q_Integer
       := 255)
       return Q_Color;

   function From_Rgb_F
    (R : Qt4.Q_Real;
     G : Qt4.Q_Real;
     B : Qt4.Q_Real;
     A : Qt4.Q_Real
       := 1.0)
       return Q_Color;

   function From_Rgba
    (Rgba : Qt4.Rgbs.Q_Rgb)
       return Q_Color;

   package Internals is

      type QColor is private;

      type QColor_Access is access all QColor;
      pragma Convention (C, QColor_Access);

      function QColor_View
       (Item : Q_Color'Class)
          return QColor_Access;
      pragma Inline (QColor_View);

      function To_Pointer
       (Address : System.Address)
          return QColor_Access;
      pragma Inline (To_Pointer);

      function To_Address
       (Pointer : QColor_Access)
          return System.Address;
      pragma Inline (To_Address);

      function Create_Wrapper
       (Item : Internals.QColor_Access)
          return Q_Color;

   private

      type QColor is record
         Placeholder : Interfaces.C.char_array (1 .. Qt_Ada.Internals.Value_Class_Sizes.QColor_C_Size_Of);
      end record;
      pragma Convention (C, QColor);

   end Internals;

private

   type Q_Color is new Ada.Finalization.Controlled with record
      Storage : aliased Internals.QColor;
      Object  : Internals.QColor_Access := null;
      Wrapper : Boolean := False;
   end record;

   overriding
   procedure Adjust (Self : in out Q_Color);

   overriding
   procedure Finalize (Self : in out Q_Color);

   overriding
   procedure Initialize (Self : in out Q_Color);

end Qt4.Colors;
