1. ----------------------------------------------------------------------- 
  2. --              GtkAda - Ada95 binding for Gtk+/Gnome                -- 
  3. --                                                                   -- 
  4. --                Copyright (C) 2006-2007 AdaCore                    -- 
  5. --                                                                   -- 
  6. -- This library is free software; you can redistribute it and/or     -- 
  7. -- modify it under the terms of the GNU General Public               -- 
  8. -- License as published by the Free Software Foundation; either      -- 
  9. -- version 2 of the License, or (at your option) any later version.  -- 
  10. --                                                                   -- 
  11. -- This library is distributed in the hope that it will be useful,   -- 
  12. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  13. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  14. -- General Public License for more details.                          -- 
  15. --                                                                   -- 
  16. -- You should have received a copy of the GNU General Public         -- 
  17. -- License along with this library; if not, write to the             -- 
  18. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  19. -- Boston, MA 02111-1307, USA.                                       -- 
  20. --                                                                   -- 
  21. -- As a special exception, if other files instantiate generics from  -- 
  22. -- this unit, or you link this unit with other files to produce an   -- 
  23. -- executable, this  unit  does not  by itself cause  the resulting  -- 
  24. -- executable to be covered by the GNU General Public License. This  -- 
  25. -- exception does not however invalidate any other reasons why the   -- 
  26. -- executable file  might be covered by the  GNU Public License.     -- 
  27. ----------------------------------------------------------------------- 
  28.  
  29. --  <description> 
  30. --  The Gtk_Font_Button is a button which displays the currently selected font 
  31. --  an allows to open a font selection dialog to change the font. It is 
  32. --  suitable widget for selecting a font in a preference dialog. 
  33. --  </description> 
  34. --  <c_version>2.8.17</c_version> 
  35. --  <group>Selectors</group> 
  36. --  <screenshot>font-button.png</screenshot> 
  37.  
  38. with Glib.Properties; 
  39. with Gtk.Button; 
  40.  
  41. package Gtk.Font_Button is 
  42.  
  43.    type Gtk_Font_Button_Record is new Gtk.Button.Gtk_Button_Record with 
  44.      null record; 
  45.    type Gtk_Font_Button is access all Gtk_Font_Button_Record'Class; 
  46.  
  47.    procedure Gtk_New (Font_Button : out Gtk_Font_Button); 
  48.    procedure Initialize (Font_Button : access Gtk_Font_Button_Record'Class); 
  49.    --  Creates a new font picker widget. 
  50.  
  51.    procedure Gtk_New_With_Font 
  52.      (Font_Button : out Gtk_Font_Button; Fontname : String); 
  53.    procedure Initialize_With_Font 
  54.      (Font_Button : access Gtk_Font_Button_Record'Class; Fontname : String); 
  55.    --  Creates a new font picker widget. 
  56.  
  57.    function Get_Type return Gtk.Gtk_Type; 
  58.    --  Return the internal value associated with a Gtk_Font_Button 
  59.  
  60.    function Set_Font_Name 
  61.      (Font_Button : access Gtk_Font_Button_Record; 
  62.       Fontname    : String) return Boolean; 
  63.    function Get_Font_Name 
  64.      (Font_Button : access Gtk_Font_Button_Record) return String; 
  65.    --  Sets or updates the currently-displayed font in font picker dialog. 
  66.    --  Returns the value of Gtk.Font_Selection.Set_Font_Name if the font 
  67.    --  selection dialog exists, False otherwise. 
  68.  
  69.    procedure Set_Show_Size 
  70.      (Font_Button : access Gtk_Font_Button_Record; Show_Size : Boolean); 
  71.    function Get_Show_Size 
  72.      (Font_Button : access Gtk_Font_Button_Record) return Boolean; 
  73.    --  If Show_Size is True, the font size will be displayed along with the 
  74.    --  name of the selected font. 
  75.  
  76.    procedure Set_Show_Style 
  77.      (Font_Button : access Gtk_Font_Button_Record; Show_Style : Boolean); 
  78.    function Get_Show_Style 
  79.      (Font_Button : access Gtk_Font_Button_Record) return Boolean; 
  80.    --  Returns whether the name of the font style will be shown in the label. 
  81.  
  82.    procedure Set_Title 
  83.      (Font_Button : access Gtk_Font_Button_Record; Title : String); 
  84.    function Get_Title 
  85.      (Font_Button : access Gtk_Font_Button_Record) return String; 
  86.    --  Retrieves the title of the font selection dialog. 
  87.  
  88.    procedure Set_Use_Font 
  89.      (Font_Button : access Gtk_Font_Button_Record; Use_Font : Boolean); 
  90.    function Get_Use_Font 
  91.      (Font_Button : access Gtk_Font_Button_Record) return Boolean; 
  92.    --  If Use_Font is True, the font name will be written using the selected 
  93.    --  font. 
  94.  
  95.    procedure Set_Use_Size 
  96.      (Font_Button : access Gtk_Font_Button_Record; Use_Size : Boolean); 
  97.    function Get_Use_Size 
  98.      (Font_Button : access Gtk_Font_Button_Record) return Boolean; 
  99.    --  If Use_Size is True, the font name will be written using the selected 
  100.    --  size. 
  101.  
  102.    ---------------- 
  103.    -- Properties -- 
  104.    ---------------- 
  105.  
  106.    --  <properties> 
  107.    --  The following properties are defined for this widget. See 
  108.    --  Glib.Properties for more information on properties. 
  109.    -- 
  110.    --  Name:  Font_Name_Property 
  111.    --  Type:  String 
  112.    --  Descr: The name of the selected font 
  113.    -- 
  114.    --  Name:  Show_Size_Property 
  115.    --  Type:  Boolean 
  116.    --  Descr: Whether selected font size is shown in the label 
  117.    -- 
  118.    --  Name:  Show_Style_Property 
  119.    --  Type:  Boolean 
  120.    --  Descr: Whether the selected font style is shown in the label 
  121.    -- 
  122.    --  Name:  Title_Property 
  123.    --  Type:  String 
  124.    --  Descr: The title of the font selection dialog 
  125.    -- 
  126.    --  Name:  Use_Font_Property 
  127.    --  Type:  Boolean 
  128.    --  Descr: Whether the label is drawn in the selected font 
  129.    -- 
  130.    --  Name:  Use_Size_Property 
  131.    --  Type:  Boolean 
  132.    --  Descr: Whether the label is drawn with the selected font size 
  133.    -- 
  134.    --  </properties> 
  135.  
  136.    Font_Name_Property  : constant Glib.Properties.Property_String; 
  137.    Show_Size_Property  : constant Glib.Properties.Property_Boolean; 
  138.    Show_Style_Property : constant Glib.Properties.Property_Boolean; 
  139.    Title_Property      : constant Glib.Properties.Property_String; 
  140.    Use_Font_Property   : constant Glib.Properties.Property_Boolean; 
  141.    Use_Size_Property   : constant Glib.Properties.Property_Boolean; 
  142.  
  143.    ------------- 
  144.    -- Signals -- 
  145.    ------------- 
  146.  
  147.    --  <signals> 
  148.    --  The following new signals are defined for this widget: 
  149.    -- 
  150.    --  - "font-set" 
  151.    --    procedure Handler (Button : access Gtk_Font_Button_Record'Class); 
  152.    --    The font-set signal is emitted when the user selects a font. When 
  153.    --    handling this signal, use Get_Font_Name to find out which font was 
  154.    --    just selected. 
  155.    --    Note that this signal is only emitted when the user changes the font. 
  156.    --    If you need to react to programmatic font changes as well, use the 
  157.    --    notify::font-name signal. 
  158.    --  </signals> 
  159.  
  160.    Signal_Font_Set : constant Glib.Signal_Name := "font-set"; 
  161.  
  162. private 
  163.    Font_Name_Property : constant Glib.Properties.Property_String := 
  164.      Glib.Properties.Build ("font-name"); 
  165.    Show_Size_Property : constant Glib.Properties.Property_Boolean := 
  166.      Glib.Properties.Build ("show-size"); 
  167.    Show_Style_Property : constant Glib.Properties.Property_Boolean := 
  168.      Glib.Properties.Build ("show-style"); 
  169.    Title_Property : constant Glib.Properties.Property_String := 
  170.      Glib.Properties.Build ("title"); 
  171.    Use_Font_Property : constant Glib.Properties.Property_Boolean := 
  172.      Glib.Properties.Build ("use-font"); 
  173.    Use_Size_Property : constant Glib.Properties.Property_Boolean := 
  174.      Glib.Properties.Build ("use-size"); 
  175.  
  176.    pragma Import (C, Get_Type, "gtk_font_button_get_type"); 
  177. end Gtk.Font_Button;