1. ------------------------------------------------------------------------------ 
  2. --                                                                          -- 
  3. --      Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet       -- 
  4. --                     Copyright (C) 2000-2014, AdaCore                     -- 
  5. --                                                                          -- 
  6. -- This library is free software;  you can redistribute it and/or modify it -- 
  7. -- under terms of the  GNU General Public License  as published by the Free -- 
  8. -- Software  Foundation;  either version 3,  or (at your  option) any later -- 
  9. -- version. This library is distributed in the hope that it will be useful, -- 
  10. -- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- -- 
  11. -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            -- 
  12. --                                                                          -- 
  13. -- As a special exception under Section 7 of GPL version 3, you are granted -- 
  14. -- additional permissions described in the GCC Runtime Library Exception,   -- 
  15. -- version 3.1, as published by the Free Software Foundation.               -- 
  16. --                                                                          -- 
  17. -- You should have received a copy of the GNU General Public License and    -- 
  18. -- a copy of the GCC Runtime Library Exception along with this program;     -- 
  19. -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    -- 
  20. -- <http://www.gnu.org/licenses/>.                                          -- 
  21. --                                                                          -- 
  22. ------------------------------------------------------------------------------ 
  23.  
  24. --  <description> 
  25. --  A Gtk.Check_Menu_Item.Gtk_Check_Menu_Item is a menu item that maintains 
  26. --  the state of a boolean value in addition to a Gtk.Menu_Item.Gtk_Menu_Item 
  27. --  usual role in activating application code. 
  28. -- 
  29. --  A check box indicating the state of the boolean value is displayed at the 
  30. --  left side of the Gtk.Menu_Item.Gtk_Menu_Item. Activating the 
  31. --  Gtk.Menu_Item.Gtk_Menu_Item toggles the value. 
  32. -- 
  33. --  </description> 
  34. pragma Ada_2005; 
  35.  
  36. pragma Warnings (Off, "*is already use-visible*"); 
  37. with Glib;            use Glib; 
  38. with Glib.Object;     use Glib.Object; 
  39. with Glib.Properties; use Glib.Properties; 
  40. with Glib.Types;      use Glib.Types; 
  41. with Glib.Variant;    use Glib.Variant; 
  42. with Gtk.Action;      use Gtk.Action; 
  43. with Gtk.Actionable;  use Gtk.Actionable; 
  44. with Gtk.Activatable; use Gtk.Activatable; 
  45. with Gtk.Buildable;   use Gtk.Buildable; 
  46. with Gtk.Menu_Item;   use Gtk.Menu_Item; 
  47.  
  48. package Gtk.Check_Menu_Item is 
  49.  
  50.    type Gtk_Check_Menu_Item_Record is new Gtk_Menu_Item_Record with null record; 
  51.    type Gtk_Check_Menu_Item is access all Gtk_Check_Menu_Item_Record'Class; 
  52.  
  53.    ------------------ 
  54.    -- Constructors -- 
  55.    ------------------ 
  56.  
  57.    procedure Gtk_New 
  58.       (Check_Menu_Item : out Gtk_Check_Menu_Item; 
  59.        Label           : UTF8_String := ""); 
  60.    procedure Initialize 
  61.       (Check_Menu_Item : not null access Gtk_Check_Menu_Item_Record'Class; 
  62.        Label           : UTF8_String := ""); 
  63.    --  Creates a new Gtk.Check_Menu_Item.Gtk_Check_Menu_Item with a label. 
  64.    --  "label": the string to use for the label. 
  65.  
  66.    function Gtk_Check_Menu_Item_New_With_Label 
  67.       (Label : UTF8_String := "") return Gtk_Check_Menu_Item; 
  68.    --  Creates a new Gtk.Check_Menu_Item.Gtk_Check_Menu_Item with a label. 
  69.    --  "label": the string to use for the label. 
  70.  
  71.    procedure Gtk_New_With_Mnemonic 
  72.       (Check_Menu_Item : out Gtk_Check_Menu_Item; 
  73.        Label           : UTF8_String); 
  74.    procedure Initialize_With_Mnemonic 
  75.       (Check_Menu_Item : not null access Gtk_Check_Menu_Item_Record'Class; 
  76.        Label           : UTF8_String); 
  77.    --  Creates a new Gtk.Check_Menu_Item.Gtk_Check_Menu_Item containing a 
  78.    --  label. The label will be created using Gtk.Label.Gtk_New_With_Mnemonic, 
  79.    --  so underscores in Label indicate the mnemonic for the menu item. 
  80.    --  "label": The text of the button, with an underscore in front of the 
  81.    --  character 
  82.  
  83.    function Gtk_Check_Menu_Item_New_With_Mnemonic 
  84.       (Label : UTF8_String) return Gtk_Check_Menu_Item; 
  85.    --  Creates a new Gtk.Check_Menu_Item.Gtk_Check_Menu_Item containing a 
  86.    --  label. The label will be created using Gtk.Label.Gtk_New_With_Mnemonic, 
  87.    --  so underscores in Label indicate the mnemonic for the menu item. 
  88.    --  "label": The text of the button, with an underscore in front of the 
  89.    --  character 
  90.  
  91.    function Get_Type return Glib.GType; 
  92.    pragma Import (C, Get_Type, "gtk_check_menu_item_get_type"); 
  93.  
  94.    ------------- 
  95.    -- Methods -- 
  96.    ------------- 
  97.  
  98.    function Get_Active 
  99.       (Check_Menu_Item : not null access Gtk_Check_Menu_Item_Record) 
  100.        return Boolean; 
  101.    --  Returns whether the check menu item is active. See 
  102.    --  gtk_check_menu_item_set_active (). 
  103.  
  104.    procedure Set_Active 
  105.       (Check_Menu_Item : not null access Gtk_Check_Menu_Item_Record; 
  106.        Is_Active       : Boolean); 
  107.    --  Sets the active state of the menu item's check box. 
  108.    --  "is_active": boolean value indicating whether the check box is active. 
  109.  
  110.    function Get_Draw_As_Radio 
  111.       (Check_Menu_Item : not null access Gtk_Check_Menu_Item_Record) 
  112.        return Boolean; 
  113.    --  Returns whether Check_Menu_Item looks like a 
  114.    --  Gtk.Radio_Menu_Item.Gtk_Radio_Menu_Item 
  115.    --  Since: gtk+ 2.4 
  116.  
  117.    procedure Set_Draw_As_Radio 
  118.       (Check_Menu_Item : not null access Gtk_Check_Menu_Item_Record; 
  119.        Draw_As_Radio   : Boolean); 
  120.    --  Sets whether Check_Menu_Item is drawn like a 
  121.    --  Gtk.Radio_Menu_Item.Gtk_Radio_Menu_Item 
  122.    --  Since: gtk+ 2.4 
  123.    --  "draw_as_radio": whether Check_Menu_Item is drawn like a 
  124.    --  Gtk.Radio_Menu_Item.Gtk_Radio_Menu_Item 
  125.  
  126.    function Get_Inconsistent 
  127.       (Check_Menu_Item : not null access Gtk_Check_Menu_Item_Record) 
  128.        return Boolean; 
  129.    --  Retrieves the value set by Gtk.Check_Menu_Item.Set_Inconsistent. 
  130.  
  131.    procedure Set_Inconsistent 
  132.       (Check_Menu_Item : not null access Gtk_Check_Menu_Item_Record; 
  133.        Setting         : Boolean); 
  134.    --  If the user has selected a range of elements (such as some text or 
  135.    --  spreadsheet cells) that are affected by a boolean setting, and the 
  136.    --  current values in that range are inconsistent, you may want to display 
  137.    --  the check in an "in between" state. This function turns on "in between" 
  138.    --  display. Normally you would turn off the inconsistent state again if the 
  139.    --  user explicitly selects a setting. This has to be done manually, 
  140.    --  Gtk.Check_Menu_Item.Set_Inconsistent only affects visual appearance, it 
  141.    --  doesn't affect the semantics of the widget. 
  142.    --  "setting": True to display an "inconsistent" third state check 
  143.  
  144.    procedure Toggled 
  145.       (Check_Menu_Item : not null access Gtk_Check_Menu_Item_Record); 
  146.    --  Emits the Gtk.Check_Menu_Item.Gtk_Check_Menu_Item::toggled signal. 
  147.  
  148.    --------------------------------------------- 
  149.    -- Inherited subprograms (from interfaces) -- 
  150.    --------------------------------------------- 
  151.    --  Methods inherited from the Buildable interface are not duplicated here 
  152.    --  since they are meant to be used by tools, mostly. If you need to call 
  153.    --  them, use an explicit cast through the "-" operator below. 
  154.  
  155.    function Get_Action_Name 
  156.       (Self : not null access Gtk_Check_Menu_Item_Record) return UTF8_String; 
  157.  
  158.    procedure Set_Action_Name 
  159.       (Self        : not null access Gtk_Check_Menu_Item_Record; 
  160.        Action_Name : UTF8_String); 
  161.  
  162.    function Get_Action_Target_Value 
  163.       (Self : not null access Gtk_Check_Menu_Item_Record) 
  164.        return Glib.Variant.Gvariant; 
  165.  
  166.    procedure Set_Action_Target_Value 
  167.       (Self         : not null access Gtk_Check_Menu_Item_Record; 
  168.        Target_Value : Glib.Variant.Gvariant); 
  169.  
  170.    procedure Set_Detailed_Action_Name 
  171.       (Self                 : not null access Gtk_Check_Menu_Item_Record; 
  172.        Detailed_Action_Name : UTF8_String); 
  173.  
  174.    procedure Do_Set_Related_Action 
  175.       (Self   : not null access Gtk_Check_Menu_Item_Record; 
  176.        Action : not null access Gtk.Action.Gtk_Action_Record'Class); 
  177.  
  178.    function Get_Related_Action 
  179.       (Self : not null access Gtk_Check_Menu_Item_Record) 
  180.        return Gtk.Action.Gtk_Action; 
  181.  
  182.    procedure Set_Related_Action 
  183.       (Self   : not null access Gtk_Check_Menu_Item_Record; 
  184.        Action : not null access Gtk.Action.Gtk_Action_Record'Class); 
  185.  
  186.    function Get_Use_Action_Appearance 
  187.       (Self : not null access Gtk_Check_Menu_Item_Record) return Boolean; 
  188.  
  189.    procedure Set_Use_Action_Appearance 
  190.       (Self           : not null access Gtk_Check_Menu_Item_Record; 
  191.        Use_Appearance : Boolean); 
  192.  
  193.    procedure Sync_Action_Properties 
  194.       (Self   : not null access Gtk_Check_Menu_Item_Record; 
  195.        Action : access Gtk.Action.Gtk_Action_Record'Class); 
  196.  
  197.    ---------------- 
  198.    -- Properties -- 
  199.    ---------------- 
  200.    --  The following properties are defined for this widget. See 
  201.    --  Glib.Properties for more information on properties) 
  202.  
  203.    Active_Property : constant Glib.Properties.Property_Boolean; 
  204.  
  205.    Draw_As_Radio_Property : constant Glib.Properties.Property_Boolean; 
  206.  
  207.    Inconsistent_Property : constant Glib.Properties.Property_Boolean; 
  208.  
  209.    ------------- 
  210.    -- Signals -- 
  211.    ------------- 
  212.  
  213.    type Cb_Gtk_Check_Menu_Item_Void is not null access procedure 
  214.      (Self : access Gtk_Check_Menu_Item_Record'Class); 
  215.  
  216.    type Cb_GObject_Void is not null access procedure 
  217.      (Self : access Glib.Object.GObject_Record'Class); 
  218.  
  219.    Signal_Toggled : constant Glib.Signal_Name := "toggled"; 
  220.    procedure On_Toggled 
  221.       (Self  : not null access Gtk_Check_Menu_Item_Record; 
  222.        Call  : Cb_Gtk_Check_Menu_Item_Void; 
  223.        After : Boolean := False); 
  224.    procedure On_Toggled 
  225.       (Self  : not null access Gtk_Check_Menu_Item_Record; 
  226.        Call  : Cb_GObject_Void; 
  227.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  228.        After : Boolean := False); 
  229.    --  This signal is emitted when the state of the check box is changed. 
  230.    -- 
  231.    --  A signal handler can use Gtk.Check_Menu_Item.Get_Active to discover the 
  232.    --  new state. 
  233.  
  234.    ---------------- 
  235.    -- Interfaces -- 
  236.    ---------------- 
  237.    --  This class implements several interfaces. See Glib.Types 
  238.    -- 
  239.    --  - "Actionable" 
  240.    -- 
  241.    --  - "Activatable" 
  242.    -- 
  243.    --  - "Buildable" 
  244.  
  245.    package Implements_Gtk_Actionable is new Glib.Types.Implements 
  246.      (Gtk.Actionable.Gtk_Actionable, Gtk_Check_Menu_Item_Record, Gtk_Check_Menu_Item); 
  247.    function "+" 
  248.      (Widget : access Gtk_Check_Menu_Item_Record'Class) 
  249.    return Gtk.Actionable.Gtk_Actionable 
  250.    renames Implements_Gtk_Actionable.To_Interface; 
  251.    function "-" 
  252.      (Interf : Gtk.Actionable.Gtk_Actionable) 
  253.    return Gtk_Check_Menu_Item 
  254.    renames Implements_Gtk_Actionable.To_Object; 
  255.  
  256.    package Implements_Gtk_Activatable is new Glib.Types.Implements 
  257.      (Gtk.Activatable.Gtk_Activatable, Gtk_Check_Menu_Item_Record, Gtk_Check_Menu_Item); 
  258.    function "+" 
  259.      (Widget : access Gtk_Check_Menu_Item_Record'Class) 
  260.    return Gtk.Activatable.Gtk_Activatable 
  261.    renames Implements_Gtk_Activatable.To_Interface; 
  262.    function "-" 
  263.      (Interf : Gtk.Activatable.Gtk_Activatable) 
  264.    return Gtk_Check_Menu_Item 
  265.    renames Implements_Gtk_Activatable.To_Object; 
  266.  
  267.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  268.      (Gtk.Buildable.Gtk_Buildable, Gtk_Check_Menu_Item_Record, Gtk_Check_Menu_Item); 
  269.    function "+" 
  270.      (Widget : access Gtk_Check_Menu_Item_Record'Class) 
  271.    return Gtk.Buildable.Gtk_Buildable 
  272.    renames Implements_Gtk_Buildable.To_Interface; 
  273.    function "-" 
  274.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  275.    return Gtk_Check_Menu_Item 
  276.    renames Implements_Gtk_Buildable.To_Object; 
  277.  
  278. private 
  279.    Inconsistent_Property : constant Glib.Properties.Property_Boolean := 
  280.      Glib.Properties.Build ("inconsistent"); 
  281.    Draw_As_Radio_Property : constant Glib.Properties.Property_Boolean := 
  282.      Glib.Properties.Build ("draw-as-radio"); 
  283.    Active_Property : constant Glib.Properties.Property_Boolean := 
  284.      Glib.Properties.Build ("active"); 
  285. end Gtk.Check_Menu_Item;