1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --   Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet   -- 
  5. --                Copyright (C) 2000-2013, AdaCore                   -- 
  6. --                                                                   -- 
  7. -- This library is free software; you can redistribute it and/or     -- 
  8. -- modify it under the terms of the GNU General Public               -- 
  9. -- License as published by the Free Software Foundation; either      -- 
  10. -- version 2 of the License, or (at your option) any later version.  -- 
  11. --                                                                   -- 
  12. -- This library is distributed in the hope that it will be useful,   -- 
  13. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  14. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  15. -- General Public License for more details.                          -- 
  16. --                                                                   -- 
  17. -- You should have received a copy of the GNU General Public         -- 
  18. -- License along with this library; if not, write to the             -- 
  19. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  20. -- Boston, MA 02111-1307, USA.                                       -- 
  21. --                                                                   -- 
  22. -- As a special exception, if other files instantiate generics from  -- 
  23. -- this unit, or you link this unit with other files to produce an   -- 
  24. -- executable, this  unit  does not  by itself cause  the resulting  -- 
  25. -- executable to be covered by the GNU General Public License. This  -- 
  26. -- exception does not however invalidate any other reasons why the   -- 
  27. -- executable file  might be covered by the  GNU Public License.     -- 
  28. ----------------------------------------------------------------------- 
  29.  
  30. --  <description> 
  31. --  This widget provides a nice way for the user of your application to select 
  32. --  fonts. It first searches on your system for the list of fonts available, 
  33. --  and displays a set of boxes to select them based on their name, their 
  34. --  weight, their size, etc. This widget is provided in two forms, one widget 
  35. --  that can be embedded in any container, a Gtk_Font_Selection, whereas the 
  36. --  other one comes directly in its own separate window (to be popped up as a 
  37. --  dialog). 
  38. -- 
  39. --  Some filters can be applied to the widget, when you want the user to 
  40. --  select only a font only among a specific subset (like bitmap or true-type 
  41. --  fonts for instance). There are two kinds of filters: a base filter, set in 
  42. --  your application and that the user can not change; a user filter that can 
  43. --  be modified interactively by the user. 
  44. -- 
  45. --  </description> 
  46. --  <screenshot>gtk-fontsel</screenshot> 
  47. --  <group>Selectors</group> 
  48. --  <testgtk>create_font_selection.adb</testgtk> 
  49.  
  50. pragma Warnings (Off, "*is already use-visible*"); 
  51. with Gdk;             use Gdk; 
  52. with Gdk.Font;        use Gdk.Font; 
  53. with Glib;            use Glib; 
  54. with Glib.Properties; use Glib.Properties; 
  55. with Glib.Types;      use Glib.Types; 
  56. with Gtk.Box;         use Gtk.Box; 
  57. with Gtk.Buildable;   use Gtk.Buildable; 
  58. with Gtk.Enums;       use Gtk.Enums; 
  59. with Gtk.Orientable;  use Gtk.Orientable; 
  60. with Gtk.Widget;      use Gtk.Widget; 
  61.  
  62. package Gtk.Font_Selection is 
  63.  
  64.    type Gtk_Font_Selection_Record is new Gtk_Vbox_Record with null record; 
  65.    type Gtk_Font_Selection is access all Gtk_Font_Selection_Record'Class; 
  66.  
  67.    ------------------ 
  68.    -- Constructors -- 
  69.    ------------------ 
  70.  
  71.    procedure Gtk_New (Fontsel : out Gtk_Font_Selection); 
  72.    procedure Initialize (Fontsel : access Gtk_Font_Selection_Record'Class); 
  73.    --  Creates a new Gtk.Font_Selection.Gtk_Font_Selection. 
  74.  
  75.    function Get_Type return Glib.GType; 
  76.    pragma Import (C, Get_Type, "gtk_font_selection_get_type"); 
  77.  
  78.    ------------- 
  79.    -- Methods -- 
  80.    ------------- 
  81.  
  82.    function Get_Face_List 
  83.       (Fontsel : access Gtk_Font_Selection_Record) 
  84.        return Gtk.Widget.Gtk_Widget; 
  85.    --  This returns the Gtk.Treeview.Gtk_Treeview which lists all styles 
  86.    --  available for the selected font. For example, 'Regular', 'Bold', etc. 
  87.    --  Since: gtk+ 2.14 
  88.  
  89.    function Get_Family_List 
  90.       (Fontsel : access Gtk_Font_Selection_Record) 
  91.        return Gtk.Widget.Gtk_Widget; 
  92.    --  This returns the Gtk.Treeview.Gtk_Treeview that lists font families, 
  93.    --  for example, 'Sans', 'Serif', etc. 
  94.    --  Since: gtk+ 2.14 
  95.  
  96.    function Get_Font 
  97.       (Fontsel : access Gtk_Font_Selection_Record) return Gdk.Font.Gdk_Font; 
  98.    pragma Obsolescent (Get_Font); 
  99.    --  Gets the currently-selected font. 
  100.    --  Deprecated since 2.0, Use Gtk.Font_Selection.Get_Font_Name instead. 
  101.  
  102.    function Get_Font_Name 
  103.       (Fontsel : access Gtk_Font_Selection_Record) return UTF8_String; 
  104.    function Set_Font_Name 
  105.       (Fontsel  : access Gtk_Font_Selection_Record; 
  106.        Fontname : UTF8_String) return Boolean; 
  107.    --  Sets the currently-selected font. Note that the Fontsel needs to know 
  108.    --  the screen in which it will appear for this to work; this can be 
  109.    --  guaranteed by simply making sure that the such font exists or if the 
  110.    --  Fontsel doesn't belong to a particular screen yet. 
  111.    --  "fontname": a font name like "Helvetica 12" or "Times Bold 18" 
  112.  
  113.    function Get_Preview_Entry 
  114.       (Fontsel : access Gtk_Font_Selection_Record) 
  115.        return Gtk.Widget.Gtk_Widget; 
  116.    --  This returns the Gtk.GEntry.Gtk_Entry used to display the font as a 
  117.    --  preview. 
  118.    --  Since: gtk+ 2.14 
  119.  
  120.    function Get_Preview_Text 
  121.       (Fontsel : access Gtk_Font_Selection_Record) return UTF8_String; 
  122.    procedure Set_Preview_Text 
  123.       (Fontsel : access Gtk_Font_Selection_Record; 
  124.        Text    : UTF8_String); 
  125.    --  Sets the text displayed in the preview area. The Text is used to show 
  126.    --  how the selected font looks. 
  127.    --  "text": the text to display in the preview area 
  128.  
  129.    function Get_Size 
  130.       (Fontsel : access Gtk_Font_Selection_Record) return Gint; 
  131.    --  The selected font size. or -1 if no font size is selected. 
  132.    --  Since: gtk+ 2.14 
  133.  
  134.    function Get_Size_Entry 
  135.       (Fontsel : access Gtk_Font_Selection_Record) 
  136.        return Gtk.Widget.Gtk_Widget; 
  137.    --  This returns the Gtk.GEntry.Gtk_Entry used to allow the user to edit 
  138.    --  the font number manually instead of selecting it from the list of font 
  139.    --  sizes. 
  140.    --  Since: gtk+ 2.14 
  141.  
  142.    function Get_Size_List 
  143.       (Fontsel : access Gtk_Font_Selection_Record) 
  144.        return Gtk.Widget.Gtk_Widget; 
  145.    --  This returns the GtkTreeeView used to list font sizes. 
  146.    --  Since: gtk+ 2.14 
  147.  
  148.    --------------------- 
  149.    -- Interfaces_Impl -- 
  150.    --------------------- 
  151.  
  152.    function Get_Orientation 
  153.       (Self : access Gtk_Font_Selection_Record) 
  154.        return Gtk.Enums.Gtk_Orientation; 
  155.    procedure Set_Orientation 
  156.       (Self        : access Gtk_Font_Selection_Record; 
  157.        Orientation : Gtk.Enums.Gtk_Orientation); 
  158.  
  159.    ---------------- 
  160.    -- Interfaces -- 
  161.    ---------------- 
  162.    --  This class implements several interfaces. See Glib.Types 
  163.    -- 
  164.    --  - "Buildable" 
  165.    -- 
  166.    --  - "Orientable" 
  167.  
  168.    package Implements_Buildable is new Glib.Types.Implements 
  169.      (Gtk.Buildable.Gtk_Buildable, Gtk_Font_Selection_Record, Gtk_Font_Selection); 
  170.    function "+" 
  171.      (Widget : access Gtk_Font_Selection_Record'Class) 
  172.    return Gtk.Buildable.Gtk_Buildable 
  173.    renames Implements_Buildable.To_Interface; 
  174.    function "-" 
  175.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  176.    return Gtk_Font_Selection 
  177.    renames Implements_Buildable.To_Object; 
  178.  
  179.    package Implements_Orientable is new Glib.Types.Implements 
  180.      (Gtk.Orientable.Gtk_Orientable, Gtk_Font_Selection_Record, Gtk_Font_Selection); 
  181.    function "+" 
  182.      (Widget : access Gtk_Font_Selection_Record'Class) 
  183.    return Gtk.Orientable.Gtk_Orientable 
  184.    renames Implements_Orientable.To_Interface; 
  185.    function "-" 
  186.      (Interf : Gtk.Orientable.Gtk_Orientable) 
  187.    return Gtk_Font_Selection 
  188.    renames Implements_Orientable.To_Object; 
  189.  
  190.    ---------------- 
  191.    -- Properties -- 
  192.    ---------------- 
  193.    --  The following properties are defined for this widget. See 
  194.    --  Glib.Properties for more information on properties) 
  195.    -- 
  196.    --  Name: Font_Property 
  197.    --  Type: Gdk.Font 
  198.    --  Flags: read-write 
  199.    -- 
  200.    --  Name: Font_Name_Property 
  201.    --  Type: UTF8_String 
  202.    --  Flags: read-write 
  203.    -- 
  204.    --  Name: Preview_Text_Property 
  205.    --  Type: UTF8_String 
  206.    --  Flags: read-write 
  207.  
  208.    Font_Property : constant Glib.Properties.Property_Boxed; 
  209.    Font_Name_Property : constant Glib.Properties.Property_String; 
  210.    Preview_Text_Property : constant Glib.Properties.Property_String; 
  211.  
  212. private 
  213.    Font_Property : constant Glib.Properties.Property_Boxed := 
  214.      Glib.Properties.Build ("font"); 
  215.    Font_Name_Property : constant Glib.Properties.Property_String := 
  216.      Glib.Properties.Build ("font-name"); 
  217.    Preview_Text_Property : constant Glib.Properties.Property_String := 
  218.      Glib.Properties.Build ("preview-text"); 
  219. end Gtk.Font_Selection;