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-2006 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. -- -- -- -- -- -- -- -- -- -- -- --
  23. ----------------------------------------------------------------------- 
  24.  
  25. --  <description> 
  26. --  This widget provides a nice way for the user of your application to 
  27. --  select fonts. 
  28. --  It first searches on your system for the list of fonts available, and 
  29. --  displays a set of boxes to select them based on their name, their 
  30. --  weight, their size, etc. 
  31. --  This widget is provided in two forms, one widget that can be embedded 
  32. --  in any container, a Gtk_Font_Selection, whereas the other one comes 
  33. --  directly in its own separate window (to be popped up as a dialog). 
  34. -- 
  35. --  Some filters can be applied to the widget, when you want the user to 
  36. --  select only a font only among a specific subset (like bitmap or 
  37. --  true-type fonts for instance). 
  38. --  There are two kinds of filters: a base filter, set in your application 
  39. --  and that the user can not change; a user filter that can be modified 
  40. --  interactively by the user. 
  41. -- 
  42. --  </description> 
  43. --  <c_version>2.8.17</c_version> 
  44. --  <group>Selectors</group> 
  45. --  <testgtk>create_font_selection.adb</testgtk> 
  46. --  <screenshot>gtk-fontsel</screenshot> 
  47.  
  48. with Glib.Properties; 
  49. with Gdk.Font; 
  50. with Gtk.Box; 
  51. with Gtk.Button; 
  52. with Gtk.Dialog; 
  53.  
  54. package Gtk.Font_Selection is 
  55.  
  56.    type Gtk_Font_Selection_Dialog_Record is new 
  57.      Gtk.Dialog.Gtk_Dialog_Record with private; 
  58.    type Gtk_Font_Selection_Dialog is access all 
  59.      Gtk_Font_Selection_Dialog_Record'Class; 
  60.  
  61.    type Gtk_Font_Selection_Record is new 
  62.      Gtk.Box.Gtk_Box_Record with private; 
  63.    type Gtk_Font_Selection is access all Gtk_Font_Selection_Record'Class; 
  64.  
  65.    ------------------------------ 
  66.    -- Font_Selection functions -- 
  67.    ------------------------------ 
  68.  
  69.    procedure Gtk_New (Widget : out Gtk_Font_Selection); 
  70.    procedure Initialize (Widget : access Gtk_Font_Selection_Record'Class); 
  71.    --  Creates or initialises a new font selection widget. 
  72.    --  It can be added to any existing container. 
  73.  
  74.    function Get_Type return Gtk.Gtk_Type; 
  75.    --  Return the internal value associated with a Gtk_Font_Selection. 
  76.  
  77.    function Set_Font_Name 
  78.      (Fontsel  : access Gtk_Font_Selection_Record; 
  79.       Fontname : String) return Boolean; 
  80.    function Get_Font_Name 
  81.      (Fontsel : access Gtk_Font_Selection_Record) return String; 
  82.    --  Set the name and attributes of the selected font in Fontsel. 
  83.    --  Fontname should have the format described in Pango.Font. 
  84.    --  Fontself must have been displayed on the screen already 
  85.  
  86.    procedure Set_Preview_Text 
  87.      (Fontsel : access Gtk_Font_Selection_Record; Text : UTF8_String); 
  88.    function Get_Preview_Text 
  89.      (Fontsel : access Gtk_Font_Selection_Record) return UTF8_String; 
  90.    --  Set or Get the string used to preview the selected font in the dialog. 
  91.  
  92.    ------------------------------------- 
  93.    -- Font_Selection_Dialog functions -- 
  94.    ------------------------------------- 
  95.  
  96.    procedure Gtk_New 
  97.      (Widget : out Gtk_Font_Selection_Dialog; Title : UTF8_String); 
  98.    procedure Initialize 
  99.      (Widget : access Gtk_Font_Selection_Dialog_Record'Class; 
  100.       Title  : UTF8_String); 
  101.    --  Creates or initialises a new dialog to select a font. 
  102.    --  The font selection widget has its own window, whose title is chosen 
  103.    --  by Title. 
  104.  
  105.    function Dialog_Get_Type return Gtk.Gtk_Type; 
  106.    --  Return the internal value associated with a Gtk_Font_Selection_Dialog. 
  107.  
  108.    function Set_Font_Name 
  109.      (Fsd      : access Gtk_Font_Selection_Dialog_Record; 
  110.       Fontname : String) return Boolean; 
  111.    function Get_Font_Name 
  112.      (Fsd : access Gtk_Font_Selection_Dialog_Record) return String; 
  113.    --  Return the name of the font selected by the user. 
  114.    --  It returns an empty string if not font is selected. 
  115.    --  The string has the same format as excepted in the Gdk.Font package. 
  116.    --  This is also the standard format on X11 systems. 
  117.  
  118.    procedure Set_Preview_Text 
  119.      (Fsd : access Gtk_Font_Selection_Dialog_Record; Text : UTF8_String); 
  120.    function Get_Preview_Text 
  121.      (Fsd : access Gtk_Font_Selection_Dialog_Record) return UTF8_String; 
  122.    --  Return the string used to preview the selected font in the dialog. 
  123.  
  124.    function Get_Cancel_Button 
  125.      (Fsd : access Gtk_Font_Selection_Dialog_Record) 
  126.       return Gtk.Button.Gtk_Button; 
  127.    --  Return the Id of the cancel button of the dialog. 
  128.    --  You can use this to set up a callback on that button. 
  129.    --  The callback should close the dialog, and ignore any value that has been 
  130.    --  set in it. 
  131.  
  132.    function Get_OK_Button 
  133.      (Fsd : access Gtk_Font_Selection_Dialog_Record) 
  134.       return Gtk.Button.Gtk_Button; 
  135.    --  Return the Id of the Ok button. 
  136.    --  The callback set on this button should close the dialog if the selected 
  137.    --  font is valid, and do whatever if should with it. 
  138.  
  139.    function Get_Apply_Button 
  140.      (Fsd : access Gtk_Font_Selection_Dialog_Record) 
  141.       return Gtk.Button.Gtk_Button; 
  142.    --  Return the Id of the Apply button. 
  143.    --  The callback on this button should temporarily apply the font, but 
  144.    --  should be able to cancel its effect if the Cancel button is selected. 
  145.  
  146.    ----------------- 
  147.    -- Obsolescent -- 
  148.    ----------------- 
  149.    --  All subprograms below are now obsolescent in gtk+. They might be removed 
  150.    --  from future versions of gtk+ (and therefore GtkAda). 
  151.    --  To find out whether your code uses any of these, we recommend compiling 
  152.    --  with the -gnatwj switch 
  153.    --  <doc_ignore> 
  154.  
  155.    function Get_Font 
  156.      (Fontsel : access Gtk_Font_Selection_Record) return Gdk.Font.Gdk_Font; 
  157.    pragma Obsolescent;  --  Get_Font 
  158.    --  Allocate and return the font selected by the user. 
  159.    --  This newly created font can be used as is by all the drawing functions 
  160.    --  in the Gdk.Drawable package. 
  161.    --  If not font has been selected, Gdk.Font.Null_Font is returned. 
  162.  
  163.    function Get_Font 
  164.      (Fsd : access Gtk_Font_Selection_Dialog_Record) return Gdk.Font.Gdk_Font; 
  165.    pragma Obsolescent;  --  Dialog_Get_Font 
  166.    --  Allocate and return the font selected by the user. 
  167.    --  This newly created font can be used as is by all the drawing functions 
  168.    --  in the Gdk.Drawable package. 
  169.    --  If not font has been selected, Gdk.Font.Null_Font is returned. 
  170.  
  171.    --  </doc_ignore> 
  172.  
  173.    ---------------- 
  174.    -- Properties -- 
  175.    ---------------- 
  176.  
  177.    --  <properties> 
  178.    --  The following properties are defined for this widget. See 
  179.    --  Glib.Properties for more information on properties. 
  180.    -- 
  181.    --  Name:  Font_Property 
  182.    --  Type:  Boxed 
  183.    --  Descr: The GdkFont that is currently selected 
  184.    -- 
  185.    --  Name:  Font_Name_Property 
  186.    --  Type:  String 
  187.    --  Descr: The X string that represents this font 
  188.    -- 
  189.    --  Name:  Preview_Text_Property 
  190.    --  Type:  String 
  191.    --  Descr: The text to display in order to demonstrate the selected font 
  192.    -- 
  193.    --  </properties> 
  194.  
  195.    --  Font_Property         : constant Glib.Properties.Property_Boxed; 
  196.    Font_Name_Property    : constant Glib.Properties.Property_String; 
  197.    Preview_Text_Property : constant Glib.Properties.Property_String; 
  198.  
  199.    ------------- 
  200.    -- Signals -- 
  201.    ------------- 
  202.  
  203.    --  <signals> 
  204.    --  The following new signals are defined for this widget: 
  205.    --  </signals> 
  206.  
  207. private 
  208.    type Gtk_Font_Selection_Dialog_Record is new 
  209.      Gtk.Dialog.Gtk_Dialog_Record with null record; 
  210.  
  211.    type Gtk_Font_Selection_Record is new 
  212.      Gtk.Box.Gtk_Box_Record with null record; 
  213.  
  214.    --     Font_Property : constant Glib.Properties.Property_Boxed := 
  215.    --       Glib.Properties.Build ("font"); 
  216.    Font_Name_Property : constant Glib.Properties.Property_String := 
  217.      Glib.Properties.Build ("font-name"); 
  218.    Preview_Text_Property : constant Glib.Properties.Property_String := 
  219.      Glib.Properties.Build ("preview-text"); 
  220.  
  221.    pragma Import (C, Get_Type, "gtk_font_selection_get_type"); 
  222.    pragma Import (C, Dialog_Get_Type, "gtk_font_selection_dialog_get_type"); 
  223.  
  224. end Gtk.Font_Selection;