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