------------------------------------------------------------------------------
--                                                                          --
--                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.                                      --
--                                                                          --
------------------------------------------------------------------------------
--  $Revision: 3769 $ $Date: 2010-10-24 03:16:28 +0400 (Sun, 24 Oct 2010) $
------------------------------------------------------------------------------
with Qt_Ada.Internals.Graphics_Item_Registry;
with Qt_Ada.Internals.Graphics_Items;

package body Qt4.List_Of_Graphics_Items is

   function new_QListOfQGraphicsItem return not null access
     Qt4_Entities.Cpp_Class;
   pragma Import
    (C, new_QListOfQGraphicsItem, "__Qt4Ada_new_QListOfQGraphicsItem");

   procedure delete_QListOfQGraphicsItem
    (Cpp_Object : not null access Qt4_Entities.Cpp_Class);
   pragma Import
    (C, delete_QListOfQGraphicsItem, "__Qt4Ada_delete_QListOfQGraphicsItem");

   function comparison_QListOfQGraphicsItem_wrapper
    (Left  : not null access List_Of_Graphics_Items.Thin.QListOfQGraphicsItem;
     Right : not null access List_Of_Graphics_Items.Thin.QListOfQGraphicsItem)
      return bool;
   pragma Import (C,
                  comparison_QListOfQGraphicsItem_wrapper,
                  "__Qt4Ada_comparison_QListOfQGraphicsItem_wrapper");

   function value_wrapper
    (Self : not null access List_Of_Graphics_Items.Thin.QListOfQGraphicsItem;
     I    : Interfaces.C.int)
       return not null Qt_Ada.Internals.Graphics_Items.QGraphicsItem_Access;
   pragma Import
    (C, value_wrapper, "__Qt4Ada_QListOfQGraphicsItem_value_wrapper");

   procedure append_wrapper
    (Self  : not null access List_Of_Graphics_Items.Thin.QListOfQGraphicsItem;
     Value : not null access Qt_Ada.Internals.Graphics_Items.QGraphicsItem);
   pragma Import
      (C, append_wrapper, "__Qt4Ada_QListOfQGraphicsItem_append_wrapper");

   function count_wrapper
    (Self  : not null access List_Of_Graphics_Items.Thin.QListOfQGraphicsItem)
       return Interfaces.C.int;
   pragma Import
      (C, count_wrapper, "__Qt4Ada_QListOfQGraphicsItem_count_wrapper");

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> =
   --!    <ImplementationNotes>
   ---------------------------------------------------------------------------
   overriding function "="
    (Left  : Q_List_Of_Q_Graphics_Item;
     Right : Q_List_Of_Q_Graphics_Item) return Boolean is
   begin
      return To_Boolean (comparison_QListOfQGraphicsItem_wrapper
                           (Internals.QListOfQGraphicsItem_View (Left),
                            Internals.QListOfQGraphicsItem_View (Right)));
   end "=";

   ------------
   -- Append --
   ------------

   procedure Append
    (Self  : in out Q_List_Of_Q_Graphics_Item;
     Value : not null access Qt4.Graphics_Items.Q_Graphics_Item'Class)
   is
   begin
      append_wrapper (Internals.QListOfQGraphicsItem_View (Self),
                      Value.QGraphicsItem_View);
   end Append;

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> Copy_Cpp_Object
   --!    <ImplementationNotes>
   ---------------------------------------------------------------------------
   overriding function Copy_Cpp_Object (Self : not null access Q_List_Of_Q_Graphics_Item)
      return not null access Qt4_Entities.Cpp_Class is
   begin
      return Thin.copy_QListOfQGraphicsItem (Self.Cpp_Object);
   end Copy_Cpp_Object;

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> Count
   --!    <ImplementationNotes>
   ---------------------------------------------------------------------------
   function Count (Self : Q_List_Of_Q_Graphics_Item)
     return Qt4.Q_Integer is
   begin
      return Qt4.Q_Integer
              (count_wrapper (Internals.QListOfQGraphicsItem_View (Self)));
   end Count;

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> Default_Cpp_Object
   --!    <ImplementationNotes>
   ---------------------------------------------------------------------------
   overriding function Default_Cpp_Object
    (Self : not null access Q_List_Of_Q_Graphics_Item)
      return access Qt4_Entities.Cpp_Class
   is
      pragma Unreferenced (Self);
      --  Параметр необходим для диспетчеризации надклассового вызова.

   begin
      return new_QListOfQGraphicsItem;
   end Default_Cpp_Object;

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> Delete_Cpp_Object
   --!    <ImplementationNotes>
   ---------------------------------------------------------------------------
   overriding
   procedure Delete_Cpp_Object
    (Self : not null access Q_List_Of_Q_Graphics_Item) is
   begin
      delete_QListOfQGraphicsItem (Self.Cpp_Object);
   end Delete_Cpp_Object;

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

   function Value (Self : Q_List_Of_Q_Graphics_Item;
                   I    : Q_Integer)
     return not null access Qt4.Graphics_Items.Q_Graphics_Item'Class is
   begin
      return
        Qt4.Graphics_Items.Q_Graphics_Item'Class
         (Qt_Ada.Internals.Graphics_Item_Registry.To_Q_Graphics_Item
           (value_wrapper (Internals.QListOfQGraphicsItem_View (Self),
                           Interfaces.C.int (I))).all)'Access;
   end Value;

   package body Internals is

      ------------------------------------------------------------------------
      --! <Subprogram>
      --!    <Unit> QListOfQGraphicsItem_View
      --!    <ImplementationNotes>
      ------------------------------------------------------------------------
      function QListOfQGraphicsItem_View (Self : Q_List_Of_Q_Graphics_Item)
      return not null access Thin.QListOfQGraphicsItem
      is
      begin
         return Qt4_Entities.Cpp_Object (Self);
      end QListOfQGraphicsItem_View;

   end Internals;

end Qt4.List_Of_Graphics_Items;
