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