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_Toggle_Button is like a regular button, but can be in one of 
  27. --  two states, "active" or "inactive". Its visual aspect is modified 
  28. --  when the state is changed. 
  29. -- 
  30. --  You should consider using a Gtk_Check_Button instead, since it looks 
  31. --  nicer and provides more visual clues that the button can be 
  32. --  toggled. 
  33. --  </description> 
  34. --  <c_version>2.8.17</c_version> 
  35. --  <screenshot>gtk-toggle_button</screenshot> 
  36. --  <group>Buttons and Toggles</group> 
  37. --  <testgtk>create_toggle_buttons.adb</testgtk> 
  38.  
  39. with Glib.Properties; 
  40. with Gtk.Button; 
  41.  
  42. package Gtk.Toggle_Button is 
  43.  
  44.    type Gtk_Toggle_Button_Record is new Gtk.Button.Gtk_Button_Record 
  45.      with private; 
  46.    type Gtk_Toggle_Button is access all Gtk_Toggle_Button_Record'Class; 
  47.  
  48.    procedure Gtk_New 
  49.      (Toggle_Button : out Gtk_Toggle_Button; 
  50.       Label         : UTF8_String := ""); 
  51.    --  Initialize a button. 
  52.    --  If Label is "", then no label is created inside the button and 
  53.    --  you will have to provide your own child through a call to 
  54.    --  Gtk.Container.Add. This is the recommended way to put a pixmap 
  55.    --  inside a toggle button. 
  56.  
  57.    procedure Gtk_New_With_Mnemonic 
  58.      (Toggle_Button : out Gtk_Toggle_Button; 
  59.       Label         : UTF8_String); 
  60.    --  Create a Gtk_Toggle_Button containing Label. The Label will be created 
  61.    --  using Gtk.Label.Gtk_New_With_Mnemonic, so underscores in Label indicate 
  62.    --  the mnemonic for the button. 
  63.  
  64.    procedure Initialize 
  65.      (Toggle_Button : access Gtk_Toggle_Button_Record'Class; 
  66.       Label         : UTF8_String := ""); 
  67.    --  Internal initialization function. 
  68.    --  See the section "Creating your own widgets" in the documentation. 
  69.  
  70.    procedure Initialize_With_Mnemonic 
  71.      (Toggle_Button : access Gtk_Toggle_Button_Record'Class; 
  72.       Label         : UTF8_String); 
  73.    --  Internal initialization function. 
  74.  
  75.    function Get_Type return Glib.GType; 
  76.    --  Return the internal value associated with a Gtk_Toggle_Button. 
  77.  
  78.    procedure Set_Mode 
  79.      (Toggle_Button  : access Gtk_Toggle_Button_Record; 
  80.       Draw_Indicator : Boolean); 
  81.    function Get_Mode 
  82.      (Toggle_Button : access Gtk_Toggle_Button_Record) return Boolean; 
  83.    --  Change the mode of the button. 
  84.    --  If Draw_Indicator is False, then the button is hidden. 
  85.  
  86.    procedure Set_Active 
  87.      (Toggle_Button : access Gtk_Toggle_Button_Record; 
  88.       Is_Active     : Boolean); 
  89.    function Get_Active 
  90.      (Toggle_Button : access Gtk_Toggle_Button_Record) return Boolean; 
  91.    --  Change the state of the button. 
  92.    --  When Is_Active is True, the button is drawn as a pressed button. 
  93.  
  94.    procedure Set_Inconsistent 
  95.      (Toggle_Button : access Gtk_Toggle_Button_Record; 
  96.       Setting       : Boolean := True); 
  97.    function Get_Inconsistent 
  98.      (Toggle_Button : access Gtk_Toggle_Button_Record) return Boolean; 
  99.    --  If the user has selected a range of elements (such as some text or 
  100.    --  spreadsheet cells) that are affected by a toggle button, and the 
  101.    --  current values in that range are inconsistent, you may want to 
  102.    --  display the toggle in an "in between" state. This function turns on 
  103.    --  "in between" display.  Normally you would turn off the inconsistent 
  104.    --  state again if the user toggles the toggle button. This has to be 
  105.    --  done manually, Set_Inconsistent only affects visual appearance, it 
  106.    --  doesn't affect the semantics of the button. 
  107.  
  108.    ---------------------- 
  109.    -- Signals emission -- 
  110.    ---------------------- 
  111.  
  112.    procedure Toggled (Toggle_Button : access Gtk_Toggle_Button_Record); 
  113.    --  Emit the toggled signal on this widget. 
  114.    --  Note that the state of the button is not changed, only the callbacks 
  115.    --  are called. 
  116.  
  117.    ---------------- 
  118.    -- Properties -- 
  119.    ---------------- 
  120.  
  121.    --  <properties> 
  122.    --  The following properties are defined for this widget. See 
  123.    --  Glib.Properties for more information on properties. 
  124.    -- 
  125.    --  Name:  Active_Property 
  126.    --  Type:  Boolean 
  127.    --  Descr: If the toggle button should be pressed in or not 
  128.    -- 
  129.    --  Name:  Draw_Indicator_Property 
  130.    --  Type:  Boolean 
  131.    --  Descr: If the toggle part of the button is displayed 
  132.    -- 
  133.    --  Name:  Inconsistent_Property 
  134.    --  Type:  Boolean 
  135.    --  Descr: If the toggle button is in an \ 
  136.    -- 
  137.    --  </properties> 
  138.  
  139.    Active_Property         : constant Glib.Properties.Property_Boolean; 
  140.    Draw_Indicator_Property : constant Glib.Properties.Property_Boolean; 
  141.    Inconsistent_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.    --  - "toggled" 
  151.    --    procedure Handler (Toggle : access Gtk_Toggle_Button_Record'Class); 
  152.    -- 
  153.    --    This signal is emitted every time the state of the button is 
  154.    --    modified. 
  155.    --  </signals> 
  156.  
  157.    Signal_Toggled : constant Glib.Signal_Name := "toggled"; 
  158.  
  159. private 
  160.    type Gtk_Toggle_Button_Record is new Gtk.Button.Gtk_Button_Record 
  161.       with null record; 
  162.  
  163.    Active_Property         : constant Glib.Properties.Property_Boolean := 
  164.      Glib.Properties.Build ("active"); 
  165.    Draw_Indicator_Property : constant Glib.Properties.Property_Boolean := 
  166.      Glib.Properties.Build ("draw-indicator"); 
  167.    Inconsistent_Property   : constant Glib.Properties.Property_Boolean := 
  168.      Glib.Properties.Build ("inconsistent"); 
  169.  
  170.    pragma Import (C, Get_Type, "gtk_toggle_button_get_type"); 
  171. end Gtk.Toggle_Button; 
  172.  
  173. --  <example> 
  174. --  <include>../examples/documentation/toggle.adb</include> 
  175. --  </example>