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. --  GtkOverlay is a container which contains a single main child, on top of 
  26. --  which it can place 'overlay' widgets. The position of each overlay widget 
  27. --  is determined by its Gtk.Widget.Gtk_Widget:halign and 
  28. --  Gtk.Widget.Gtk_Widget:valign properties. E.g. a widget with both alignments 
  29. --  set to Gtk.Widget.Align_Start will be placed at the top left corner of the 
  30. --  main widget, whereas an overlay with halign set to Gtk.Widget.Align_Center 
  31. --  and valign set to Gtk.Widget.Align_End will be placed a the bottom edge of 
  32. --  the main widget, horizontally centered. The position can be adjusted by 
  33. --  setting the margin properties of the child to non-zero values. 
  34. -- 
  35. --  More complicated placement of overlays is possible by connecting to the 
  36. --  Gtk.Overlay.Gtk_Overlay::get-child-position signal. 
  37. -- 
  38. --  == GtkOverlay as GtkBuildable == 
  39. -- 
  40. --  The GtkOverlay implementation of the GtkBuildable interface supports 
  41. --  placing a child as an overlay by specifying "overlay" as the "type" 
  42. --  attribute of a <tag class="starttag">child</tag> element. 
  43. -- 
  44. -- 
  45. --  </description> 
  46. pragma Ada_2005; 
  47.  
  48. pragma Warnings (Off, "*is already use-visible*"); 
  49. with Cairo.Region;  use Cairo.Region; 
  50. with Glib;          use Glib; 
  51. with Glib.Object;   use Glib.Object; 
  52. with Glib.Types;    use Glib.Types; 
  53. with Gtk.Bin;       use Gtk.Bin; 
  54. with Gtk.Buildable; use Gtk.Buildable; 
  55. with Gtk.Widget;    use Gtk.Widget; 
  56.  
  57. package Gtk.Overlay is 
  58.  
  59.    type Gtk_Overlay_Record is new Gtk_Bin_Record with null record; 
  60.    type Gtk_Overlay is access all Gtk_Overlay_Record'Class; 
  61.  
  62.    ------------------ 
  63.    -- Constructors -- 
  64.    ------------------ 
  65.  
  66.    procedure Gtk_New (Self : out Gtk_Overlay); 
  67.    procedure Initialize (Self : not null access Gtk_Overlay_Record'Class); 
  68.    --  Creates a new Gtk.Overlay.Gtk_Overlay. 
  69.    --  Since: gtk+ 3.2 
  70.  
  71.    function Gtk_Overlay_New return Gtk_Overlay; 
  72.    --  Creates a new Gtk.Overlay.Gtk_Overlay. 
  73.    --  Since: gtk+ 3.2 
  74.  
  75.    function Get_Type return Glib.GType; 
  76.    pragma Import (C, Get_Type, "gtk_overlay_get_type"); 
  77.  
  78.    ------------- 
  79.    -- Methods -- 
  80.    ------------- 
  81.  
  82.    procedure Add_Overlay 
  83.       (Self   : not null access Gtk_Overlay_Record; 
  84.        Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class); 
  85.    --  Adds Widget to Overlay. 
  86.    --  The widget will be stacked on top of the main widget added with 
  87.    --  Gtk.Container.Add. 
  88.    --  The position at which Widget is placed is determined from its 
  89.    --  Gtk.Widget.Gtk_Widget:halign and Gtk.Widget.Gtk_Widget:valign 
  90.    --  properties. 
  91.    --  Since: gtk+ 3.2 
  92.    --  "widget": a Gtk.Widget.Gtk_Widget to be added to the container 
  93.  
  94.    ------------- 
  95.    -- Signals -- 
  96.    ------------- 
  97.  
  98.    type Cb_Gtk_Overlay_Gtk_Widget_Cairo_Rectangle_Int_Boolean is not null access function 
  99.      (Self       : access Gtk_Overlay_Record'Class; 
  100.       Widget     : not null access Gtk.Widget.Gtk_Widget_Record'Class; 
  101.       Allocation : access Cairo.Region.Cairo_Rectangle_Int) 
  102.    return Boolean; 
  103.  
  104.    type Cb_GObject_Gtk_Widget_Cairo_Rectangle_Int_Boolean is not null access function 
  105.      (Self       : access Glib.Object.GObject_Record'Class; 
  106.       Widget     : not null access Gtk.Widget.Gtk_Widget_Record'Class; 
  107.       Allocation : access Cairo.Region.Cairo_Rectangle_Int) 
  108.    return Boolean; 
  109.  
  110.    Signal_Get_Child_Position : constant Glib.Signal_Name := "get-child-position"; 
  111.    procedure On_Get_Child_Position 
  112.       (Self  : not null access Gtk_Overlay_Record; 
  113.        Call  : Cb_Gtk_Overlay_Gtk_Widget_Cairo_Rectangle_Int_Boolean; 
  114.        After : Boolean := False); 
  115.    procedure On_Get_Child_Position 
  116.       (Self  : not null access Gtk_Overlay_Record; 
  117.        Call  : Cb_GObject_Gtk_Widget_Cairo_Rectangle_Int_Boolean; 
  118.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  119.        After : Boolean := False); 
  120.    --  The ::get-child-position signal is emitted to determine the position 
  121.    --  and size of any overlay child widgets. A handler for this signal should 
  122.    --  fill Allocation with the desired position and size for Widget, relative 
  123.    --  to the 'main' child of Overlay. 
  124.    -- 
  125.    --  The default handler for this signal uses the Widget's halign and valign 
  126.    --  properties to determine the position and gives the widget its natural 
  127.    --  size (except that an alignment of Gtk.Widget.Align_Fill will cause the 
  128.    --  overlay to be full-width/height). If the main child is a 
  129.    --  Gtk.Scrolled_Window.Gtk_Scrolled_Window, the overlays are placed 
  130.    --  relative to its contents. 
  131.    -- 
  132.    --  Return: True if the Allocation has been filled 
  133.    --  
  134.    --  Callback parameters: 
  135.    --    --  "widget": the child widget to position 
  136.    --    --  "allocation": return location for the allocation 
  137.  
  138.    ---------------- 
  139.    -- Interfaces -- 
  140.    ---------------- 
  141.    --  This class implements several interfaces. See Glib.Types 
  142.    -- 
  143.    --  - "Buildable" 
  144.  
  145.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  146.      (Gtk.Buildable.Gtk_Buildable, Gtk_Overlay_Record, Gtk_Overlay); 
  147.    function "+" 
  148.      (Widget : access Gtk_Overlay_Record'Class) 
  149.    return Gtk.Buildable.Gtk_Buildable 
  150.    renames Implements_Gtk_Buildable.To_Interface; 
  151.    function "-" 
  152.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  153.    return Gtk_Overlay 
  154.    renames Implements_Gtk_Buildable.To_Object; 
  155.  
  156. end Gtk.Overlay;