------------------------------------------------------------------------------
--                                                                          --
--                An Ada2005 binding to the Qt C++ framework                --
--                                                                          --
------------------------------------------------------------------------------
--                                                                          --
-- Copyright © 2007-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) $
------------------------------------------------------------------------------
private with Ada.Finalization;
with Interfaces.C;
with Qt4.String_Lists;
with Qt4.Strings;
private with Qt_Ada.Internals.Value_Class_Sizes;
with System;

package Qt4.Fonts is

   use type Interfaces.C.int;

   --  QFont::Capitalization

   type Capitalization is
    (Mixed_Case,
     All_Uppercase,
     All_Lowercase,
     Small_Caps,
     Capitalize);
   pragma Convention (C, Capitalization);
   for Capitalization'Size use Interfaces.C.unsigned'Size;

   --  QFont::Stretch

   type Font_Stretch is new Interfaces.C.unsigned;

   Ultra_Condensed : constant Font_Stretch := 50;
   Extra_Condensed : constant Font_Stretch := 62;
   Condensed       : constant Font_Stretch := 75;
   Semi_Condensed  : constant Font_Stretch := 87;
   Unstretched     : constant Font_Stretch := 100;
   Semi_Expanded   : constant Font_Stretch := 112;
   Expanded        : constant Font_Stretch := 125;
   Extra_Expanded  : constant Font_Stretch := 150;
   Ultra_Expanded  : constant Font_Stretch := 200;

   --  QFont::Style

   type Font_Style is
    (Style_Normal,
     Style_Italic,
     Style_Oblique);
   pragma Convention (C, Font_Style);
   for Font_Style'Size use Interfaces.C.unsigned'Size;

   --  QFont::StyleHint

   type Font_Style_Hint is
    (Helvetica,
     Times,
     Courier,
     Old_English,
     System_Font,
     Any_Style);
   pragma Convention (C, Font_Style_Hint);
   for Font_Style_Hint'Size use Interfaces.C.unsigned'Size;

   Sans_Serif  : constant Font_Style_Hint := Helvetica;
   Serif       : constant Font_Style_Hint := Times;
   Type_Writer : constant Font_Style_Hint := Courier;
   Decorative  : constant Font_Style_Hint := Old_English;

   --  QFont::Weight

   type Font_Weight is new Interfaces.C.int range -1 .. 99;

   Weight_Unspecified : constant Font_Weight := -1;
   Weight_Light       : constant Font_Weight := 25;
   Weight_Normal      : constant Font_Weight := 50;
   Weight_Demi_Bold   : constant Font_Weight := 63;
   Weight_Bold        : constant Font_Weight := 75;
   Weight_Black       : constant Font_Weight := 87;

   type Q_Font is tagged private;

   function Create
     return Q_Font;

   function Create
    (Family : Qt4.Strings.Q_String'Class;
     Point_Size : Qt4.Q_Integer
       := -1;
     Weight : Font_Weight
       := Weight_Unspecified;
     Italic : Boolean
       := False)
       return Q_Font;

   function Bold
    (Self : Q_Font'Class)
       return Boolean;

   function Default_Family
    (Self : Q_Font'Class)
       return Qt4.Strings.Q_String;

   function Exact_Match
    (Self : Q_Font'Class)
       return Boolean;

   function Family
    (Self : Q_Font'Class)
       return Qt4.Strings.Q_String;

   function Fixed_Pitch
    (Self : Q_Font'Class)
       return Boolean;

   function From_String
    (Self : not null access Q_Font'Class;
     Descrip : Qt4.Strings.Q_String'Class)
       return Boolean;

   function Is_Copy_Of
    (Self : Q_Font'Class;
     F : Q_Font'Class)
       return Boolean;

   function Italic
    (Self : Q_Font'Class)
       return Boolean;

   function Kerning
    (Self : Q_Font'Class)
       return Boolean;

   function Key
    (Self : Q_Font'Class)
       return Qt4.Strings.Q_String;

   function Last_Resort_Family
    (Self : Q_Font'Class)
       return Qt4.Strings.Q_String;

   function Last_Resort_Font
    (Self : Q_Font'Class)
       return Qt4.Strings.Q_String;

   function Overline
    (Self : Q_Font'Class)
       return Boolean;

   function Pixel_Size
    (Self : Q_Font'Class)
       return Qt4.Q_Integer;

   function Point_Size
    (Self : Q_Font'Class)
       return Qt4.Q_Integer;

   function Point_Size_F
    (Self : Q_Font'Class)
       return Qt4.Q_Real;

   function Raw_Mode
    (Self : Q_Font'Class)
       return Boolean;

   function Raw_Name
    (Self : Q_Font'Class)
       return Qt4.Strings.Q_String;

   function Resolve
    (Self : Q_Font'Class;
     F : Q_Font'Class)
       return Q_Font;

   procedure Set_Bold
    (Self : in out Q_Font'Class;
     Enable : Boolean);

   procedure Set_Family
    (Self : in out Q_Font'Class;
     Family : Qt4.Strings.Q_String'Class);

   procedure Set_Fixed_Pitch
    (Self : in out Q_Font'Class;
     Enable : Boolean);

   procedure Set_Italic
    (Self : in out Q_Font'Class;
     Enable : Boolean);

   procedure Set_Kerning
    (Self : in out Q_Font'Class;
     Enable : Boolean);

   procedure Set_Overline
    (Self : in out Q_Font'Class;
     Enable : Boolean);

   procedure Set_Pixel_Size
    (Self : in out Q_Font'Class;
     Size : Qt4.Q_Integer);

   procedure Set_Point_Size
    (Self : in out Q_Font'Class;
     Size : Qt4.Q_Integer);

   procedure Set_Point_Size_F
    (Self : in out Q_Font'Class;
     Size : Qt4.Q_Real);

   procedure Set_Raw_Mode
    (Self : in out Q_Font'Class;
     Enable : Boolean);

   procedure Set_Raw_Name
    (Self : in out Q_Font'Class;
     Name : Qt4.Strings.Q_String'Class);

   procedure Set_Stretch
    (Self : in out Q_Font'Class;
     Factor : Font_Stretch);

   procedure Set_Strike_Out
    (Self : in out Q_Font'Class;
     Enable : Boolean);

   procedure Set_Style
    (Self : in out Q_Font'Class;
     Style : Font_Style);

   procedure Set_Underline
    (Self : in out Q_Font'Class;
     Enable : Boolean);

   procedure Set_Weight
    (Self : in out Q_Font'Class;
     Weight : Font_Weight);

   function Stretch
    (Self : Q_Font'Class)
       return Font_Stretch;

   function Strike_Out
    (Self : Q_Font'Class)
       return Boolean;

   function Style
    (Self : Q_Font'Class)
       return Font_Style;

   function Style_Hint
    (Self : Q_Font'Class)
       return Font_Style_Hint;

   function To_String
    (Self : Q_Font'Class)
       return Qt4.Strings.Q_String;

   function Underline
    (Self : Q_Font'Class)
       return Boolean;

   function Weight
    (Self : Q_Font'Class)
       return Font_Weight;

   function "="
    (Self : Q_Font;
     F : Q_Font)
       return Boolean;

   function "<"
    (Self : Q_Font;
     F : Q_Font)
       return Boolean;

   procedure Insert_Substitution
    (Family_Name : Qt4.Strings.Q_String'Class;
     Substitute_Name : Qt4.Strings.Q_String'Class);

   procedure Insert_Substitutions
    (Family_Name : Qt4.Strings.Q_String'Class;
     Substitute_Names : Qt4.String_Lists.Q_String_List'Class);

   procedure Remove_Substitution
    (Family_Name : Qt4.Strings.Q_String'Class);

   function Substitute
    (Family_Name : Qt4.Strings.Q_String'Class)
       return Qt4.Strings.Q_String;

   function Substitutes
    (Family_Name : Qt4.Strings.Q_String'Class)
       return Qt4.String_Lists.Q_String_List;

   function Substitutions
     return Qt4.String_Lists.Q_String_List;

   package Internals is

      type QFont is private;

      type QFont_Access is access all QFont;
      pragma Convention (C, QFont_Access);

      function QFont_View
       (Item : Q_Font'Class)
          return QFont_Access;
      pragma Inline (QFont_View);

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

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

      function Create_Wrapper
       (Item : Internals.QFont_Access)
          return Q_Font;

   private

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

   end Internals;

private

   type Q_Font is new Ada.Finalization.Controlled with record
      Storage : aliased Internals.QFont;
      Object  : Internals.QFont_Access := null;
      Wrapper : Boolean := False;
   end record;

   overriding
   procedure Adjust (Self : in out Q_Font);

   overriding
   procedure Finalize (Self : in out Q_Font);

   overriding
   procedure Initialize (Self : in out Q_Font);

end Qt4.Fonts;
