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. --  Gtk.Layout.Gtk_Layout is similar to Gtk.Drawing_Area.Gtk_Drawing_Area in 
  26. --  that it's a "blank slate" and doesn't do anything but paint a blank 
  27. --  background by default. It's different in that it supports scrolling 
  28. --  natively (you can add it to a Gtk.Scrolled_Window.Gtk_Scrolled_Window), and 
  29. --  it can contain child widgets, since it's a Gtk.Container.Gtk_Container. 
  30. --  However if you're just going to draw, a Gtk.Drawing_Area.Gtk_Drawing_Area 
  31. --  is a better choice since it has lower overhead. 
  32. -- 
  33. --  When handling expose events on a Gtk.Layout.Gtk_Layout, you must draw to 
  34. --  GTK_LAYOUT (layout)->bin_window, rather than to GTK_WIDGET 
  35. --  (layout)->window, as you would for a drawing area. 
  36. -- 
  37. --  </description> 
  38. --  <description> 
  39. --  A Gtk_Layout is a widget that can have an almost infinite size, without 
  40. --  occupying a lot of memory. Its children can be located anywhere within it, 
  41. --  but will only appear on the screen if the visible area of the layout 
  42. --  contains them. Just like a Gtk_Viewport, its visible area is indicated by 
  43. --  two Gtk_Adjustment widgets, and thus a Gtk_Layout can be put as is in a 
  44. --  Gtk_Scrolled_Window. As for Gtk_Fixed containers, the children can be 
  45. --  located anywhere in the layout (no automatic organization is done). But, as 
  46. --  opposed to Gtk_Fixed widgets, a Gtk_Layout does not try to resize itself to 
  47. --  show all its children. 
  48. -- 
  49. --  Starting from GtkAda 2.0, you have to call Set_Size and specify the 
  50. --  maximum size of the layout, otherwise children added with Put outside the 
  51. --  size defined for the layout will never be visible. One way to do this is to 
  52. --  systematically call Set_Size before calling Put, and make sure you specify 
  53. --  a size big enough for the layout. 
  54. -- 
  55. --  </description> 
  56. --  <screenshot>gtk-layout</screenshot> 
  57. --  <group>Layout containers</group> 
  58. --  <testgtk>create_layout.adb</testgtk> 
  59. pragma Ada_2005; 
  60.  
  61. pragma Warnings (Off, "*is already use-visible*"); 
  62. with Gdk;             use Gdk; 
  63. with Glib;            use Glib; 
  64. with Glib.Properties; use Glib.Properties; 
  65. with Glib.Types;      use Glib.Types; 
  66. with Gtk.Adjustment;  use Gtk.Adjustment; 
  67. with Gtk.Buildable;   use Gtk.Buildable; 
  68. with Gtk.Container;   use Gtk.Container; 
  69. with Gtk.Enums;       use Gtk.Enums; 
  70. with Gtk.Scrollable;  use Gtk.Scrollable; 
  71. with Gtk.Widget;      use Gtk.Widget; 
  72.  
  73. package Gtk.Layout is 
  74.  
  75.    type Gtk_Layout_Record is new Gtk_Container_Record with null record; 
  76.    type Gtk_Layout is access all Gtk_Layout_Record'Class; 
  77.  
  78.    ------------------ 
  79.    -- Constructors -- 
  80.    ------------------ 
  81.  
  82.    procedure Gtk_New 
  83.       (Layout      : out Gtk_Layout; 
  84.        Hadjustment : Gtk.Adjustment.Gtk_Adjustment := null; 
  85.        Vadjustment : Gtk.Adjustment.Gtk_Adjustment := null); 
  86.    procedure Initialize 
  87.       (Layout      : not null access Gtk_Layout_Record'Class; 
  88.        Hadjustment : Gtk.Adjustment.Gtk_Adjustment := null; 
  89.        Vadjustment : Gtk.Adjustment.Gtk_Adjustment := null); 
  90.    --  Creates a new Gtk.Layout.Gtk_Layout. Unless you have a specific 
  91.    --  adjustment you'd like the layout to use for scrolling, pass null for 
  92.    --  Hadjustment and Vadjustment. 
  93.    --  "hadjustment": horizontal scroll adjustment, or null 
  94.    --  "vadjustment": vertical scroll adjustment, or null 
  95.  
  96.    function Gtk_Layout_New 
  97.       (Hadjustment : Gtk.Adjustment.Gtk_Adjustment := null; 
  98.        Vadjustment : Gtk.Adjustment.Gtk_Adjustment := null) 
  99.        return Gtk_Layout; 
  100.    --  Creates a new Gtk.Layout.Gtk_Layout. Unless you have a specific 
  101.    --  adjustment you'd like the layout to use for scrolling, pass null for 
  102.    --  Hadjustment and Vadjustment. 
  103.    --  "hadjustment": horizontal scroll adjustment, or null 
  104.    --  "vadjustment": vertical scroll adjustment, or null 
  105.  
  106.    function Get_Type return Glib.GType; 
  107.    pragma Import (C, Get_Type, "gtk_layout_get_type"); 
  108.  
  109.    ------------- 
  110.    -- Methods -- 
  111.    ------------- 
  112.  
  113.    function Get_Bin_Window 
  114.       (Layout : not null access Gtk_Layout_Record) return Gdk.Gdk_Window; 
  115.    --  Retrieve the bin window of the layout used for drawing operations. 
  116.    --  Since: gtk+ 2.14 
  117.  
  118.    procedure Get_Size 
  119.       (Layout : not null access Gtk_Layout_Record; 
  120.        Width  : out Guint; 
  121.        Height : out Guint); 
  122.    --  Gets the size that has been set on the layout, and that determines the 
  123.    --  total extents of the layout's scrollbar area. See gtk_layout_set_size 
  124.    --  (). 
  125.    --  "width": location to store the width set on Layout, or null 
  126.    --  "height": location to store the height set on Layout, or null 
  127.  
  128.    procedure Set_Size 
  129.       (Layout : not null access Gtk_Layout_Record; 
  130.        Width  : Guint; 
  131.        Height : Guint); 
  132.    --  Sets the size of the scrollable area of the layout. 
  133.    --  "width": width of entire scrollable area 
  134.    --  "height": height of entire scrollable area 
  135.  
  136.    procedure Move 
  137.       (Layout       : not null access Gtk_Layout_Record; 
  138.        Child_Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class; 
  139.        X            : Gint; 
  140.        Y            : Gint); 
  141.    --  Moves a current child of Layout to a new position. 
  142.    --  "child_widget": a current child of Layout 
  143.    --  "x": X position to move to 
  144.    --  "y": Y position to move to 
  145.  
  146.    procedure Put 
  147.       (Layout       : not null access Gtk_Layout_Record; 
  148.        Child_Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class; 
  149.        X            : Gint; 
  150.        Y            : Gint); 
  151.    --  The child will be displayed on the screen only if at least part of it 
  152.    --  intersects the visible area of the layout. The layout does not resize 
  153.    --  itself to automatically show the widget. You also need to call Set_Size, 
  154.    --  if the size you initially defined is smaller than (X, Y), or the child 
  155.    --  will never be visible even if the layout is scrolled. 
  156.    --  "child_widget": child widget 
  157.    --  "x": X position of child widget 
  158.    --  "y": Y position of child widget 
  159.  
  160.    --------------------------------------------- 
  161.    -- Inherited subprograms (from interfaces) -- 
  162.    --------------------------------------------- 
  163.    --  Methods inherited from the Buildable interface are not duplicated here 
  164.    --  since they are meant to be used by tools, mostly. If you need to call 
  165.    --  them, use an explicit cast through the "-" operator below. 
  166.  
  167.    function Get_Hadjustment 
  168.       (Self : not null access Gtk_Layout_Record) 
  169.        return Gtk.Adjustment.Gtk_Adjustment; 
  170.  
  171.    procedure Set_Hadjustment 
  172.       (Self        : not null access Gtk_Layout_Record; 
  173.        Hadjustment : access Gtk.Adjustment.Gtk_Adjustment_Record'Class); 
  174.  
  175.    function Get_Hscroll_Policy 
  176.       (Self : not null access Gtk_Layout_Record) 
  177.        return Gtk.Enums.Gtk_Scrollable_Policy; 
  178.  
  179.    procedure Set_Hscroll_Policy 
  180.       (Self   : not null access Gtk_Layout_Record; 
  181.        Policy : Gtk.Enums.Gtk_Scrollable_Policy); 
  182.  
  183.    function Get_Vadjustment 
  184.       (Self : not null access Gtk_Layout_Record) 
  185.        return Gtk.Adjustment.Gtk_Adjustment; 
  186.  
  187.    procedure Set_Vadjustment 
  188.       (Self        : not null access Gtk_Layout_Record; 
  189.        Vadjustment : access Gtk.Adjustment.Gtk_Adjustment_Record'Class); 
  190.  
  191.    function Get_Vscroll_Policy 
  192.       (Self : not null access Gtk_Layout_Record) 
  193.        return Gtk.Enums.Gtk_Scrollable_Policy; 
  194.  
  195.    procedure Set_Vscroll_Policy 
  196.       (Self   : not null access Gtk_Layout_Record; 
  197.        Policy : Gtk.Enums.Gtk_Scrollable_Policy); 
  198.  
  199.    ---------------- 
  200.    -- Properties -- 
  201.    ---------------- 
  202.    --  The following properties are defined for this widget. See 
  203.    --  Glib.Properties for more information on properties) 
  204.  
  205.    Height_Property : constant Glib.Properties.Property_Uint; 
  206.  
  207.    Width_Property : constant Glib.Properties.Property_Uint; 
  208.  
  209.    ---------------- 
  210.    -- Interfaces -- 
  211.    ---------------- 
  212.    --  This class implements several interfaces. See Glib.Types 
  213.    -- 
  214.    --  - "Buildable" 
  215.    -- 
  216.    --  - "Scrollable" 
  217.  
  218.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  219.      (Gtk.Buildable.Gtk_Buildable, Gtk_Layout_Record, Gtk_Layout); 
  220.    function "+" 
  221.      (Widget : access Gtk_Layout_Record'Class) 
  222.    return Gtk.Buildable.Gtk_Buildable 
  223.    renames Implements_Gtk_Buildable.To_Interface; 
  224.    function "-" 
  225.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  226.    return Gtk_Layout 
  227.    renames Implements_Gtk_Buildable.To_Object; 
  228.  
  229.    package Implements_Gtk_Scrollable is new Glib.Types.Implements 
  230.      (Gtk.Scrollable.Gtk_Scrollable, Gtk_Layout_Record, Gtk_Layout); 
  231.    function "+" 
  232.      (Widget : access Gtk_Layout_Record'Class) 
  233.    return Gtk.Scrollable.Gtk_Scrollable 
  234.    renames Implements_Gtk_Scrollable.To_Interface; 
  235.    function "-" 
  236.      (Interf : Gtk.Scrollable.Gtk_Scrollable) 
  237.    return Gtk_Layout 
  238.    renames Implements_Gtk_Scrollable.To_Object; 
  239.  
  240. private 
  241.    Width_Property : constant Glib.Properties.Property_Uint := 
  242.      Glib.Properties.Build ("width"); 
  243.    Height_Property : constant Glib.Properties.Property_Uint := 
  244.      Glib.Properties.Build ("height"); 
  245. end Gtk.Layout;