------------------------------------------------------------------------------
--                                                                          --
--                An Ada2005 binding to the Qt C++ framework                --
--                                                                          --
------------------------------------------------------------------------------
--                                                                          --
-- Copyright © 2007-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.                                      --
--                                                                          --
------------------------------------------------------------------------------
--    This file has been generated automatically. Please don't edit it.     --
------------------------------------------------------------------------------
pragma Style_Checks ("NM32766");
with System.Address_To_Access_Conversions;

with Qt4_Debug;

package body Qt4.Points is

   procedure Q_Point_Image (Item : Q_Point);
   pragma Export (Ada, Q_Point_Image, "q_point_image");

   function initialize_QPoint
    (Storage : in System.Address)
      return Internals.QPoint_Access;
   pragma Import (C, initialize_QPoint, "__QtAda_inititialize_QPoint");

   function initialize_QPoint_int_int
    (Storage : in System.Address;
     Xpos : in Qt4.Q_Integer;
     Ypos : in Qt4.Q_Integer)
      return Internals.QPoint_Access;
   pragma Import (C, initialize_QPoint_int_int, "__QtAda_inititialize_QPoint_int_int");

   function adjust_QPoint
    (Storage : in System.Address;
     From    : in Internals.QPoint_Access)
       return Internals.QPoint_Access;
   pragma Import (C, adjust_QPoint, "__QtAda_adjust_QPoint");

   procedure finalize_QPoint (Object : in Internals.QPoint_Access);
   pragma Import (C, finalize_QPoint, "__QtAda_finalize_QPoint");

   function QPoint_isNull
    (Self : in Internals.QPoint_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QPoint_isNull, "__QtAda_QPoint_isNull_Q");

   function QPoint_manhattanLength
    (Self : in Internals.QPoint_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QPoint_manhattanLength, "__QtAda_QPoint_manhattanLength_Q");

   procedure QPoint_setX_int
    (Self : in Internals.QPoint_Access;
     X : in Qt4.Q_Integer);
   pragma Import (C, QPoint_setX_int, "__QtAda_QPoint_setX_int");

   procedure QPoint_setY_int
    (Self : in Internals.QPoint_Access;
     Y : in Qt4.Q_Integer);
   pragma Import (C, QPoint_setY_int, "__QtAda_QPoint_setY_int");

   function QPoint_x
    (Self : in Internals.QPoint_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QPoint_x, "__QtAda_QPoint_x_Q");

   function QPoint_y
    (Self : in Internals.QPoint_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QPoint_y, "__QtAda_QPoint_y_Q");

   function eq_QPointCR_QPointCR
    (P_1 : in Internals.QPoint_Access;
     P_2 : in Internals.QPoint_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, eq_QPointCR_QPointCR, "__QtAda_eq_QPointCR_QPointCR");

   procedure plus_QPointCR_QPointCR
    (Returns : in Internals.QPoint_Access;
     P_1 : in Internals.QPoint_Access;
     P_2 : in Internals.QPoint_Access);
   pragma Import (C, plus_QPointCR_QPointCR, "__QtAda_plus_QPointCR_QPointCR");

   procedure minus_QPointCR_QPointCR
    (Returns : in Internals.QPoint_Access;
     P_1 : in Internals.QPoint_Access;
     P_2 : in Internals.QPoint_Access);
   pragma Import (C, minus_QPointCR_QPointCR, "__QtAda_minus_QPointCR_QPointCR");

   procedure multiplication_QPointCR_qreal
    (Returns : in Internals.QPoint_Access;
     P : in Internals.QPoint_Access;
     S : in Qt4.Q_Real);
   pragma Import (C, multiplication_QPointCR_qreal, "__QtAda_multiplication_QPointCR_qreal");

   procedure multiplication_qreal_QPointCR
    (Returns : in Internals.QPoint_Access;
     S : in Qt4.Q_Real;
     P : in Internals.QPoint_Access);
   pragma Import (C, multiplication_qreal_QPointCR, "__QtAda_multiplication_qreal_QPointCR");

   procedure minus_QPointCR
    (Returns : in Internals.QPoint_Access;
     P_1 : in Internals.QPoint_Access);
   pragma Import (C, minus_QPointCR, "__QtAda_minus_QPointCR");

   procedure division_QPointCR_qreal
    (Returns : in Internals.QPoint_Access;
     P : in Internals.QPoint_Access;
     S : in Qt4.Q_Real);
   pragma Import (C, division_QPointCR_qreal, "__QtAda_division_QPointCR_qreal");

   -------------------
   -- Q_Point_Image --
   -------------------

   procedure Q_Point_Image (Item : Q_Point) is
   begin
      Qt4_Debug.Output
       ("(x => "
          & Q_Integer_Image (Item.X)
          & ", y => "
          & Q_Integer_Image (Item.Y)
          & ')');
   end Q_Point_Image;

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

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

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

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

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

   overriding
   procedure Initialize (Self : in out Q_Point) is
      use type Internals.QPoint_Access;

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

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

   function Create
    (Xpos : in Qt4.Q_Integer;
     Ypos : in Qt4.Q_Integer)
       return Q_Point
   is
   begin
      return Self : Q_Point
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QPoint_int_int (Self.Storage'Address, Xpos, Ypos);
      end return;
   end Create;

   -------------
   -- Is_Null --
   -------------

   function Is_Null
    (Self : in Q_Point'Class)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QPoint_isNull (Self.Object), 0);
   end Is_Null;

   ----------------------
   -- Manhattan_Length --
   ----------------------

   function Manhattan_Length
    (Self : in Q_Point'Class)
       return Qt4.Q_Integer
   is
   begin
      return QPoint_manhattanLength (Self.Object);
   end Manhattan_Length;

   -----------
   -- Set_X --
   -----------

   procedure Set_X
    (Self : in out Q_Point'Class;
     X : in Qt4.Q_Integer)
   is
   begin
      QPoint_setX_int (Self.Object, X);
   end Set_X;

   -----------
   -- Set_Y --
   -----------

   procedure Set_Y
    (Self : in out Q_Point'Class;
     Y : in Qt4.Q_Integer)
   is
   begin
      QPoint_setY_int (Self.Object, Y);
   end Set_Y;

   -------
   -- X --
   -------

   function X
    (Self : in Q_Point'Class)
       return Qt4.Q_Integer
   is
   begin
      return QPoint_x (Self.Object);
   end X;

   -------
   -- Y --
   -------

   function Y
    (Self : in Q_Point'Class)
       return Qt4.Q_Integer
   is
   begin
      return QPoint_y (Self.Object);
   end Y;

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

   function "="
    (P_1 : in Q_Point;
     P_2 : in Q_Point)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (eq_QPointCR_QPointCR (P_1.Object, P_2.Object), 0);
   end "=";

   ---------
   -- "+" --
   ---------

   function "+"
    (P_1 : in Q_Point;
     P_2 : in Q_Point)
       return Q_Point
   is
   begin
      return Returns : Q_Point do
         plus_QPointCR_QPointCR (Returns.Object, P_1.Object, P_2.Object);
      end return;
   end "+";

   ---------
   -- "-" --
   ---------

   function "-"
    (P_1 : in Q_Point;
     P_2 : in Q_Point)
       return Q_Point
   is
   begin
      return Returns : Q_Point do
         minus_QPointCR_QPointCR (Returns.Object, P_1.Object, P_2.Object);
      end return;
   end "-";

   ---------
   -- "*" --
   ---------

   function "*"
    (P : in Q_Point;
     S : in Qt4.Q_Real)
       return Q_Point
   is
   begin
      return Returns : Q_Point do
         multiplication_QPointCR_qreal (Returns.Object, P.Object, S);
      end return;
   end "*";

   ---------
   -- "*" --
   ---------

   function "*"
    (S : in Qt4.Q_Real;
     P : in Q_Point)
       return Q_Point
   is
   begin
      return Returns : Q_Point do
         multiplication_qreal_QPointCR (Returns.Object, S, P.Object);
      end return;
   end "*";

   ---------
   -- "-" --
   ---------

   function "-"
    (P_1 : in Q_Point)
       return Q_Point
   is
   begin
      return Returns : Q_Point do
         minus_QPointCR (Returns.Object, P_1.Object);
      end return;
   end "-";

   ---------
   -- "/" --
   ---------

   function "/"
    (P : in Q_Point;
     S : in Qt4.Q_Real)
       return Q_Point
   is
   begin
      return Returns : Q_Point do
         division_QPointCR_qreal (Returns.Object, P.Object, S);
      end return;
   end "/";

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

   package body Internals is

   -----------------
   -- QPoint_View --
   -----------------

      function QPoint_View
       (Item : in Q_Point'Class)
          return QPoint_Access
      is
      begin
         return Item.Object;
      end QPoint_View;

      package QPoint_Conversions is
        new System.Address_To_Access_Conversions
             (QPoint);

   ----------------------
   -- QPointTo_Pointer --
   ----------------------

      function To_Pointer
       (Address : in System.Address)
          return QPoint_Access
      is
      begin
         return
           QPoint_Access
            (QPoint_Conversions.To_Pointer
            (Address));
      end To_Pointer;

   ----------------------
   -- QPointTo_Address --
   ----------------------

      function To_Address
       (Pointer : in QPoint_Access)
          return System.Address
      is
      begin
         return
           QPoint_Conversions.To_Address
            (QPoint_Conversions.Object_Pointer
              (Pointer));
      end To_Address;

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

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

   end Internals;

end Qt4.Points;
