1. ------------------------------------------------------------------------------ 
  2. --                                                                          -- 
  3. --      Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet       -- 
  4. --                     Copyright (C) 2000-2014, AdaCore                     -- 
  5. --                                                                          -- 
  6. -- This library is free software;  you can redistribute it and/or modify it -- 
  7. -- under terms of the  GNU General Public License  as published by the Free -- 
  8. -- Software  Foundation;  either version 3,  or (at your  option) any later -- 
  9. -- version. This library is distributed in the hope that it will be useful, -- 
  10. -- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- -- 
  11. -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            -- 
  12. --                                                                          -- 
  13. -- As a special exception under Section 7 of GPL version 3, you are granted -- 
  14. -- additional permissions described in the GCC Runtime Library Exception,   -- 
  15. -- version 3.1, as published by the Free Software Foundation.               -- 
  16. --                                                                          -- 
  17. -- You should have received a copy of the GNU General Public License and    -- 
  18. -- a copy of the GCC Runtime Library Exception along with this program;     -- 
  19. -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    -- 
  20. -- <http://www.gnu.org/licenses/>.                                          -- 
  21. --                                                                          -- 
  22. ------------------------------------------------------------------------------ 
  23.  
  24. pragma Ada_2005; 
  25.  
  26. pragma Warnings (Off, "*is already use-visible*"); 
  27. with Glib;               use Glib; 
  28. with Glib.Object;        use Glib.Object; 
  29. with Pango.Enums;        use Pango.Enums; 
  30. with Pango.Font;         use Pango.Font; 
  31. with Pango.Font_Family;  use Pango.Font_Family; 
  32. with Pango.Font_Metrics; use Pango.Font_Metrics; 
  33. with Pango.Fontset;      use Pango.Fontset; 
  34. with Pango.Language;     use Pango.Language; 
  35. with Pango.Matrix;       use Pango.Matrix; 
  36.  
  37. package Pango.Context is 
  38.  
  39.    type Pango_Context_Record is new GObject_Record with null record; 
  40.    type Pango_Context is access all Pango_Context_Record'Class; 
  41.  
  42.    ------------------ 
  43.    -- Constructors -- 
  44.    ------------------ 
  45.  
  46.    procedure Gdk_New (Self : out Pango_Context); 
  47.    --  Creates a new Pango.Context.Pango_Context initialized to default 
  48.    --  values. 
  49.    --  This function is not particularly useful as it should always be 
  50.    --  followed by a pango_context_set_font_map call, and the function 
  51.    --  Pango.Font_Map.Create_Context does these two steps together and hence 
  52.    --  users are recommended to use that. 
  53.    --  If you are using Pango as part of a higher-level system, that system 
  54.    --  may have it's own way of create a Pango.Context.Pango_Context. For 
  55.    --  instance, the GTK+ toolkit has, among others, 
  56.    --  gdk_pango_context_get_for_screen, and Gtk.Widget.Get_Pango_Context. Use 
  57.    --  those instead. 
  58.  
  59.    procedure Initialize (Self : not null access Pango_Context_Record'Class); 
  60.    --  Creates a new Pango.Context.Pango_Context initialized to default 
  61.    --  values. 
  62.    --  This function is not particularly useful as it should always be 
  63.    --  followed by a pango_context_set_font_map call, and the function 
  64.    --  Pango.Font_Map.Create_Context does these two steps together and hence 
  65.    --  users are recommended to use that. 
  66.    --  If you are using Pango as part of a higher-level system, that system 
  67.    --  may have it's own way of create a Pango.Context.Pango_Context. For 
  68.    --  instance, the GTK+ toolkit has, among others, 
  69.    --  gdk_pango_context_get_for_screen, and Gtk.Widget.Get_Pango_Context. Use 
  70.    --  those instead. 
  71.  
  72.    function Pango_Context_New return Pango_Context; 
  73.    --  Creates a new Pango.Context.Pango_Context initialized to default 
  74.    --  values. 
  75.    --  This function is not particularly useful as it should always be 
  76.    --  followed by a pango_context_set_font_map call, and the function 
  77.    --  Pango.Font_Map.Create_Context does these two steps together and hence 
  78.    --  users are recommended to use that. 
  79.    --  If you are using Pango as part of a higher-level system, that system 
  80.    --  may have it's own way of create a Pango.Context.Pango_Context. For 
  81.    --  instance, the GTK+ toolkit has, among others, 
  82.    --  gdk_pango_context_get_for_screen, and Gtk.Widget.Get_Pango_Context. Use 
  83.    --  those instead. 
  84.  
  85.    function Get_Type return Glib.GType; 
  86.    pragma Import (C, Get_Type, "pango_context_get_type"); 
  87.  
  88.    ------------- 
  89.    -- Methods -- 
  90.    ------------- 
  91.  
  92.    procedure Changed (Self : not null access Pango_Context_Record); 
  93.    --  Forces a change in the context, which will cause any 
  94.    --  Pango.Layout.Pango_Layout using this context to re-layout. 
  95.    --  This function is only useful when implementing a new backend for Pango, 
  96.    --  something applications won't do. Backends should call this function if 
  97.    --  they have attached extra data to the context and such data is changed. 
  98.    --  Since: gtk+ 1.32.4 
  99.  
  100.    function Get_Base_Dir 
  101.       (Self : not null access Pango_Context_Record) 
  102.        return Pango.Enums.Direction; 
  103.    --  Retrieves the base direction for the context. See 
  104.    --  Pango.Context.Set_Base_Dir. 
  105.  
  106.    procedure Set_Base_Dir 
  107.       (Self      : not null access Pango_Context_Record; 
  108.        Direction : Pango.Enums.Direction); 
  109.    --  Sets the base direction for the context. 
  110.    --  The base direction is used in applying the Unicode bidirectional 
  111.    --  algorithm; if the Direction is Pango.Enums.Pango_Direction_Ltr or 
  112.    --  Pango.Enums.Pango_Direction_Rtl, then the value will be used as the 
  113.    --  paragraph direction in the Unicode bidirectional algorithm. A value of 
  114.    --  Pango.Enums.Pango_Direction_Weak_Ltr or 
  115.    --  Pango.Enums.Pango_Direction_Weak_Rtl is used only for paragraphs that do 
  116.    --  not contain any strong characters themselves. 
  117.    --  "direction": the new base direction 
  118.  
  119.    function Get_Base_Gravity 
  120.       (Self : not null access Pango_Context_Record) 
  121.        return Pango.Enums.Gravity; 
  122.    --  Retrieves the base gravity for the context. See 
  123.    --  Pango.Context.Set_Base_Gravity. 
  124.    --  Since: gtk+ 1.16 
  125.  
  126.    procedure Set_Base_Gravity 
  127.       (Self    : not null access Pango_Context_Record; 
  128.        Gravity : Pango.Enums.Gravity); 
  129.    --  Sets the base gravity for the context. 
  130.    --  The base gravity is used in laying vertical text out. 
  131.    --  Since: gtk+ 1.16 
  132.    --  "gravity": the new base gravity 
  133.  
  134.    function Get_Font_Description 
  135.       (Self : not null access Pango_Context_Record) 
  136.        return Pango.Font.Pango_Font_Description; 
  137.    --  Retrieve the default font description for the context. 
  138.  
  139.    procedure Set_Font_Description 
  140.       (Self : not null access Pango_Context_Record; 
  141.        Desc : Pango.Font.Pango_Font_Description); 
  142.    --  Set the default font description for the context 
  143.    --  "desc": the new pango font description 
  144.  
  145.    function Get_Gravity 
  146.       (Self : not null access Pango_Context_Record) 
  147.        return Pango.Enums.Gravity; 
  148.    --  Retrieves the gravity for the context. This is similar to 
  149.    --  Pango.Context.Get_Base_Gravity, except for when the base gravity is 
  150.    --  Pango.Enums.Pango_Gravity_Auto for which pango_gravity_get_for_matrix is 
  151.    --  used to return the gravity from the current context matrix. 
  152.    --  Since: gtk+ 1.16 
  153.  
  154.    function Get_Gravity_Hint 
  155.       (Self : not null access Pango_Context_Record) 
  156.        return Pango.Enums.GravityHint; 
  157.    --  Retrieves the gravity hint for the context. See 
  158.    --  Pango.Context.Set_Gravity_Hint for details. 
  159.    --  Since: gtk+ 1.16 
  160.  
  161.    procedure Set_Gravity_Hint 
  162.       (Self : not null access Pango_Context_Record; 
  163.        Hint : Pango.Enums.GravityHint); 
  164.    --  Sets the gravity hint for the context. 
  165.    --  The gravity hint is used in laying vertical text out, and is only 
  166.    --  relevant if gravity of the context as returned by 
  167.    --  Pango.Context.Get_Gravity is set Pango.Enums.Pango_Gravity_East or 
  168.    --  Pango.Enums.Pango_Gravity_West. 
  169.    --  Since: gtk+ 1.16 
  170.    --  "hint": the new gravity hint 
  171.  
  172.    function Get_Language 
  173.       (Self : not null access Pango_Context_Record) 
  174.        return Pango.Language.Pango_Language; 
  175.    --  Retrieves the global language tag for the context. 
  176.  
  177.    procedure Set_Language 
  178.       (Self     : not null access Pango_Context_Record; 
  179.        Language : Pango.Language.Pango_Language); 
  180.    --  Sets the global language tag for the context. The default language for 
  181.    --  the locale of the running process can be found using 
  182.    --  Pango.Language.Get_Default. 
  183.    --  "language": the new language tag. 
  184.  
  185.    function Get_Matrix 
  186.       (Self : not null access Pango_Context_Record) 
  187.        return Pango.Matrix.Pango_Matrix; 
  188.    --  Gets the transformation matrix that will be applied when rendering with 
  189.    --  this context. See Pango.Context.Set_Matrix. 
  190.    --  Since: gtk+ 1.6 
  191.  
  192.    procedure Set_Matrix 
  193.       (Self   : not null access Pango_Context_Record; 
  194.        Matrix : Pango.Matrix.Pango_Matrix); 
  195.    --  Sets the transformation matrix that will be applied when rendering with 
  196.    --  this context. Note that reported metrics are in the user space 
  197.    --  coordinates before the application of the matrix, not device-space 
  198.    --  coordinates after the application of the matrix. So, they don't scale 
  199.    --  with the matrix, though they may change slightly for different matrices, 
  200.    --  depending on how the text is fit to the pixel grid. 
  201.    --  Since: gtk+ 1.6 
  202.    --  "matrix": a Pango.Matrix.Pango_Matrix, or null to unset any existing 
  203.    --  matrix. (No matrix set is the same as setting the identity matrix.) 
  204.  
  205.    function Get_Metrics 
  206.       (Self     : not null access Pango_Context_Record; 
  207.        Desc     : Pango.Font.Pango_Font_Description; 
  208.        Language : Pango.Language.Pango_Language) 
  209.        return Pango.Font_Metrics.Pango_Font_Metrics; 
  210.    --  Get overall metric information for a particular font description. Since 
  211.    --  the metrics may be substantially different for different scripts, a 
  212.    --  language tag can be provided to indicate that the metrics should be 
  213.    --  retrieved that correspond to the script(s) used by that language. 
  214.    --  The Pango.Font.Pango_Font_Description is interpreted in the same way as 
  215.    --  by pango_itemize, and the family name may be a comma separated list of 
  216.    --  figures. If characters from multiple of these families would be used to 
  217.    --  render the string, then the returned fonts would be a composite of the 
  218.    --  metrics for the fonts loaded for the individual families. 
  219.    --  "desc": a Pango.Font.Pango_Font_Description structure. null means that 
  220.    --  the font description from the context will be used. 
  221.    --  "language": language tag used to determine which script to get the 
  222.    --  metrics for. null means that the language tag from the context will be 
  223.    --  used. If no language tag is set on the context, metrics for the default 
  224.    --  language (as determined by Pango.Language.Get_Default) will be returned. 
  225.  
  226.    function Get_Serial 
  227.       (Self : not null access Pango_Context_Record) return Guint; 
  228.    --  Returns the current serial number of Context. The serial number is 
  229.    --  initialized to an small number larger than zero when a new context is 
  230.    --  created and is increased whenever the context is changed using any of 
  231.    --  the setter functions, or the Pango.Font_Map.Pango_Font_Map it uses to 
  232.    --  find fonts has changed. The serial may wrap, but will never have the 
  233.    --  value 0. Since it can wrap, never compare it with "less than", always 
  234.    --  use "not equals". 
  235.    --  This can be used to automatically detect changes to a 
  236.    --  Pango.Context.Pango_Context, and is only useful when implementing 
  237.    --  objects that need update when their Pango.Context.Pango_Context changes, 
  238.    --  like Pango.Layout.Pango_Layout. 
  239.    --  Since: gtk+ 1.32.4 
  240.  
  241.    function List_Families 
  242.       (Self : not null access Pango_Context_Record) 
  243.        return Pango_Font_Family_Array; 
  244.    --  List all families for a context. 
  245.  
  246.    function Load_Font 
  247.       (Self : not null access Pango_Context_Record; 
  248.        Desc : Pango.Font.Pango_Font_Description) 
  249.        return Pango.Font.Pango_Font; 
  250.    --  Loads the font in one of the fontmaps in the context that is the 
  251.    --  closest match for Desc. 
  252.    --  "desc": a Pango.Font.Pango_Font_Description describing the font to load 
  253.  
  254.    function Load_Fontset 
  255.       (Self     : not null access Pango_Context_Record; 
  256.        Desc     : Pango.Font.Pango_Font_Description; 
  257.        Language : Pango.Language.Pango_Language) 
  258.        return Pango.Fontset.Pango_Fontset; 
  259.    --  Load a set of fonts in the context that can be used to render a font 
  260.    --  matching Desc. 
  261.    --  "desc": a Pango.Font.Pango_Font_Description describing the fonts to 
  262.    --  load 
  263.    --  "language": a Pango.Language.Pango_Language the fonts will be used for 
  264.  
  265. end Pango.Context;