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. --  This widget represents one of the lines in a menu, on which the user can 
  32. --  click to execute an action. The menu items can be bound to a submenu, so 
  33. --  that clicking on them will in fact display the submenu on the screen. 
  34. -- 
  35. --  They can also be associated with key shortcuts (called accelerators). See 
  36. --  the subprogram Set_Accel_Path, and the subprograms in the package 
  37. --  Gtk.Accel_Map. 
  38. -- 
  39. --  Activating the proper options in the theme files will allow the user to 
  40. --  interactively modify the shortcuts. 
  41. --  </description> 
  42. --  <c_version>2.16.6</c_version> 
  43. --  <group>Menus and Toolbars</group> 
  44.  
  45. with Glib.Properties; 
  46. with Gtk.Item; 
  47. with Gtk.Widget; 
  48.  
  49. package Gtk.Menu_Item is 
  50.  
  51.    type Gtk_Menu_Item_Record is new Item.Gtk_Item_Record with private; 
  52.    type Gtk_Menu_Item is access all Gtk_Menu_Item_Record'Class; 
  53.  
  54.    Null_Submenu : constant Widget.Gtk_Widget; 
  55.  
  56.    procedure Gtk_New 
  57.      (Menu_Item : out Gtk_Menu_Item; Label : UTF8_String := ""); 
  58.    procedure Initialize 
  59.      (Menu_Item : access Gtk_Menu_Item_Record'Class; Label : UTF8_String); 
  60.    --  Creates or initializes a new menu item containing a simple label. 
  61.  
  62.    procedure Gtk_New_With_Mnemonic 
  63.      (Menu_Item : out Gtk_Menu_Item; 
  64.       Label     : UTF8_String); 
  65.    procedure Initialize_With_Mnemonic 
  66.      (Menu_Item : access Gtk_Menu_Item_Record'Class; 
  67.       Label     : UTF8_String); 
  68.    --  Creates or initializes a new Gtk_Menu_Item containing a label. 
  69.    --  The label is created using Gtk.Label.Gtk_New_With_Mnemonic, so 
  70.    --  underscores in Label indicate the mnemonic for the menu item. 
  71.    -- 
  72.    --  Warning: with some versions of gtk+, the menu_item will not be properly 
  73.    --  destroyed when you remove it from its parent menu, if you created it 
  74.    --  with a non-empty Label. In this case, you first need to destroy the 
  75.    --  child of the Menu_Item, and then remove it from its parent menu. 
  76.  
  77.    function Get_Type return Gtk.Gtk_Type; 
  78.    --  Return the internal value associated with a Gtk_Menu_Item. 
  79.  
  80.    procedure Set_Submenu 
  81.      (Menu_Item : access Gtk_Menu_Item_Record; 
  82.       Submenu   : access Widget.Gtk_Widget_Record'Class); 
  83.    function Get_Submenu 
  84.      (Menu_Item : access Gtk_Menu_Item_Record) return Gtk.Widget.Gtk_Widget; 
  85.    --  Set or Get the submenu underneath Menu_Item. 
  86.  
  87.    procedure Set_Label 
  88.      (Menu_Item : access Gtk_Menu_Item_Record; 
  89.       Label     : String); 
  90.    function Get_Label 
  91.      (Menu_Item : access Gtk_Menu_Item_Record) 
  92.       return String; 
  93.    --  Controls the text in Menu_Item's label. 
  94.  
  95.    procedure Set_Right_Justified 
  96.      (Menu_Item : access Gtk_Menu_Item_Record; 
  97.       Justify   : Boolean := True); 
  98.    function Get_Right_Justified 
  99.      (Menu_Item : access Gtk_Menu_Item_Record) return Boolean; 
  100.    --  Sets whether the menu item appears justified at the right side of a menu 
  101.    --  bar. This was traditionally done for "Help" menu items, but is now 
  102.    --  considered a bad idea. (If the widget layout is reversed for a 
  103.    --  right-to-left language like Hebrew or Arabic, right-justified-menu-items 
  104.    --  appear at the left.) 
  105.  
  106.    procedure Set_Use_Underline 
  107.      (Menu_Item : access Gtk_Menu_Item_Record; 
  108.       Setting   : Boolean); 
  109.    function Get_Use_Underline 
  110.      (Menu_Item : access Gtk_Menu_Item_Record) 
  111.       return Boolean; 
  112.    --  If true, an underline in the text indicates the next character should be 
  113.    --  used for the mnemonic accelerator key. 
  114.  
  115.    procedure Set_Accel_Path 
  116.      (Menu_Item  : access Gtk_Menu_Item_Record; 
  117.       Accel_Path : UTF8_String); 
  118.    function Get_Accel_Path 
  119.      (Menu_Item : access Gtk_Menu_Item_Record) 
  120.       return String; 
  121.    --  Set the path that will be used to reference the widget in calls to the 
  122.    --  subprograms in Gtk.Accel_Map. This means, for instance, that the widget 
  123.    --  is fully setup for interactive modification of the shortcuts by the 
  124.    --  user, should he choose to activate this possibility in his themes (see 
  125.    --  gtk-accel_map.ads for more information). 
  126.  
  127.    ----------------- 
  128.    -- Obsolescent -- 
  129.    ----------------- 
  130.    --  All subprograms below are now obsolescent in gtk+. They might be removed 
  131.    --  from future versions of gtk+ (and therefore GtkAda). 
  132.    --  To find out whether your code uses any of these, we recommend compiling 
  133.    --  with the -gnatwj switch 
  134.    --  <doc_ignore> 
  135.  
  136.    procedure Remove_Submenu (Menu_Item : access Gtk_Menu_Item_Record); 
  137.    pragma Obsolescent; --  Remove_Submenu 
  138.    --  Remove the menu_item's submenu 
  139.    -- 
  140.    --  Deprecated: 2.12: Remove_Submenu deprecated and should not be used 
  141.    --  in newly written code. Use Set_Submenu instead. 
  142.  
  143.    procedure Set_Right_Justify 
  144.      (Menu_Item : access Gtk_Menu_Item_Record; 
  145.       Justify   : Boolean) renames Set_Right_Justified; 
  146.    --  pragma Obsolescent; 
  147.    --  This procedure is needed by Gate to automate the code generation. 
  148.  
  149.    procedure Right_Justify (Menu_Item : access Gtk_Menu_Item_Record); 
  150.    pragma Obsolescent; 
  151.    --  Use Set_Right_Justified with Justify = True instead. 
  152.  
  153.    --  </doc_ignore> 
  154.  
  155.    ------------- 
  156.    -- Signals -- 
  157.    ------------- 
  158.  
  159.    --  <signals> 
  160.    --  The following new signals are defined for this widget: 
  161.    -- 
  162.    --  - "activate" 
  163.    --    procedure Handler 
  164.    --      (Menu_Item : access Gtk_Menu_Item_Record'Class); 
  165.    --    Emitted when the menu item has been activated, ie the user has clicked 
  166.    --    on it (or use a key shortcut for this) 
  167.    -- 
  168.    --  - "activate_item" 
  169.    --    procedure Handler 
  170.    --      (Menu_Item : access Gtk_Menu_Item_Record'Class); 
  171.    --    ??? 
  172.    -- 
  173.    --  - "toggle_size_request" 
  174.    --    procedure Handler 
  175.    --      (Menu_Item : access Gtk_Menu_Item_Record'Class; 
  176.    --       Request   : Gtk_Requisition_Access); 
  177.    --    Query the menu item to ask for its preferred size (this might not be 
  178.    --    the one actually allocated for it, depending on screen space) 
  179.    -- 
  180.    --  - "toggle_size_allocate" 
  181.    --    procedure Handler 
  182.    --      (Menu_Item  : access Gtk_Menu_Item_Record'Class; 
  183.    --       Allocation : Gtk_Allocation_Request); 
  184.    --    You should emit this signal to allocate a specific size for the item. 
  185.    --    In practice, you will not need to do this yourself, since gtk+ takes 
  186.    --    care of it correctly most of the time. 
  187.    -- 
  188.    --  </signals> 
  189.    -- 
  190.    --  If you want to get a signal every time the menu item is made visible 
  191.    --  on screen, for instance because you want to dynamically set its 
  192.    --  sensitive state, you should connect to the "map" signal of the 
  193.    --  toplevel menu, as in: 
  194.    --     Gtkada.Handlers.Widget_Callback.Object_Connect 
  195.    --        (Get_Toplevel (Item), "map", 
  196.    --         Slot_Object => Item); 
  197.  
  198.    Signal_Activate             : constant Glib.Signal_Name := 
  199.                                    "activate"; 
  200.    Signal_Activate_Item        : constant Glib.Signal_Name := 
  201.                                    "activate_item"; 
  202.    Signal_Toggle_Size_Allocate : constant Glib.Signal_Name := 
  203.                                    "toggle_size_allocate"; 
  204.    Signal_Toggle_Size_Request  : constant Glib.Signal_Name := 
  205.                                    "toggle_size_request"; 
  206.  
  207.    procedure Gtk_Select (Menu_Item : access Gtk_Menu_Item_Record); 
  208.    --  Emits the "select" signal on Menu_Item 
  209.  
  210.    procedure Deselect (Menu_Item : access Gtk_Menu_Item_Record); 
  211.    --  Emits the "deselect" signal on Menu_Item 
  212.  
  213.    procedure Activate (Menu_Item : access Gtk_Menu_Item_Record); 
  214.    --  Emits the "activate" signal on Menu_Item 
  215.  
  216.    procedure Toggle_Size_Allocate 
  217.      (Menu_Item  : access Gtk_Menu_Item_Record; 
  218.       Allocation : Gtk.Widget.Gtk_Allocation); 
  219.    --  Emits the "toggle_size_allocate" signal on Menu_Item 
  220.  
  221.    procedure Toggle_Size_Request 
  222.      (Menu_Item   : access Gtk_Menu_Item_Record; 
  223.       Requisition : out Gtk.Widget.Gtk_Requisition); 
  224.    --  Emits the "toggle_size_request" signal on Menu_Item 
  225.  
  226.    ---------------- 
  227.    -- Properties -- 
  228.    ---------------- 
  229.  
  230.    --  <properties> 
  231.    --  The following properties are defined for this widget. See 
  232.    --  Glib.Properties for more information on properties. 
  233.    -- 
  234.    --  Name:  Accel_Path_Property 
  235.    --  Type:  String 
  236.    --  Descr: Sets the accelerator path of the menu item 
  237.    -- 
  238.    --  Name:  Label_Property 
  239.    --  Type:  String 
  240.    --  Descr: The text for the child label 
  241.    -- 
  242.    --  Name:  Right_Justified_Property 
  243.    --  Type:  Boolean 
  244.    --  Descr: Sets whether the menu item appears justified at the right 
  245.    --         side of a menu bar 
  246.    -- 
  247.    --  Name:  Submenu_Property 
  248.    --  Type:  Object 
  249.    --  Descr: The submenu attached to the menu item, or null if it has none 
  250.    -- 
  251.    --  Name:  Use_Underline_Property 
  252.    --  Type:  Boolean 
  253.    --  Descr: If set, an underline in the text indicates the next character 
  254.    --         should be used for the mnemonic accelerator key 
  255.    -- 
  256.    --  </properties> 
  257.  
  258.    Accel_Path_Property      : constant Glib.Properties.Property_String; 
  259.    Label_Property           : constant Glib.Properties.Property_String; 
  260.    Right_Justified_Property : constant Glib.Properties.Property_Boolean; 
  261.    Submenu_Property         : constant Glib.Properties.Property_Object; 
  262.    Use_Underline_Property   : constant Glib.Properties.Property_Boolean; 
  263.  
  264.    ---------------------- 
  265.    -- Style Properties -- 
  266.    ---------------------- 
  267.    --  The following properties can be changed through the gtk theme and 
  268.    --  configuration files, and retrieved through Gtk.Widget.Style_Get_Property 
  269.  
  270.    --  <style_properties> 
  271.    --  Name:  Arrow_Scaling_Property 
  272.    --  Type:  Float 
  273.    --  Descr: Amount of space used up by arrow, relative to the menu item's 
  274.    --         font size 
  275.    -- 
  276.    --  Name:  Width_Chars_Property 
  277.    --  Type:  Int 
  278.    --  Descr: The minimum desired width of the menu item in characters 
  279.    -- 
  280.    --  </style_properties> 
  281.  
  282.    Arrow_Scaling_Property : constant Glib.Properties.Property_Float; 
  283.    Width_Chars_Property   : constant Glib.Properties.Property_Int; 
  284.  
  285. private 
  286.    type Gtk_Menu_Item_Record is new Item.Gtk_Item_Record with null record; 
  287.  
  288.    Accel_Path_Property : constant Glib.Properties.Property_String := 
  289.      Glib.Properties.Build ("accel-path"); 
  290.    Label_Property : constant Glib.Properties.Property_String := 
  291.      Glib.Properties.Build ("label"); 
  292.    Right_Justified_Property : constant Glib.Properties.Property_Boolean := 
  293.      Glib.Properties.Build ("right-justified"); 
  294.    Submenu_Property : constant Glib.Properties.Property_Object := 
  295.      Glib.Properties.Build ("submenu"); 
  296.    Use_Underline_Property : constant Glib.Properties.Property_Boolean := 
  297.      Glib.Properties.Build ("use-underline"); 
  298.  
  299.    Arrow_Scaling_Property : constant Glib.Properties.Property_Float := 
  300.      Glib.Properties.Build ("arrow-scaling"); 
  301.    Width_Chars_Property : constant Glib.Properties.Property_Int := 
  302.      Glib.Properties.Build ("width-chars"); 
  303.  
  304.    Null_Submenu : constant Widget.Gtk_Widget := null; 
  305.  
  306.    pragma Import (C, Get_Type, "gtk_menu_item_get_type"); 
  307. end Gtk.Menu_Item; 
  308.  
  309. --  missing: 
  310. --  procedure Toggle_Size_Request 
  311. --    (Menu_Item   : access Gtk_Menu_Item_Record; 
  312. --     Requisition : int*); 
  313. --  Emit the signal "toggle_size_request" 
  314.  
  315. --  procedure Toggle_Size_Allocate 
  316. --    (Menu_Item  : access Gtk_Menu_Item_Record; 
  317. --     Allocation : Gint); 
  318. --  Emit the signal "toggle_size_allocate"