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