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

with Qt4.Strings;

package body Qt4.Icons is

   function initialize_QIcon
    (Storage : System.Address)
      return Internals.QIcon_Access;
   pragma Import (C, initialize_QIcon, "__QtAda_inititialize_QIcon");

   function initialize_QIcon_QPixmapCR
    (Storage : System.Address;
     Pixmap : Qt4.Pixmaps.Internals.QPixmap_Access)
      return Internals.QIcon_Access;
   pragma Import (C, initialize_QIcon_QPixmapCR, "__QtAda_inititialize_QIcon_QPixmapCR");

   function initialize_QIcon_QStringCR
    (Storage : System.Address;
     File_Name : Qt4.Strings.Internals.QString_Access)
      return Internals.QIcon_Access;
   pragma Import (C, initialize_QIcon_QStringCR, "__QtAda_inititialize_QIcon_QStringCR");

   function adjust_QIcon
    (Storage : System.Address;
     From    : Internals.QIcon_Access)
       return Internals.QIcon_Access;
   pragma Import (C, adjust_QIcon, "__QtAda_adjust_QIcon");

   procedure finalize_QIcon (Object : Internals.QIcon_Access);
   pragma Import (C, finalize_QIcon, "__QtAda_finalize_QIcon");

   procedure QIcon_actualSize_QSizeCR_Mode_State
    (Returns : Qt4.Sizes.Internals.QSize_Access;
     Self : Internals.QIcon_Access;
     Size : Qt4.Sizes.Internals.QSize_Access;
     Mode : Qt4.Icons.Mode;
     State : Qt4.Icons.State);
   pragma Import (C, QIcon_actualSize_QSizeCR_Mode_State, "__QtAda_QIcon_actualSize_QSizeCR_Mode_State_Q");

   procedure QIcon_addFile_QStringCR_QSizeCR_Mode_State
    (Self : Internals.QIcon_Access;
     File_Name : Qt4.Strings.Internals.QString_Access;
     Size : Qt4.Sizes.Internals.QSize_Access;
     Mode : Qt4.Icons.Mode;
     State : Qt4.Icons.State);
   pragma Import (C, QIcon_addFile_QStringCR_QSizeCR_Mode_State, "__QtAda_QIcon_addFile_QStringCR_QSizeCR_Mode_State");

   procedure QIcon_addPixmap_QPixmapCR_Mode_State
    (Self : Internals.QIcon_Access;
     Pixmap : Qt4.Pixmaps.Internals.QPixmap_Access;
     Mode : Qt4.Icons.Mode;
     State : Qt4.Icons.State);
   pragma Import (C, QIcon_addPixmap_QPixmapCR_Mode_State, "__QtAda_QIcon_addPixmap_QPixmapCR_Mode_State");

   function QIcon_isNull
    (Self : Internals.QIcon_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QIcon_isNull, "__QtAda_QIcon_isNull_Q");

   procedure QIcon_pixmap_QSizeCR_Mode_State
    (Returns : Qt4.Pixmaps.Internals.QPixmap_Access;
     Self : Internals.QIcon_Access;
     Size : Qt4.Sizes.Internals.QSize_Access;
     Mode : Qt4.Icons.Mode;
     State : Qt4.Icons.State);
   pragma Import (C, QIcon_pixmap_QSizeCR_Mode_State, "__QtAda_QIcon_pixmap_QSizeCR_Mode_State_Q");

   procedure QIcon_pixmap_int_int_Mode_State
    (Returns : Qt4.Pixmaps.Internals.QPixmap_Access;
     Self : Internals.QIcon_Access;
     W : Qt4.Q_Integer;
     H : Qt4.Q_Integer;
     Mode : Qt4.Icons.Mode;
     State : Qt4.Icons.State);
   pragma Import (C, QIcon_pixmap_int_int_Mode_State, "__QtAda_QIcon_pixmap_int_int_Mode_State_Q");

   procedure QIcon_pixmap_int_Mode_State
    (Returns : Qt4.Pixmaps.Internals.QPixmap_Access;
     Self : Internals.QIcon_Access;
     Extent : Qt4.Q_Integer;
     Mode : Qt4.Icons.Mode;
     State : Qt4.Icons.State);
   pragma Import (C, QIcon_pixmap_int_Mode_State, "__QtAda_QIcon_pixmap_int_Mode_State_Q");

   procedure QIcon_operator_QVariant
    (Returns : not null Qt4.Variants.Internals.QVariant_Access;
     Self    : not null Internals.QIcon_Access);
   pragma Import (C, QIcon_operator_QVariant, "__QtAda_QIcon_operator_QVariant");

   procedure QVariant_value_QIcon
    (Self    : not null Internals.QIcon_Access;
     Returns : not null Qt4.Variants.Internals.QVariant_Access);
   pragma Import (C, QVariant_value_QIcon, "__QtAda_QVariant_value_QIcon");

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

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

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

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

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

   overriding
   procedure Initialize (Self : in out Q_Icon) is
      use type Internals.QIcon_Access;

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

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

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

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

   function Create
    (File_Name : Qt4.Strings.Q_String'Class)
       return Q_Icon
   is
   begin
      return Self : Q_Icon
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QIcon_QStringCR (Self.Storage'Address, Qt4.Strings.Internals.QString_View (File_Name));
      end return;
   end Create;

   -----------------
   -- Actual_Size --
   -----------------

   function Actual_Size
    (Self : Q_Icon'Class;
     Size : Qt4.Sizes.Q_Size'Class;
     Mode : Qt4.Icons.Mode
       := Normal;
     State : Qt4.Icons.State
       := Off)
       return Qt4.Sizes.Q_Size
   is
   begin
      return Returns : Qt4.Sizes.Q_Size do
         QIcon_actualSize_QSizeCR_Mode_State (Qt4.Sizes.Internals.QSize_View (Returns), Self.Object, Qt4.Sizes.Internals.QSize_View (Size), Mode, State);
      end return;
   end Actual_Size;

   --------------
   -- Add_File --
   --------------

   procedure Add_File
    (Self : in out Q_Icon'Class;
     File_Name : Qt4.Strings.Q_String'Class;
     Size : Qt4.Sizes.Q_Size'Class;
     Mode : Qt4.Icons.Mode
       := Normal;
     State : Qt4.Icons.State
       := Off)
   is
   begin
      QIcon_addFile_QStringCR_QSizeCR_Mode_State (Self.Object, Qt4.Strings.Internals.QString_View (File_Name), Qt4.Sizes.Internals.QSize_View (Size), Mode, State);
   end Add_File;

   ----------------
   -- Add_Pixmap --
   ----------------

   procedure Add_Pixmap
    (Self : in out Q_Icon'Class;
     Pixmap : Qt4.Pixmaps.Q_Pixmap'Class;
     Mode : Qt4.Icons.Mode
       := Normal;
     State : Qt4.Icons.State
       := Off)
   is
   begin
      QIcon_addPixmap_QPixmapCR_Mode_State (Self.Object, Qt4.Pixmaps.Internals.QPixmap_View (Pixmap), Mode, State);
   end Add_Pixmap;

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

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

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

   function Pixmap
    (Self : Q_Icon'Class;
     Size : Qt4.Sizes.Q_Size'Class;
     Mode : Qt4.Icons.Mode
       := Normal;
     State : Qt4.Icons.State
       := Off)
       return Qt4.Pixmaps.Q_Pixmap
   is
   begin
      return Returns : Qt4.Pixmaps.Q_Pixmap do
         QIcon_pixmap_QSizeCR_Mode_State (Qt4.Pixmaps.Internals.QPixmap_View (Returns), Self.Object, Qt4.Sizes.Internals.QSize_View (Size), Mode, State);
      end return;
   end Pixmap;

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

   function Pixmap
    (Self : Q_Icon'Class;
     W : Qt4.Q_Integer;
     H : Qt4.Q_Integer;
     Mode : Qt4.Icons.Mode
       := Normal;
     State : Qt4.Icons.State
       := Off)
       return Qt4.Pixmaps.Q_Pixmap
   is
   begin
      return Returns : Qt4.Pixmaps.Q_Pixmap do
         QIcon_pixmap_int_int_Mode_State (Qt4.Pixmaps.Internals.QPixmap_View (Returns), Self.Object, W, H, Mode, State);
      end return;
   end Pixmap;

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

   function Pixmap
    (Self : Q_Icon'Class;
     Extent : Qt4.Q_Integer;
     Mode : Qt4.Icons.Mode
       := Normal;
     State : Qt4.Icons.State
       := Off)
       return Qt4.Pixmaps.Q_Pixmap
   is
   begin
      return Returns : Qt4.Pixmaps.Q_Pixmap do
         QIcon_pixmap_int_Mode_State (Qt4.Pixmaps.Internals.QPixmap_View (Returns), Self.Object, Extent, Mode, State);
      end return;
   end Pixmap;

   ------------------
   -- To_Q_Variant --
   ------------------

   function To_Q_Variant
    (Self : Q_Icon'Class)
       return Qt4.Variants.Q_Variant
   is
   begin
      return Returns : Qt4.Variants.Q_Variant do
         QIcon_operator_QVariant (Qt4.Variants.Internals.QVariant_View (Returns), Self.Object);
      end return;
   end To_Q_Variant;

   ---------------
   -- To_Q_Icon --
   ---------------

   function To_Q_Icon
    (Self : Qt4.Variants.Q_Variant)
       return Q_Icon
   is
   begin
      return Returns : Q_Icon do
         QVariant_value_QIcon (Returns.Object, Qt4.Variants.Internals.QVariant_View (Self));
      end return;
   end To_Q_Icon;

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

   package body Internals is

   ----------------
   -- QIcon_View --
   ----------------

      function QIcon_View
       (Item : Q_Icon'Class)
          return QIcon_Access
      is
      begin
         return Item.Object;
      end QIcon_View;

      package QIcon_Conversions is
        new System.Address_To_Access_Conversions
             (QIcon);

   ---------------------
   -- QIconTo_Pointer --
   ---------------------

      function To_Pointer
       (Address : System.Address)
          return QIcon_Access
      is
      begin
         return
           QIcon_Access
            (QIcon_Conversions.To_Pointer
            (Address));
      end To_Pointer;

   ---------------------
   -- QIconTo_Address --
   ---------------------

      function To_Address
       (Pointer : QIcon_Access)
          return System.Address
      is
      begin
         return
           QIcon_Conversions.To_Address
            (QIcon_Conversions.Object_Pointer
              (Pointer));
      end To_Address;

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

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

   end Internals;

end Qt4.Icons;
