------------------------------------------------------------------------------
--                                                                          --
--                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: 3769 $ $Date: 2010-10-24 03:16:28 +0400 (Sun, 24 Oct 2010) $
------------------------------------------------------------------------------
with Ada.Finalization;

package body Qt4.Style_Option_View_Items is

   procedure font_wrapper
     (Self   : not null access Qt4.Style_Options.Thin.QStyleOption;
      Result : not null access Qt4.Fonts.Internals.QFont);
   pragma Import
    (C, font_wrapper, "__Qt4Ada_QStyleOptionViewItem_font_wrapper");

   procedure palette_wrapper
     (Self   : not null access Qt4.Style_Options.Thin.QStyleOption;
      Result : not null access Qt4.Palettes.Thin.QPalette);
   pragma Import
    (C, palette_wrapper, "__Qt4Ada_QStyleOptionViewItem_palette_wrapper");

   function state_wrapper
     (Self : not null access Qt4.Style_Options.Thin.QStyleOption)
       return Qt4.Styles.State;
   pragma Import
    (C, state_wrapper, "__Qt4Ada_QStyleOptionViewItem_state_wrapper");

   procedure setState_wrapper
    (Self  : not null access Qt4.Style_Options.Thin.QStyleOption;
     State : Qt4.Styles.State);
   pragma Import
    (C, setState_wrapper, "__Qt4Ada_QStyleOptionViewItem_setState_wrapper");

   function type_wrapper
    (Self : not null access Qt4.Style_Options.Thin.QStyleOption)
       return Interfaces.C.int;
   pragma Import
    (C, type_wrapper, "__Qt4Ada_QStyleOptionViewItem_type_wrapper");

   function version_wrapper
    (Self : not null access Qt4.Style_Options.Thin.QStyleOption)
       return Interfaces.C.int;
   pragma Import
    (C, version_wrapper, "__Qt4Ada_QStyleOptionViewItem_version_wrapper");

   function new_QStyleOptionViewItem
     return not null access Qt4_Entities.Cpp_Class;
   pragma Import
    (C, new_QStyleOptionViewItem, "__Qt4Ada_new_QStyleOptionViewItem");

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> Create
   --!    <Purpose>
   --!    <Exceptions>
   ---------------------------------------------------------------------------
   function Create
    (The_Type    : Qt4.Style_Options.Internals.Option_Type;
     The_Version : Qt4.Style_Options.Internals.Style_Option_Version;
     Cpp_Object  : not null access Qt4.Style_Options.Thin.QStyleOption)
       return Qt4.Style_Options.Q_Style_Option'Class;

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> Create
   --!    <ImplementationNotes>
   ---------------------------------------------------------------------------
   function Create
    (The_Type    : Qt4.Style_Options.Internals.Option_Type;
     The_Version : Qt4.Style_Options.Internals.Style_Option_Version;
     Cpp_Object  : not null access Qt4.Style_Options.Thin.QStyleOption)
       return Qt4.Style_Options.Q_Style_Option'Class
   is
      use type Qt4.Style_Options.Internals.Option_Type;
      use type Qt4.Style_Options.Internals.Style_Option_Version;

   begin
      if The_Type /= Qt4.Style_Options.Internals.SO_View_Item
        and The_Version /= 1
      then
         raise Program_Error;
      end if;

      return
        Q_Style_Option_View_Item'
         (Ada.Finalization.Controlled with
            Cpp_Object => Cpp_Object,
            Role       => Qt4_Entities.Wrapper,
            Class      => Qt4_Entities.Static,
            others     => <>);
   end Create;

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> Default_Cpp_Object
   --!    <ImplementationNotes>
   ---------------------------------------------------------------------------
   overriding function Default_Cpp_Object
    (Self : not null access Q_Style_Option_View_Item)
     return access Qt4_Entities.Cpp_Class
   is
      pragma Unreferenced (Self);
      --  XXX параметр не используется и нужен для диспетчеризации вызова.

   begin
      return new_QStyleOptionViewItem;
   end Default_Cpp_Object;

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> Font
   --!    <ImplementationNotes>
   ---------------------------------------------------------------------------
   function Font (Self : Q_Style_Option_View_Item) return Qt4.Fonts.Q_Font
   is
   begin
      return Result : Qt4.Fonts.Q_Font do
         font_wrapper
          (Qt4.Style_Options.Internals.QStyleOption_View (Self),
           Qt4.Fonts.Internals.QFont_View (Result));
      end return;
   end Font;

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> Version
   --!    <ImplementationNotes>
   ---------------------------------------------------------------------------
   function Get_Type (Self : Q_Style_Option_View_Item)
     return Q_Integer
   is
   begin
      return Q_Integer
              (type_wrapper
              (Qt4.Style_Options.Internals.QStyleOption_View (Self)));
   end Get_Type;

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> Palette
   --!    <ImplementationNotes>
   ---------------------------------------------------------------------------
   function Palette (Self : Q_Style_Option_View_Item)
     return Qt4.Palettes.Q_Palette
   is
   begin
      return Result : Qt4.Palettes.Q_Palette do
         palette_wrapper (Qt4.Style_Options.Internals.QStyleOption_View (Self),
                          Qt4.Palettes.Internals.QPalette_View (Result));
      end return;
   end Palette;

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> State
   --!    <ImplementationNotes>
   ---------------------------------------------------------------------------
   procedure Set_State
    (Self : Q_Style_Option_View_Item; State : Qt4.Styles.State)
   is
   begin
      setState_wrapper (Qt4.Style_Options.Internals.QStyleOption_View (Self),
                        State);
   end Set_State;

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> State
   --!    <ImplementationNotes>
   ---------------------------------------------------------------------------
   overriding function State
    (Self : Q_Style_Option_View_Item) return Qt4.Styles.State is
   begin
      return state_wrapper
              (Qt4.Style_Options.Internals.QStyleOption_View (Self));
   end State;

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> Version
   --!    <ImplementationNotes>
   ---------------------------------------------------------------------------
   function Version (Self : Q_Style_Option_View_Item)
     return Q_Integer
   is
   begin
      return Q_Integer
              (version_wrapper
              (Qt4.Style_Options.Internals.QStyleOption_View (Self)));
   end Version;

begin
   Qt4.Style_Options.Internals.Register
    (Qt4.Style_Options.Internals.SO_View_Item, 1, Create'Access);
end Qt4.Style_Option_View_Items;
