------------------------------------------------------------------------------
--                                                                          --
--                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;

package body Qt4.Text_Lengths is

   function initialize_QTextLength
    (Storage : System.Address)
      return Internals.QTextLength_Access;
   pragma Import (C, initialize_QTextLength, "__QtAda_inititialize_QTextLength");

   function initialize_QTextLength_Type_qreal
    (Storage : System.Address;
     Length_Type : Text_Length_Type;
     Value : Qt4.Q_Real)
      return Internals.QTextLength_Access;
   pragma Import (C, initialize_QTextLength_Type_qreal, "__QtAda_inititialize_QTextLength_Type_qreal");

   function adjust_QTextLength
    (Storage : System.Address;
     From    : Internals.QTextLength_Access)
       return Internals.QTextLength_Access;
   pragma Import (C, adjust_QTextLength, "__QtAda_adjust_QTextLength");

   procedure finalize_QTextLength (Object : Internals.QTextLength_Access);
   pragma Import (C, finalize_QTextLength, "__QtAda_finalize_QTextLength");

   function QTextLength_rawValue
    (Self : Internals.QTextLength_Access)
       return Qt4.Q_Real;
   pragma Import (C, QTextLength_rawValue, "__QtAda_QTextLength_rawValue_Q");

   function QTextLength_type
    (Self : Internals.QTextLength_Access)
       return Text_Length_Type;
   pragma Import (C, QTextLength_type, "__QtAda_QTextLength_type_Q");

   function QTextLength_value_qreal
    (Self : Internals.QTextLength_Access;
     Maximum_Length : Qt4.Q_Real)
       return Qt4.Q_Real;
   pragma Import (C, QTextLength_value_qreal, "__QtAda_QTextLength_value_qreal_Q");

   function eq_QTextLengthCR
    (Self : Internals.QTextLength_Access;
     Other : Internals.QTextLength_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, eq_QTextLengthCR, "__QtAda_QTextLength_eq_QTextLengthCR_Q");

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

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

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

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

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

   overriding
   procedure Initialize (Self : in out Q_Text_Length) is
      use type Internals.QTextLength_Access;

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

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

   function Create
    (Length_Type : Text_Length_Type;
     Value : Qt4.Q_Real)
       return Q_Text_Length is
   begin
      return Self : Q_Text_Length
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QTextLength_Type_qreal (Self.Storage'Address, Length_Type, Value);
      end return;
   end Create;

   ---------------
   -- Raw_Value --
   ---------------

   function Raw_Value
    (Self : Q_Text_Length'Class)
       return Qt4.Q_Real is
   begin
      return QTextLength_rawValue (Self.Object);
   end Raw_Value;

   -----------------
   -- Length_Type --
   -----------------

   function Length_Type
    (Self : Q_Text_Length'Class)
       return Text_Length_Type is
   begin
      return QTextLength_type (Self.Object);
   end Length_Type;

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

   function Value
    (Self : Q_Text_Length'Class;
     Maximum_Length : Qt4.Q_Real)
       return Qt4.Q_Real is
   begin
      return QTextLength_value_qreal (Self.Object, Maximum_Length);
   end Value;

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

   overriding function "="
    (Self : Q_Text_Length;
     Other : Q_Text_Length)
       return Boolean is
   begin
      return Interfaces.C."/=" (eq_QTextLengthCR (Self.Object, Other.Object), 0);
   end "=";

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

   package body Internals is

   ----------------------
   -- QTextLength_View --
   ----------------------

      function QTextLength_View
       (Item : Q_Text_Length'Class)
          return QTextLength_Access is
      begin
         return Item.Object;
      end QTextLength_View;

      package QTextLength_Conversions is
        new System.Address_To_Access_Conversions
             (QTextLength);

   ---------------------------
   -- QTextLengthTo_Pointer --
   ---------------------------

      function To_Pointer
       (Address : System.Address)
          return QTextLength_Access is
      begin
         return
           QTextLength_Access
            (QTextLength_Conversions.To_Pointer
            (Address));
      end To_Pointer;

   ---------------------------
   -- QTextLengthTo_Address --
   ---------------------------

      function To_Address
       (Pointer : QTextLength_Access)
          return System.Address is
      begin
         return
           QTextLength_Conversions.To_Address
            (QTextLength_Conversions.Object_Pointer
              (Pointer));
      end To_Address;

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

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

   end Internals;

end Qt4.Text_Lengths;
