------------------------------------------------------------------------------
--                                                                          --
--                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: 3764 $ $Date: 2010-10-23 23:13:39 +0400 (Sat, 23 Oct 2010) $
------------------------------------------------------------------------------
private with Ada.Finalization;
limited with Qt4.Colors;
with Qt4.Matrices;
with Qt4.Paint_Devices;
with Qt4.Paint_Engines;
with Qt4.Rects;
with Qt4.Sizes;
limited with Qt4.Strings;
with Qt4.Transforms;
private with Qt_Ada.Internals.Value_Class_Sizes;
with Qt_Ada.Internals.Paint_Devices;

package Qt4.Pixmaps is

   type Q_Pixmap is new Qt4.Paint_Devices.Q_Paint_Device with private;

   type Q_Bitmap is new Q_Pixmap with private;

   function Create
     return Q_Pixmap;

   function Create
    (Width  : Qt4.Q_Integer;
     Height : Qt4.Q_Integer)
       return Q_Pixmap;

   function Create
    (File_Name : Qt4.Strings.Q_String'Class;
     Format    : String := "";
     Flags     : Qt4.Image_Conversion_Flags := Qt4.Auto_Color)
       return Q_Pixmap;

   function Create
    (Size : Qt4.Sizes.Q_Size'Class)
       return Q_Pixmap;

   function Create
    (Pixmap : Q_Pixmap'Class)
       return Q_Bitmap;

   function Create
    (Width  : Qt4.Q_Integer;
     Height : Qt4.Q_Integer)
       return Q_Bitmap;

   function Create
    (Size : Qt4.Sizes.Q_Size'Class)
       return Q_Bitmap;

   function Alpha_Channel
    (Self : Q_Pixmap'Class)
       return Q_Pixmap;

   function Copy
    (Self : Q_Pixmap'Class;
     Rect : Qt4.Rects.Q_Rect'Class)
       return Q_Pixmap;

   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;

   function Create_Heuristic_Mask
    (Self       : Q_Pixmap'Class;
     Clip_Tight : Boolean
       := True)
       return Q_Bitmap;

   function Create_Mask_From_Color
    (Self       : Q_Pixmap'Class;
     Mask_Color : Qt4.Colors.Q_Color'Class;
     Mode       : Qt4.Mask_Mode)
       return Q_Bitmap;

   function Create_Mask_From_Color
    (Self       : Q_Pixmap'Class;
     Mask_Color : Qt4.Colors.Q_Color'Class)
       return Q_Bitmap;

   function Depth
    (Self : Q_Pixmap'Class)
       return Qt4.Q_Integer;

   procedure Detach
    (Self : in out Q_Pixmap'Class);

   procedure Fill
    (Self       : in out Q_Pixmap'Class;
     Fill_Color : Qt4.Colors.Q_Color'Class);

   function Has_Alpha
    (Self : Q_Pixmap'Class)
       return Boolean;

   function Has_Alpha_Channel
    (Self : Q_Pixmap'Class)
       return Boolean;

   function Height
    (Self : Q_Pixmap'Class)
       return Qt4.Q_Integer;

   function Is_Null
    (Self : Q_Pixmap'Class)
       return Boolean;

   function Is_Q_Bitmap
    (Self : Q_Pixmap'Class)
       return Boolean;

   function Mask
    (Self : Q_Pixmap'Class)
       return Q_Bitmap;

   function Rect
    (Self : Q_Pixmap'Class)
       return Qt4.Rects.Q_Rect;

   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;

   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;

   function Scaled_To_Height
    (Self   : Q_Pixmap'Class;
     Height : Qt4.Q_Integer;
     Mode   : Qt4.Transformation_Mode
       := Fast_Transformation)
       return Q_Pixmap;

   function Scaled_To_Width
    (Self  : Q_Pixmap'Class;
     Width : Qt4.Q_Integer;
     Mode  : Qt4.Transformation_Mode
       := Fast_Transformation)
       return Q_Pixmap;

   procedure Set_Alpha_Channel
    (Self          : in out Q_Pixmap'Class;
     Alpha_Channel : Q_Pixmap'Class);

   procedure Set_Mask
    (Self : in out Q_Pixmap'Class;
     Mask : Q_Bitmap'Class);

   function Size
    (Self : Q_Pixmap'Class)
       return Qt4.Sizes.Q_Size;

   function Transformed
    (Self   : Q_Pixmap'Class;
     Matrix : Qt4.Transforms.Q_Transform'Class;
     Mode   : Qt4.Transformation_Mode
       := Fast_Transformation)
       return Q_Pixmap;

   function Transformed
    (Self   : Q_Pixmap'Class;
     Matrix : Qt4.Matrices.Q_Matrix'Class;
     Mode   : Qt4.Transformation_Mode
       := Fast_Transformation)
       return Q_Pixmap;

   function Width
    (Self : Q_Pixmap'Class)
       return Qt4.Q_Integer;

   function Default_Depth
     return Qt4.Q_Integer;

   function True_Matrix
    (Matrix : Qt4.Transforms.Q_Transform'Class;
     Width  : Qt4.Q_Integer;
     Height : Qt4.Q_Integer)
       return Qt4.Transforms.Q_Transform;

   function True_Matrix
    (Matrix : Qt4.Matrices.Q_Matrix'Class;
     Width  : Qt4.Q_Integer;
     Height : Qt4.Q_Integer)
       return Qt4.Matrices.Q_Matrix;

   procedure Clear
    (Self : in out Q_Bitmap'Class);

   function Transformed
    (Self   : Q_Bitmap'Class;
     Matrix : Qt4.Transforms.Q_Transform'Class)
       return Q_Bitmap;

   function Transformed
    (Self   : Q_Bitmap'Class;
     Matrix : Qt4.Matrices.Q_Matrix'Class)
       return Q_Bitmap;

   package Internals is

      type QPixmap is private;

      type QPixmap_Access is access all QPixmap;
      pragma Convention (C, QPixmap_Access);

      function QPixmap_View
       (Item : Q_Pixmap'Class)
          return QPixmap_Access;
      pragma Inline (QPixmap_View);

      function To_Pointer
       (Address : System.Address)
          return QPixmap_Access;
      pragma Inline (To_Pointer);

      function To_Address
       (Pointer : QPixmap_Access)
          return System.Address;
      pragma Inline (To_Address);

      function Create_Wrapper
       (Item : Internals.QPixmap_Access)
          return Q_Pixmap;

      function Create_Wrapper
       (Item : Internals.QPixmap_Access)
          return Q_Bitmap;

   private

      type QPixmap is record
         Placeholder : Interfaces.C.char_array (1 .. Qt_Ada.Internals.Value_Class_Sizes.QPixmap_C_Size_Of);
      end record;
      pragma Convention (C, QPixmap);

   end Internals;

private

   type Q_Pixmap is new Ada.Finalization.Controlled
     and Qt4.Paint_Devices.Q_Paint_Device with
   record
      Storage : aliased Internals.QPixmap;
      Object  : Internals.QPixmap_Access := null;
      Wrapper : Boolean := False;
   end record;

   overriding
   procedure Adjust (Self : in out Q_Pixmap);

   overriding
   procedure Finalize (Self : in out Q_Pixmap);

   overriding
   procedure Initialize (Self : in out Q_Pixmap);

   overriding
   function QPaintDevice_View
    (Self : not null access constant Q_Pixmap)
       return not null Qt_Ada.Internals.Paint_Devices.QPaintDevice_Access;

   overriding
   function Paint_Engine
    (Self : not null access Q_Pixmap)
       return not null access Qt4.Paint_Engines.Q_Paint_Engine;

   type Q_Bitmap is new Q_Pixmap with null record;

   overriding
   procedure Adjust (Self : in out Q_Bitmap);

   overriding
   procedure Finalize (Self : in out Q_Bitmap);

   overriding
   procedure Initialize (Self : in out Q_Bitmap);

end Qt4.Pixmaps;
