------------------------------------------------------------------------------
--                                                                          --
--                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 Qt4.Rects;
with Qt4.Styles;
with Qt4_Entities;

package Qt4.Style_Options is

   package Thin is

      subtype QStyleOption is Qt4_Entities.Cpp_Class;

      function copy_QStyleOption (Cpp_Object : not null access QStyleOption)
        return not null access QStyleOption;
      pragma Import (C, copy_QStyleOption, "__Qt4Ada_copy_QStyleOption");

   end Thin;

   type Q_Style_Option is new Qt4_Entities.Entity with null record;

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> Create
   --!    <Purpose>
   --!    <Exceptions>
   ---------------------------------------------------------------------------
   function Create return Q_Style_Option;

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> Create
   --!    <Purpose>
   --!    <Exceptions>
   ---------------------------------------------------------------------------
   function State (Self : Q_Style_Option) return Qt4.Styles.State;

   procedure Set_Rect
    (Self : Q_Style_Option'Class;
     Rect : Qt4.Rects.Q_Rect);

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

   package Internals is

      --  enum QStyleOption::OptionType

      type Option_Type is new Interfaces.C.int;
      SO_Default             : constant Option_Type := 0;
      SO_Focus_Rect          : constant Option_Type := 1;
      SO_Button              : constant Option_Type := 2;
      SO_Tab                 : constant Option_Type := 3;
      SO_MenuItem            : constant Option_Type := 4;
      SO_Frame               : constant Option_Type := 5;
      SO_Progress_Bar        : constant Option_Type := 6;
      SO_Tool_Box            : constant Option_Type := 7;
      SO_Header              : constant Option_Type := 8;
      SO_Q3_Dock_Window      : constant Option_Type := 9;
      SO_Dock_Widget         : constant Option_Type := 10;
      SO_Q3_List_View_Item   : constant Option_Type := 11;
      SO_View_Item           : constant Option_Type := 12;
      SO_Tab_Widget_Frame    : constant Option_Type := 13;
      SO_TabBar_Base         : constant Option_Type := 14;
      SO_Rubber_Band         : constant Option_Type := 15;
      SO_Tool_Bar            : constant Option_Type := 16;
      SO_Graphics_Item       : constant Option_Type := 17;
      SO_Complex             : constant Option_Type := 16#000f0000#;
      SO_Slider              : constant Option_Type := 16#000f0001#;
      SO_Spin_Box            : constant Option_Type := 16#000f0002#;
      SO_Tool_Button         : constant Option_Type := 16#000f0003#;
      SO_Combo_Box           : constant Option_Type := 16#000f0004#;
      SO_Q3_List_View        : constant Option_Type := 16#000f0005#;
      SO_Title_Bar           : constant Option_Type := 16#000f0006#;
      SO_Group_Box           : constant Option_Type := 16#000f0007#;
      SO_Size_Grip           : constant Option_Type := 16#000f0008#;
      SO_Custom_Base         : constant Option_Type := 16#00000f00#;
      SO_Complex_Custom_Base : constant Option_Type := 16#0f000000#;

      --  enum QStyleOption::StyleOptionType

      type Style_Option_Type is new Interfaces.C.int;

      --  XXX вместо зарезервированного слова Type используется The_Type.
      The_Type : constant Style_Option_Type := Style_Option_Type (SO_Default);

      --  enum QStyleOption::StyleOptionVersion

      type Style_Option_Version is new Interfaces.C.int;

      Version : Style_Option_Version := 1;

      type Ada_Object_Constructor is
        access function (The_Type     : Option_Type;
                         The_Version  : Style_Option_Version;
                         Cpp_Object   : not null access Thin.QStyleOption)
           return Q_Style_Option'Class;

      ------------------------------------------------------------------------
      --! <Subprogram>
      --!    <Unit> QStyleOption_View
      --!    <Purpose> Возвращает ссылку на ассоциированный объект C++.
      --!    <Exceptions>
      ------------------------------------------------------------------------
      function QStyleOption_View (Self : Q_Style_Option'Class)
        return not null access Thin.QStyleOption;

      ------------------------------------------------------------------------
      --! <Subprogram>
      --!    <Unit> Create_Wrapper
      --!    <Purpose>
      --!    <Exceptions>
      ------------------------------------------------------------------------
      function Create_Wrapper (Cpp_Object : not null access Thin.QStyleOption)
        return Q_Style_Option'Class;

      ------------------------------------------------------------------------
      --! <Subprogram>
      --!    <Unit> Register
      --!    <Purpose> Производит регистрацию подпрограммы создания Ada объекта
      --! для инкапсуляции подклассов QStyleOption. Этот механиз используется
      --! только для классов объявленных в C++. Для классов, описанных на Ada
      --! используется реестр экземпляров событий, заполняемый при
      --! инициализации обертки и освобождаемый деструктором Ada объекта.
      --!    <Exceptions>
      -------------------------------------------------------------------------
      procedure Register (The_Type    : Option_Type;
                          The_Version : Style_Option_Version;
                          Constructor : Ada_Object_Constructor);

   end Internals;

private

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> Copy_Cpp_Object
   --!    <Purpose> Осуществляет копирование ассоциированного объекта C++.
   --!    <Exceptions>
   ---------------------------------------------------------------------------
   overriding
   function Copy_Cpp_Object (Self : not null access Q_Style_Option)
     return not null access Qt4_Entities.Cpp_Class;

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> Delete_Cpp_Object
   --!    <Purpose> Осуществляет уничтожение ассоциированного объекта C++.
   --!    <Exceptions>
   ---------------------------------------------------------------------------
   overriding
   procedure Delete_Cpp_Object (Self : not null access Q_Style_Option);

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> Default_Cpp_Object
   --!    <Purpose> Возвращает новый пустой экземпляр класса QStyleOption.
   --!    <Exceptions>
   ---------------------------------------------------------------------------
   overriding
   function Default_Cpp_Object (Self : not null access Q_Style_Option)
     return access Qt4_Entities.Cpp_Class;

end Qt4.Style_Options;
