------------------------------------------------------------------------------
--                                                                          --
--                An Ada2005 binding to the Qt C++ framework                --
--                                                                          --
------------------------------------------------------------------------------
--                                                                          --
-- Copyright © 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.     --
------------------------------------------------------------------------------
with System.Address_To_Access_Conversions;

package body Qt4.Cursors is

   function initialize_QCursor
    (Storage : System.Address)
      return Internals.QCursor_Access;
   pragma Import (C, initialize_QCursor, "__QtAda_inititialize_QCursor");

   function initialize_QCursor_CursorShape
    (Storage : System.Address;
     Shape : Qt4.Cursor_Shape)
      return Internals.QCursor_Access;
   pragma Import (C, initialize_QCursor_CursorShape, "__QtAda_inititialize_QCursor_CursorShape");

   function initialize_QCursor_QBitmapCR_QBitmapCR_int_int
    (Storage : System.Address;
     Bitmap : Qt4.Pixmaps.Internals.QPixmap_Access;
     Mask : Qt4.Pixmaps.Internals.QPixmap_Access;
     Hot_X : Qt4.Q_Integer;
     Hot_Y : Qt4.Q_Integer)
      return Internals.QCursor_Access;
   pragma Import (C, initialize_QCursor_QBitmapCR_QBitmapCR_int_int, "__QtAda_inititialize_QCursor_QBitmapCR_QBitmapCR_int_int");

   function initialize_QCursor_QPixmapCR_int_int
    (Storage : System.Address;
     Pixmap : Qt4.Pixmaps.Internals.QPixmap_Access;
     Hot_X : Qt4.Q_Integer;
     Hot_Y : Qt4.Q_Integer)
      return Internals.QCursor_Access;
   pragma Import (C, initialize_QCursor_QPixmapCR_int_int, "__QtAda_inititialize_QCursor_QPixmapCR_int_int");

   function adjust_QCursor
    (Storage : System.Address;
     From    : Internals.QCursor_Access)
       return Internals.QCursor_Access;
   pragma Import (C, adjust_QCursor, "__QtAda_adjust_QCursor");

   procedure finalize_QCursor (Object : Internals.QCursor_Access);
   pragma Import (C, finalize_QCursor, "__QtAda_finalize_QCursor");

   procedure QCursor_bitmap
    (Returns : Qt4.Pixmaps.Internals.QPixmap_Access;
     Self : Internals.QCursor_Access);
   pragma Import (C, QCursor_bitmap, "__QtAda_QCursor_bitmap_Q");

   procedure QCursor_hotSpot
    (Returns : Qt4.Points.Internals.QPoint_Access;
     Self : Internals.QCursor_Access);
   pragma Import (C, QCursor_hotSpot, "__QtAda_QCursor_hotSpot_Q");

   procedure QCursor_mask
    (Returns : Qt4.Pixmaps.Internals.QPixmap_Access;
     Self : Internals.QCursor_Access);
   pragma Import (C, QCursor_mask, "__QtAda_QCursor_mask_Q");

   procedure QCursor_pixmap
    (Returns : Qt4.Pixmaps.Internals.QPixmap_Access;
     Self : Internals.QCursor_Access);
   pragma Import (C, QCursor_pixmap, "__QtAda_QCursor_pixmap_Q");

   procedure QCursor_setShape_CursorShape
    (Self : Internals.QCursor_Access;
     Shape : Qt4.Cursor_Shape);
   pragma Import (C, QCursor_setShape_CursorShape, "__QtAda_QCursor_setShape_CursorShape");

   function QCursor_shape
    (Self : Internals.QCursor_Access)
       return Qt4.Cursor_Shape;
   pragma Import (C, QCursor_shape, "__QtAda_QCursor_shape_Q");

   procedure QCursor_pos
    (Returns : Qt4.Points.Internals.QPoint_Access);
   pragma Import (C, QCursor_pos, "__QtAda_QCursor_pos_S");

   procedure QCursor_setPos_int_int
    (X : Qt4.Q_Integer;
     Y : Qt4.Q_Integer);
   pragma Import (C, QCursor_setPos_int_int, "__QtAda_QCursor_setPos_int_int_S");

   procedure QCursor_setPos_QPointCR
    (P : Qt4.Points.Internals.QPoint_Access);
   pragma Import (C, QCursor_setPos_QPointCR, "__QtAda_QCursor_setPos_QPointCR_S");

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

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

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

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

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

   overriding
   procedure Initialize (Self : in out Q_Cursor) is
      use type Internals.QCursor_Access;

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

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

   function Create
    (Shape : Qt4.Cursor_Shape)
       return Q_Cursor
   is
   begin
      return Self : Q_Cursor
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QCursor_CursorShape (Self.Storage'Address, Shape);
      end return;
   end Create;

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

   function Create
    (Bitmap : Qt4.Bitmaps.Q_Bitmap'Class;
     Mask : Qt4.Bitmaps.Q_Bitmap'Class;
     Hot_X : Qt4.Q_Integer
       := -1;
     Hot_Y : Qt4.Q_Integer
       := -1)
       return Q_Cursor
   is
   begin
      return Self : Q_Cursor
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QCursor_QBitmapCR_QBitmapCR_int_int (Self.Storage'Address, Qt4.Bitmaps.Internals.QPixmap_View (Bitmap), Qt4.Bitmaps.Internals.QPixmap_View (Mask), Hot_X, Hot_Y);
      end return;
   end Create;

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

   function Create
    (Pixmap : Qt4.Pixmaps.Q_Pixmap'Class;
     Hot_X : Qt4.Q_Integer
       := -1;
     Hot_Y : Qt4.Q_Integer
       := -1)
       return Q_Cursor
   is
   begin
      return Self : Q_Cursor
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QCursor_QPixmapCR_int_int (Self.Storage'Address, Qt4.Pixmaps.Internals.QPixmap_View (Pixmap), Hot_X, Hot_Y);
      end return;
   end Create;

   ------------
   -- Bitmap --
   ------------

   function Bitmap
    (Self : Q_Cursor'Class)
       return Qt4.Bitmaps.Q_Bitmap
   is
   begin
      return Returns : Qt4.Bitmaps.Q_Bitmap do
         QCursor_bitmap (Qt4.Bitmaps.Internals.QPixmap_View (Returns), Self.Object);
      end return;
   end Bitmap;

   --------------
   -- Hot_Spot --
   --------------

   function Hot_Spot
    (Self : Q_Cursor'Class)
       return Qt4.Points.Q_Point
   is
   begin
      return Returns : Qt4.Points.Q_Point do
         QCursor_hotSpot (Qt4.Points.Internals.QPoint_View (Returns), Self.Object);
      end return;
   end Hot_Spot;

   ----------
   -- Mask --
   ----------

   function Mask
    (Self : Q_Cursor'Class)
       return Qt4.Bitmaps.Q_Bitmap
   is
   begin
      return Returns : Qt4.Bitmaps.Q_Bitmap do
         QCursor_mask (Qt4.Bitmaps.Internals.QPixmap_View (Returns), Self.Object);
      end return;
   end Mask;

   ------------
   -- Pixmap --
   ------------

   function Pixmap
    (Self : Q_Cursor'Class)
       return Qt4.Pixmaps.Q_Pixmap
   is
   begin
      return Returns : Qt4.Pixmaps.Q_Pixmap do
         QCursor_pixmap (Qt4.Pixmaps.Internals.QPixmap_View (Returns), Self.Object);
      end return;
   end Pixmap;

   ---------------
   -- Set_Shape --
   ---------------

   procedure Set_Shape
    (Self : in out Q_Cursor'Class;
     Shape : Qt4.Cursor_Shape)
   is
   begin
      QCursor_setShape_CursorShape (Self.Object, Shape);
   end Set_Shape;

   -----------
   -- Shape --
   -----------

   function Shape
    (Self : Q_Cursor'Class)
       return Qt4.Cursor_Shape
   is
   begin
      return QCursor_shape (Self.Object);
   end Shape;

   ---------
   -- Pos --
   ---------

   function Pos
     return Qt4.Points.Q_Point
   is
   begin
      return Returns : Qt4.Points.Q_Point do
         QCursor_pos (Qt4.Points.Internals.QPoint_View (Returns));
      end return;
   end Pos;

   -------------
   -- Set_Pos --
   -------------

   procedure Set_Pos
    (X : Qt4.Q_Integer;
     Y : Qt4.Q_Integer)
   is
   begin
      QCursor_setPos_int_int (X, Y);
   end Set_Pos;

   -------------
   -- Set_Pos --
   -------------

   procedure Set_Pos
    (P : Qt4.Points.Q_Point'Class)
   is
   begin
      QCursor_setPos_QPointCR (Qt4.Points.Internals.QPoint_View (P));
   end Set_Pos;

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

   package body Internals is

   ------------------
   -- QCursor_View --
   ------------------

      function QCursor_View
       (Item : Q_Cursor'Class)
          return QCursor_Access
      is
      begin
         return Item.Object;
      end QCursor_View;

      package QCursor_Conversions is
        new System.Address_To_Access_Conversions
             (QCursor);

   -----------------------
   -- QCursorTo_Pointer --
   -----------------------

      function To_Pointer
       (Address : System.Address)
          return QCursor_Access
      is
      begin
         return
           QCursor_Access
            (QCursor_Conversions.To_Pointer
            (Address));
      end To_Pointer;

   -----------------------
   -- QCursorTo_Address --
   -----------------------

      function To_Address
       (Pointer : QCursor_Access)
          return System.Address
      is
      begin
         return
           QCursor_Conversions.To_Address
            (QCursor_Conversions.Object_Pointer
              (Pointer));
      end To_Address;

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

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

   end Internals;

end Qt4.Cursors;
