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 toolbar is created with a call to Gtk.Toolbar.Gtk_New. 
  26. -- 
  27. --  A toolbar can contain instances of a subclass of 
  28. --  Gtk.Tool_Item.Gtk_Tool_Item. To add a Gtk.Tool_Item.Gtk_Tool_Item to the a 
  29. --  toolbar, use Gtk.Toolbar.Insert. To remove an item from the toolbar use 
  30. --  Gtk.Container.Remove. To add a button to the toolbar, add an instance of 
  31. --  Gtk.Tool_Button.Gtk_Tool_Button. 
  32. -- 
  33. --  Toolbar items can be visually grouped by adding instances of 
  34. --  Gtk.Separator_Tool_Item.Gtk_Separator_Tool_Item to the toolbar. If the 
  35. --  GtkToolbar child property "expand" is TRUE and the property 
  36. --  Gtk.Separator_Tool_Item.Gtk_Separator_Tool_Item:draw is set to FALSE, the 
  37. --  effect is to force all following items to the end of the toolbar. 
  38. -- 
  39. --  Creating a context menu for the toolbar can be done by connecting to the 
  40. --  Gtk.Toolbar.Gtk_Toolbar::popup-context-menu signal. 
  41. -- 
  42. --  </description> 
  43. pragma Ada_2005; 
  44.  
  45. pragma Warnings (Off, "*is already use-visible*"); 
  46. with Glib;            use Glib; 
  47. with Glib.Object;     use Glib.Object; 
  48. with Glib.Properties; use Glib.Properties; 
  49. with Glib.Types;      use Glib.Types; 
  50. with Gtk.Buildable;   use Gtk.Buildable; 
  51. with Gtk.Container;   use Gtk.Container; 
  52. with Gtk.Enums;       use Gtk.Enums; 
  53. with Gtk.Orientable;  use Gtk.Orientable; 
  54. with Gtk.Size_Group;  use Gtk.Size_Group; 
  55. with Gtk.Tool_Item;   use Gtk.Tool_Item; 
  56. with Gtk.Tool_Shell;  use Gtk.Tool_Shell; 
  57. with Pango.Layout;    use Pango.Layout; 
  58.  
  59. package Gtk.Toolbar is 
  60.  
  61.    type Gtk_Toolbar_Record is new Gtk_Container_Record with null record; 
  62.    type Gtk_Toolbar is access all Gtk_Toolbar_Record'Class; 
  63.  
  64.    ------------------ 
  65.    -- Constructors -- 
  66.    ------------------ 
  67.  
  68.    procedure Gtk_New (Toolbar : out Gtk_Toolbar); 
  69.    procedure Initialize (Toolbar : not null access Gtk_Toolbar_Record'Class); 
  70.    --  Creates a new toolbar. 
  71.  
  72.    function Gtk_Toolbar_New return Gtk_Toolbar; 
  73.    --  Creates a new toolbar. 
  74.  
  75.    function Get_Type return Glib.GType; 
  76.    pragma Import (C, Get_Type, "gtk_toolbar_get_type"); 
  77.  
  78.    ------------- 
  79.    -- Methods -- 
  80.    ------------- 
  81.  
  82.    function Get_Drop_Index 
  83.       (Toolbar : not null access Gtk_Toolbar_Record; 
  84.        X       : Gint; 
  85.        Y       : Gint) return Gint; 
  86.    --  Returns the position corresponding to the indicated point on Toolbar. 
  87.    --  This is useful when dragging items to the toolbar: this function returns 
  88.    --  the position a new item should be inserted. 
  89.    --  X and Y are in Toolbar coordinates. 
  90.    --  Since: gtk+ 2.4 
  91.    --  "x": x coordinate of a point on the toolbar 
  92.    --  "y": y coordinate of a point on the toolbar 
  93.  
  94.    function Get_Icon_Size 
  95.       (Toolbar : not null access Gtk_Toolbar_Record) 
  96.        return Gtk.Enums.Gtk_Icon_Size; 
  97.    --  Retrieves the icon size for the toolbar. See Gtk.Toolbar.Set_Icon_Size. 
  98.  
  99.    procedure Set_Icon_Size 
  100.       (Toolbar   : not null access Gtk_Toolbar_Record; 
  101.        Icon_Size : Gtk.Enums.Gtk_Icon_Size); 
  102.    --  This function sets the size of stock icons in the toolbar. You can call 
  103.    --  it both before you add the icons and after they've been added. The size 
  104.    --  you set will override user preferences for the default icon size. 
  105.    --  This should only be used for special-purpose toolbars, normal 
  106.    --  application toolbars should respect the user preferences for the size of 
  107.    --  icons. 
  108.    --  "icon_size": The Gtk.Enums.Gtk_Icon_Size that stock icons in the 
  109.    --  toolbar shall have. 
  110.  
  111.    function Get_Item_Index 
  112.       (Toolbar : not null access Gtk_Toolbar_Record; 
  113.        Item    : not null access Gtk.Tool_Item.Gtk_Tool_Item_Record'Class) 
  114.        return Gint; 
  115.    --  Returns the position of Item on the toolbar, starting from 0. It is an 
  116.    --  error if Item is not a child of the toolbar. 
  117.    --  Since: gtk+ 2.4 
  118.    --  "item": a Gtk.Tool_Item.Gtk_Tool_Item that is a child of Toolbar 
  119.  
  120.    function Get_N_Items 
  121.       (Toolbar : not null access Gtk_Toolbar_Record) return Gint; 
  122.    --  Returns the number of items on the toolbar. 
  123.    --  Since: gtk+ 2.4 
  124.  
  125.    function Get_Nth_Item 
  126.       (Toolbar : not null access Gtk_Toolbar_Record; 
  127.        N       : Gint) return Gtk.Tool_Item.Gtk_Tool_Item; 
  128.    --  Returns the N<!-- -->'th item on Toolbar, or null if the toolbar does 
  129.    --  not contain an N<!-- -->'th item. 
  130.    --  Since: gtk+ 2.4 
  131.    --  "n": A position on the toolbar 
  132.  
  133.    function Get_Relief_Style 
  134.       (Toolbar : not null access Gtk_Toolbar_Record) 
  135.        return Gtk.Enums.Gtk_Relief_Style; 
  136.    --  Returns the relief style of buttons on Toolbar. See 
  137.    --  Gtk.Button.Set_Relief. 
  138.    --  Since: gtk+ 2.4 
  139.  
  140.    function Get_Show_Arrow 
  141.       (Toolbar : not null access Gtk_Toolbar_Record) return Boolean; 
  142.    --  Returns whether the toolbar has an overflow menu. See 
  143.    --  Gtk.Toolbar.Set_Show_Arrow. 
  144.    --  Since: gtk+ 2.4 
  145.  
  146.    procedure Set_Show_Arrow 
  147.       (Toolbar    : not null access Gtk_Toolbar_Record; 
  148.        Show_Arrow : Boolean := True); 
  149.    --  Sets whether to show an overflow menu when Toolbar doesn't have room 
  150.    --  for all items on it. If True, items that there are not room are 
  151.    --  available through an overflow menu. 
  152.    --  Since: gtk+ 2.4 
  153.    --  "show_arrow": Whether to show an overflow menu 
  154.  
  155.    function Get_Style 
  156.       (Toolbar : not null access Gtk_Toolbar_Record) 
  157.        return Gtk.Enums.Gtk_Toolbar_Style; 
  158.    --  Retrieves whether the toolbar has text, icons, or both . See 
  159.    --  Gtk.Toolbar.Set_Style. 
  160.  
  161.    procedure Set_Style 
  162.       (Toolbar : not null access Gtk_Toolbar_Record; 
  163.        Style   : Gtk.Enums.Gtk_Toolbar_Style); 
  164.    --  Alters the view of Toolbar to display either icons only, text only, or 
  165.    --  both. 
  166.    --  "style": the new style for Toolbar. 
  167.  
  168.    procedure Insert 
  169.       (Toolbar : not null access Gtk_Toolbar_Record; 
  170.        Item    : not null access Gtk.Tool_Item.Gtk_Tool_Item_Record'Class; 
  171.        Pos     : Gint := -1); 
  172.    --  Insert a Gtk.Tool_Item.Gtk_Tool_Item into the toolbar at position Pos. 
  173.    --  If Pos is 0 the item is prepended to the start of the toolbar. If Pos is 
  174.    --  negative, the item is appended to the end of the toolbar. 
  175.    --  Since: gtk+ 2.4 
  176.    --  "item": a Gtk.Tool_Item.Gtk_Tool_Item 
  177.    --  "pos": the position of the new item 
  178.  
  179.    procedure Set_Drop_Highlight_Item 
  180.       (Toolbar   : not null access Gtk_Toolbar_Record; 
  181.        Tool_Item : access Gtk.Tool_Item.Gtk_Tool_Item_Record'Class; 
  182.        Index     : Gint); 
  183.    --  Highlights Toolbar to give an idea of what it would look like if Item 
  184.    --  was added to Toolbar at the position indicated by Index_. If Item is 
  185.    --  null, highlighting is turned off. In that case Index_ is ignored. 
  186.    --  The Tool_Item passed to this function must not be part of any widget 
  187.    --  hierarchy. When an item is set as drop highlight item it can not added 
  188.    --  to any widget hierarchy or used as highlight item for another toolbar. 
  189.    --  Since: gtk+ 2.4 
  190.    --  "tool_item": a Gtk.Tool_Item.Gtk_Tool_Item, or null to turn of 
  191.    --  highlighting 
  192.    --  "index_": a position on Toolbar 
  193.  
  194.    procedure Unset_Icon_Size (Toolbar : not null access Gtk_Toolbar_Record); 
  195.    --  Unsets toolbar icon size set with Gtk.Toolbar.Set_Icon_Size, so that 
  196.    --  user preferences will be used to determine the icon size. 
  197.  
  198.    procedure Unset_Style (Toolbar : not null access Gtk_Toolbar_Record); 
  199.    --  Unsets a toolbar style set with Gtk.Toolbar.Set_Style, so that user 
  200.    --  preferences will be used to determine the toolbar style. 
  201.  
  202.    --------------------------------------------- 
  203.    -- Inherited subprograms (from interfaces) -- 
  204.    --------------------------------------------- 
  205.    --  Methods inherited from the Buildable interface are not duplicated here 
  206.    --  since they are meant to be used by tools, mostly. If you need to call 
  207.    --  them, use an explicit cast through the "-" operator below. 
  208.  
  209.    function Get_Orientation 
  210.       (Self : not null access Gtk_Toolbar_Record) 
  211.        return Gtk.Enums.Gtk_Orientation; 
  212.  
  213.    procedure Set_Orientation 
  214.       (Self        : not null access Gtk_Toolbar_Record; 
  215.        Orientation : Gtk.Enums.Gtk_Orientation); 
  216.  
  217.    function Get_Ellipsize_Mode 
  218.       (Self : not null access Gtk_Toolbar_Record) 
  219.        return Pango.Layout.Pango_Ellipsize_Mode; 
  220.  
  221.    function Get_Text_Alignment 
  222.       (Self : not null access Gtk_Toolbar_Record) return Gfloat; 
  223.  
  224.    function Get_Text_Orientation 
  225.       (Self : not null access Gtk_Toolbar_Record) 
  226.        return Gtk.Enums.Gtk_Orientation; 
  227.  
  228.    function Get_Text_Size_Group 
  229.       (Self : not null access Gtk_Toolbar_Record) 
  230.        return Gtk.Size_Group.Gtk_Size_Group; 
  231.  
  232.    procedure Rebuild_Menu (Self : not null access Gtk_Toolbar_Record); 
  233.  
  234.    ---------------- 
  235.    -- Properties -- 
  236.    ---------------- 
  237.    --  The following properties are defined for this widget. See 
  238.    --  Glib.Properties for more information on properties) 
  239.  
  240.    Icon_Size_Property : constant Glib.Properties.Property_Int; 
  241.    --  The size of the icons in a toolbar is normally determined by the 
  242.    --  toolbar-icon-size setting. When this property is set, it overrides the 
  243.    --  setting. 
  244.    -- 
  245.    --  This should only be used for special-purpose toolbars, normal 
  246.    --  application toolbars should respect the user preferences for the size of 
  247.    --  icons. 
  248.  
  249.    Icon_Size_Set_Property : constant Glib.Properties.Property_Boolean; 
  250.    --  Is True if the icon-size property has been set. 
  251.  
  252.    Show_Arrow_Property : constant Glib.Properties.Property_Boolean; 
  253.  
  254.    Toolbar_Style_Property : constant Gtk.Enums.Property_Gtk_Toolbar_Style; 
  255.  
  256.    ------------- 
  257.    -- Signals -- 
  258.    ------------- 
  259.  
  260.    type Cb_Gtk_Toolbar_Boolean_Boolean is not null access function 
  261.      (Self       : access Gtk_Toolbar_Record'Class; 
  262.       Focus_Home : Boolean) return Boolean; 
  263.  
  264.    type Cb_GObject_Boolean_Boolean is not null access function 
  265.      (Self       : access Glib.Object.GObject_Record'Class; 
  266.       Focus_Home : Boolean) return Boolean; 
  267.  
  268.    Signal_Focus_Home_Or_End : constant Glib.Signal_Name := "focus-home-or-end"; 
  269.    procedure On_Focus_Home_Or_End 
  270.       (Self  : not null access Gtk_Toolbar_Record; 
  271.        Call  : Cb_Gtk_Toolbar_Boolean_Boolean; 
  272.        After : Boolean := False); 
  273.    procedure On_Focus_Home_Or_End 
  274.       (Self  : not null access Gtk_Toolbar_Record; 
  275.        Call  : Cb_GObject_Boolean_Boolean; 
  276.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  277.        After : Boolean := False); 
  278.    --  A keybinding signal used internally by GTK+. This signal can't be used 
  279.    --  in application code 
  280.    --  
  281.    --  Callback parameters: 
  282.    --    --  "focus_home": True if the first item should be focused 
  283.    --    --  Returns True if the signal was handled, False if not 
  284.  
  285.    type Cb_Gtk_Toolbar_Gtk_Orientation_Void is not null access procedure 
  286.      (Self        : access Gtk_Toolbar_Record'Class; 
  287.       Orientation : Gtk.Enums.Gtk_Orientation); 
  288.  
  289.    type Cb_GObject_Gtk_Orientation_Void is not null access procedure 
  290.      (Self        : access Glib.Object.GObject_Record'Class; 
  291.       Orientation : Gtk.Enums.Gtk_Orientation); 
  292.  
  293.    Signal_Orientation_Changed : constant Glib.Signal_Name := "orientation-changed"; 
  294.    procedure On_Orientation_Changed 
  295.       (Self  : not null access Gtk_Toolbar_Record; 
  296.        Call  : Cb_Gtk_Toolbar_Gtk_Orientation_Void; 
  297.        After : Boolean := False); 
  298.    procedure On_Orientation_Changed 
  299.       (Self  : not null access Gtk_Toolbar_Record; 
  300.        Call  : Cb_GObject_Gtk_Orientation_Void; 
  301.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  302.        After : Boolean := False); 
  303.    --  Emitted when the orientation of the toolbar changes. 
  304.  
  305.    type Cb_Gtk_Toolbar_Gint_Gint_Gint_Boolean is not null access function 
  306.      (Self   : access Gtk_Toolbar_Record'Class; 
  307.       X      : Gint; 
  308.       Y      : Gint; 
  309.       Button : Gint) return Boolean; 
  310.  
  311.    type Cb_GObject_Gint_Gint_Gint_Boolean is not null access function 
  312.      (Self   : access Glib.Object.GObject_Record'Class; 
  313.       X      : Gint; 
  314.       Y      : Gint; 
  315.       Button : Gint) return Boolean; 
  316.  
  317.    Signal_Popup_Context_Menu : constant Glib.Signal_Name := "popup-context-menu"; 
  318.    procedure On_Popup_Context_Menu 
  319.       (Self  : not null access Gtk_Toolbar_Record; 
  320.        Call  : Cb_Gtk_Toolbar_Gint_Gint_Gint_Boolean; 
  321.        After : Boolean := False); 
  322.    procedure On_Popup_Context_Menu 
  323.       (Self  : not null access Gtk_Toolbar_Record; 
  324.        Call  : Cb_GObject_Gint_Gint_Gint_Boolean; 
  325.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  326.        After : Boolean := False); 
  327.    --  Emitted when the user right-clicks the toolbar or uses the keybinding 
  328.    --  to display a popup menu. 
  329.    -- 
  330.    --  Application developers should handle this signal if they want to 
  331.    --  display a context menu on the toolbar. The context-menu should appear at 
  332.    --  the coordinates given by X and Y. The mouse button number is given by 
  333.    --  the Button parameter. If the menu was popped up using the keybaord, 
  334.    --  Button is -1. 
  335.    --  
  336.    --  Callback parameters: 
  337.    --    --  "x": the x coordinate of the point where the menu should appear 
  338.    --    --  "y": the y coordinate of the point where the menu should appear 
  339.    --    --  "button": the mouse button the user pressed, or -1 
  340.    --    --  Returns return True if the signal was handled, False if not 
  341.  
  342.    type Cb_Gtk_Toolbar_Gtk_Toolbar_Style_Void is not null access procedure 
  343.      (Self  : access Gtk_Toolbar_Record'Class; 
  344.       Style : Gtk.Enums.Gtk_Toolbar_Style); 
  345.  
  346.    type Cb_GObject_Gtk_Toolbar_Style_Void is not null access procedure 
  347.      (Self  : access Glib.Object.GObject_Record'Class; 
  348.       Style : Gtk.Enums.Gtk_Toolbar_Style); 
  349.  
  350.    Signal_Style_Changed : constant Glib.Signal_Name := "style-changed"; 
  351.    procedure On_Style_Changed 
  352.       (Self  : not null access Gtk_Toolbar_Record; 
  353.        Call  : Cb_Gtk_Toolbar_Gtk_Toolbar_Style_Void; 
  354.        After : Boolean := False); 
  355.    procedure On_Style_Changed 
  356.       (Self  : not null access Gtk_Toolbar_Record; 
  357.        Call  : Cb_GObject_Gtk_Toolbar_Style_Void; 
  358.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  359.        After : Boolean := False); 
  360.    --  Emitted when the style of the toolbar changes. 
  361.  
  362.    ---------------- 
  363.    -- Interfaces -- 
  364.    ---------------- 
  365.    --  This class implements several interfaces. See Glib.Types 
  366.    -- 
  367.    --  - "Buildable" 
  368.    -- 
  369.    --  - "Orientable" 
  370.    -- 
  371.    --  - "ToolShell" 
  372.  
  373.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  374.      (Gtk.Buildable.Gtk_Buildable, Gtk_Toolbar_Record, Gtk_Toolbar); 
  375.    function "+" 
  376.      (Widget : access Gtk_Toolbar_Record'Class) 
  377.    return Gtk.Buildable.Gtk_Buildable 
  378.    renames Implements_Gtk_Buildable.To_Interface; 
  379.    function "-" 
  380.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  381.    return Gtk_Toolbar 
  382.    renames Implements_Gtk_Buildable.To_Object; 
  383.  
  384.    package Implements_Gtk_Orientable is new Glib.Types.Implements 
  385.      (Gtk.Orientable.Gtk_Orientable, Gtk_Toolbar_Record, Gtk_Toolbar); 
  386.    function "+" 
  387.      (Widget : access Gtk_Toolbar_Record'Class) 
  388.    return Gtk.Orientable.Gtk_Orientable 
  389.    renames Implements_Gtk_Orientable.To_Interface; 
  390.    function "-" 
  391.      (Interf : Gtk.Orientable.Gtk_Orientable) 
  392.    return Gtk_Toolbar 
  393.    renames Implements_Gtk_Orientable.To_Object; 
  394.  
  395.    package Implements_Gtk_Tool_Shell is new Glib.Types.Implements 
  396.      (Gtk.Tool_Shell.Gtk_Tool_Shell, Gtk_Toolbar_Record, Gtk_Toolbar); 
  397.    function "+" 
  398.      (Widget : access Gtk_Toolbar_Record'Class) 
  399.    return Gtk.Tool_Shell.Gtk_Tool_Shell 
  400.    renames Implements_Gtk_Tool_Shell.To_Interface; 
  401.    function "-" 
  402.      (Interf : Gtk.Tool_Shell.Gtk_Tool_Shell) 
  403.    return Gtk_Toolbar 
  404.    renames Implements_Gtk_Tool_Shell.To_Object; 
  405.  
  406. private 
  407.    Toolbar_Style_Property : constant Gtk.Enums.Property_Gtk_Toolbar_Style := 
  408.      Gtk.Enums.Build ("toolbar-style"); 
  409.    Show_Arrow_Property : constant Glib.Properties.Property_Boolean := 
  410.      Glib.Properties.Build ("show-arrow"); 
  411.    Icon_Size_Set_Property : constant Glib.Properties.Property_Boolean := 
  412.      Glib.Properties.Build ("icon-size-set"); 
  413.    Icon_Size_Property : constant Glib.Properties.Property_Int := 
  414.      Glib.Properties.Build ("icon-size"); 
  415. end Gtk.Toolbar;