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. -- 
  27. --  This widget is a base class for all menu widgets. It contains a list of 
  28. --  items that can be navigated, selected and activated by the user. 
  29. --  It can not be instantiated directly. 
  30. -- 
  31. --  A menu is considered "active" when it is displayed on the screen, or, in 
  32. --  the case of a menu_bar when one of its menus is active. 
  33. -- 
  34. --  An item is "selected" if it is displayed in a prelight state and its 
  35. --  submenu (if any) displayed. 
  36. -- 
  37. --  </description> 
  38. --  <c_version>2.8.17</c_version> 
  39. --  <group>Menus and Toolbars</group> 
  40.  
  41. with Glib.Properties; 
  42. with Gtk.Container; 
  43. with Gtk.Menu_Item; use Gtk.Menu_Item; 
  44.  
  45. package Gtk.Menu_Shell is 
  46.  
  47.    type Gtk_Menu_Shell_Record is new 
  48.      Gtk.Container.Gtk_Container_Record with private; 
  49.    type Gtk_Menu_Shell is access all Gtk_Menu_Shell_Record'Class; 
  50.  
  51.    function Get_Type return Gtk.Gtk_Type; 
  52.    --  Return the internal value associated with a Gtk_Menu_Shell. 
  53.  
  54.    procedure Append 
  55.      (Menu_Shell : access Gtk_Menu_Shell_Record; 
  56.       Child      : access Gtk_Menu_Item_Record'Class); 
  57.    --  Add a new item at the end of the menu. 
  58.  
  59.    procedure Prepend 
  60.      (Menu_Shell : access Gtk_Menu_Shell_Record; 
  61.       Child      : access Gtk_Menu_Item_Record'Class); 
  62.    --  Add a new item at the beginning of the menu 
  63.  
  64.    procedure Insert 
  65.      (Menu_Shell : access Gtk_Menu_Shell_Record; 
  66.       Child      : access Gtk_Menu_Item_Record'Class; 
  67.       Position   : Gint); 
  68.    --  Add a new item at a specific position in the menu. 
  69.    --  The first item is at position 0. To insert as the last item in the menu, 
  70.    --  set Position to -1. 
  71.  
  72.    procedure Set_Take_Focus 
  73.      (Menu_Shell : access Gtk_Menu_Shell_Record; 
  74.       Take_Focus : Boolean := True); 
  75.    function Get_Take_Focus 
  76.      (Menu_Shell : access Gtk_Menu_Shell_Record) return Boolean; 
  77.    --  If Take_Focus is TRUE the menu shell will take the keyboard focus so 
  78.    --  that it will receive all keyboard events which is needed to enable 
  79.    --  keyboard navigation in menus. 
  80.    -- 
  81.    --  Setting Take_Focus to FALSE is useful only for special applications like 
  82.    --  virtual keyboard implementations which should not take keyboard focus. 
  83.    -- 
  84.    --  The Take_Focus state of a menu or menu bar is automatically propagated 
  85.    --  to submenus whenever a submenu is popped up, so you don't have to worry 
  86.    --  about recursively setting it for your entire menu hierarchy. Only when 
  87.    --  programmatically picking a submenu and popping it up manually, the 
  88.    --  Take_Focus property of the submenu needs to be set explicitely. 
  89.    -- 
  90.    --  Note that setting it to %ALSE has side-effects: 
  91.    -- 
  92.    --  If the focus is in some other app, it keeps the focus and keynav in 
  93.    --  the menu doesn't work. Consequently, keynav on the menu will only 
  94.    --  work if the focus is on some toplevel owned by the onscreen keyboard. 
  95.    -- 
  96.    --  To avoid confusing the user, menus with Take_Focus set to FALSE 
  97.    --  should not display mnemonics or accelerators, since it cannot be 
  98.    --  guaranteed that they will work. 
  99.  
  100.    procedure Select_First 
  101.      (Menu_Shell       : access Gtk_Menu_Shell_Record; 
  102.       Search_Sensitive : Boolean); 
  103.    --  Select the first visible or selectable child of the menu shell; 
  104.    --  don't select tearoff items unless the only item is a tearoff 
  105.    --  item. 
  106.    --  If Search_Sensitive is True, search for the first selectable menu item, 
  107.    --  otherwise select nothing if the first item isn't sensitive. This should 
  108.    --  be False if the menu is being popped up initially. 
  109.  
  110.    ---------------------- 
  111.    -- Signals emission -- 
  112.    ---------------------- 
  113.  
  114.    procedure Deactivate (Menu_Shell : access Gtk_Menu_Shell_Record); 
  115.    --  Emit the "deactivate" signal. 
  116.    --  This deselects the selected item, ungrabs the mouse and keyboard, and 
  117.    --  erase the Menu_Shell from the screen. 
  118.  
  119.    procedure Select_Item 
  120.      (Menu_Shell : access Gtk_Menu_Shell_Record; 
  121.       Item       : access Gtk_Menu_Item_Record'Class); 
  122.    --  Select a new item in the menu, after deselecting the current item. 
  123.  
  124.    procedure Deselect (Menu_Shell : access Gtk_Menu_Shell_Record); 
  125.    --  Deselect the currently selected item. 
  126.  
  127.    procedure Activate_Item 
  128.      (Menu_Shell       : access Gtk_Menu_Shell_Record; 
  129.       Item             : access Gtk_Menu_Item_Record'Class; 
  130.       Force_Deactivate : Boolean); 
  131.    --  Activate the item. 
  132.    --  If Force_Deactivate is True or the menu_shell sets this property, 
  133.    --  Menu_Shell and all its parent menus are deactivated and erased from 
  134.    --  the screen. 
  135.  
  136.    procedure Cancel (Menu_Shell : access Gtk_Menu_Shell_Record); 
  137.    --  Cancels the selection within the menu shell. 
  138.  
  139.    ---------------- 
  140.    -- Properties -- 
  141.    ---------------- 
  142.  
  143.    --  <properties> 
  144.    --  The following properties are defined for this widget. See 
  145.    --  Glib.Properties for more information on properties. 
  146.    -- 
  147.    --  Name:  Take_Focus_Property 
  148.    --  Type:  Boolean 
  149.    --  Descr: A boolean that determines whether the menu grabs the keyboard 
  150.    --         focus 
  151.    -- 
  152.    --  </properties> 
  153.  
  154.    Take_Focus_Property : constant Glib.Properties.Property_Boolean; 
  155.  
  156.    ------------- 
  157.    -- Signals -- 
  158.    ------------- 
  159.  
  160.    --  <signals> 
  161.    --  The following new signals are defined for this widget: 
  162.    -- 
  163.    --  - "deactivate" 
  164.    --    procedure Handler (Menu_Shell : access Gtk_Menu_Shell_Record'Class); 
  165.    --    Emitted when the menu is deactivated, ie is erased from the screen. 
  166.    -- 
  167.    --  - "selection-done" 
  168.    --    procedure Handler (Menu_Shell : access Gtk_Menu_Shell_Record'Class); 
  169.    --    Emitted when an item has been selected. The menu shell might not be 
  170.    --    activated when the signal is emitted. 
  171.    -- 
  172.    --  - "move_current" 
  173.    --    procedure Handler (Menu_Shell : access Gtk_Menu_Shell_Record'Class; 
  174.    --                       Direction  : Gtk_Menu_Direction_Type); 
  175.    --    You should emit this signal to request that another menu item be 
  176.    --    selected. It is mostly useful when bound to a keybinding. 
  177.    --    In a menu, this is bound by default to the arrow keys to move the 
  178.    --    the selection. 
  179.    -- 
  180.    --  - "cycle_focus" 
  181.    --    procedure Handler (Menu_Shell : access Gtk_Menu_Shell_Record'Class; 
  182.    --                       Direction  : Gtk_Menu_Direction_Type); 
  183.    --    You should emit this signal to request that another child of 
  184.    --    Menu_Shell gets the focus. The child is not activated. 
  185.    -- 
  186.    --  - "activate_current" 
  187.    --    procedure Handler (Menu_Shell : access Gtk_Menu_Shell_Record'Class; 
  188.    --                       Force_Hide : Gboolean); 
  189.    --    Activates the current menu item within the Menu_Shell. 
  190.    --    if Force_Hide is True, hide the menu afterwards. 
  191.    -- 
  192.    --  - "cancel" 
  193.    --    procedure Handler (Menu_Shell : access Gtk_Menu_Shell_Record'Class); 
  194.    --    Cancels the selection within the menu_shell. Causes a "selection-done" 
  195.    --    signal to be emitted. 
  196.    -- 
  197.    --  </signals> 
  198.  
  199.    Signal_Activate_Current : constant Glib.Signal_Name := "activate_current"; 
  200.    Signal_Cancel           : constant Glib.Signal_Name := "cancel"; 
  201.    Signal_Cycle_Focus      : constant Glib.Signal_Name := "cycle_focus"; 
  202.    Signal_Deactivate       : constant Glib.Signal_Name := "deactivate"; 
  203.    Signal_Move_Current     : constant Glib.Signal_Name := "move_current"; 
  204.    Signal_Selection_Done   : constant Glib.Signal_Name := "selection-done"; 
  205.  
  206. private 
  207.    type Gtk_Menu_Shell_Record is new 
  208.      Gtk.Container.Gtk_Container_Record with null record; 
  209.  
  210.    Take_Focus_Property : constant Glib.Properties.Property_Boolean := 
  211.      Glib.Properties.Build ("take-focus"); 
  212.  
  213.    pragma Import (C, Get_Type, "gtk_menu_shell_get_type"); 
  214. end Gtk.Menu_Shell;