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