------------------------------------------------------------------------------
--                                                                          --
--                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.                                      --
--                                                                          --
------------------------------------------------------------------------------
--    This file has been generated automatically. Please don't edit it.     --
------------------------------------------------------------------------------
with Qt4.Gradients;
with System.Address_To_Access_Conversions;

package body Qt4.Brushes is

   function initialize_QBrush
    (Storage : System.Address)
      return Internals.QBrush_Access;
   pragma Import (C, initialize_QBrush, "__QtAda_inititialize_QBrush");

   function initialize_QBrush_BrushStyle
    (Storage : System.Address;
     Bs : Qt4.Brush_Style)
      return Internals.QBrush_Access;
   pragma Import (C, initialize_QBrush_BrushStyle, "__QtAda_inititialize_QBrush_BrushStyle");

   function initialize_QBrush_QColorCR_BrushStyle
    (Storage : System.Address;
     Color : Qt4.Colors.Internals.QColor_Access;
     Bs : Qt4.Brush_Style)
      return Internals.QBrush_Access;
   pragma Import (C, initialize_QBrush_QColorCR_BrushStyle, "__QtAda_inititialize_QBrush_QColorCR_BrushStyle");

   function initialize_QBrush_GlobalColor_BrushStyle
    (Storage : System.Address;
     Color : Qt4.Global_Color;
     Bs : Qt4.Brush_Style)
      return Internals.QBrush_Access;
   pragma Import (C, initialize_QBrush_GlobalColor_BrushStyle, "__QtAda_inititialize_QBrush_GlobalColor_BrushStyle");

   function initialize_QBrush_QColorCR_QPixmapCR
    (Storage : System.Address;
     Color : Qt4.Colors.Internals.QColor_Access;
     Pixmap : Qt4.Pixmaps.Internals.QPixmap_Access)
      return Internals.QBrush_Access;
   pragma Import (C, initialize_QBrush_QColorCR_QPixmapCR, "__QtAda_inititialize_QBrush_QColorCR_QPixmapCR");

   function initialize_QBrush_GlobalColor_QPixmapCR
    (Storage : System.Address;
     Color : Qt4.Global_Color;
     Pixmap : Qt4.Pixmaps.Internals.QPixmap_Access)
      return Internals.QBrush_Access;
   pragma Import (C, initialize_QBrush_GlobalColor_QPixmapCR, "__QtAda_inititialize_QBrush_GlobalColor_QPixmapCR");

   function initialize_QBrush_QPixmapCR
    (Storage : System.Address;
     Pixmap : Qt4.Pixmaps.Internals.QPixmap_Access)
      return Internals.QBrush_Access;
   pragma Import (C, initialize_QBrush_QPixmapCR, "__QtAda_inititialize_QBrush_QPixmapCR");

   function initialize_QBrush_QGradientCR
    (Storage : System.Address;
     Gradient : Qt4.Gradients.Internals.QGradient_Access)
      return Internals.QBrush_Access;
   pragma Import (C, initialize_QBrush_QGradientCR, "__QtAda_inititialize_QBrush_QGradientCR");

   function adjust_QBrush
    (Storage : System.Address;
     From    : Internals.QBrush_Access)
       return Internals.QBrush_Access;
   pragma Import (C, adjust_QBrush, "__QtAda_adjust_QBrush");

   procedure finalize_QBrush (Object : Internals.QBrush_Access);
   pragma Import (C, finalize_QBrush, "__QtAda_finalize_QBrush");

   procedure QBrush_color
    (Returns : Qt4.Colors.Internals.QColor_Access;
     Self : Internals.QBrush_Access);
   pragma Import (C, QBrush_color, "__QtAda_QBrush_color_Q");

   function QBrush_isDetached
    (Self : Internals.QBrush_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QBrush_isDetached, "__QtAda_QBrush_isDetached_Q");

   function QBrush_isOpaque
    (Self : Internals.QBrush_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QBrush_isOpaque, "__QtAda_QBrush_isOpaque_Q");

   procedure QBrush_matrix
    (Returns : Qt4.Matrices.Internals.QMatrix_Access;
     Self : Internals.QBrush_Access);
   pragma Import (C, QBrush_matrix, "__QtAda_QBrush_matrix_Q");

   procedure QBrush_setColor_QColorCR
    (Self : Internals.QBrush_Access;
     Color : Qt4.Colors.Internals.QColor_Access);
   pragma Import (C, QBrush_setColor_QColorCR, "__QtAda_QBrush_setColor_QColorCR");

   procedure QBrush_setColor_GlobalColor
    (Self : Internals.QBrush_Access;
     Color : Qt4.Global_Color);
   pragma Import (C, QBrush_setColor_GlobalColor, "__QtAda_QBrush_setColor_GlobalColor");

   procedure QBrush_setMatrix_QMatrixCR
    (Self : Internals.QBrush_Access;
     Mat : Qt4.Matrices.Internals.QMatrix_Access);
   pragma Import (C, QBrush_setMatrix_QMatrixCR, "__QtAda_QBrush_setMatrix_QMatrixCR");

   procedure QBrush_setStyle_BrushStyle
    (Self : Internals.QBrush_Access;
     Style : Qt4.Brush_Style);
   pragma Import (C, QBrush_setStyle_BrushStyle, "__QtAda_QBrush_setStyle_BrushStyle");

   procedure QBrush_setTexture_QPixmapCR
    (Self : Internals.QBrush_Access;
     Pixmap : Qt4.Pixmaps.Internals.QPixmap_Access);
   pragma Import (C, QBrush_setTexture_QPixmapCR, "__QtAda_QBrush_setTexture_QPixmapCR");

   procedure QBrush_setTransform_QTransformCR
    (Self : Internals.QBrush_Access;
     T : Qt4.Transforms.Internals.QTransform_Access);
   pragma Import (C, QBrush_setTransform_QTransformCR, "__QtAda_QBrush_setTransform_QTransformCR");

   function QBrush_style
    (Self : Internals.QBrush_Access)
       return Qt4.Brush_Style;
   pragma Import (C, QBrush_style, "__QtAda_QBrush_style_Q");

   procedure QBrush_texture
    (Returns : Qt4.Pixmaps.Internals.QPixmap_Access;
     Self : Internals.QBrush_Access);
   pragma Import (C, QBrush_texture, "__QtAda_QBrush_texture_Q");

   procedure QBrush_transform
    (Returns : Qt4.Transforms.Internals.QTransform_Access;
     Self : Internals.QBrush_Access);
   pragma Import (C, QBrush_transform, "__QtAda_QBrush_transform_Q");

   function eq_QBrushCR
    (Self : Internals.QBrush_Access;
     B : Internals.QBrush_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, eq_QBrushCR, "__QtAda_QBrush_eq_QBrushCR_Q");

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

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

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

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

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

   overriding
   procedure Initialize (Self : in out Q_Brush) is
      use type Internals.QBrush_Access;

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

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

   function Create return Q_Brush is
   begin
      return Self : Q_Brush
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QBrush (Self.Storage'Address);
      end return;
   end Create;

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

   function Create
    (Bs : Qt4.Brush_Style)
       return Q_Brush
   is
   begin
      return Self : Q_Brush
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QBrush_BrushStyle (Self.Storage'Address, Bs);
      end return;
   end Create;

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

   function Create
    (Color : Qt4.Colors.Q_Color'Class;
     Bs : Qt4.Brush_Style
       := Solid_Pattern)
       return Q_Brush
   is
   begin
      return Self : Q_Brush
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QBrush_QColorCR_BrushStyle (Self.Storage'Address, Qt4.Colors.Internals.QColor_View (Color), Bs);
      end return;
   end Create;

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

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

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

   function Create
    (Color : Qt4.Colors.Q_Color'Class;
     Pixmap : Qt4.Pixmaps.Q_Pixmap'Class)
       return Q_Brush
   is
   begin
      return Self : Q_Brush
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QBrush_QColorCR_QPixmapCR (Self.Storage'Address, Qt4.Colors.Internals.QColor_View (Color), Qt4.Pixmaps.Internals.QPixmap_View (Pixmap));
      end return;
   end Create;

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

   function Create
    (Color : Qt4.Global_Color;
     Pixmap : Qt4.Pixmaps.Q_Pixmap'Class)
       return Q_Brush
   is
   begin
      return Self : Q_Brush
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QBrush_GlobalColor_QPixmapCR (Self.Storage'Address, Color, Qt4.Pixmaps.Internals.QPixmap_View (Pixmap));
      end return;
   end Create;

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

   function Create
    (Pixmap : Qt4.Pixmaps.Q_Pixmap'Class)
       return Q_Brush
   is
   begin
      return Self : Q_Brush
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QBrush_QPixmapCR (Self.Storage'Address, Qt4.Pixmaps.Internals.QPixmap_View (Pixmap));
      end return;
   end Create;

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

   function Create
    (Gradient : Qt4.Gradients.Q_Gradient'Class)
       return Q_Brush
   is
   begin
      return Self : Q_Brush
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QBrush_QGradientCR (Self.Storage'Address, Qt4.Gradients.Internals.QGradient_View (Gradient));
      end return;
   end Create;

   -----------
   -- Color --
   -----------

   function Color
    (Self : Q_Brush'Class)
       return Qt4.Colors.Q_Color
   is
   begin
      return Returns : Qt4.Colors.Q_Color do
         QBrush_color (Qt4.Colors.Internals.QColor_View (Returns), Self.Object);
      end return;
   end Color;

   -----------------
   -- Is_Detached --
   -----------------

   function Is_Detached
    (Self : Q_Brush'Class)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QBrush_isDetached (Self.Object), 0);
   end Is_Detached;

   ---------------
   -- Is_Opaque --
   ---------------

   function Is_Opaque
    (Self : Q_Brush'Class)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QBrush_isOpaque (Self.Object), 0);
   end Is_Opaque;

   ------------
   -- Matrix --
   ------------

   function Matrix
    (Self : Q_Brush'Class)
       return Qt4.Matrices.Q_Matrix
   is
   begin
      return Returns : Qt4.Matrices.Q_Matrix do
         QBrush_matrix (Qt4.Matrices.Internals.QMatrix_View (Returns), Self.Object);
      end return;
   end Matrix;

   ---------------
   -- Set_Color --
   ---------------

   procedure Set_Color
    (Self : in out Q_Brush'Class;
     Color : Qt4.Colors.Q_Color'Class)
   is
   begin
      QBrush_setColor_QColorCR (Self.Object, Qt4.Colors.Internals.QColor_View (Color));
   end Set_Color;

   ---------------
   -- Set_Color --
   ---------------

   procedure Set_Color
    (Self : in out Q_Brush'Class;
     Color : Qt4.Global_Color)
   is
   begin
      QBrush_setColor_GlobalColor (Self.Object, Color);
   end Set_Color;

   ----------------
   -- Set_Matrix --
   ----------------

   procedure Set_Matrix
    (Self : in out Q_Brush'Class;
     Mat : Qt4.Matrices.Q_Matrix'Class)
   is
   begin
      QBrush_setMatrix_QMatrixCR (Self.Object, Qt4.Matrices.Internals.QMatrix_View (Mat));
   end Set_Matrix;

   ---------------
   -- Set_Style --
   ---------------

   procedure Set_Style
    (Self : in out Q_Brush'Class;
     Style : Qt4.Brush_Style)
   is
   begin
      QBrush_setStyle_BrushStyle (Self.Object, Style);
   end Set_Style;

   -----------------
   -- Set_Texture --
   -----------------

   procedure Set_Texture
    (Self : in out Q_Brush'Class;
     Pixmap : Qt4.Pixmaps.Q_Pixmap'Class)
   is
   begin
      QBrush_setTexture_QPixmapCR (Self.Object, Qt4.Pixmaps.Internals.QPixmap_View (Pixmap));
   end Set_Texture;

   -------------------
   -- Set_Transform --
   -------------------

   procedure Set_Transform
    (Self : in out Q_Brush'Class;
     T : Qt4.Transforms.Q_Transform'Class)
   is
   begin
      QBrush_setTransform_QTransformCR (Self.Object, Qt4.Transforms.Internals.QTransform_View (T));
   end Set_Transform;

   -----------
   -- Style --
   -----------

   function Style
    (Self : Q_Brush'Class)
       return Qt4.Brush_Style
   is
   begin
      return QBrush_style (Self.Object);
   end Style;

   -------------
   -- Texture --
   -------------

   function Texture
    (Self : Q_Brush'Class)
       return Qt4.Pixmaps.Q_Pixmap
   is
   begin
      return Returns : Qt4.Pixmaps.Q_Pixmap do
         QBrush_texture (Qt4.Pixmaps.Internals.QPixmap_View (Returns), Self.Object);
      end return;
   end Texture;

   ---------------
   -- Transform --
   ---------------

   function Transform
    (Self : Q_Brush'Class)
       return Qt4.Transforms.Q_Transform
   is
   begin
      return Returns : Qt4.Transforms.Q_Transform do
         QBrush_transform (Qt4.Transforms.Internals.QTransform_View (Returns), Self.Object);
      end return;
   end Transform;

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

   overriding function "="
    (Self : Q_Brush;
     B : Q_Brush)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (eq_QBrushCR (Self.Object, B.Object), 0);
   end "=";

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

   package body Internals is

   -----------------
   -- QBrush_View --
   -----------------

      function QBrush_View
       (Item : Q_Brush'Class)
          return QBrush_Access
      is
      begin
         return Item.Object;
      end QBrush_View;

      package QBrush_Conversions is
        new System.Address_To_Access_Conversions
             (QBrush);

   ----------------------
   -- QBrushTo_Pointer --
   ----------------------

      function To_Pointer
       (Address : System.Address)
          return QBrush_Access
      is
      begin
         return
           QBrush_Access
            (QBrush_Conversions.To_Pointer
            (Address));
      end To_Pointer;

   ----------------------
   -- QBrushTo_Address --
   ----------------------

      function To_Address
       (Pointer : QBrush_Access)
          return System.Address
      is
      begin
         return
           QBrush_Conversions.To_Address
            (QBrush_Conversions.Object_Pointer
              (Pointer));
      end To_Address;

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

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

   end Internals;

end Qt4.Brushes;
