------------------------------------------------------------------------------
--                                                                          --
--                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: 3777 $ $Date: 2010-10-24 11:16:05 +0400 (Sun, 24 Oct 2010) $
------------------------------------------------------------------------------
with Interfaces.C.Strings;
with Qt4.Colors;
with Qt4.Strings;
with Qt_Ada.Internals.Boolean_Conversions;
with System;
with System.Address_To_Access_Conversions;

package body Qt4.Pixmaps is

   function initialize_QBitmap
    (Storage : System.Address)
      return Internals.QPixmap_Access;
   pragma Import (C, initialize_QBitmap, "__QtAda_inititialize_QBitmap");

   function initialize_QBitmap_QPixmapCR
    (Storage : System.Address;
     Pixmap  : Internals.QPixmap_Access)
      return Internals.QPixmap_Access;
   pragma Import (C, initialize_QBitmap_QPixmapCR, "__QtAda_inititialize_QBitmap_QPixmapCR");

   function initialize_QBitmap_int_int
    (Storage : System.Address;
     Width   : Qt4.Q_Integer;
     Height  : Qt4.Q_Integer)
      return Internals.QPixmap_Access;
   pragma Import (C, initialize_QBitmap_int_int, "__QtAda_inititialize_QBitmap_int_int");

   function initialize_QBitmap_QSizeCR
    (Storage : System.Address;
     Size    : Qt4.Sizes.Internals.QSize_Access)
      return Internals.QPixmap_Access;
   pragma Import (C, initialize_QBitmap_QSizeCR, "__QtAda_inititialize_QBitmap_QSizeCR");

   function adjust_QBitmap
    (Storage : System.Address;
     From    : Internals.QPixmap_Access)
       return Internals.QPixmap_Access;
   pragma Import (C, adjust_QBitmap, "__QtAda_adjust_QBitmap");

   procedure finalize_QBitmap (Object : Internals.QPixmap_Access);
   pragma Import (C, finalize_QBitmap, "__QtAda_finalize_QBitmap");

   procedure QBitmap_clear
    (Self : Internals.QPixmap_Access);
   pragma Import (C, QBitmap_clear, "__QtAda_QBitmap_clear");

   procedure QBitmap_transformed_QTransformCR
    (Returns : Internals.QPixmap_Access;
     Self    : Internals.QPixmap_Access;
     Matrix  : Qt4.Transforms.Internals.QTransform_Access);
   pragma Import (C, QBitmap_transformed_QTransformCR, "__QtAda_QBitmap_transformed_QTransformCR_Q");

   procedure QBitmap_transformed_QMatrixCR
    (Returns : Internals.QPixmap_Access;
     Self    : Internals.QPixmap_Access;
     Matrix  : Qt4.Matrices.Internals.QMatrix_Access);
   pragma Import (C, QBitmap_transformed_QMatrixCR, "__QtAda_QBitmap_transformed_QMatrixCR_Q");

   function C_QPaintDevice_View
    (Self : not null Internals.QPixmap_Access)
       return not null Qt_Ada.Internals.Paint_Devices.QPaintDevice_Access;
   pragma Import (C, C_QPaintDevice_View, "__QtAda_QPixmap_QPaintDevice_View");

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

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

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

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

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

   overriding
   procedure Initialize (Self : in out Q_Bitmap) is
      use type Internals.QPixmap_Access;

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

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

   function Create
    (Pixmap : Q_Pixmap'Class)
       return Q_Bitmap
   is
   begin
      return Self : Q_Bitmap
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QBitmap_QPixmapCR (Self.Storage'Address, Pixmap.Object);
      end return;
   end Create;

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

   overriding function Create
    (Width  : Qt4.Q_Integer;
     Height : Qt4.Q_Integer)
       return Q_Bitmap
   is
   begin
      return Self : Q_Bitmap
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QBitmap_int_int (Self.Storage'Address, Width, Height);
      end return;
   end Create;

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

   overriding function Create
    (Size : Qt4.Sizes.Q_Size'Class)
       return Q_Bitmap
   is
   begin
      return Self : Q_Bitmap
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QBitmap_QSizeCR (Self.Storage'Address, Qt4.Sizes.Internals.QSize_View (Size));
      end return;
   end Create;

   -----------
   -- Clear --
   -----------

   procedure Clear
    (Self : in out Q_Bitmap'Class)
   is
   begin
      QBitmap_clear (Self.Object);
   end Clear;

   -----------------
   -- Transformed --
   -----------------

   function Transformed
    (Self   : Q_Bitmap'Class;
     Matrix : Qt4.Transforms.Q_Transform'Class)
       return Q_Bitmap
   is
   begin
      return Returns : Q_Bitmap do
         QBitmap_transformed_QTransformCR (Returns.Object, Self.Object, Qt4.Transforms.Internals.QTransform_View (Matrix));
      end return;
   end Transformed;

   -----------------
   -- Transformed --
   -----------------

   function Transformed
    (Self   : Q_Bitmap'Class;
     Matrix : Qt4.Matrices.Q_Matrix'Class)
       return Q_Bitmap
   is
   begin
      return Returns : Q_Bitmap do
         QBitmap_transformed_QMatrixCR (Returns.Object, Self.Object, Qt4.Matrices.Internals.QMatrix_View (Matrix));
      end return;
   end Transformed;

   function initialize_QPixmap
    (Storage : System.Address)
      return Internals.QPixmap_Access;
   pragma Import (C, initialize_QPixmap, "__QtAda_inititialize_QPixmap");

   function initialize_QPixmap_int_int
    (Storage : System.Address;
     Width   : Qt4.Q_Integer;
     Height  : Qt4.Q_Integer)
      return Internals.QPixmap_Access;
   pragma Import (C, initialize_QPixmap_int_int, "__QtAda_inititialize_QPixmap_int_int");

   function initialize_QPixmap_QSizeCR
    (Storage : System.Address;
     Size    : Qt4.Sizes.Internals.QSize_Access)
      return Internals.QPixmap_Access;
   pragma Import (C, initialize_QPixmap_QSizeCR, "__QtAda_inititialize_QPixmap_QSizeCR");

   function adjust_QPixmap
    (Storage : System.Address;
     From    : Internals.QPixmap_Access)
       return Internals.QPixmap_Access;
   pragma Import (C, adjust_QPixmap, "__QtAda_adjust_QPixmap");

   procedure finalize_QPixmap (Object : Internals.QPixmap_Access);
   pragma Import (C, finalize_QPixmap, "__QtAda_finalize_QPixmap");

   procedure QPixmap_alphaChannel
    (Returns : Internals.QPixmap_Access;
     Self    : Internals.QPixmap_Access);
   pragma Import (C, QPixmap_alphaChannel, "__QtAda_QPixmap_alphaChannel_Q");

   procedure QPixmap_copy_QRectCR
    (Returns : Internals.QPixmap_Access;
     Self    : Internals.QPixmap_Access;
     Rect    : Qt4.Rects.Internals.QRect_Access);
   pragma Import (C, QPixmap_copy_QRectCR, "__QtAda_QPixmap_copy_QRectCR_Q");

   procedure QPixmap_copy_int_int_int_int
    (Returns : Internals.QPixmap_Access;
     Self    : Internals.QPixmap_Access;
     X       : Qt4.Q_Integer;
     Y       : Qt4.Q_Integer;
     Width   : Qt4.Q_Integer;
     Height  : Qt4.Q_Integer);
   pragma Import (C, QPixmap_copy_int_int_int_int, "__QtAda_QPixmap_copy_int_int_int_int_Q");

   procedure QPixmap_createHeuristicMask_bool
    (Returns    : Internals.QPixmap_Access;
     Self       : Internals.QPixmap_Access;
     Clip_Tight : Interfaces.C.unsigned);
   pragma Import (C, QPixmap_createHeuristicMask_bool, "__QtAda_QPixmap_createHeuristicMask_bool_Q");

   procedure QPixmap_createMaskFromColor_QColorCR_MaskMode
    (Returns    : Internals.QPixmap_Access;
     Self       : Internals.QPixmap_Access;
     Mask_Color : Qt4.Colors.Internals.QColor_Access;
     Mode       : Qt4.Mask_Mode);
   pragma Import (C, QPixmap_createMaskFromColor_QColorCR_MaskMode, "__QtAda_QPixmap_createMaskFromColor_QColorCR_MaskMode_Q");

   procedure QPixmap_createMaskFromColor_QColorCR
    (Returns    : Internals.QPixmap_Access;
     Self       : Internals.QPixmap_Access;
     Mask_Color : Qt4.Colors.Internals.QColor_Access);
   pragma Import (C, QPixmap_createMaskFromColor_QColorCR, "__QtAda_QPixmap_createMaskFromColor_QColorCR_Q");

   function QPixmap_depth
    (Self : Internals.QPixmap_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QPixmap_depth, "__QtAda_QPixmap_depth_Q");

   procedure QPixmap_detach
    (Self : Internals.QPixmap_Access);
   pragma Import (C, QPixmap_detach, "__QtAda_QPixmap_detach");

   procedure QPixmap_fill_QColorCR
    (Self       : Internals.QPixmap_Access;
     Fill_Color : Qt4.Colors.Internals.QColor_Access);
   pragma Import (C, QPixmap_fill_QColorCR, "__QtAda_QPixmap_fill_QColorCR");

   function QPixmap_hasAlpha
    (Self : Internals.QPixmap_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QPixmap_hasAlpha, "__QtAda_QPixmap_hasAlpha_Q");

   function QPixmap_hasAlphaChannel
    (Self : Internals.QPixmap_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QPixmap_hasAlphaChannel, "__QtAda_QPixmap_hasAlphaChannel_Q");

   function QPixmap_height
    (Self : Internals.QPixmap_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QPixmap_height, "__QtAda_QPixmap_height_Q");

   function QPixmap_isNull
    (Self : Internals.QPixmap_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QPixmap_isNull, "__QtAda_QPixmap_isNull_Q");

   function QPixmap_isQBitmap
    (Self : Internals.QPixmap_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QPixmap_isQBitmap, "__QtAda_QPixmap_isQBitmap_Q");

   procedure QPixmap_mask
    (Returns : Internals.QPixmap_Access;
     Self    : Internals.QPixmap_Access);
   pragma Import (C, QPixmap_mask, "__QtAda_QPixmap_mask_Q");

   procedure QPixmap_rect
    (Returns : Qt4.Rects.Internals.QRect_Access;
     Self    : Internals.QPixmap_Access);
   pragma Import (C, QPixmap_rect, "__QtAda_QPixmap_rect_Q");

   procedure QPixmap_scaled_QSizeCR_AspectRatioMode_TransformationMode
    (Returns     : Internals.QPixmap_Access;
     Self        : Internals.QPixmap_Access;
     S           : Qt4.Sizes.Internals.QSize_Access;
     Aspect_Mode : Qt4.Aspect_Ratio_Mode;
     Mode        : Qt4.Transformation_Mode);
   pragma Import (C, QPixmap_scaled_QSizeCR_AspectRatioMode_TransformationMode, "__QtAda_QPixmap_scaled_QSizeCR_AspectRatioMode_TransformationMode_Q");

   procedure QPixmap_scaled_int_int_AspectRatioMode_TransformationMode
    (Returns     : Internals.QPixmap_Access;
     Self        : Internals.QPixmap_Access;
     Width       : Qt4.Q_Integer;
     Height      : Qt4.Q_Integer;
     Aspect_Mode : Qt4.Aspect_Ratio_Mode;
     Mode        : Qt4.Transformation_Mode);
   pragma Import (C, QPixmap_scaled_int_int_AspectRatioMode_TransformationMode, "__QtAda_QPixmap_scaled_int_int_AspectRatioMode_TransformationMode_Q");

   procedure QPixmap_scaledToHeight_int_TransformationMode
    (Returns : Internals.QPixmap_Access;
     Self    : Internals.QPixmap_Access;
     Height  : Qt4.Q_Integer;
     Mode    : Qt4.Transformation_Mode);
   pragma Import (C, QPixmap_scaledToHeight_int_TransformationMode, "__QtAda_QPixmap_scaledToHeight_int_TransformationMode_Q");

   procedure QPixmap_scaledToWidth_int_TransformationMode
    (Returns : Internals.QPixmap_Access;
     Self    : Internals.QPixmap_Access;
     Width   : Qt4.Q_Integer;
     Mode    : Qt4.Transformation_Mode);
   pragma Import (C, QPixmap_scaledToWidth_int_TransformationMode, "__QtAda_QPixmap_scaledToWidth_int_TransformationMode_Q");

   procedure QPixmap_setAlphaChannel_QPixmapCR
    (Self          : Internals.QPixmap_Access;
     Alpha_Channel : Internals.QPixmap_Access);
   pragma Import (C, QPixmap_setAlphaChannel_QPixmapCR, "__QtAda_QPixmap_setAlphaChannel_QPixmapCR");

   procedure QPixmap_setMask_QBitmapCR
    (Self : Internals.QPixmap_Access;
     Mask : Internals.QPixmap_Access);
   pragma Import (C, QPixmap_setMask_QBitmapCR, "__QtAda_QPixmap_setMask_QBitmapCR");

   procedure QPixmap_size
    (Returns : Qt4.Sizes.Internals.QSize_Access;
     Self    : Internals.QPixmap_Access);
   pragma Import (C, QPixmap_size, "__QtAda_QPixmap_size_Q");

   procedure QPixmap_transformed_QTransformCR_TransformationMode
    (Returns : Internals.QPixmap_Access;
     Self    : Internals.QPixmap_Access;
     Matrix  : Qt4.Transforms.Internals.QTransform_Access;
     Mode    : Qt4.Transformation_Mode);
   pragma Import (C, QPixmap_transformed_QTransformCR_TransformationMode, "__QtAda_QPixmap_transformed_QTransformCR_TransformationMode_Q");

   procedure QPixmap_transformed_QMatrixCR_TransformationMode
    (Returns : Internals.QPixmap_Access;
     Self    : Internals.QPixmap_Access;
     Matrix  : Qt4.Matrices.Internals.QMatrix_Access;
     Mode    : Qt4.Transformation_Mode);
   pragma Import (C, QPixmap_transformed_QMatrixCR_TransformationMode, "__QtAda_QPixmap_transformed_QMatrixCR_TransformationMode_Q");

   function QPixmap_width
    (Self : Internals.QPixmap_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QPixmap_width, "__QtAda_QPixmap_width_Q");

   function QPixmap_defaultDepth
     return Qt4.Q_Integer;
   pragma Import (C, QPixmap_defaultDepth, "__QtAda_QPixmap_defaultDepth_S");

   procedure QPixmap_trueMatrix_QTransformCR_int_int
    (Returns : Qt4.Transforms.Internals.QTransform_Access;
     Matrix  : Qt4.Transforms.Internals.QTransform_Access;
     Width   : Qt4.Q_Integer;
     Height  : Qt4.Q_Integer);
   pragma Import (C, QPixmap_trueMatrix_QTransformCR_int_int, "__QtAda_QPixmap_trueMatrix_QTransformCR_int_int_S");

   procedure QPixmap_trueMatrix_QMatrixCR_int_int
    (Returns : Qt4.Matrices.Internals.QMatrix_Access;
     Matrix  : Qt4.Matrices.Internals.QMatrix_Access;
     Width   : Qt4.Q_Integer;
     Height  : Qt4.Q_Integer);
   pragma Import (C, QPixmap_trueMatrix_QMatrixCR_int_int, "__QtAda_QPixmap_trueMatrix_QMatrixCR_int_int_S");

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

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

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

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

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

   overriding
   procedure Initialize (Self : in out Q_Pixmap) is
      use type Internals.QPixmap_Access;

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

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

   function Create return Q_Pixmap is
   begin
      return Self : Q_Pixmap
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QPixmap (Self.Storage'Address);
      end return;
   end Create;

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

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

   function initialize_QPixmap_QStringCR_charP_QtImageConversionFlags
    (Storage   : System.Address;
     File_Name : not null Qt4.Strings.Internals.QString_Access;
     Format    : Interfaces.C.Strings.chars_ptr;
     Flags     : Qt4.Image_Conversion_Flags)
       return not null Internals.QPixmap_Access;
   pragma Import
    (C,
     initialize_QPixmap_QStringCR_charP_QtImageConversionFlags,
     "__QtAda_initialize_QPixmap_QStringCR_charP_QtImageConversionFlags");

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

   function Create
    (File_Name : Qt4.Strings.Q_String'Class;
     Format    : String := "";
     Flags     : Qt4.Image_Conversion_Flags := Qt4.Auto_Color)
       return Q_Pixmap
   is
      C_Format : aliased Interfaces.C.char_array := Interfaces.C.To_C (Format);

   begin
      return Self : Q_Pixmap
        := (Ada.Finalization.Controlled with others => <>)
      do
         if Format /= "" then
            Self.Object := initialize_QPixmap_QStringCR_charP_QtImageConversionFlags (Self.Storage'Address, Qt4.Strings.Internals.QString_View (File_Name), Interfaces.C.Strings.To_Chars_Ptr (C_Format'Unchecked_Access), Flags);

         else
            Self.Object := initialize_QPixmap_QStringCR_charP_QtImageConversionFlags (Self.Storage'Address, Qt4.Strings.Internals.QString_View (File_Name), Interfaces.C.Strings.Null_Ptr, Flags);
         end if;
      end return;
   end Create;

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

   function Create
    (Size : Qt4.Sizes.Q_Size'Class)
       return Q_Pixmap
   is
   begin
      return Self : Q_Pixmap
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QPixmap_QSizeCR (Self.Storage'Address, Qt4.Sizes.Internals.QSize_View (Size));
      end return;
   end Create;

   -------------------
   -- Alpha_Channel --
   -------------------

   function Alpha_Channel
    (Self : Q_Pixmap'Class)
       return Q_Pixmap
   is
   begin
      return Returns : Q_Pixmap do
         QPixmap_alphaChannel (Returns.Object, Self.Object);
      end return;
   end Alpha_Channel;

   ----------
   -- Copy --
   ----------

   function Copy
    (Self : Q_Pixmap'Class;
     Rect : Qt4.Rects.Q_Rect'Class)
       return Q_Pixmap
   is
   begin
      return Returns : Q_Pixmap do
         QPixmap_copy_QRectCR (Returns.Object, Self.Object, Qt4.Rects.Internals.QRect_View (Rect));
      end return;
   end Copy;

   ----------
   -- Copy --
   ----------

   function Copy
    (Self   : Q_Pixmap'Class;
     X      : Qt4.Q_Integer;
     Y      : Qt4.Q_Integer;
     Width  : Qt4.Q_Integer;
     Height : Qt4.Q_Integer)
       return Q_Pixmap
   is
   begin
      return Returns : Q_Pixmap do
         QPixmap_copy_int_int_int_int (Returns.Object, Self.Object, X, Y, Width, Height);
      end return;
   end Copy;

   ---------------------------
   -- Create_Heuristic_Mask --
   ---------------------------

   function Create_Heuristic_Mask
    (Self       : Q_Pixmap'Class;
     Clip_Tight : Boolean
       := True)
       return Q_Bitmap
   is
   begin
      return Returns : Q_Bitmap do
         QPixmap_createHeuristicMask_bool (Returns.Object, Self.Object, Qt_Ada.Internals.Boolean_Conversions.To_unsigned (Clip_Tight));
      end return;
   end Create_Heuristic_Mask;

   ----------------------------
   -- Create_Mask_From_Color --
   ----------------------------

   function Create_Mask_From_Color
    (Self       : Q_Pixmap'Class;
     Mask_Color : Qt4.Colors.Q_Color'Class;
     Mode       : Qt4.Mask_Mode)
       return Q_Bitmap
   is
   begin
      return Returns : Q_Bitmap do
         QPixmap_createMaskFromColor_QColorCR_MaskMode (Returns.Object, Self.Object, Qt4.Colors.Internals.QColor_View (Mask_Color), Mode);
      end return;
   end Create_Mask_From_Color;

   ----------------------------
   -- Create_Mask_From_Color --
   ----------------------------

   function Create_Mask_From_Color
    (Self       : Q_Pixmap'Class;
     Mask_Color : Qt4.Colors.Q_Color'Class)
       return Q_Bitmap
   is
   begin
      return Returns : Q_Bitmap do
         QPixmap_createMaskFromColor_QColorCR (Returns.Object, Self.Object, Qt4.Colors.Internals.QColor_View (Mask_Color));
      end return;
   end Create_Mask_From_Color;

   -----------
   -- Depth --
   -----------

   function Depth
    (Self : Q_Pixmap'Class)
       return Qt4.Q_Integer
   is
   begin
      return QPixmap_depth (Self.Object);
   end Depth;

   ------------
   -- Detach --
   ------------

   procedure Detach
    (Self : in out Q_Pixmap'Class)
   is
   begin
      QPixmap_detach (Self.Object);
   end Detach;

   ----------
   -- Fill --
   ----------

   procedure Fill
    (Self       : in out Q_Pixmap'Class;
     Fill_Color : Qt4.Colors.Q_Color'Class)
   is
   begin
      QPixmap_fill_QColorCR (Self.Object, Qt4.Colors.Internals.QColor_View (Fill_Color));
   end Fill;

   ---------------
   -- Has_Alpha --
   ---------------

   function Has_Alpha
    (Self : Q_Pixmap'Class)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QPixmap_hasAlpha (Self.Object), 0);
   end Has_Alpha;

   -----------------------
   -- Has_Alpha_Channel --
   -----------------------

   function Has_Alpha_Channel
    (Self : Q_Pixmap'Class)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QPixmap_hasAlphaChannel (Self.Object), 0);
   end Has_Alpha_Channel;

   ------------
   -- Height --
   ------------

   function Height
    (Self : Q_Pixmap'Class)
       return Qt4.Q_Integer
   is
   begin
      return QPixmap_height (Self.Object);
   end Height;

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

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

   -----------------
   -- Is_Q_Bitmap --
   -----------------

   function Is_Q_Bitmap
    (Self : Q_Pixmap'Class)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QPixmap_isQBitmap (Self.Object), 0);
   end Is_Q_Bitmap;

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

   function Mask
    (Self : Q_Pixmap'Class)
       return Q_Bitmap
   is
   begin
      return Returns : Q_Bitmap do
         QPixmap_mask (Returns.Object, Self.Object);
      end return;
   end Mask;

   ----------
   -- Rect --
   ----------

   function Rect
    (Self : Q_Pixmap'Class)
       return Qt4.Rects.Q_Rect
   is
   begin
      return Returns : Qt4.Rects.Q_Rect do
         QPixmap_rect (Qt4.Rects.Internals.QRect_View (Returns), Self.Object);
      end return;
   end Rect;

   ------------
   -- Scaled --
   ------------

   function Scaled
    (Self        : Q_Pixmap'Class;
     S           : Qt4.Sizes.Q_Size'Class;
     Aspect_Mode : Qt4.Aspect_Ratio_Mode
       := Ignore_Aspect_Ratio;
     Mode        : Qt4.Transformation_Mode
       := Fast_Transformation)
       return Q_Pixmap
   is
   begin
      return Returns : Q_Pixmap do
         QPixmap_scaled_QSizeCR_AspectRatioMode_TransformationMode (Returns.Object, Self.Object, Qt4.Sizes.Internals.QSize_View (S), Aspect_Mode, Mode);
      end return;
   end Scaled;

   ------------
   -- Scaled --
   ------------

   function Scaled
    (Self        : Q_Pixmap'Class;
     Width       : Qt4.Q_Integer;
     Height      : Qt4.Q_Integer;
     Aspect_Mode : Qt4.Aspect_Ratio_Mode
       := Ignore_Aspect_Ratio;
     Mode        : Qt4.Transformation_Mode
       := Fast_Transformation)
       return Q_Pixmap
   is
   begin
      return Returns : Q_Pixmap do
         QPixmap_scaled_int_int_AspectRatioMode_TransformationMode (Returns.Object, Self.Object, Width, Height, Aspect_Mode, Mode);
      end return;
   end Scaled;

   ----------------------
   -- Scaled_To_Height --
   ----------------------

   function Scaled_To_Height
    (Self   : Q_Pixmap'Class;
     Height : Qt4.Q_Integer;
     Mode   : Qt4.Transformation_Mode
       := Fast_Transformation)
       return Q_Pixmap
   is
   begin
      return Returns : Q_Pixmap do
         QPixmap_scaledToHeight_int_TransformationMode (Returns.Object, Self.Object, Height, Mode);
      end return;
   end Scaled_To_Height;

   ---------------------
   -- Scaled_To_Width --
   ---------------------

   function Scaled_To_Width
    (Self  : Q_Pixmap'Class;
     Width : Qt4.Q_Integer;
     Mode  : Qt4.Transformation_Mode
       := Fast_Transformation)
       return Q_Pixmap
   is
   begin
      return Returns : Q_Pixmap do
         QPixmap_scaledToWidth_int_TransformationMode (Returns.Object, Self.Object, Width, Mode);
      end return;
   end Scaled_To_Width;

   -----------------------
   -- Set_Alpha_Channel --
   -----------------------

   procedure Set_Alpha_Channel
    (Self          : in out Q_Pixmap'Class;
     Alpha_Channel : Q_Pixmap'Class)
   is
   begin
      QPixmap_setAlphaChannel_QPixmapCR (Self.Object, Alpha_Channel.Object);
   end Set_Alpha_Channel;

   --------------
   -- Set_Mask --
   --------------

   procedure Set_Mask
    (Self : in out Q_Pixmap'Class;
     Mask : Q_Bitmap'Class)
   is
   begin
      QPixmap_setMask_QBitmapCR (Self.Object, Mask.Object);
   end Set_Mask;

   ----------
   -- Size --
   ----------

   function Size
    (Self : Q_Pixmap'Class)
       return Qt4.Sizes.Q_Size
   is
   begin
      return Returns : Qt4.Sizes.Q_Size do
         QPixmap_size (Qt4.Sizes.Internals.QSize_View (Returns), Self.Object);
      end return;
   end Size;

   -----------------
   -- Transformed --
   -----------------

   function Transformed
    (Self   : Q_Pixmap'Class;
     Matrix : Qt4.Transforms.Q_Transform'Class;
     Mode   : Qt4.Transformation_Mode
       := Fast_Transformation)
       return Q_Pixmap
   is
   begin
      return Returns : Q_Pixmap do
         QPixmap_transformed_QTransformCR_TransformationMode (Returns.Object, Self.Object, Qt4.Transforms.Internals.QTransform_View (Matrix), Mode);
      end return;
   end Transformed;

   -----------------
   -- Transformed --
   -----------------

   function Transformed
    (Self   : Q_Pixmap'Class;
     Matrix : Qt4.Matrices.Q_Matrix'Class;
     Mode   : Qt4.Transformation_Mode
       := Fast_Transformation)
       return Q_Pixmap
   is
   begin
      return Returns : Q_Pixmap do
         QPixmap_transformed_QMatrixCR_TransformationMode (Returns.Object, Self.Object, Qt4.Matrices.Internals.QMatrix_View (Matrix), Mode);
      end return;
   end Transformed;

   -----------
   -- Width --
   -----------

   function Width
    (Self : Q_Pixmap'Class)
       return Qt4.Q_Integer
   is
   begin
      return QPixmap_width (Self.Object);
   end Width;

   -------------------
   -- Default_Depth --
   -------------------

   function Default_Depth
     return Qt4.Q_Integer
   is
   begin
      return QPixmap_defaultDepth;
   end Default_Depth;

   -----------------
   -- True_Matrix --
   -----------------

   function True_Matrix
    (Matrix : Qt4.Transforms.Q_Transform'Class;
     Width  : Qt4.Q_Integer;
     Height : Qt4.Q_Integer)
       return Qt4.Transforms.Q_Transform
   is
   begin
      return Returns : Qt4.Transforms.Q_Transform do
         QPixmap_trueMatrix_QTransformCR_int_int (Qt4.Transforms.Internals.QTransform_View (Returns), Qt4.Transforms.Internals.QTransform_View (Matrix), Width, Height);
      end return;
   end True_Matrix;

   -----------------
   -- True_Matrix --
   -----------------

   function True_Matrix
    (Matrix : Qt4.Matrices.Q_Matrix'Class;
     Width  : Qt4.Q_Integer;
     Height : Qt4.Q_Integer)
       return Qt4.Matrices.Q_Matrix
   is
   begin
      return Returns : Qt4.Matrices.Q_Matrix do
         QPixmap_trueMatrix_QMatrixCR_int_int (Qt4.Matrices.Internals.QMatrix_View (Returns), Qt4.Matrices.Internals.QMatrix_View (Matrix), Width, Height);
      end return;
   end True_Matrix;

   -----------------------
   -- QPaintDevice_View --
   -----------------------

   overriding
   function QPaintDevice_View
    (Self : not null access constant Q_Pixmap)
       return not null Qt_Ada.Internals.Paint_Devices.QPaintDevice_Access
   is
   begin
      return
        C_QPaintDevice_View (Internals.QPixmap_View (Q_Pixmap'Class (Self.all)));
   end QPaintDevice_View;

   ------------------
   -- Paint_Engine --
   ------------------

   overriding
   function Paint_Engine
    (Self : not null access Q_Pixmap)
       return not null access Qt4.Paint_Engines.Q_Paint_Engine
   is
   begin
      pragma Warnings (Off);
      raise Program_Error;
      return null;
      pragma Warnings (On);
   end Paint_Engine;

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

   package body Internals is

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

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

      ------------------
      -- QPixmap_View --
      ------------------

      function QPixmap_View
       (Item : Q_Pixmap'Class)
          return QPixmap_Access
      is
      begin
         return Item.Object;
      end QPixmap_View;

      package QPixmap_Conversions is
        new System.Address_To_Access_Conversions
             (QPixmap);

      -----------------------
      -- QPixmapTo_Pointer --
      -----------------------

      function To_Pointer
       (Address : System.Address)
          return QPixmap_Access
      is
      begin
         return
           QPixmap_Access
            (QPixmap_Conversions.To_Pointer
            (Address));
      end To_Pointer;

      -----------------------
      -- QPixmapTo_Address --
      -----------------------

      function To_Address
       (Pointer : QPixmap_Access)
          return System.Address
      is
      begin
         return
           QPixmap_Conversions.To_Address
            (QPixmap_Conversions.Object_Pointer
              (Pointer));
      end To_Address;

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

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

   end Internals;

end Qt4.Pixmaps;
