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-2011, 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. However, Gtk_Radio_Buttons can be grouped together to 
  28. --  get a special behavior: only one button in the group can be active at any 
  29. --  given time. Thus, when the user selects one of the buttons from the group, 
  30. --  the button that was previously selected is disabled. 
  31. -- 
  32. --  The radio buttons always belongs to a group, even if there is only one in 
  33. --  this group. 
  34. -- 
  35. --  </description> 
  36. --  <screenshot>gtk-radio_button</screenshot> 
  37. --  <group>Buttons and Toggles</group> 
  38. --  <testgtk>create_radio_button.adb</testgtk> 
  39.  
  40. pragma Warnings (Off, "*is already use-visible*"); 
  41. with Glib;             use Glib; 
  42. with Glib.Properties;  use Glib.Properties; 
  43. with Glib.Types;       use Glib.Types; 
  44. with Gtk.Action;       use Gtk.Action; 
  45. with Gtk.Activatable;  use Gtk.Activatable; 
  46. with Gtk.Buildable;    use Gtk.Buildable; 
  47. with Gtk.Check_Button; use 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 Gtk_Check_Button_Record with null record; 
  53.    type Gtk_Radio_Button is access all Gtk_Radio_Button_Record'Class; 
  54.  
  55.    ------------------ 
  56.    -- Constructors -- 
  57.    ------------------ 
  58.  
  59.    procedure Gtk_New 
  60.       (Radio_Button : out Gtk_Radio_Button; 
  61.        Group        : Gtk.Widget.Widget_SList.GSList := Widget_SList.Null_List; 
  62.        Label        : UTF8_String := ""); 
  63.    procedure Initialize 
  64.       (Radio_Button : access Gtk_Radio_Button_Record'Class; 
  65.        Group        : Gtk.Widget.Widget_SList.GSList := Widget_SList.Null_List; 
  66.        Label        : UTF8_String := ""); 
  67.    --  Creates or initializes a new radio button, belonging to Group. If Label 
  68.    --  is left as the empty string, then the button will not have any child and 
  69.    --  you are free to put any thing you want in it, including a pixmap. To 
  70.    --  initialize the group (when creating the first button), leave Group to 
  71.    --  the Null_List. You can later get the new group that is created with a 
  72.    --  call to the Group subprogram below. 
  73.    --  "group": an existing radio button group, or null if you are creating a 
  74.    --  new group. 
  75.    --  "label": the text label to display next to the radio button. 
  76.  
  77.    procedure Gtk_New 
  78.       (Radio_Button : out Gtk_Radio_Button; 
  79.        Group        : Gtk.Radio_Button.Gtk_Radio_Button; 
  80.        Label        : UTF8_String := ""); 
  81.    procedure Initialize 
  82.       (Radio_Button : access Gtk_Radio_Button_Record'Class; 
  83.        Group        : Gtk.Radio_Button.Gtk_Radio_Button; 
  84.        Label        : UTF8_String := ""); 
  85.    --  Creates a new Gtk.Radio_Button.Gtk_Radio_Button with a text label, 
  86.    --  adding it to the same group as Radio_Group_Member. 
  87.    --  "Group": widget to get radio group from or null 
  88.    --  "label": a text string to display next to the radio button. 
  89.  
  90.    procedure Gtk_New_With_Mnemonic 
  91.       (Radio_Button : out Gtk_Radio_Button; 
  92.        Group        : Gtk.Widget.Widget_SList.GSList := Widget_SList.Null_List; 
  93.        Label        : UTF8_String); 
  94.    procedure Initialize_With_Mnemonic 
  95.       (Radio_Button : access Gtk_Radio_Button_Record'Class; 
  96.        Group        : Gtk.Widget.Widget_SList.GSList := Widget_SList.Null_List; 
  97.        Label        : UTF8_String); 
  98.    procedure Gtk_New_With_Mnemonic 
  99.       (Radio_Button : out Gtk_Radio_Button; 
  100.        Group        : Gtk.Radio_Button.Gtk_Radio_Button; 
  101.        Label        : UTF8_String); 
  102.    procedure Initialize_With_Mnemonic 
  103.       (Radio_Button : access Gtk_Radio_Button_Record'Class; 
  104.        Group        : Gtk.Radio_Button.Gtk_Radio_Button; 
  105.        Label        : UTF8_String); 
  106.    --  Creates a new Gtk.Radio_Button.Gtk_Radio_Button containing a label. The 
  107.    --  label will be created using Gtk.Label.Gtk_New_With_Mnemonic, so 
  108.    --  underscores in Label indicate the mnemonic for the button. 
  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.    --  "Group": widget to get radio group from or null 
  113.    --  "label": the text of the button, with an underscore in front of the 
  114.    --  mnemonic character 
  115.  
  116.    function Get_Type return Glib.GType; 
  117.    pragma Import (C, Get_Type, "gtk_radio_button_get_type"); 
  118.  
  119.    ------------- 
  120.    -- Methods -- 
  121.    ------------- 
  122.  
  123.    function Get_Group 
  124.       (Radio_Button : access Gtk_Radio_Button_Record) 
  125.        return Gtk.Widget.Widget_SList.GSList; 
  126.    procedure Set_Group 
  127.       (Radio_Button : access Gtk_Radio_Button_Record; 
  128.        Group        : Gtk.Widget.Widget_SList.GSList); 
  129.    --  Sets a Gtk.Radio_Button.Gtk_Radio_Button's group. It should be noted 
  130.    --  that this does not change the layout of your interface in any way, so if 
  131.    --  you are changing the group, it is likely you will need to re-arrange the 
  132.    --  user interface to reflect these changes. 
  133.    --  "group": an existing radio button group, such as one returned from 
  134.    --  Gtk.Radio_Button.Get_Group. 
  135.  
  136.    --------------------- 
  137.    -- Interfaces_Impl -- 
  138.    --------------------- 
  139.  
  140.    procedure Do_Set_Related_Action 
  141.       (Self   : access Gtk_Radio_Button_Record; 
  142.        Action : access Gtk.Action.Gtk_Action_Record'Class); 
  143.  
  144.    function Get_Related_Action 
  145.       (Self : access Gtk_Radio_Button_Record) return Gtk.Action.Gtk_Action; 
  146.    procedure Set_Related_Action 
  147.       (Self   : access Gtk_Radio_Button_Record; 
  148.        Action : access Gtk.Action.Gtk_Action_Record'Class); 
  149.  
  150.    function Get_Use_Action_Appearance 
  151.       (Self : access Gtk_Radio_Button_Record) return Boolean; 
  152.    procedure Set_Use_Action_Appearance 
  153.       (Self           : access Gtk_Radio_Button_Record; 
  154.        Use_Appearance : Boolean); 
  155.  
  156.    procedure Sync_Action_Properties 
  157.       (Self   : access Gtk_Radio_Button_Record; 
  158.        Action : access Gtk.Action.Gtk_Action_Record'Class); 
  159.  
  160.    ---------------- 
  161.    -- Interfaces -- 
  162.    ---------------- 
  163.    --  This class implements several interfaces. See Glib.Types 
  164.    -- 
  165.    --  - "Activatable" 
  166.    -- 
  167.    --  - "Buildable" 
  168.  
  169.    package Implements_Activatable is new Glib.Types.Implements 
  170.      (Gtk.Activatable.Gtk_Activatable, Gtk_Radio_Button_Record, Gtk_Radio_Button); 
  171.    function "+" 
  172.      (Widget : access Gtk_Radio_Button_Record'Class) 
  173.    return Gtk.Activatable.Gtk_Activatable 
  174.    renames Implements_Activatable.To_Interface; 
  175.    function "-" 
  176.      (Interf : Gtk.Activatable.Gtk_Activatable) 
  177.    return Gtk_Radio_Button 
  178.    renames Implements_Activatable.To_Object; 
  179.  
  180.    package Implements_Buildable is new Glib.Types.Implements 
  181.      (Gtk.Buildable.Gtk_Buildable, Gtk_Radio_Button_Record, Gtk_Radio_Button); 
  182.    function "+" 
  183.      (Widget : access Gtk_Radio_Button_Record'Class) 
  184.    return Gtk.Buildable.Gtk_Buildable 
  185.    renames Implements_Buildable.To_Interface; 
  186.    function "-" 
  187.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  188.    return Gtk_Radio_Button 
  189.    renames Implements_Buildable.To_Object; 
  190.  
  191.    ---------------- 
  192.    -- Properties -- 
  193.    ---------------- 
  194.    --  The following properties are defined for this widget. See 
  195.    --  Glib.Properties for more information on properties) 
  196.    -- 
  197.    --  Name: Group_Property 
  198.    --  Type: Gtk.Radio_Button.Gtk_Radio_Button 
  199.    --  Flags: write 
  200.  
  201.    Group_Property : constant Glib.Properties.Property_Object; 
  202.  
  203.    ------------- 
  204.    -- Signals -- 
  205.    ------------- 
  206.    --  The following new signals are defined for this widget: 
  207.    -- 
  208.    --  "group-changed" 
  209.    --     procedure Handler (Self : access Gtk_Radio_Button_Record'Class); 
  210.    --  Emitted when the group of radio buttons that a radio button belongs to 
  211.    --  changes. This is emitted when a radio button switches from being alone 
  212.    --  to being part of a group of 2 or more buttons, or vice-versa, and when a 
  213.    --  button is moved from one group of 2 or more buttons to a different one, 
  214.    --  but not when the composition of the group that a button belongs to 
  215.    --  changes. 
  216.  
  217.    Signal_Group_Changed : constant Glib.Signal_Name := "group-changed"; 
  218.  
  219. private 
  220.    Group_Property : constant Glib.Properties.Property_Object := 
  221.      Glib.Properties.Build ("group"); 
  222. end Gtk.Radio_Button;