1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --                Copyright (C) 2006-2010 AdaCore                    -- 
  5. --                                                                   -- 
  6. -- This library is free software; you can redistribute it and/or     -- 
  7. -- modify it under the terms of the GNU General Public               -- 
  8. -- License as published by the Free Software Foundation; either      -- 
  9. -- version 2 of the License, or (at your option) any later version.  -- 
  10. --                                                                   -- 
  11. -- This library is distributed in the hope that it will be useful,   -- 
  12. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  13. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  14. -- General Public License for more details.                          -- 
  15. --                                                                   -- 
  16. -- You should have received a copy of the GNU General Public         -- 
  17. -- License along with this library; if not, write to the             -- 
  18. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  19. -- Boston, MA 02111-1307, USA.                                       -- 
  20. --                                                                   -- 
  21. -- As a special exception, if other files instantiate generics from  -- 
  22. -- this unit, or you link this unit with other files to produce an   -- 
  23. -- executable, this  unit  does not  by itself cause  the resulting  -- 
  24. -- executable to be covered by the GNU General Public License. This  -- 
  25. -- exception does not however invalidate any other reasons why the   -- 
  26. -- executable file  might be covered by the  GNU Public License.     -- 
  27. ----------------------------------------------------------------------- 
  28.  
  29. --  <description> 
  30. --  This package defines the base class for all items that can be added into 
  31. --  a toolbar (see gtk-toolbar.ads). 
  32. --  See also Gtk.Tool_Button (gtk-tool_button.ads). 
  33. --  See also Gtk.Separator_Tool_Item (gtk-separator_tool_item). 
  34. --  </description> 
  35. --  <c_version>2.16.6</c_version> 
  36. --  <group>Menus and Toolbars</group> 
  37.  
  38. with Glib.Properties; 
  39. with Gtk.Bin; 
  40. with Gtk.Enums; 
  41. with Gtk.Menu_Item; 
  42. with Gtk.Tooltips; 
  43.  
  44. package Gtk.Tool_Item is 
  45.  
  46.    type Gtk_Tool_Item_Record is new Gtk.Bin.Gtk_Bin_Record with null record; 
  47.    type Gtk_Tool_Item is access all Gtk_Tool_Item_Record'Class; 
  48.  
  49.    -------------------- 
  50.    -- Creating items -- 
  51.    -------------------- 
  52.  
  53.    procedure Gtk_New    (Item : out Gtk_Tool_Item); 
  54.    procedure Initialize (Item : access Gtk_Tool_Item_Record'Class); 
  55.    --  Create a new tool item, which contains a single child. 
  56.  
  57.    function Get_Type return GType; 
  58.    --  Return the internal value associated with a Gtk_Button. 
  59.  
  60.    procedure Set_Expand 
  61.      (Tool_Item : access Gtk_Tool_Item_Record; 
  62.       Expand    : Boolean); 
  63.    function Get_Expand 
  64.      (Tool_Item : access Gtk_Tool_Item_Record) 
  65.       return Boolean; 
  66.    --   Sets whether Tool_Item is allocated extra space when there is more room 
  67.    --   on the toolbar than needed for the items. The effect is that the item 
  68.    --   gets bigger when the toolbar gets bigger. 
  69.  
  70.    procedure Set_Homogeneous 
  71.      (Tool_Item   : access Gtk_Tool_Item_Record; 
  72.       Homogeneous : Boolean); 
  73.    function Get_Homogeneous 
  74.      (Tool_Item : access Gtk_Tool_Item_Record) 
  75.       return Boolean; 
  76.    --  Sets whether Tool_Item is to be allocated the same size as other 
  77.    --  homogeneous items. The effect is that all homogeneous items will have 
  78.    --  the same width as the widest of the items. 
  79.  
  80.    function Get_Icon_Size 
  81.      (Tool_Item : access Gtk_Tool_Item_Record) 
  82.       return Gtk.Enums.Gtk_Icon_Size; 
  83.    --  Returns the icon size used for Tool_Item. Custom subclasses of 
  84.    --  Gtk_Tool_Item_Record should call this function to find out what size 
  85.    --  icons they should use. This settings depends on the toolbar that 
  86.    --  contains the item 
  87.  
  88.    procedure Set_Is_Important 
  89.      (Tool_Item    : access Gtk_Tool_Item_Record; 
  90.       Is_Important : Boolean); 
  91.    function Get_Is_Important 
  92.      (Tool_Item : access Gtk_Tool_Item_Record) 
  93.       return Boolean; 
  94.    --  Sets whether Tool_Item should be considered important. The 
  95.    --  Gtk_Tool_Button class uses this property to determine whether to show or 
  96.    --  hide its label when the toolbar style is Toolbar_Both_Horiz. The result 
  97.    --  is that only tool buttons with the "is_important" property set have 
  98.    --  labels, an effect known as "priority text". 
  99.  
  100.    function Get_Orientation 
  101.      (Tool_Item : access Gtk_Tool_Item_Record) 
  102.       return Gtk.Enums.Gtk_Orientation; 
  103.    --  Returns the orientation used for Tool_Item. 
  104.  
  105.    procedure Set_Proxy_Menu_Item 
  106.      (Tool_Item    : access Gtk_Tool_Item_Record; 
  107.       Menu_Item_Id : String; 
  108.       Menu_Item    : Gtk.Menu_Item.Gtk_Menu_Item); 
  109.    function Get_Proxy_Menu_Item 
  110.      (Tool_Item    : access Gtk_Tool_Item_Record; 
  111.       Menu_Item_Id : String) 
  112.       return Gtk.Menu_Item.Gtk_Menu_Item; 
  113.    --  Sets the menu item used in the toolbar overflow menu. Menu_Item_Id is 
  114.    --  used to identify the caller of this function and should also be used 
  115.    --  with Get_Proxy_Menu_Item. 
  116.    --  Custom subclasses of Gtk_Tool_Item_Record should use this function to 
  117.    --  update their menu item when the tool item changes. 
  118.    --  See also Gtk.Toolbar.Set_Show_Arrow. 
  119.  
  120.    function Retrieve_Proxy_Menu_Item 
  121.      (Tool_Item : access Gtk_Tool_Item_Record) 
  122.       return Gtk.Menu_Item.Gtk_Menu_Item; 
  123.    --  Returns the menu item that was last set by Set_Proxy_Menu_Item, ie the 
  124.    --  menu item that will appear in the overflow menu. This might be 
  125.    --  different from the one set through Set_Proxy_Menu_Item, if someone else 
  126.    --  has overriden the menu afterward. 
  127.  
  128.    procedure Rebuild_Menu (Tool_Item : access Gtk_Tool_Item_Record); 
  129.    --  Calling this function signals to the toolbar that the 
  130.    --  overflow menu item for Tool_Item has changed. If the 
  131.    --  overflow menu is visible when this function it called, 
  132.    --  the menu will be rebuilt. 
  133.  
  134.    procedure Set_Tooltip 
  135.      (Tool_Item   : access Gtk_Tool_Item_Record; 
  136.       Tooltips    : access Gtk.Tooltips.Gtk_Tooltips_Record'Class; 
  137.       Tip_Text    : String; 
  138.       Tip_Private : String := ""); 
  139.    --  Sets the tooltips object to be used for Tool item, the text to be 
  140.    --  displayed as tooltip on the item and the private text to be used 
  141.  
  142.    procedure Set_Tooltip_Markup 
  143.      (Tool_Item : access Gtk_Tool_Item_Record; 
  144.       Markup    : UTF8_String); 
  145.    --  Sets the markup text to be displayed as tooltip on the item. 
  146.    --  See Gtk.Widget.Set_Tooltip_Markup. 
  147.  
  148.    procedure Set_Tooltip_Text 
  149.      (Tool_Item : access Gtk_Tool_Item_Record; 
  150.       Text      : UTF8_String); 
  151.    --  Sets the text to be displayed as tooltip on the item. 
  152.    --  See Gtk.Widget.Set_Tooltip_Text. 
  153.  
  154.    procedure Set_Visible_Vertical 
  155.      (Toolitem         : access Gtk_Tool_Item_Record; 
  156.       Visible_Vertical : Boolean); 
  157.    function Get_Visible_Vertical 
  158.      (Toolitem : access Gtk_Tool_Item_Record) 
  159.       return Boolean; 
  160.    --  Sets whether Toolitem is visible when the toolbar is docked 
  161.    --  vertically. Some tool items, such as text entries, are too wide to be 
  162.    --  useful on a vertically docked toolbar. If visible_vertical is False 
  163.    --  Toolitem will not appear on toolbars that are docked vertically. 
  164.  
  165.    procedure Set_Visible_Horizontal 
  166.      (Toolitem           : access Gtk_Tool_Item_Record; 
  167.       Visible_Horizontal : Boolean); 
  168.    function Get_Visible_Horizontal 
  169.      (Toolitem : access Gtk_Tool_Item_Record) 
  170.       return Boolean; 
  171.    --  Same as Set_Visible_Vertical, but for a horizontal orientation 
  172.  
  173.    procedure Set_Use_Drag_Window 
  174.      (Toolitem        : access Gtk_Tool_Item_Record; 
  175.       Use_Drag_Window : Boolean); 
  176.    function Get_Use_Drag_Window 
  177.      (Toolitem : access Gtk_Tool_Item_Record) 
  178.       return Boolean; 
  179.    --  Sets whether Toolitem has a drag window. When True the 
  180.    --  toolitem can be used as a drag source through gtk_drag_source_set(). 
  181.    --  When Toolitem has a drag window it will intercept all events, 
  182.    --  even those that would otherwise be sent to a child of Toolitem. 
  183.  
  184.    function Get_Relief_Style 
  185.      (Tool_Item : access Gtk_Tool_Item_Record) 
  186.       return Gtk.Enums.Gtk_Relief_Style; 
  187.    --  Get the relief style of the item 
  188.  
  189.    function Get_Toolbar_Style 
  190.      (Tool_Item : access Gtk_Tool_Item_Record) 
  191.       return Gtk.Enums.Gtk_Toolbar_Style; 
  192.    --  Get the style of the toolbar that contains the item 
  193.  
  194.    procedure Toolbar_Reconfigured (Tool_Item : access Gtk_Tool_Item_Record); 
  195.    --  Emits the signal #GtkToolItem::toolbar_reconfigured on Tool_Item. 
  196.    --  Gtk_Toolbar and other Gtk_Tool_Shell implementations use this function 
  197.    --  to notify children when some aspect of their configuration changes. 
  198.  
  199.    ---------------- 
  200.    -- Properties -- 
  201.    ---------------- 
  202.  
  203.    --  <properties> 
  204.    --  The following properties are defined for this widget. See 
  205.    --  Glib.Properties for more information on properties. 
  206.    -- 
  207.    --  - Name: Visible_Horizontal_Property 
  208.    --    Type: Boolean 
  209.    --    See : Set_Visible_Horizontal 
  210.    -- 
  211.    --  - Name: Visible_Vertical_Property 
  212.    --    Type: Boolean 
  213.    --    See : Set_Visible_Vertical 
  214.    -- 
  215.    --  - Name: Is_Important_Property 
  216.    --    Type: Boolean 
  217.    --    See : Set_Is_Important 
  218.    -- 
  219.    --  </properties> 
  220.  
  221.    Visible_Horizontal_Property : constant Glib.Properties.Property_Boolean; 
  222.    Visible_Vertical_Property   : constant Glib.Properties.Property_Boolean; 
  223.    Is_Important_Property       : constant Glib.Properties.Property_Boolean; 
  224.  
  225.    ------------- 
  226.    -- Signals -- 
  227.    ------------- 
  228.  
  229.    --  <signals> 
  230.    --  The following new signals are defined for this widget: 
  231.    -- 
  232.    --  - "create_menu_proxy" 
  233.    --    function Handler 
  234.    --       (Item : access Gtk_Tool_Item_Record'Class) return Boolean; 
  235.    --    Emitted when the toolbar needs information from the item about whether 
  236.    --    the item should appear in the toolbar overflow menu. In response, the 
  237.    --    item should either: 
  238.    --       - call Set_Proxy_Menu_Item with a null parameter, and return True, 
  239.    --         to indicate that the item should not appear 
  240.    --       - call Set_Proxy_Menu_Item with a new menu item, and return True 
  241.    --       - return False to indicate that the signal wasn't handled. The item 
  242.    --         will not appear in the overflow menu unless a later handler 
  243.    --         installs a menu item 
  244.    --    The toolbar may cache the result of this signal. See Rebuild_Menu to 
  245.    --    invalidate the cache. 
  246.    -- 
  247.    --  - "toolbar_reconfigured" 
  248.    --    procedure Handler (Item : access Gtk_Tool_Item_Record'Class); 
  249.    --    Emitted when some property of the toolbar that Item belongs to has 
  250.    --    changed. 
  251.    -- 
  252.    --  - "set_tooltip" 
  253.    --    function Handler 
  254.    --       (Item        : access Gtk_Tool_Item_Record'Class; 
  255.    --        Tooltips    : access Gtk_Tooltips_Record'Class; 
  256.    --        Tip         : String; 
  257.    --        Tip_Private : String) return Boolean; 
  258.    --    Emitted when the item's tooltip has changed through Set_Tooltip. 
  259.    --    Should return True if the signal was handled. 
  260.    -- 
  261.    --  </signals> 
  262.  
  263.    Signal_Create_Menu_Proxy    : constant Glib.Signal_Name := 
  264.                                    "create_menu_proxy"; 
  265.    Signal_Toolbar_Reconfigured : constant Glib.Signal_Name := 
  266.                                    "toolbar_reconfigured"; 
  267.    Signal_Set_Tooltip          : constant Glib.Signal_Name := 
  268.                                    "set_tooltip"; 
  269.  
  270. private 
  271.  
  272.    pragma Import (C, Get_Type, "gtk_tool_item_get_type"); 
  273.  
  274.    Visible_Horizontal_Property : constant Glib.Properties.Property_Boolean := 
  275.      Glib.Properties.Build ("visible-horizontal"); 
  276.    Visible_Vertical_Property   : constant Glib.Properties.Property_Boolean := 
  277.      Glib.Properties.Build ("visible-vertical"); 
  278.    Is_Important_Property       : constant Glib.Properties.Property_Boolean := 
  279.      Glib.Properties.Build ("is-important"); 
  280. end Gtk.Tool_Item;