------------------------------------------------------------------------------
--                                                                          --
--                An Ada2005 binding to the Qt C++ framework                --
--                                                                          --
------------------------------------------------------------------------------
--                                                                          --
-- Copyright © 2007-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.     --
------------------------------------------------------------------------------
pragma Style_Checks ("NM32766");
with Qt_Ada.Internals.Boolean_Conversions;
with System.Address_To_Access_Conversions;

package body Qt4.Polygons is

   function initialize_QPolygon
    (Storage : System.Address)
      return Internals.QPolygon_Access;
   pragma Import (C, initialize_QPolygon, "__QtAda_inititialize_QPolygon");

   function initialize_QPolygon_int
    (Storage : System.Address;
     Size : Qt4.Q_Integer)
      return Internals.QPolygon_Access;
   pragma Import (C, initialize_QPolygon_int, "__QtAda_inititialize_QPolygon_int");

   function initialize_QPolygon_QRectCR_bool
    (Storage : System.Address;
     R : Qt4.Rects.Internals.QRect_Access;
     Closed : Interfaces.C.unsigned)
      return Internals.QPolygon_Access;
   pragma Import (C, initialize_QPolygon_QRectCR_bool, "__QtAda_inititialize_QPolygon_QRectCR_bool");

   function adjust_QPolygon
    (Storage : System.Address;
     From    : Internals.QPolygon_Access)
       return Internals.QPolygon_Access;
   pragma Import (C, adjust_QPolygon, "__QtAda_adjust_QPolygon");

   procedure finalize_QPolygon (Object : Internals.QPolygon_Access);
   pragma Import (C, finalize_QPolygon, "__QtAda_finalize_QPolygon");

   procedure QPolygon_boundingRect
    (Returns : Qt4.Rects.Internals.QRect_Access;
     Self : Internals.QPolygon_Access);
   pragma Import (C, QPolygon_boundingRect, "__QtAda_QPolygon_boundingRect_Q");

   function QPolygon_containsPoint_QPointCR_FillRule
    (Self : Internals.QPolygon_Access;
     Pt : Qt4.Points.Internals.QPoint_Access;
     Fill_Rule : Qt4.Fill_Rule)
       return Interfaces.C.unsigned;
   pragma Import (C, QPolygon_containsPoint_QPointCR_FillRule, "__QtAda_QPolygon_containsPoint_QPointCR_FillRule_Q");

   procedure QPolygon_intersected_QPolygonCR
    (Returns : Internals.QPolygon_Access;
     Self : Internals.QPolygon_Access;
     R : Internals.QPolygon_Access);
   pragma Import (C, QPolygon_intersected_QPolygonCR, "__QtAda_QPolygon_intersected_QPolygonCR_Q");

   procedure QPolygon_point_int_intP_intP
    (Self : Internals.QPolygon_Access;
     I : Qt4.Q_Integer;
     X : out Qt4.Q_Integer;
     Y : out Qt4.Q_Integer);
   pragma Import (C, QPolygon_point_int_intP_intP, "__QtAda_QPolygon_point_int_intP_intP_Q");

   procedure QPolygon_point_int
    (Returns : Qt4.Points.Internals.QPoint_Access;
     Self : Internals.QPolygon_Access;
     I : Qt4.Q_Integer);
   pragma Import (C, QPolygon_point_int, "__QtAda_QPolygon_point_int_Q");

   procedure QPolygon_putPoints_int_int_QPolygonCR_int
    (Self : Internals.QPolygon_Access;
     Index : Qt4.Q_Integer;
     N_Points : Qt4.Q_Integer;
     From : Internals.QPolygon_Access;
     From_Index : Qt4.Q_Integer);
   pragma Import (C, QPolygon_putPoints_int_int_QPolygonCR_int, "__QtAda_QPolygon_putPoints_int_int_QPolygonCR_int");

   procedure QPolygon_setPoint_int_int_int
    (Self : Internals.QPolygon_Access;
     Index : Qt4.Q_Integer;
     X : Qt4.Q_Integer;
     Y : Qt4.Q_Integer);
   pragma Import (C, QPolygon_setPoint_int_int_int, "__QtAda_QPolygon_setPoint_int_int_int");

   procedure QPolygon_setPoint_int_QPointCR
    (Self : Internals.QPolygon_Access;
     Index : Qt4.Q_Integer;
     P : Qt4.Points.Internals.QPoint_Access);
   pragma Import (C, QPolygon_setPoint_int_QPointCR, "__QtAda_QPolygon_setPoint_int_QPointCR");

   procedure QPolygon_subtracted_QPolygonCR
    (Returns : Internals.QPolygon_Access;
     Self : Internals.QPolygon_Access;
     R : Internals.QPolygon_Access);
   pragma Import (C, QPolygon_subtracted_QPolygonCR, "__QtAda_QPolygon_subtracted_QPolygonCR_Q");

   procedure QPolygon_translate_int_int
    (Self : Internals.QPolygon_Access;
     Dx : Qt4.Q_Integer;
     Dy : Qt4.Q_Integer);
   pragma Import (C, QPolygon_translate_int_int, "__QtAda_QPolygon_translate_int_int");

   procedure QPolygon_translate_QPointCR
    (Self : Internals.QPolygon_Access;
     Offset : Qt4.Points.Internals.QPoint_Access);
   pragma Import (C, QPolygon_translate_QPointCR, "__QtAda_QPolygon_translate_QPointCR");

   procedure QPolygon_united_QPolygonCR
    (Returns : Internals.QPolygon_Access;
     Self : Internals.QPolygon_Access;
     R : Internals.QPolygon_Access);
   pragma Import (C, QPolygon_united_QPolygonCR, "__QtAda_QPolygon_united_QPolygonCR_Q");

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

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

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

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

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

   overriding
   procedure Initialize (Self : in out Q_Polygon) is
      use type Internals.QPolygon_Access;

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

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

   function Create
    (Size : Qt4.Q_Integer)
       return Q_Polygon
   is
   begin
      return Self : Q_Polygon
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QPolygon_int (Self.Storage'Address, Size);
      end return;
   end Create;

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

   function Create
    (R : Qt4.Rects.Q_Rect'Class;
     Closed : Boolean
       := False)
       return Q_Polygon
   is
   begin
      return Self : Q_Polygon
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QPolygon_QRectCR_bool (Self.Storage'Address, Qt4.Rects.Internals.QRect_View (R), Qt_Ada.Internals.Boolean_Conversions.To_unsigned (Closed));
      end return;
   end Create;

   -------------------
   -- Bounding_Rect --
   -------------------

   function Bounding_Rect
    (Self : Q_Polygon'Class)
       return Qt4.Rects.Q_Rect
   is
   begin
      return Returns : Qt4.Rects.Q_Rect do
         QPolygon_boundingRect (Qt4.Rects.Internals.QRect_View (Returns), Self.Object);
      end return;
   end Bounding_Rect;

   --------------------
   -- Contains_Point --
   --------------------

   function Contains_Point
    (Self : Q_Polygon'Class;
     Pt : Qt4.Points.Q_Point'Class;
     Fill_Rule : Qt4.Fill_Rule)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QPolygon_containsPoint_QPointCR_FillRule (Self.Object, Qt4.Points.Internals.QPoint_View (Pt), Fill_Rule), 0);
   end Contains_Point;

   -----------------
   -- Intersected --
   -----------------

   function Intersected
    (Self : Q_Polygon'Class;
     R : Q_Polygon'Class)
       return Q_Polygon
   is
   begin
      return Returns : Q_Polygon do
         QPolygon_intersected_QPolygonCR (Returns.Object, Self.Object, R.Object);
      end return;
   end Intersected;

   -----------
   -- Point --
   -----------

   procedure Point
    (Self : Q_Polygon'Class;
     I : Qt4.Q_Integer;
     X : out Qt4.Q_Integer;
     Y : out Qt4.Q_Integer)
   is
   begin
      QPolygon_point_int_intP_intP (Self.Object, I, X, Y);
   end Point;

   -----------
   -- Point --
   -----------

   function Point
    (Self : Q_Polygon'Class;
     I : Qt4.Q_Integer)
       return Qt4.Points.Q_Point
   is
   begin
      return Returns : Qt4.Points.Q_Point do
         QPolygon_point_int (Qt4.Points.Internals.QPoint_View (Returns), Self.Object, I);
      end return;
   end Point;

   ----------------
   -- Put_Points --
   ----------------

   procedure Put_Points
    (Self : in out Q_Polygon'Class;
     Index : Qt4.Q_Integer;
     N_Points : Qt4.Q_Integer;
     From : Q_Polygon'Class;
     From_Index : Qt4.Q_Integer
       := 0)
   is
   begin
      QPolygon_putPoints_int_int_QPolygonCR_int (Self.Object, Index, N_Points, From.Object, From_Index);
   end Put_Points;

   ---------------
   -- Set_Point --
   ---------------

   procedure Set_Point
    (Self : in out Q_Polygon'Class;
     Index : Qt4.Q_Integer;
     X : Qt4.Q_Integer;
     Y : Qt4.Q_Integer)
   is
   begin
      QPolygon_setPoint_int_int_int (Self.Object, Index, X, Y);
   end Set_Point;

   ---------------
   -- Set_Point --
   ---------------

   procedure Set_Point
    (Self : in out Q_Polygon'Class;
     Index : Qt4.Q_Integer;
     P : Qt4.Points.Q_Point'Class)
   is
   begin
      QPolygon_setPoint_int_QPointCR (Self.Object, Index, Qt4.Points.Internals.QPoint_View (P));
   end Set_Point;

   ----------------
   -- Subtracted --
   ----------------

   function Subtracted
    (Self : Q_Polygon'Class;
     R : Q_Polygon'Class)
       return Q_Polygon
   is
   begin
      return Returns : Q_Polygon do
         QPolygon_subtracted_QPolygonCR (Returns.Object, Self.Object, R.Object);
      end return;
   end Subtracted;

   ---------------
   -- Translate --
   ---------------

   procedure Translate
    (Self : in out Q_Polygon'Class;
     Dx : Qt4.Q_Integer;
     Dy : Qt4.Q_Integer)
   is
   begin
      QPolygon_translate_int_int (Self.Object, Dx, Dy);
   end Translate;

   ---------------
   -- Translate --
   ---------------

   procedure Translate
    (Self : in out Q_Polygon'Class;
     Offset : Qt4.Points.Q_Point'Class)
   is
   begin
      QPolygon_translate_QPointCR (Self.Object, Qt4.Points.Internals.QPoint_View (Offset));
   end Translate;

   ------------
   -- United --
   ------------

   function United
    (Self : Q_Polygon'Class;
     R : Q_Polygon'Class)
       return Q_Polygon
   is
   begin
      return Returns : Q_Polygon do
         QPolygon_united_QPolygonCR (Returns.Object, Self.Object, R.Object);
      end return;
   end United;

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

   package body Internals is

   -------------------
   -- QPolygon_View --
   -------------------

      function QPolygon_View
       (Item : Q_Polygon'Class)
          return QPolygon_Access
      is
      begin
         return Item.Object;
      end QPolygon_View;

      package QPolygon_Conversions is
        new System.Address_To_Access_Conversions
             (QPolygon);

   ------------------------
   -- QPolygonTo_Pointer --
   ------------------------

      function To_Pointer
       (Address : System.Address)
          return QPolygon_Access
      is
      begin
         return
           QPolygon_Access
            (QPolygon_Conversions.To_Pointer
            (Address));
      end To_Pointer;

   ------------------------
   -- QPolygonTo_Address --
   ------------------------

      function To_Address
       (Pointer : QPolygon_Access)
          return System.Address
      is
      begin
         return
           QPolygon_Conversions.To_Address
            (QPolygon_Conversions.Object_Pointer
              (Pointer));
      end To_Address;

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

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

   end Internals;

end Qt4.Polygons;
