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