------------------------------------------------------------------------------
--                                                                          --
--                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.                                      --
--                                                                          --
------------------------------------------------------------------------------
--    This file has been generated automatically. Please don't edit it.     --
------------------------------------------------------------------------------
with Qt_Ada.Internals.Boolean_Conversions;
with System.Address_To_Access_Conversions;

package body Qt4.Pens is

   function initialize_QPen
    (Storage : System.Address)
      return Internals.QPen_Access;
   pragma Import (C, initialize_QPen, "__QtAda_inititialize_QPen");

   function initialize_QPen_PenStyle
    (Storage : System.Address;
     Style : Qt4.Pen_Style)
      return Internals.QPen_Access;
   pragma Import (C, initialize_QPen_PenStyle, "__QtAda_inititialize_QPen_PenStyle");

   function initialize_QPen_QColorCR
    (Storage : System.Address;
     Color : Qt4.Colors.Internals.QColor_Access)
      return Internals.QPen_Access;
   pragma Import (C, initialize_QPen_QColorCR, "__QtAda_inititialize_QPen_QColorCR");

   function initialize_QPen_QBrushCR_qreal_PenStyle_PenCapStyle_PenJoinStyle
    (Storage : System.Address;
     Brush : Qt4.Brushes.Internals.QBrush_Access;
     Width : Qt4.Q_Real;
     S : Qt4.Pen_Style;
     C : Qt4.Pen_Cap_Style;
     J : Qt4.Pen_Join_Style)
      return Internals.QPen_Access;
   pragma Import (C, initialize_QPen_QBrushCR_qreal_PenStyle_PenCapStyle_PenJoinStyle, "__QtAda_inititialize_QPen_QBrushCR_qreal_PenStyle_PenCapStyle_PenJoinStyle");

   function adjust_QPen
    (Storage : System.Address;
     From    : Internals.QPen_Access)
       return Internals.QPen_Access;
   pragma Import (C, adjust_QPen, "__QtAda_adjust_QPen");

   procedure finalize_QPen (Object : Internals.QPen_Access);
   pragma Import (C, finalize_QPen, "__QtAda_finalize_QPen");

   procedure QPen_brush
    (Returns : Qt4.Brushes.Internals.QBrush_Access;
     Self : Internals.QPen_Access);
   pragma Import (C, QPen_brush, "__QtAda_QPen_brush_Q");

   function QPen_capStyle
    (Self : Internals.QPen_Access)
       return Qt4.Pen_Cap_Style;
   pragma Import (C, QPen_capStyle, "__QtAda_QPen_capStyle_Q");

   procedure QPen_color
    (Returns : Qt4.Colors.Internals.QColor_Access;
     Self : Internals.QPen_Access);
   pragma Import (C, QPen_color, "__QtAda_QPen_color_Q");

   function QPen_dashOffset
    (Self : Internals.QPen_Access)
       return Qt4.Q_Real;
   pragma Import (C, QPen_dashOffset, "__QtAda_QPen_dashOffset_Q");

   function QPen_isCosmetic
    (Self : Internals.QPen_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QPen_isCosmetic, "__QtAda_QPen_isCosmetic_Q");

   function QPen_isSolid
    (Self : Internals.QPen_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QPen_isSolid, "__QtAda_QPen_isSolid_Q");

   function QPen_joinStyle
    (Self : Internals.QPen_Access)
       return Qt4.Pen_Join_Style;
   pragma Import (C, QPen_joinStyle, "__QtAda_QPen_joinStyle_Q");

   function QPen_miterLimit
    (Self : Internals.QPen_Access)
       return Qt4.Q_Real;
   pragma Import (C, QPen_miterLimit, "__QtAda_QPen_miterLimit_Q");

   procedure QPen_setBrush_QBrushCR
    (Self : Internals.QPen_Access;
     Brush : Qt4.Brushes.Internals.QBrush_Access);
   pragma Import (C, QPen_setBrush_QBrushCR, "__QtAda_QPen_setBrush_QBrushCR");

   procedure QPen_setCapStyle_PenCapStyle
    (Self : Internals.QPen_Access;
     Style : Qt4.Pen_Cap_Style);
   pragma Import (C, QPen_setCapStyle_PenCapStyle, "__QtAda_QPen_setCapStyle_PenCapStyle");

   procedure QPen_setColor_QColorCR
    (Self : Internals.QPen_Access;
     Color : Qt4.Colors.Internals.QColor_Access);
   pragma Import (C, QPen_setColor_QColorCR, "__QtAda_QPen_setColor_QColorCR");

   procedure QPen_setCosmetic_bool
    (Self : Internals.QPen_Access;
     Cosmetic : Interfaces.C.unsigned);
   pragma Import (C, QPen_setCosmetic_bool, "__QtAda_QPen_setCosmetic_bool");

   procedure QPen_setDashOffset_qreal
    (Self : Internals.QPen_Access;
     Doffset : Qt4.Q_Real);
   pragma Import (C, QPen_setDashOffset_qreal, "__QtAda_QPen_setDashOffset_qreal");

   procedure QPen_setJoinStyle_PenJoinStyle
    (Self : Internals.QPen_Access;
     Pcs : Qt4.Pen_Join_Style);
   pragma Import (C, QPen_setJoinStyle_PenJoinStyle, "__QtAda_QPen_setJoinStyle_PenJoinStyle");

   procedure QPen_setMiterLimit_qreal
    (Self : Internals.QPen_Access;
     Limit : Qt4.Q_Real);
   pragma Import (C, QPen_setMiterLimit_qreal, "__QtAda_QPen_setMiterLimit_qreal");

   procedure QPen_setStyle_PenStyle
    (Self : Internals.QPen_Access;
     Style : Qt4.Pen_Style);
   pragma Import (C, QPen_setStyle_PenStyle, "__QtAda_QPen_setStyle_PenStyle");

   procedure QPen_setWidth_int
    (Self : Internals.QPen_Access;
     Width : Qt4.Q_Integer);
   pragma Import (C, QPen_setWidth_int, "__QtAda_QPen_setWidth_int");

   procedure QPen_setWidthF_qreal
    (Self : Internals.QPen_Access;
     Width : Qt4.Q_Real);
   pragma Import (C, QPen_setWidthF_qreal, "__QtAda_QPen_setWidthF_qreal");

   function QPen_style
    (Self : Internals.QPen_Access)
       return Qt4.Pen_Style;
   pragma Import (C, QPen_style, "__QtAda_QPen_style_Q");

   function QPen_width
    (Self : Internals.QPen_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QPen_width, "__QtAda_QPen_width_Q");

   function QPen_widthF
    (Self : Internals.QPen_Access)
       return Qt4.Q_Real;
   pragma Import (C, QPen_widthF, "__QtAda_QPen_widthF_Q");

   function eq_QPenCR
    (Self : Internals.QPen_Access;
     Pen : Internals.QPen_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, eq_QPenCR, "__QtAda_QPen_eq_QPenCR_Q");

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

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

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

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

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

   overriding
   procedure Initialize (Self : in out Q_Pen) is
      use type Internals.QPen_Access;

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

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

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

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

   function Create
    (Style : Qt4.Pen_Style)
       return Q_Pen
   is
   begin
      return Self : Q_Pen
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QPen_PenStyle (Self.Storage'Address, Style);
      end return;
   end Create;

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

   function Create
    (Color : Qt4.Colors.Q_Color'Class)
       return Q_Pen
   is
   begin
      return Self : Q_Pen
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QPen_QColorCR (Self.Storage'Address, Qt4.Colors.Internals.QColor_View (Color));
      end return;
   end Create;

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

   function Create
    (Brush : Qt4.Brushes.Q_Brush'Class;
     Width : Qt4.Q_Real;
     S : Qt4.Pen_Style
       := Solid_Line;
     C : Qt4.Pen_Cap_Style
       := Square_Cap;
     J : Qt4.Pen_Join_Style
       := Bevel_Join)
       return Q_Pen
   is
   begin
      return Self : Q_Pen
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QPen_QBrushCR_qreal_PenStyle_PenCapStyle_PenJoinStyle (Self.Storage'Address, Qt4.Brushes.Internals.QBrush_View (Brush), Width, S, C, J);
      end return;
   end Create;

   -----------
   -- Brush --
   -----------

   function Brush
    (Self : Q_Pen'Class)
       return Qt4.Brushes.Q_Brush
   is
   begin
      return Returns : Qt4.Brushes.Q_Brush do
         QPen_brush (Qt4.Brushes.Internals.QBrush_View (Returns), Self.Object);
      end return;
   end Brush;

   ---------------
   -- Cap_Style --
   ---------------

   function Cap_Style
    (Self : Q_Pen'Class)
       return Qt4.Pen_Cap_Style
   is
   begin
      return QPen_capStyle (Self.Object);
   end Cap_Style;

   -----------
   -- Color --
   -----------

   function Color
    (Self : Q_Pen'Class)
       return Qt4.Colors.Q_Color
   is
   begin
      return Returns : Qt4.Colors.Q_Color do
         QPen_color (Qt4.Colors.Internals.QColor_View (Returns), Self.Object);
      end return;
   end Color;

   -----------------
   -- Dash_Offset --
   -----------------

   function Dash_Offset
    (Self : Q_Pen'Class)
       return Qt4.Q_Real
   is
   begin
      return QPen_dashOffset (Self.Object);
   end Dash_Offset;

   -----------------
   -- Is_Cosmetic --
   -----------------

   function Is_Cosmetic
    (Self : Q_Pen'Class)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QPen_isCosmetic (Self.Object), 0);
   end Is_Cosmetic;

   --------------
   -- Is_Solid --
   --------------

   function Is_Solid
    (Self : Q_Pen'Class)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QPen_isSolid (Self.Object), 0);
   end Is_Solid;

   ----------------
   -- Join_Style --
   ----------------

   function Join_Style
    (Self : Q_Pen'Class)
       return Qt4.Pen_Join_Style
   is
   begin
      return QPen_joinStyle (Self.Object);
   end Join_Style;

   -----------------
   -- Miter_Limit --
   -----------------

   function Miter_Limit
    (Self : Q_Pen'Class)
       return Qt4.Q_Real
   is
   begin
      return QPen_miterLimit (Self.Object);
   end Miter_Limit;

   ---------------
   -- Set_Brush --
   ---------------

   procedure Set_Brush
    (Self : in out Q_Pen'Class;
     Brush : Qt4.Brushes.Q_Brush'Class)
   is
   begin
      QPen_setBrush_QBrushCR (Self.Object, Qt4.Brushes.Internals.QBrush_View (Brush));
   end Set_Brush;

   -------------------
   -- Set_Cap_Style --
   -------------------

   procedure Set_Cap_Style
    (Self : in out Q_Pen'Class;
     Style : Qt4.Pen_Cap_Style)
   is
   begin
      QPen_setCapStyle_PenCapStyle (Self.Object, Style);
   end Set_Cap_Style;

   ---------------
   -- Set_Color --
   ---------------

   procedure Set_Color
    (Self : in out Q_Pen'Class;
     Color : Qt4.Colors.Q_Color'Class)
   is
   begin
      QPen_setColor_QColorCR (Self.Object, Qt4.Colors.Internals.QColor_View (Color));
   end Set_Color;

   ------------------
   -- Set_Cosmetic --
   ------------------

   procedure Set_Cosmetic
    (Self : in out Q_Pen'Class;
     Cosmetic : Boolean)
   is
   begin
      QPen_setCosmetic_bool (Self.Object, Qt_Ada.Internals.Boolean_Conversions.To_unsigned (Cosmetic));
   end Set_Cosmetic;

   ---------------------
   -- Set_Dash_Offset --
   ---------------------

   procedure Set_Dash_Offset
    (Self : in out Q_Pen'Class;
     Doffset : Qt4.Q_Real)
   is
   begin
      QPen_setDashOffset_qreal (Self.Object, Doffset);
   end Set_Dash_Offset;

   --------------------
   -- Set_Join_Style --
   --------------------

   procedure Set_Join_Style
    (Self : in out Q_Pen'Class;
     Pcs : Qt4.Pen_Join_Style)
   is
   begin
      QPen_setJoinStyle_PenJoinStyle (Self.Object, Pcs);
   end Set_Join_Style;

   ---------------------
   -- Set_Miter_Limit --
   ---------------------

   procedure Set_Miter_Limit
    (Self : in out Q_Pen'Class;
     Limit : Qt4.Q_Real)
   is
   begin
      QPen_setMiterLimit_qreal (Self.Object, Limit);
   end Set_Miter_Limit;

   ---------------
   -- Set_Style --
   ---------------

   procedure Set_Style
    (Self : in out Q_Pen'Class;
     Style : Qt4.Pen_Style)
   is
   begin
      QPen_setStyle_PenStyle (Self.Object, Style);
   end Set_Style;

   ---------------
   -- Set_Width --
   ---------------

   procedure Set_Width
    (Self : in out Q_Pen'Class;
     Width : Qt4.Q_Integer)
   is
   begin
      QPen_setWidth_int (Self.Object, Width);
   end Set_Width;

   -----------------
   -- Set_Width_F --
   -----------------

   procedure Set_Width_F
    (Self : in out Q_Pen'Class;
     Width : Qt4.Q_Real)
   is
   begin
      QPen_setWidthF_qreal (Self.Object, Width);
   end Set_Width_F;

   -----------
   -- Style --
   -----------

   function Style
    (Self : Q_Pen'Class)
       return Qt4.Pen_Style
   is
   begin
      return QPen_style (Self.Object);
   end Style;

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

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

   -------------
   -- Width_F --
   -------------

   function Width_F
    (Self : Q_Pen'Class)
       return Qt4.Q_Real
   is
   begin
      return QPen_widthF (Self.Object);
   end Width_F;

   ---------
   -- "=" --
   ---------

   overriding function "="
    (Self : Q_Pen;
     Pen : Q_Pen)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (eq_QPenCR (Self.Object, Pen.Object), 0);
   end "=";

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

   package body Internals is

   ---------------
   -- QPen_View --
   ---------------

      function QPen_View
       (Item : Q_Pen'Class)
          return QPen_Access
      is
      begin
         return Item.Object;
      end QPen_View;

      package QPen_Conversions is
        new System.Address_To_Access_Conversions
             (QPen);

   --------------------
   -- QPenTo_Pointer --
   --------------------

      function To_Pointer
       (Address : System.Address)
          return QPen_Access
      is
      begin
         return
           QPen_Access
            (QPen_Conversions.To_Pointer
            (Address));
      end To_Pointer;

   --------------------
   -- QPenTo_Address --
   --------------------

      function To_Address
       (Pointer : QPen_Access)
          return System.Address
      is
      begin
         return
           QPen_Conversions.To_Address
            (QPen_Conversions.Object_Pointer
              (Pointer));
      end To_Address;

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

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

   end Internals;

end Qt4.Pens;
