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. --  <description> 
  25. --  Gtk.Font_Chooser.Gtk_Font_Chooser is an interface that can be implemented 
  26. --  by widgets displaying the list of fonts. In GTK+, the main objects that 
  27. --  implement this interface are 
  28. --  Gtk.Font_Chooser_Widget.Gtk_Font_Chooser_Widget, 
  29. --  Gtk.Font_Chooser_Dialog.Gtk_Font_Chooser_Dialog and 
  30. --  Gtk.Font_Button.Gtk_Font_Button. 
  31. -- 
  32. --  </description> 
  33. pragma Ada_2005; 
  34.  
  35. pragma Warnings (Off, "*is already use-visible*"); 
  36. with Glib;              use Glib; 
  37. with Glib.Object;       use Glib.Object; 
  38. with Glib.Properties;   use Glib.Properties; 
  39. with Glib.Types;        use Glib.Types; 
  40. with Pango.Font;        use Pango.Font; 
  41. with Pango.Font_Face;   use Pango.Font_Face; 
  42. with Pango.Font_Family; use Pango.Font_Family; 
  43.  
  44. package Gtk.Font_Chooser is 
  45.  
  46.    type Gtk_Font_Chooser is new Glib.Types.GType_Interface; 
  47.    Null_Gtk_Font_Chooser : constant Gtk_Font_Chooser; 
  48.  
  49.    --------------- 
  50.    -- Callbacks -- 
  51.    --------------- 
  52.  
  53.    type Gtk_Font_Filter_Func is access function 
  54.      (Family : not null access Pango.Font_Family.Pango_Font_Family_Record'Class; 
  55.       Face   : not null access Pango.Font_Face.Pango_Font_Face_Record'Class) 
  56.    return Boolean; 
  57.    --  The type of function that is used for deciding what fonts get shown in 
  58.    --  a Gtk.Font_Chooser.Gtk_Font_Chooser. See 
  59.    --  Gtk.Font_Chooser.Set_Filter_Func. 
  60.    --  "family": a Pango.Font_Family.Pango_Font_Family 
  61.    --  "face": a Pango.Font_Face.Pango_Font_Face belonging to Family 
  62.  
  63.    ------------------ 
  64.    -- Constructors -- 
  65.    ------------------ 
  66.  
  67.    function Get_Type return Glib.GType; 
  68.    pragma Import (C, Get_Type, "gtk_font_chooser_get_type"); 
  69.  
  70.    ------------- 
  71.    -- Methods -- 
  72.    ------------- 
  73.  
  74.    function Get_Font (Self : Gtk_Font_Chooser) return UTF8_String; 
  75.    --  Gets the currently-selected font name. 
  76.    --  Note that this can be a different string than what you set with 
  77.    --  Gtk.Font_Chooser.Set_Font, as the font chooser widget may normalize font 
  78.    --  names and thus return a string with a different structure. For example, 
  79.    --  "Helvetica Italic Bold 12" could be normalized to "Helvetica Bold Italic 
  80.    --  12". 
  81.    --  Use Pango.Font.Equal if you want to compare two font descriptions. 
  82.    --  Since: gtk+ 3.2 
  83.  
  84.    procedure Set_Font (Self : Gtk_Font_Chooser; Fontname : UTF8_String); 
  85.    --  Sets the currently-selected font. 
  86.    --  Since: gtk+ 3.2 
  87.    --  "fontname": a font name like "Helvetica 12" or "Times Bold 18" 
  88.  
  89.    function Get_Font_Desc 
  90.       (Self : Gtk_Font_Chooser) return Pango.Font.Pango_Font_Description; 
  91.    pragma Import (C, Get_Font_Desc, "gtk_font_chooser_get_font_desc"); 
  92.    --  Gets the currently-selected font. 
  93.    --  Note that this can be a different string than what you set with 
  94.    --  Gtk.Font_Chooser.Set_Font, as the font chooser widget may normalize font 
  95.    --  names and thus return a string with a different structure. For example, 
  96.    --  "Helvetica Italic Bold 12" could be normalized to "Helvetica Bold Italic 
  97.    --  12". 
  98.    --  Use Pango.Font.Equal if you want to compare two font descriptions. 
  99.    --  Since: gtk+ 3.2 
  100.  
  101.    procedure Set_Font_Desc 
  102.       (Self      : Gtk_Font_Chooser; 
  103.        Font_Desc : Pango.Font.Pango_Font_Description); 
  104.    pragma Import (C, Set_Font_Desc, "gtk_font_chooser_set_font_desc"); 
  105.    --  Sets the currently-selected font from Font_Desc. 
  106.    --  Since: gtk+ 3.2 
  107.    --  "font_desc": a Pango.Font.Pango_Font_Description 
  108.  
  109.    function Get_Font_Face 
  110.       (Self : Gtk_Font_Chooser) return Pango.Font_Face.Pango_Font_Face; 
  111.    --  Gets the Pango.Font_Face.Pango_Font_Face representing the selected font 
  112.    --  group details (i.e. family, slant, weight, width, etc). 
  113.    --  If the selected font is not installed, returns null. 
  114.    --  Since: gtk+ 3.2 
  115.  
  116.    function Get_Font_Family 
  117.       (Self : Gtk_Font_Chooser) return Pango.Font_Family.Pango_Font_Family; 
  118.    --  Gets the Pango.Font_Family.Pango_Font_Family representing the selected 
  119.    --  font family. Font families are a collection of font faces. 
  120.    --  If the selected font is not installed, returns null. 
  121.    --  Since: gtk+ 3.2 
  122.  
  123.    function Get_Font_Size (Self : Gtk_Font_Chooser) return Gint; 
  124.    pragma Import (C, Get_Font_Size, "gtk_font_chooser_get_font_size"); 
  125.    --  The selected font size. 
  126.    --  Since: gtk+ 3.2 
  127.  
  128.    function Get_Preview_Text (Self : Gtk_Font_Chooser) return UTF8_String; 
  129.    --  Gets the text displayed in the preview area. 
  130.    --  Since: gtk+ 3.2 
  131.  
  132.    procedure Set_Preview_Text (Self : Gtk_Font_Chooser; Text : UTF8_String); 
  133.    --  Sets the text displayed in the preview area. The Text is used to show 
  134.    --  how the selected font looks. 
  135.    --  Since: gtk+ 3.2 
  136.    --  "text": the text to display in the preview area 
  137.  
  138.    function Get_Show_Preview_Entry (Self : Gtk_Font_Chooser) return Boolean; 
  139.    --  Returns whether the preview entry is shown or not. 
  140.    --  Since: gtk+ 3.2 
  141.  
  142.    procedure Set_Show_Preview_Entry 
  143.       (Self               : Gtk_Font_Chooser; 
  144.        Show_Preview_Entry : Boolean); 
  145.    --  Shows or hides the editable preview entry. 
  146.    --  Since: gtk+ 3.2 
  147.    --  "show_preview_entry": whether to show the editable preview entry or not 
  148.  
  149.    procedure Set_Filter_Func 
  150.       (Self   : Gtk_Font_Chooser; 
  151.        Filter : Gtk_Font_Filter_Func); 
  152.    --  Adds a filter function that decides which fonts to display in the font 
  153.    --  chooser. 
  154.    --  Since: gtk+ 3.2 
  155.    --  "filter": a Gtk_Font_Filter_Func, or null 
  156.  
  157.    generic 
  158.       type User_Data_Type (<>) is private; 
  159.       with procedure Destroy (Data : in out User_Data_Type) is null; 
  160.    package Set_Filter_Func_User_Data is 
  161.  
  162.       type Gtk_Font_Filter_Func is access function 
  163.         (Family : not null access Pango.Font_Family.Pango_Font_Family_Record'Class; 
  164.          Face   : not null access Pango.Font_Face.Pango_Font_Face_Record'Class; 
  165.          Data   : User_Data_Type) return Boolean; 
  166.       --  The type of function that is used for deciding what fonts get shown in 
  167.       --  a Gtk.Font_Chooser.Gtk_Font_Chooser. See 
  168.       --  Gtk.Font_Chooser.Set_Filter_Func. 
  169.       --  "family": a Pango.Font_Family.Pango_Font_Family 
  170.       --  "face": a Pango.Font_Face.Pango_Font_Face belonging to Family 
  171.       --  "data": user data passed to Gtk.Font_Chooser.Set_Filter_Func 
  172.  
  173.       procedure Set_Filter_Func 
  174.          (Self      : Gtk.Font_Chooser.Gtk_Font_Chooser; 
  175.           Filter    : Gtk_Font_Filter_Func; 
  176.           User_Data : User_Data_Type); 
  177.       --  Adds a filter function that decides which fonts to display in the 
  178.       --  font chooser. 
  179.       --  Since: gtk+ 3.2 
  180.       --  "filter": a Gtk_Font_Filter_Func, or null 
  181.       --  "user_data": data to pass to Filter 
  182.  
  183.    end Set_Filter_Func_User_Data; 
  184.  
  185.    ---------------- 
  186.    -- Properties -- 
  187.    ---------------- 
  188.    --  The following properties are defined for this widget. See 
  189.    --  Glib.Properties for more information on properties) 
  190.  
  191.    Font_Property : constant Glib.Properties.Property_String; 
  192.    --  The font description as a string, e.g. "Sans Italic 12". 
  193.  
  194.    Font_Desc_Property : constant Pango.Font.Property_Font_Description; 
  195.    --  Type: Pango.Font.Pango_Font_Description 
  196.    --  The font description as a Pango.Font.Pango_Font_Description. 
  197.  
  198.    Preview_Text_Property : constant Glib.Properties.Property_String; 
  199.    --  The string with which to preview the font. 
  200.  
  201.    Show_Preview_Entry_Property : constant Glib.Properties.Property_Boolean; 
  202.    --  Whether to show an entry to change the preview text. 
  203.  
  204.    ------------- 
  205.    -- Signals -- 
  206.    ------------- 
  207.  
  208.    type Cb_Gtk_Font_Chooser_UTF8_String_Void is not null access procedure 
  209.      (Self     : Gtk_Font_Chooser; 
  210.       Fontname : UTF8_String); 
  211.  
  212.    type Cb_GObject_UTF8_String_Void is not null access procedure 
  213.      (Self     : access Glib.Object.GObject_Record'Class; 
  214.       Fontname : UTF8_String); 
  215.  
  216.    Signal_Font_Activated : constant Glib.Signal_Name := "font-activated"; 
  217.    procedure On_Font_Activated 
  218.       (Self  : Gtk_Font_Chooser; 
  219.        Call  : Cb_Gtk_Font_Chooser_UTF8_String_Void; 
  220.        After : Boolean := False); 
  221.    procedure On_Font_Activated 
  222.       (Self  : Gtk_Font_Chooser; 
  223.        Call  : Cb_GObject_UTF8_String_Void; 
  224.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  225.        After : Boolean := False); 
  226.    --  Emitted when a font is activated. This usually happens when the user 
  227.    --  double clicks an item, or an item is selected and the user presses one 
  228.    --  of the keys Space, Shift+Space, Return or Enter. 
  229.  
  230.    ---------------- 
  231.    -- Interfaces -- 
  232.    ---------------- 
  233.    --  This class implements several interfaces. See Glib.Types 
  234.    -- 
  235.    --  - "Gtk_Font_Chooser" 
  236.  
  237.    function "+" (W : Gtk_Font_Chooser) return Gtk_Font_Chooser; 
  238.    pragma Inline ("+"); 
  239.  
  240. private 
  241.    Show_Preview_Entry_Property : constant Glib.Properties.Property_Boolean := 
  242.      Glib.Properties.Build ("show-preview-entry"); 
  243.    Preview_Text_Property : constant Glib.Properties.Property_String := 
  244.      Glib.Properties.Build ("preview-text"); 
  245.    Font_Desc_Property : constant Pango.Font.Property_Font_Description := 
  246.      Pango.Font.Build ("font-desc"); 
  247.    Font_Property : constant Glib.Properties.Property_String := 
  248.      Glib.Properties.Build ("font"); 
  249.  
  250. Null_Gtk_Font_Chooser : constant Gtk_Font_Chooser := 
  251.    Gtk_Font_Chooser (Glib.Types.Null_Interface); 
  252. end Gtk.Font_Chooser;