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-2007 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. --  A Gtk_Radio_Button is a simple button that has two states, like a 
  27. --  Gtk_Toggle_Button. 
  28. --  However, Gtk_Radio_Buttons can be grouped together to get a special 
  29. --  behavior: only one button in the group can be active at any given time. 
  30. --  Thus, when the user selects one of the buttons from the group, the button 
  31. --  that was previously selected is disabled. 
  32. -- 
  33. --  The radio buttons always belongs to a group, even if there is only one in 
  34. --  this group 
  35. --  </description> 
  36. --  <c_version>2.8.17</c_version> 
  37. --  <screenshot>gtk-radio_button</screenshot> 
  38. --  <group>Buttons and Toggles</group> 
  39. --  <testgtk>create_radio_button.adb</testgtk> 
  40.  
  41. with Glib.Properties; 
  42. with Gtk.Check_Button; 
  43. with Gtk.Widget; use Gtk.Widget; 
  44.  
  45. package Gtk.Radio_Button is 
  46.  
  47.    type Gtk_Radio_Button_Record is new Check_Button.Gtk_Check_Button_Record 
  48.      with private; 
  49.    type Gtk_Radio_Button is access all Gtk_Radio_Button_Record'Class; 
  50.  
  51.    procedure Gtk_New 
  52.      (Radio_Button : out Gtk_Radio_Button; 
  53.       Group        : Widget_SList.GSlist := Widget_SList.Null_List; 
  54.       Label        : UTF8_String := ""); 
  55.    procedure Initialize 
  56.      (Radio_Button : access Gtk_Radio_Button_Record'Class; 
  57.       Group        : Widget_SList.GSlist; 
  58.       Label        : UTF8_String); 
  59.    --  Creates or initializes a new radio button, belonging to Group. 
  60.    --  If Label is left as the empty string, then the button will not have any 
  61.    --  child and you are free to put any thing you want in it, including a 
  62.    --  pixmap. 
  63.    --  To initialize the group (when creating the first button), leave Group 
  64.    --  to the Null_List. You can later get the new group that is created with 
  65.    --  a call to the Group subprogram below. 
  66.  
  67.    procedure Gtk_New 
  68.      (Radio_Button : out Gtk_Radio_Button; 
  69.       Group        : Gtk_Radio_Button; 
  70.       Label        : UTF8_String := ""); 
  71.    procedure Initialize 
  72.      (Radio_Button : access Gtk_Radio_Button_Record'Class; 
  73.       Group        : Gtk_Radio_Button; 
  74.       Label        : UTF8_String); 
  75.    --  Creates or initializes a new radio button in the same group as Group. 
  76.    --  If Label is left as the empty string, Radio_Button is created without 
  77.    --  any child and you can put whatever you want in it, including a pixmap. 
  78.    --  To initialize a new group (when creating the first button), you should 
  79.    --  pass it null or a button that has not been created with Gtk_New, as in 
  80.    --  the example below. 
  81.  
  82.    procedure Gtk_New_With_Mnemonic 
  83.      (Radio_Button : out Gtk_Radio_Button; 
  84.       Group        : Widget_SList.GSlist := Widget_SList.Null_List; 
  85.       Label        : UTF8_String); 
  86.    procedure Initialize_With_Mnemonic 
  87.      (Radio_Button : access Gtk_Radio_Button_Record'Class; 
  88.       Group        : Widget_SList.GSlist; 
  89.       Label        : UTF8_String); 
  90.    --  Create a new Gtk_Radio_Button containing a Label. The Label is created 
  91.    --  using Gtk.Label.New_With_Mnemonic, so underscores in Label indicate 
  92.    --  the mnemonic for the button. 
  93.    --  To initialize a new group (when creating the first button), you should 
  94.    --  pass it null or a button that has not been created with Gtk_New, as in 
  95.    --  the example below. 
  96.  
  97.    procedure Gtk_New_With_Mnemonic 
  98.      (Radio_Button : out Gtk_Radio_Button; 
  99.       Group        : Gtk_Radio_Button; 
  100.       Label        : UTF8_String); 
  101.    procedure Initialize_With_Mnemonic 
  102.      (Radio_Button : access Gtk_Radio_Button_Record'Class; 
  103.       Group        : Gtk_Radio_Button; 
  104.       Label        : UTF8_String); 
  105.    --  Creates or initializes a new radio button in the same group as Group. 
  106.    --  The label is created using Gtk.Label.New_With_Mnemonic, so underscores 
  107.    --  in Label indicate the mnemonic for the button. 
  108.    -- 
  109.    --  To initialize a new group (when creating the first button), you should 
  110.    --  pass it null or a button that has not been created with Gtk_New, as in 
  111.    --  the example below. 
  112.  
  113.    function Get_Type return Gtk.Gtk_Type; 
  114.    --  Return the internal value associated with a Gtk_Radio_Button. 
  115.  
  116.    procedure Set_Group 
  117.      (Radio_Button : access Gtk_Radio_Button_Record; 
  118.       Group        : Widget_SList.GSlist); 
  119.    function Get_Group 
  120.      (Radio_Button : access Gtk_Radio_Button_Record) 
  121.       return Widget_SList.GSlist; 
  122.    --  Modify the group to which the button belongs. 
  123.    --  This will not change anything visually. 
  124.    --  This can be used as an argument to the first version of Gtk_New above, 
  125.    --  or the list can also be traversed to get all the buttons. 
  126.  
  127.    ----------------- 
  128.    -- Obsolescent -- 
  129.    ----------------- 
  130.    --  All subprograms below are now obsolescent in gtk+. They might be removed 
  131.    --  from future versions of gtk+ (and therefore GtkAda). 
  132.    --  To find out whether your code uses any of these, we recommend compiling 
  133.    --  with the -gnatwj switch 
  134.    --  <doc_ignore> 
  135.  
  136.    function Group 
  137.      (Radio_Button : access Gtk_Radio_Button_Record) 
  138.       return Widget_SList.GSlist renames Get_Group; 
  139.    --  pragma Obsolescent; 
  140.  
  141.    --  </doc_ignore> 
  142.  
  143.    ---------------- 
  144.    -- Properties -- 
  145.    ---------------- 
  146.  
  147.    --  <properties> 
  148.    --  The following properties are defined for this widget. See 
  149.    --  Glib.Properties for more information on properties. 
  150.    -- 
  151.    --  Name:  Group_Property 
  152.    --  Type:  Object 
  153.    --  Descr: The radio button whose group this widget belongs to. 
  154.    -- 
  155.    --  </properties> 
  156.  
  157.    Group_Property : constant Glib.Properties.Property_Object; 
  158.  
  159.    ------------- 
  160.    -- Signals -- 
  161.    ------------- 
  162.  
  163.    --  <signals> 
  164.    --  The following new signals are defined for this widget: 
  165.    -- 
  166.    --  - "group-changed" 
  167.    --    procedure Handler (Radio : access Gtk_Radio_Button_Record'Class); 
  168.    --    This signal is emitted when the group of the button is changed 
  169.    --  </signals> 
  170.  
  171.    Signal_Group_Changed : constant Glib.Signal_Name := "group-changed"; 
  172.  
  173. private 
  174.    type Gtk_Radio_Button_Record is new Check_Button.Gtk_Check_Button_Record 
  175.      with null record; 
  176.  
  177.    Group_Property : constant Glib.Properties.Property_Object := 
  178.      Glib.Properties.Build ("group"); 
  179.  
  180.    pragma Import (C, Get_Type, "gtk_radio_button_get_type"); 
  181. end Gtk.Radio_Button; 
  182.  
  183. --  <example> 
  184. --  --  This creates a group of two buttons. Note how the group is initialized. 
  185. -- 
  186. --  declare 
  187. --     Radio_Button : Gtk_Radio_Button; 
  188. --  begin 
  189. --     Gtk_New (Radio_Button, 
  190. --              Group       => Radio_Button, 
  191. --              Label       => "First button"); 
  192. --     Gtk_New (Radio_Button, 
  193. --              Group       => Radio_Button, 
  194. --              Label       => "Second button"); 
  195. --  end; 
  196. --  </example>