------------------------------------------------------------------------------
--                                                                          --
--                An Ada2005 binding to the Qt C++ framework                --
--                                                                          --
------------------------------------------------------------------------------
--                                                                          --
-- Copyright © 2008, 2009 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: 3640 $ $Date: 2009-11-27 11:34:03 +0300 (Fri, 27 Nov 2009) $
------------------------------------------------------------------------------
pragma Style_Checks ("M32766");
with System.Address_To_Access_Conversions;

package body Qt4.Colors is

   function initialize_QColor
    (Storage : System.Address)
      return Internals.QColor_Access;
   pragma Import (C, initialize_QColor, "__QtAda_inititialize_QColor");

   function initialize_QColor_int_int_int_int
    (Storage : System.Address;
     R : Qt4.Q_Integer;
     G : Qt4.Q_Integer;
     B : Qt4.Q_Integer;
     A : Qt4.Q_Integer)
      return Internals.QColor_Access;
   pragma Import (C, initialize_QColor_int_int_int_int, "__QtAda_inititialize_QColor_int_int_int_int");

   function initialize_QColor_QRgb
    (Storage : System.Address;
     Color : Qt4.Rgbs.Q_Rgb)
      return Internals.QColor_Access;
   pragma Import (C, initialize_QColor_QRgb, "__QtAda_inititialize_QColor_QRgb");

   function initialize_QColor_QStringCR
    (Storage : System.Address;
     Name : Qt4.Strings.Internals.QString_Access)
      return Internals.QColor_Access;
   pragma Import (C, initialize_QColor_QStringCR, "__QtAda_inititialize_QColor_QStringCR");

   function initialize_QColor_GlobalColor
    (Storage : System.Address;
     Color : Qt4.Global_Color)
      return Internals.QColor_Access;
   pragma Import (C, initialize_QColor_GlobalColor, "__QtAda_inititialize_QColor_GlobalColor");

   function adjust_QColor
    (Storage : System.Address;
     From    : Internals.QColor_Access)
       return Internals.QColor_Access;
   pragma Import (C, adjust_QColor, "__QtAda_adjust_QColor");

   procedure finalize_QColor (Object : Internals.QColor_Access);
   pragma Import (C, finalize_QColor, "__QtAda_finalize_QColor");

   function QColor_alpha
    (Self : Internals.QColor_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QColor_alpha, "__QtAda_QColor_alpha_Q");

   function QColor_alphaF
    (Self : Internals.QColor_Access)
       return Qt4.Q_Real;
   pragma Import (C, QColor_alphaF, "__QtAda_QColor_alphaF_Q");

   function QColor_black
    (Self : Internals.QColor_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QColor_black, "__QtAda_QColor_black_Q");

   function QColor_blackF
    (Self : Internals.QColor_Access)
       return Qt4.Q_Real;
   pragma Import (C, QColor_blackF, "__QtAda_QColor_blackF_Q");

   function QColor_blue
    (Self : Internals.QColor_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QColor_blue, "__QtAda_QColor_blue_Q");

   function QColor_blueF
    (Self : Internals.QColor_Access)
       return Qt4.Q_Real;
   pragma Import (C, QColor_blueF, "__QtAda_QColor_blueF_Q");

   procedure QColor_convertTo_Spec
    (Returns : Internals.QColor_Access;
     Self : Internals.QColor_Access;
     Spec : Color_Spec);
   pragma Import (C, QColor_convertTo_Spec, "__QtAda_QColor_convertTo_Spec_Q");

   function QColor_cyan
    (Self : Internals.QColor_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QColor_cyan, "__QtAda_QColor_cyan_Q");

   function QColor_cyanF
    (Self : Internals.QColor_Access)
       return Qt4.Q_Real;
   pragma Import (C, QColor_cyanF, "__QtAda_QColor_cyanF_Q");

   procedure QColor_darker_int
    (Returns : Internals.QColor_Access;
     Self : Internals.QColor_Access;
     F : Qt4.Q_Integer);
   pragma Import (C, QColor_darker_int, "__QtAda_QColor_darker_int_Q");

   function QColor_green
    (Self : Internals.QColor_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QColor_green, "__QtAda_QColor_green_Q");

   function QColor_greenF
    (Self : Internals.QColor_Access)
       return Qt4.Q_Real;
   pragma Import (C, QColor_greenF, "__QtAda_QColor_greenF_Q");

   function QColor_hue
    (Self : Internals.QColor_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QColor_hue, "__QtAda_QColor_hue_Q");

   function QColor_hueF
    (Self : Internals.QColor_Access)
       return Qt4.Q_Real;
   pragma Import (C, QColor_hueF, "__QtAda_QColor_hueF_Q");

   function QColor_isValid
    (Self : Internals.QColor_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QColor_isValid, "__QtAda_QColor_isValid_Q");

   procedure QColor_lighter_int
    (Returns : Internals.QColor_Access;
     Self : Internals.QColor_Access;
     F : Qt4.Q_Integer);
   pragma Import (C, QColor_lighter_int, "__QtAda_QColor_lighter_int_Q");

   function QColor_magenta
    (Self : Internals.QColor_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QColor_magenta, "__QtAda_QColor_magenta_Q");

   function QColor_magentaF
    (Self : Internals.QColor_Access)
       return Qt4.Q_Real;
   pragma Import (C, QColor_magentaF, "__QtAda_QColor_magentaF_Q");

   procedure QColor_name
    (Returns : Qt4.Strings.Internals.QString_Access;
     Self : Internals.QColor_Access);
   pragma Import (C, QColor_name, "__QtAda_QColor_name_Q");

   function QColor_red
    (Self : Internals.QColor_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QColor_red, "__QtAda_QColor_red_Q");

   function QColor_redF
    (Self : Internals.QColor_Access)
       return Qt4.Q_Real;
   pragma Import (C, QColor_redF, "__QtAda_QColor_redF_Q");

   function QColor_rgb
    (Self : Internals.QColor_Access)
       return Qt4.Rgbs.Q_Rgb;
   pragma Import (C, QColor_rgb, "__QtAda_QColor_rgb_Q");

   function QColor_rgba
    (Self : Internals.QColor_Access)
       return Qt4.Rgbs.Q_Rgb;
   pragma Import (C, QColor_rgba, "__QtAda_QColor_rgba_Q");

   function QColor_saturation
    (Self : Internals.QColor_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QColor_saturation, "__QtAda_QColor_saturation_Q");

   function QColor_saturationF
    (Self : Internals.QColor_Access)
       return Qt4.Q_Real;
   pragma Import (C, QColor_saturationF, "__QtAda_QColor_saturationF_Q");

   procedure QColor_setAlpha_int
    (Self : Internals.QColor_Access;
     Alpha : Qt4.Q_Integer);
   pragma Import (C, QColor_setAlpha_int, "__QtAda_QColor_setAlpha_int");

   procedure QColor_setAlphaF_qreal
    (Self : Internals.QColor_Access;
     Alpha : Qt4.Q_Real);
   pragma Import (C, QColor_setAlphaF_qreal, "__QtAda_QColor_setAlphaF_qreal");

   procedure QColor_setBlue_int
    (Self : Internals.QColor_Access;
     Blue : Qt4.Q_Integer);
   pragma Import (C, QColor_setBlue_int, "__QtAda_QColor_setBlue_int");

   procedure QColor_setBlueF_qreal
    (Self : Internals.QColor_Access;
     Blue : Qt4.Q_Real);
   pragma Import (C, QColor_setBlueF_qreal, "__QtAda_QColor_setBlueF_qreal");

   procedure QColor_setCmyk_int_int_int_int_int
    (Self : Internals.QColor_Access;
     C : Qt4.Q_Integer;
     M : Qt4.Q_Integer;
     Y : Qt4.Q_Integer;
     K : Qt4.Q_Integer;
     A : Qt4.Q_Integer);
   pragma Import (C, QColor_setCmyk_int_int_int_int_int, "__QtAda_QColor_setCmyk_int_int_int_int_int");

   procedure QColor_setCmykF_qreal_qreal_qreal_qreal_qreal
    (Self : Internals.QColor_Access;
     C : Qt4.Q_Real;
     M : Qt4.Q_Real;
     Y : Qt4.Q_Real;
     K : Qt4.Q_Real;
     A : Qt4.Q_Real);
   pragma Import (C, QColor_setCmykF_qreal_qreal_qreal_qreal_qreal, "__QtAda_QColor_setCmykF_qreal_qreal_qreal_qreal_qreal");

   procedure QColor_setGreen_int
    (Self : Internals.QColor_Access;
     Green : Qt4.Q_Integer);
   pragma Import (C, QColor_setGreen_int, "__QtAda_QColor_setGreen_int");

   procedure QColor_setGreenF_qreal
    (Self : Internals.QColor_Access;
     Green : Qt4.Q_Real);
   pragma Import (C, QColor_setGreenF_qreal, "__QtAda_QColor_setGreenF_qreal");

   procedure QColor_setHsv_int_int_int_int
    (Self : Internals.QColor_Access;
     H : Qt4.Q_Integer;
     S : Qt4.Q_Integer;
     V : Qt4.Q_Integer;
     A : Qt4.Q_Integer);
   pragma Import (C, QColor_setHsv_int_int_int_int, "__QtAda_QColor_setHsv_int_int_int_int");

   procedure QColor_setHsvF_qreal_qreal_qreal_qreal
    (Self : Internals.QColor_Access;
     H : Qt4.Q_Real;
     S : Qt4.Q_Real;
     V : Qt4.Q_Real;
     A : Qt4.Q_Real);
   pragma Import (C, QColor_setHsvF_qreal_qreal_qreal_qreal, "__QtAda_QColor_setHsvF_qreal_qreal_qreal_qreal");

   procedure QColor_setNamedColor_QStringCR
    (Self : Internals.QColor_Access;
     Name : Qt4.Strings.Internals.QString_Access);
   pragma Import (C, QColor_setNamedColor_QStringCR, "__QtAda_QColor_setNamedColor_QStringCR");

   procedure QColor_setRed_int
    (Self : Internals.QColor_Access;
     Red : Qt4.Q_Integer);
   pragma Import (C, QColor_setRed_int, "__QtAda_QColor_setRed_int");

   procedure QColor_setRedF_qreal
    (Self : Internals.QColor_Access;
     Red : Qt4.Q_Real);
   pragma Import (C, QColor_setRedF_qreal, "__QtAda_QColor_setRedF_qreal");

   procedure QColor_setRgb_int_int_int_int
    (Self : Internals.QColor_Access;
     R : Qt4.Q_Integer;
     G : Qt4.Q_Integer;
     B : Qt4.Q_Integer;
     A : Qt4.Q_Integer);
   pragma Import (C, QColor_setRgb_int_int_int_int, "__QtAda_QColor_setRgb_int_int_int_int");

   procedure QColor_setRgb_QRgb
    (Self : Internals.QColor_Access;
     Rgb : Qt4.Rgbs.Q_Rgb);
   pragma Import (C, QColor_setRgb_QRgb, "__QtAda_QColor_setRgb_QRgb");

   procedure QColor_setRgbF_qreal_qreal_qreal_qreal
    (Self : Internals.QColor_Access;
     R : Qt4.Q_Real;
     G : Qt4.Q_Real;
     B : Qt4.Q_Real;
     A : Qt4.Q_Real);
   pragma Import (C, QColor_setRgbF_qreal_qreal_qreal_qreal, "__QtAda_QColor_setRgbF_qreal_qreal_qreal_qreal");

   procedure QColor_setRgba_QRgb
    (Self : Internals.QColor_Access;
     Rgba : Qt4.Rgbs.Q_Rgb);
   pragma Import (C, QColor_setRgba_QRgb, "__QtAda_QColor_setRgba_QRgb");

   function QColor_spec
    (Self : Internals.QColor_Access)
       return Color_Spec;
   pragma Import (C, QColor_spec, "__QtAda_QColor_spec_Q");

   procedure QColor_toCmyk
    (Returns : Internals.QColor_Access;
     Self : Internals.QColor_Access);
   pragma Import (C, QColor_toCmyk, "__QtAda_QColor_toCmyk_Q");

   procedure QColor_toHsv
    (Returns : Internals.QColor_Access;
     Self : Internals.QColor_Access);
   pragma Import (C, QColor_toHsv, "__QtAda_QColor_toHsv_Q");

   procedure QColor_toRgb
    (Returns : Internals.QColor_Access;
     Self : Internals.QColor_Access);
   pragma Import (C, QColor_toRgb, "__QtAda_QColor_toRgb_Q");

   function QColor_value
    (Self : Internals.QColor_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QColor_value, "__QtAda_QColor_value_Q");

   function QColor_valueF
    (Self : Internals.QColor_Access)
       return Qt4.Q_Real;
   pragma Import (C, QColor_valueF, "__QtAda_QColor_valueF_Q");

   function QColor_yellow
    (Self : Internals.QColor_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QColor_yellow, "__QtAda_QColor_yellow_Q");

   function QColor_yellowF
    (Self : Internals.QColor_Access)
       return Qt4.Q_Real;
   pragma Import (C, QColor_yellowF, "__QtAda_QColor_yellowF_Q");

   function eq_QColorCR
    (Self : Internals.QColor_Access;
     Color : Internals.QColor_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, eq_QColorCR, "__QtAda_QColor_eq_QColorCR_Q");

   procedure QColor_fromCmyk_int_int_int_int_int
    (Returns : Internals.QColor_Access;
     C : Qt4.Q_Integer;
     M : Qt4.Q_Integer;
     Y : Qt4.Q_Integer;
     K : Qt4.Q_Integer;
     A : Qt4.Q_Integer);
   pragma Import (C, QColor_fromCmyk_int_int_int_int_int, "__QtAda_QColor_fromCmyk_int_int_int_int_int_S");

   procedure QColor_fromCmykF_qreal_qreal_qreal_qreal_qreal
    (Returns : Internals.QColor_Access;
     C : Qt4.Q_Real;
     M : Qt4.Q_Real;
     Y : Qt4.Q_Real;
     K : Qt4.Q_Real;
     A : Qt4.Q_Real);
   pragma Import (C, QColor_fromCmykF_qreal_qreal_qreal_qreal_qreal, "__QtAda_QColor_fromCmykF_qreal_qreal_qreal_qreal_qreal_S");

   procedure QColor_fromHsv_int_int_int_int
    (Returns : Internals.QColor_Access;
     H : Qt4.Q_Integer;
     S : Qt4.Q_Integer;
     V : Qt4.Q_Integer;
     A : Qt4.Q_Integer);
   pragma Import (C, QColor_fromHsv_int_int_int_int, "__QtAda_QColor_fromHsv_int_int_int_int_S");

   procedure QColor_fromHsvF_qreal_qreal_qreal_qreal
    (Returns : Internals.QColor_Access;
     H : Qt4.Q_Real;
     S : Qt4.Q_Real;
     V : Qt4.Q_Real;
     A : Qt4.Q_Real);
   pragma Import (C, QColor_fromHsvF_qreal_qreal_qreal_qreal, "__QtAda_QColor_fromHsvF_qreal_qreal_qreal_qreal_S");

   procedure QColor_fromRgb_QRgb
    (Returns : Internals.QColor_Access;
     Rgb : Qt4.Rgbs.Q_Rgb);
   pragma Import (C, QColor_fromRgb_QRgb, "__QtAda_QColor_fromRgb_QRgb_S");

   procedure QColor_fromRgb_int_int_int_int
    (Returns : Internals.QColor_Access;
     R : Qt4.Q_Integer;
     G : Qt4.Q_Integer;
     B : Qt4.Q_Integer;
     A : Qt4.Q_Integer);
   pragma Import (C, QColor_fromRgb_int_int_int_int, "__QtAda_QColor_fromRgb_int_int_int_int_S");

   procedure QColor_fromRgbF_qreal_qreal_qreal_qreal
    (Returns : Internals.QColor_Access;
     R : Qt4.Q_Real;
     G : Qt4.Q_Real;
     B : Qt4.Q_Real;
     A : Qt4.Q_Real);
   pragma Import (C, QColor_fromRgbF_qreal_qreal_qreal_qreal, "__QtAda_QColor_fromRgbF_qreal_qreal_qreal_qreal_S");

   procedure QColor_fromRgba_QRgb
    (Returns : Internals.QColor_Access;
     Rgba : Qt4.Rgbs.Q_Rgb);
   pragma Import (C, QColor_fromRgba_QRgb, "__QtAda_QColor_fromRgba_QRgb_S");

   ------------
   -- Adjust --
   ------------

   overriding
   procedure Adjust (Self : in out Q_Color) is
   begin
      Self.Object := adjust_QColor (Self.Storage'Address, Self.Object);
      Self.Wrapper := False;
   end Adjust;

   --------------
   -- Finalize --
   --------------

   overriding
   procedure Finalize (Self : in out Q_Color) is
   begin
      if not Self.Wrapper then
         finalize_QColor (Self.Object);
      end if;
   end Finalize;

   ----------------
   -- Initialize --
   ----------------

   overriding
   procedure Initialize (Self : in out Q_Color) is
      use type Internals.QColor_Access;

   begin
      if Self.Object = null then
         Self.Object := initialize_QColor (Self.Storage'Address);
      end if;
   end Initialize;

   ------------
   -- Create --
   ------------

   function Create
    (R : Qt4.Q_Integer;
     G : Qt4.Q_Integer;
     B : Qt4.Q_Integer;
     A : Qt4.Q_Integer
       := 255)
       return Q_Color
   is
   begin
      return Self : Q_Color
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QColor_int_int_int_int (Self.Storage'Address, R, G, B, A);
      end return;
   end Create;

   ------------
   -- Create --
   ------------

   function Create
    (Color : Qt4.Rgbs.Q_Rgb)
       return Q_Color
   is
   begin
      return Self : Q_Color
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QColor_QRgb (Self.Storage'Address, Color);
      end return;
   end Create;

   ------------
   -- Create --
   ------------

   function Create
    (Name : Qt4.Strings.Q_String'Class)
       return Q_Color
   is
   begin
      return Self : Q_Color
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QColor_QStringCR (Self.Storage'Address, Qt4.Strings.Internals.QString_View (Name));
      end return;
   end Create;

   ------------
   -- Create --
   ------------

   function Create
    (Color : Qt4.Global_Color)
       return Q_Color
   is
   begin
      return Self : Q_Color
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QColor_GlobalColor (Self.Storage'Address, Color);
      end return;
   end Create;

   -----------
   -- Alpha --
   -----------

   function Alpha
    (Self : Q_Color'Class)
       return Qt4.Q_Integer
   is
   begin
      return QColor_alpha (Self.Object);
   end Alpha;

   -------------
   -- Alpha_F --
   -------------

   function Alpha_F
    (Self : Q_Color'Class)
       return Qt4.Q_Real
   is
   begin
      return QColor_alphaF (Self.Object);
   end Alpha_F;

   -----------
   -- Black --
   -----------

   function Black
    (Self : Q_Color'Class)
       return Qt4.Q_Integer
   is
   begin
      return QColor_black (Self.Object);
   end Black;

   -------------
   -- Black_F --
   -------------

   function Black_F
    (Self : Q_Color'Class)
       return Qt4.Q_Real
   is
   begin
      return QColor_blackF (Self.Object);
   end Black_F;

   ----------
   -- Blue --
   ----------

   function Blue
    (Self : Q_Color'Class)
       return Qt4.Q_Integer
   is
   begin
      return QColor_blue (Self.Object);
   end Blue;

   ------------
   -- Blue_F --
   ------------

   function Blue_F
    (Self : Q_Color'Class)
       return Qt4.Q_Real
   is
   begin
      return QColor_blueF (Self.Object);
   end Blue_F;

   ----------------
   -- Convert_To --
   ----------------

   function Convert_To
    (Self : Q_Color'Class;
     Spec : Color_Spec)
       return Q_Color
   is
   begin
      return Returns : Q_Color do
         QColor_convertTo_Spec (Returns.Object, Self.Object, Spec);
      end return;
   end Convert_To;

   ----------
   -- Cyan --
   ----------

   function Cyan
    (Self : Q_Color'Class)
       return Qt4.Q_Integer
   is
   begin
      return QColor_cyan (Self.Object);
   end Cyan;

   ------------
   -- Cyan_F --
   ------------

   function Cyan_F
    (Self : Q_Color'Class)
       return Qt4.Q_Real
   is
   begin
      return QColor_cyanF (Self.Object);
   end Cyan_F;

   ------------
   -- Darker --
   ------------

   function Darker
    (Self : Q_Color'Class;
     F : Qt4.Q_Integer
       := 200)
       return Q_Color
   is
   begin
      return Returns : Q_Color do
         QColor_darker_int (Returns.Object, Self.Object, F);
      end return;
   end Darker;

   -----------
   -- Green --
   -----------

   function Green
    (Self : Q_Color'Class)
       return Qt4.Q_Integer
   is
   begin
      return QColor_green (Self.Object);
   end Green;

   -------------
   -- Green_F --
   -------------

   function Green_F
    (Self : Q_Color'Class)
       return Qt4.Q_Real
   is
   begin
      return QColor_greenF (Self.Object);
   end Green_F;

   ---------
   -- Hue --
   ---------

   function Hue
    (Self : Q_Color'Class)
       return Qt4.Q_Integer
   is
   begin
      return QColor_hue (Self.Object);
   end Hue;

   -----------
   -- Hue_F --
   -----------

   function Hue_F
    (Self : Q_Color'Class)
       return Qt4.Q_Real
   is
   begin
      return QColor_hueF (Self.Object);
   end Hue_F;

   --------------
   -- Is_Valid --
   --------------

   function Is_Valid
    (Self : Q_Color'Class)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QColor_isValid (Self.Object), 0);
   end Is_Valid;

   -------------
   -- Lighter --
   -------------

   function Lighter
    (Self : Q_Color'Class;
     F : Qt4.Q_Integer
       := 150)
       return Q_Color
   is
   begin
      return Returns : Q_Color do
         QColor_lighter_int (Returns.Object, Self.Object, F);
      end return;
   end Lighter;

   -------------
   -- Magenta --
   -------------

   function Magenta
    (Self : Q_Color'Class)
       return Qt4.Q_Integer
   is
   begin
      return QColor_magenta (Self.Object);
   end Magenta;

   ---------------
   -- Magenta_F --
   ---------------

   function Magenta_F
    (Self : Q_Color'Class)
       return Qt4.Q_Real
   is
   begin
      return QColor_magentaF (Self.Object);
   end Magenta_F;

   ----------
   -- Name --
   ----------

   function Name
    (Self : Q_Color'Class)
       return Qt4.Strings.Q_String
   is
   begin
      return Returns : Qt4.Strings.Q_String do
         QColor_name (Qt4.Strings.Internals.QString_View (Returns), Self.Object);
      end return;
   end Name;

   ---------
   -- Red --
   ---------

   function Red
    (Self : Q_Color'Class)
       return Qt4.Q_Integer
   is
   begin
      return QColor_red (Self.Object);
   end Red;

   -----------
   -- Red_F --
   -----------

   function Red_F
    (Self : Q_Color'Class)
       return Qt4.Q_Real
   is
   begin
      return QColor_redF (Self.Object);
   end Red_F;

   ---------
   -- Rgb --
   ---------

   function Rgb
    (Self : Q_Color'Class)
       return Qt4.Rgbs.Q_Rgb
   is
   begin
      return QColor_rgb (Self.Object);
   end Rgb;

   ----------
   -- Rgba --
   ----------

   function Rgba
    (Self : Q_Color'Class)
       return Qt4.Rgbs.Q_Rgb
   is
   begin
      return QColor_rgba (Self.Object);
   end Rgba;

   ----------------
   -- Saturation --
   ----------------

   function Saturation
    (Self : Q_Color'Class)
       return Qt4.Q_Integer
   is
   begin
      return QColor_saturation (Self.Object);
   end Saturation;

   ------------------
   -- Saturation_F --
   ------------------

   function Saturation_F
    (Self : Q_Color'Class)
       return Qt4.Q_Real
   is
   begin
      return QColor_saturationF (Self.Object);
   end Saturation_F;

   ---------------
   -- Set_Alpha --
   ---------------

   procedure Set_Alpha
    (Self : in out Q_Color'Class;
     Alpha : Qt4.Q_Integer)
   is
   begin
      QColor_setAlpha_int (Self.Object, Alpha);
   end Set_Alpha;

   -----------------
   -- Set_Alpha_F --
   -----------------

   procedure Set_Alpha_F
    (Self : in out Q_Color'Class;
     Alpha : Qt4.Q_Real)
   is
   begin
      QColor_setAlphaF_qreal (Self.Object, Alpha);
   end Set_Alpha_F;

   --------------
   -- Set_Blue --
   --------------

   procedure Set_Blue
    (Self : in out Q_Color'Class;
     Blue : Qt4.Q_Integer)
   is
   begin
      QColor_setBlue_int (Self.Object, Blue);
   end Set_Blue;

   ----------------
   -- Set_Blue_F --
   ----------------

   procedure Set_Blue_F
    (Self : in out Q_Color'Class;
     Blue : Qt4.Q_Real)
   is
   begin
      QColor_setBlueF_qreal (Self.Object, Blue);
   end Set_Blue_F;

   --------------
   -- Set_Cmyk --
   --------------

   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)
   is
   begin
      QColor_setCmyk_int_int_int_int_int (Self.Object, C, M, Y, K, A);
   end Set_Cmyk;

   ----------------
   -- Set_Cmyk_F --
   ----------------

   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)
   is
   begin
      QColor_setCmykF_qreal_qreal_qreal_qreal_qreal (Self.Object, C, M, Y, K, A);
   end Set_Cmyk_F;

   ---------------
   -- Set_Green --
   ---------------

   procedure Set_Green
    (Self : in out Q_Color'Class;
     Green : Qt4.Q_Integer)
   is
   begin
      QColor_setGreen_int (Self.Object, Green);
   end Set_Green;

   -----------------
   -- Set_Green_F --
   -----------------

   procedure Set_Green_F
    (Self : in out Q_Color'Class;
     Green : Qt4.Q_Real)
   is
   begin
      QColor_setGreenF_qreal (Self.Object, Green);
   end Set_Green_F;

   -------------
   -- Set_Hsv --
   -------------

   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)
   is
   begin
      QColor_setHsv_int_int_int_int (Self.Object, H, S, V, A);
   end Set_Hsv;

   ---------------
   -- Set_Hsv_F --
   ---------------

   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)
   is
   begin
      QColor_setHsvF_qreal_qreal_qreal_qreal (Self.Object, H, S, V, A);
   end Set_Hsv_F;

   ---------------------
   -- Set_Named_Color --
   ---------------------

   procedure Set_Named_Color
    (Self : in out Q_Color'Class;
     Name : Qt4.Strings.Q_String'Class)
   is
   begin
      QColor_setNamedColor_QStringCR (Self.Object, Qt4.Strings.Internals.QString_View (Name));
   end Set_Named_Color;

   -------------
   -- Set_Red --
   -------------

   procedure Set_Red
    (Self : in out Q_Color'Class;
     Red : Qt4.Q_Integer)
   is
   begin
      QColor_setRed_int (Self.Object, Red);
   end Set_Red;

   ---------------
   -- Set_Red_F --
   ---------------

   procedure Set_Red_F
    (Self : in out Q_Color'Class;
     Red : Qt4.Q_Real)
   is
   begin
      QColor_setRedF_qreal (Self.Object, Red);
   end Set_Red_F;

   -------------
   -- Set_Rgb --
   -------------

   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)
   is
   begin
      QColor_setRgb_int_int_int_int (Self.Object, R, G, B, A);
   end Set_Rgb;

   -------------
   -- Set_Rgb --
   -------------

   procedure Set_Rgb
    (Self : in out Q_Color'Class;
     Rgb : Qt4.Rgbs.Q_Rgb)
   is
   begin
      QColor_setRgb_QRgb (Self.Object, Rgb);
   end Set_Rgb;

   ---------------
   -- Set_Rgb_F --
   ---------------

   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)
   is
   begin
      QColor_setRgbF_qreal_qreal_qreal_qreal (Self.Object, R, G, B, A);
   end Set_Rgb_F;

   --------------
   -- Set_Rgba --
   --------------

   procedure Set_Rgba
    (Self : in out Q_Color'Class;
     Rgba : Qt4.Rgbs.Q_Rgb)
   is
   begin
      QColor_setRgba_QRgb (Self.Object, Rgba);
   end Set_Rgba;

   ----------
   -- Spec --
   ----------

   function Spec
    (Self : Q_Color'Class)
       return Color_Spec
   is
   begin
      return QColor_spec (Self.Object);
   end Spec;

   -------------
   -- To_Cmyk --
   -------------

   function To_Cmyk
    (Self : Q_Color'Class)
       return Q_Color
   is
   begin
      return Returns : Q_Color do
         QColor_toCmyk (Returns.Object, Self.Object);
      end return;
   end To_Cmyk;

   ------------
   -- To_Hsv --
   ------------

   function To_Hsv
    (Self : Q_Color'Class)
       return Q_Color
   is
   begin
      return Returns : Q_Color do
         QColor_toHsv (Returns.Object, Self.Object);
      end return;
   end To_Hsv;

   ------------
   -- To_Rgb --
   ------------

   function To_Rgb
    (Self : Q_Color'Class)
       return Q_Color
   is
   begin
      return Returns : Q_Color do
         QColor_toRgb (Returns.Object, Self.Object);
      end return;
   end To_Rgb;

   -----------
   -- Value --
   -----------

   function Value
    (Self : Q_Color'Class)
       return Qt4.Q_Integer
   is
   begin
      return QColor_value (Self.Object);
   end Value;

   -------------
   -- Value_F --
   -------------

   function Value_F
    (Self : Q_Color'Class)
       return Qt4.Q_Real
   is
   begin
      return QColor_valueF (Self.Object);
   end Value_F;

   ------------
   -- Yellow --
   ------------

   function Yellow
    (Self : Q_Color'Class)
       return Qt4.Q_Integer
   is
   begin
      return QColor_yellow (Self.Object);
   end Yellow;

   --------------
   -- Yellow_F --
   --------------

   function Yellow_F
    (Self : Q_Color'Class)
       return Qt4.Q_Real
   is
   begin
      return QColor_yellowF (Self.Object);
   end Yellow_F;

   ---------
   -- "=" --
   ---------

   overriding
   function "="
    (Self : Q_Color;
     Color : Q_Color)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (eq_QColorCR (Self.Object, Color.Object), 0);
   end "=";

   ---------------
   -- From_Cmyk --
   ---------------

   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
   is
   begin
      return Returns : Q_Color do
         QColor_fromCmyk_int_int_int_int_int (Returns.Object, C, M, Y, K, A);
      end return;
   end From_Cmyk;

   -----------------
   -- From_Cmyk_F --
   -----------------

   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
   is
   begin
      return Returns : Q_Color do
         QColor_fromCmykF_qreal_qreal_qreal_qreal_qreal (Returns.Object, C, M, Y, K, A);
      end return;
   end From_Cmyk_F;

   --------------
   -- From_Hsv --
   --------------

   function From_Hsv
    (H : Qt4.Q_Integer;
     S : Qt4.Q_Integer;
     V : Qt4.Q_Integer;
     A : Qt4.Q_Integer
       := 255)
       return Q_Color
   is
   begin
      return Returns : Q_Color do
         QColor_fromHsv_int_int_int_int (Returns.Object, H, S, V, A);
      end return;
   end From_Hsv;

   ----------------
   -- From_Hsv_F --
   ----------------

   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
   is
   begin
      return Returns : Q_Color do
         QColor_fromHsvF_qreal_qreal_qreal_qreal (Returns.Object, H, S, V, A);
      end return;
   end From_Hsv_F;

   --------------
   -- From_Rgb --
   --------------

   function From_Rgb
    (Rgb : Qt4.Rgbs.Q_Rgb)
       return Q_Color
   is
   begin
      return Returns : Q_Color do
         QColor_fromRgb_QRgb (Returns.Object, Rgb);
      end return;
   end From_Rgb;

   --------------
   -- From_Rgb --
   --------------

   function From_Rgb
    (R : Qt4.Q_Integer;
     G : Qt4.Q_Integer;
     B : Qt4.Q_Integer;
     A : Qt4.Q_Integer
       := 255)
       return Q_Color
   is
   begin
      return Returns : Q_Color do
         QColor_fromRgb_int_int_int_int (Returns.Object, R, G, B, A);
      end return;
   end From_Rgb;

   ----------------
   -- From_Rgb_F --
   ----------------

   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
   is
   begin
      return Returns : Q_Color do
         QColor_fromRgbF_qreal_qreal_qreal_qreal (Returns.Object, R, G, B, A);
      end return;
   end From_Rgb_F;

   ---------------
   -- From_Rgba --
   ---------------

   function From_Rgba
    (Rgba : Qt4.Rgbs.Q_Rgb)
       return Q_Color
   is
   begin
      return Returns : Q_Color do
         QColor_fromRgba_QRgb (Returns.Object, Rgba);
      end return;
   end From_Rgba;

   ---------------
   -- Internals --
   ---------------

   package body Internals is

   -----------------
   -- QColor_View --
   -----------------

      function QColor_View
       (Item : Q_Color'Class)
          return QColor_Access
      is
      begin
         return Item.Object;
      end QColor_View;

      package QColor_Conversions is
        new System.Address_To_Access_Conversions
             (QColor);

   ----------------------
   -- QColorTo_Pointer --
   ----------------------

      function To_Pointer
       (Address : System.Address)
          return QColor_Access
      is
      begin
         return
           QColor_Access
            (QColor_Conversions.To_Pointer
            (Address));
      end To_Pointer;

   ----------------------
   -- QColorTo_Address --
   ----------------------

      function To_Address
       (Pointer : QColor_Access)
          return System.Address
      is
      begin
         return
           QColor_Conversions.To_Address
            (QColor_Conversions.Object_Pointer
              (Pointer));
      end To_Address;

   --------------------
   -- Create_Wrapper --
   --------------------

      function Create_Wrapper
       (Item : Internals.QColor_Access)
          return Q_Color
      is
      begin
         return Q_Color'
          (Ada.Finalization.Controlled with
             Object  => Item,
             Wrapper => True,
             others  => <>);
      end Create_Wrapper;

   end Internals;

end Qt4.Colors;
