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. --  This widget provides a nice way for the user of your application to select 
  26. --  fonts. It first searches on your system for the list of fonts available, 
  27. --  and displays a set of boxes to select them based on their name, their 
  28. --  weight, their size, etc. This widget is provided in two forms, one widget 
  29. --  that can be embedded in any container, a Gtk_Font_Selection, whereas the 
  30. --  other one comes directly in its own separate window (to be popped up as a 
  31. --  dialog). 
  32. -- 
  33. --  Some filters can be applied to the widget, when you want the user to 
  34. --  select only a font only among a specific subset (like bitmap or true-type 
  35. --  fonts for instance). There are two kinds of filters: a base filter, set in 
  36. --  your application and that the user can not change; a user filter that can 
  37. --  be modified interactively by the user. 
  38. -- 
  39. --  </description> 
  40. --  <screenshot>gtk-fontsel</screenshot> 
  41. --  <group>Selectors</group> 
  42. --  <testgtk>create_font_selection.adb</testgtk> 
  43. pragma Ada_2005; 
  44.  
  45. pragma Warnings (Off, "*is already use-visible*"); 
  46. with Glib;            use Glib; 
  47. with Glib.Properties; use Glib.Properties; 
  48. with Glib.Types;      use Glib.Types; 
  49. with Gtk.Box;         use Gtk.Box; 
  50. with Gtk.Buildable;   use Gtk.Buildable; 
  51. with Gtk.Enums;       use Gtk.Enums; 
  52. with Gtk.Orientable;  use Gtk.Orientable; 
  53. with Gtk.Widget;      use Gtk.Widget; 
  54.  
  55. package Gtk.Font_Selection is 
  56.  
  57.    type Gtk_Font_Selection_Record is new Gtk_Box_Record with null record; 
  58.    type Gtk_Font_Selection is access all Gtk_Font_Selection_Record'Class; 
  59.  
  60.    ------------------ 
  61.    -- Constructors -- 
  62.    ------------------ 
  63.  
  64.    procedure Gtk_New (Fontsel : out Gtk_Font_Selection); 
  65.    procedure Initialize 
  66.       (Fontsel : not null access Gtk_Font_Selection_Record'Class); 
  67.    --  Creates a new Gtk.Font_Selection.Gtk_Font_Selection. 
  68.  
  69.    function Gtk_Font_Selection_New return Gtk_Font_Selection; 
  70.    --  Creates a new Gtk.Font_Selection.Gtk_Font_Selection. 
  71.  
  72.    function Get_Type return Glib.GType; 
  73.    pragma Import (C, Get_Type, "gtk_font_selection_get_type"); 
  74.  
  75.    ------------- 
  76.    -- Methods -- 
  77.    ------------- 
  78.  
  79.    function Get_Face_List 
  80.       (Fontsel : not null access Gtk_Font_Selection_Record) 
  81.        return Gtk.Widget.Gtk_Widget; 
  82.    pragma Obsolescent (Get_Face_List); 
  83.    --  This returns the Gtk.Tree_View.Gtk_Tree_View which lists all styles 
  84.    --  available for the selected font. For example, 'Regular', 'Bold', etc. 
  85.    --  Since: gtk+ 2.14 
  86.    --  Deprecated since 3.2, Use Gtk.Font_Chooser.Gtk_Font_Chooser 
  87.  
  88.    function Get_Family_List 
  89.       (Fontsel : not null access Gtk_Font_Selection_Record) 
  90.        return Gtk.Widget.Gtk_Widget; 
  91.    pragma Obsolescent (Get_Family_List); 
  92.    --  This returns the Gtk.Tree_View.Gtk_Tree_View that lists font families, 
  93.    --  for example, 'Sans', 'Serif', etc. 
  94.    --  Since: gtk+ 2.14 
  95.    --  Deprecated since 3.2, Use Gtk.Font_Chooser.Gtk_Font_Chooser 
  96.  
  97.    function Get_Font_Name 
  98.       (Fontsel : not null access Gtk_Font_Selection_Record) 
  99.        return UTF8_String; 
  100.    pragma Obsolescent (Get_Font_Name); 
  101.    --  Gets the currently-selected font name. 
  102.    --  Note that this can be a different string than what you set with 
  103.    --  Gtk.Font_Selection.Set_Font_Name, as the font selection widget may 
  104.    --  normalize font names and thus return a string with a different 
  105.    --  structure. For example, "Helvetica Italic Bold 12" could be normalized 
  106.    --  to "Helvetica Bold Italic 12". Use Pango.Font.Equal if you want to 
  107.    --  compare two font descriptions. 
  108.    --  Deprecated since 3.2, Use Gtk.Font_Chooser.Gtk_Font_Chooser 
  109.  
  110.    function Set_Font_Name 
  111.       (Fontsel  : not null access Gtk_Font_Selection_Record; 
  112.        Fontname : UTF8_String) return Boolean; 
  113.    pragma Obsolescent (Set_Font_Name); 
  114.    --  Sets the currently-selected font. 
  115.    --  Note that the Fontsel needs to know the screen in which it will appear 
  116.    --  for this to work; this can be guaranteed by simply making sure that the 
  117.    --  Fontsel is inserted in a toplevel window before you call this function. 
  118.    --  Deprecated since 3.2, Use Gtk.Font_Chooser.Gtk_Font_Chooser 
  119.    --  "fontname": a font name like "Helvetica 12" or "Times Bold 18" 
  120.  
  121.    function Get_Preview_Entry 
  122.       (Fontsel : not null access Gtk_Font_Selection_Record) 
  123.        return Gtk.Widget.Gtk_Widget; 
  124.    pragma Obsolescent (Get_Preview_Entry); 
  125.    --  This returns the Gtk.GEntry.Gtk_Entry used to display the font as a 
  126.    --  preview. 
  127.    --  Since: gtk+ 2.14 
  128.    --  Deprecated since 3.2, Use Gtk.Font_Chooser.Gtk_Font_Chooser 
  129.  
  130.    function Get_Preview_Text 
  131.       (Fontsel : not null access Gtk_Font_Selection_Record) 
  132.        return UTF8_String; 
  133.    pragma Obsolescent (Get_Preview_Text); 
  134.    --  Gets the text displayed in the preview area. 
  135.    --  Deprecated since 3.2, Use Gtk.Font_Chooser.Gtk_Font_Chooser 
  136.  
  137.    procedure Set_Preview_Text 
  138.       (Fontsel : not null access Gtk_Font_Selection_Record; 
  139.        Text    : UTF8_String); 
  140.    pragma Obsolescent (Set_Preview_Text); 
  141.    --  Sets the text displayed in the preview area. The Text is used to show 
  142.    --  how the selected font looks. 
  143.    --  Deprecated since 3.2, Use Gtk.Font_Chooser.Gtk_Font_Chooser 
  144.    --  "text": the text to display in the preview area 
  145.  
  146.    function Get_Size 
  147.       (Fontsel : not null access Gtk_Font_Selection_Record) return Gint; 
  148.    pragma Obsolescent (Get_Size); 
  149.    --  The selected font size. 
  150.    --  Since: gtk+ 2.14 
  151.    --  Deprecated since 3.2, Use Gtk.Font_Chooser.Gtk_Font_Chooser 
  152.  
  153.    function Get_Size_Entry 
  154.       (Fontsel : not null access Gtk_Font_Selection_Record) 
  155.        return Gtk.Widget.Gtk_Widget; 
  156.    pragma Obsolescent (Get_Size_Entry); 
  157.    --  This returns the Gtk.GEntry.Gtk_Entry used to allow the user to edit 
  158.    --  the font number manually instead of selecting it from the list of font 
  159.    --  sizes. 
  160.    --  Since: gtk+ 2.14 
  161.    --  Deprecated since 3.2, Use Gtk.Font_Chooser.Gtk_Font_Chooser 
  162.  
  163.    function Get_Size_List 
  164.       (Fontsel : not null access Gtk_Font_Selection_Record) 
  165.        return Gtk.Widget.Gtk_Widget; 
  166.    pragma Obsolescent (Get_Size_List); 
  167.    --  This returns the Gtk.Tree_View.Gtk_Tree_View used to list font sizes. 
  168.    --  Since: gtk+ 2.14 
  169.    --  Deprecated since 3.2, Use Gtk.Font_Chooser.Gtk_Font_Chooser 
  170.  
  171.    --------------------------------------------- 
  172.    -- Inherited subprograms (from interfaces) -- 
  173.    --------------------------------------------- 
  174.    --  Methods inherited from the Buildable interface are not duplicated here 
  175.    --  since they are meant to be used by tools, mostly. If you need to call 
  176.    --  them, use an explicit cast through the "-" operator below. 
  177.  
  178.    function Get_Orientation 
  179.       (Self : not null access Gtk_Font_Selection_Record) 
  180.        return Gtk.Enums.Gtk_Orientation; 
  181.  
  182.    procedure Set_Orientation 
  183.       (Self        : not null access Gtk_Font_Selection_Record; 
  184.        Orientation : Gtk.Enums.Gtk_Orientation); 
  185.  
  186.    ---------------- 
  187.    -- Properties -- 
  188.    ---------------- 
  189.    --  The following properties are defined for this widget. See 
  190.    --  Glib.Properties for more information on properties) 
  191.  
  192.    Font_Name_Property : constant Glib.Properties.Property_String; 
  193.  
  194.    Preview_Text_Property : constant Glib.Properties.Property_String; 
  195.  
  196.    ---------------- 
  197.    -- Interfaces -- 
  198.    ---------------- 
  199.    --  This class implements several interfaces. See Glib.Types 
  200.    -- 
  201.    --  - "Buildable" 
  202.    -- 
  203.    --  - "Orientable" 
  204.  
  205.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  206.      (Gtk.Buildable.Gtk_Buildable, Gtk_Font_Selection_Record, Gtk_Font_Selection); 
  207.    function "+" 
  208.      (Widget : access Gtk_Font_Selection_Record'Class) 
  209.    return Gtk.Buildable.Gtk_Buildable 
  210.    renames Implements_Gtk_Buildable.To_Interface; 
  211.    function "-" 
  212.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  213.    return Gtk_Font_Selection 
  214.    renames Implements_Gtk_Buildable.To_Object; 
  215.  
  216.    package Implements_Gtk_Orientable is new Glib.Types.Implements 
  217.      (Gtk.Orientable.Gtk_Orientable, Gtk_Font_Selection_Record, Gtk_Font_Selection); 
  218.    function "+" 
  219.      (Widget : access Gtk_Font_Selection_Record'Class) 
  220.    return Gtk.Orientable.Gtk_Orientable 
  221.    renames Implements_Gtk_Orientable.To_Interface; 
  222.    function "-" 
  223.      (Interf : Gtk.Orientable.Gtk_Orientable) 
  224.    return Gtk_Font_Selection 
  225.    renames Implements_Gtk_Orientable.To_Object; 
  226.  
  227. private 
  228.    Preview_Text_Property : constant Glib.Properties.Property_String := 
  229.      Glib.Properties.Build ("preview-text"); 
  230.    Font_Name_Property : constant Glib.Properties.Property_String := 
  231.      Glib.Properties.Build ("font-name"); 
  232. end Gtk.Font_Selection;