1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --   Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet   -- 
  5. --                Copyright (C) 2000-2011, AdaCore                   -- 
  6. --                                                                   -- 
  7. -- This library is free software; you can redistribute it and/or     -- 
  8. -- modify it under the terms of the GNU General Public               -- 
  9. -- License as published by the Free Software Foundation; either      -- 
  10. -- version 2 of the License, or (at your option) any later version.  -- 
  11. --                                                                   -- 
  12. -- This library is distributed in the hope that it will be useful,   -- 
  13. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  14. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  15. -- General Public License for more details.                          -- 
  16. --                                                                   -- 
  17. -- You should have received a copy of the GNU General Public         -- 
  18. -- License along with this library; if not, write to the             -- 
  19. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  20. -- Boston, MA 02111-1307, USA.                                       -- 
  21. --                                                                   -- 
  22. -- -- -- -- -- -- -- -- -- -- -- --
  23. ----------------------------------------------------------------------- 
  24.  
  25. --  <description> 
  26. --  A Gtk_Layout is a widget that can have an almost infinite size, without 
  27. --  occupying a lot of memory. Its children can be located anywhere within it, 
  28. --  but will only appear on the screen if the visible area of the layout 
  29. --  contains them. Just like a Gtk_Viewport, its visible area is indicated by 
  30. --  two Gtk_Adjustment widgets, and thus a Gtk_Layout can be put as is in a 
  31. --  Gtk_Scrolled_Window. As for Gtk_Fixed containers, the children can be 
  32. --  located anywhere in the layout (no automatic organization is done). But, as 
  33. --  opposed to Gtk_Fixed widgets, a Gtk_Layout does not try to resize itself to 
  34. --  show all its children. 
  35. -- 
  36. --  Starting from GtkAda 2.0, you have to call Set_Size and specify the 
  37. --  maximum size of the layout, otherwise children added with Put outside the 
  38. --  size defined for the layout will never be visible. One way to do this is to 
  39. --  systematically call Set_Size before calling Put, and make sure you specify 
  40. --  a size big enough for the layout. 
  41. -- 
  42. --  </description> 
  43. --  <screenshot>gtk-layout</screenshot> 
  44. --  <group>Layout containers</group> 
  45. --  <testgtk>create_layout.adb</testgtk> 
  46.  
  47. pragma Warnings (Off, "*is already use-visible*"); 
  48. with Gdk.Window;      use Gdk.Window; 
  49. with Glib;            use Glib; 
  50. with Glib.Properties; use Glib.Properties; 
  51. with Glib.Types;      use Glib.Types; 
  52. with Gtk.Adjustment;  use Gtk.Adjustment; 
  53. with Gtk.Buildable;   use Gtk.Buildable; 
  54. with Gtk.Container;   use Gtk.Container; 
  55. with Gtk.Widget;      use Gtk.Widget; 
  56.  
  57. package Gtk.Layout is 
  58.  
  59.    type Gtk_Layout_Record is new Gtk_Container_Record with null record; 
  60.    type Gtk_Layout is access all Gtk_Layout_Record'Class; 
  61.  
  62.    ------------------ 
  63.    -- Constructors -- 
  64.    ------------------ 
  65.  
  66.    procedure Gtk_New 
  67.       (Layout      : out Gtk_Layout; 
  68.        Hadjustment : Gtk.Adjustment.Gtk_Adjustment := null; 
  69.        Vadjustment : Gtk.Adjustment.Gtk_Adjustment := null); 
  70.    procedure Initialize 
  71.       (Layout      : access Gtk_Layout_Record'Class; 
  72.        Hadjustment : Gtk.Adjustment.Gtk_Adjustment := null; 
  73.        Vadjustment : Gtk.Adjustment.Gtk_Adjustment := null); 
  74.    --  Creates a new Gtk.Layout.Gtk_Layout. Unless you have a specific 
  75.    --  adjustment you'd like the layout to use for scrolling, pass null for 
  76.    --  "hadjustment": horizontal scroll adjustment, or null 
  77.    --  "vadjustment": vertical scroll adjustment, or null 
  78.  
  79.    function Get_Type return Glib.GType; 
  80.    pragma Import (C, Get_Type, "gtk_layout_get_type"); 
  81.  
  82.    ------------- 
  83.    -- Methods -- 
  84.    ------------- 
  85.  
  86.    procedure Freeze (Layout : access Gtk_Layout_Record); 
  87.    --  This is a deprecated function, it doesn't do anything useful. 
  88.  
  89.    function Get_Bin_Window 
  90.       (Layout : access Gtk_Layout_Record) return Gdk.Window.Gdk_Window; 
  91.    --  Retrieve the bin window of the layout used for drawing operations. 
  92.    --  Since: gtk+ 2.14 
  93.    --  Returns a Gdk.Window.Gdk_Window 
  94.  
  95.    function Get_Hadjustment 
  96.       (Layout : access Gtk_Layout_Record) 
  97.        return Gtk.Adjustment.Gtk_Adjustment; 
  98.    procedure Set_Hadjustment 
  99.       (Layout     : access Gtk_Layout_Record; 
  100.        Adjustment : access Gtk.Adjustment.Gtk_Adjustment_Record'Class); 
  101.    --  Return the adjustment that indicate the horizontal visual area of the 
  102.    --  layout. You generally do not have to modify the value of this adjustment 
  103.    --  yourself, since this is done automatically when the layout has been put 
  104.    --  in a Gtk_Scrolled_Window. 
  105.    --  "adjustment": new scroll adjustment 
  106.  
  107.    procedure Get_Size 
  108.       (Layout : access Gtk_Layout_Record; 
  109.        Width  : out Guint; 
  110.        Height : out Guint); 
  111.    procedure Set_Size 
  112.       (Layout : access Gtk_Layout_Record; 
  113.        Width  : Guint; 
  114.        Height : Guint); 
  115.    --  Sets the size of the scrollable area of the layout. 
  116.    --  "width": width of entire scrollable area 
  117.    --  "height": height of entire scrollable area 
  118.  
  119.    function Get_Vadjustment 
  120.       (Layout : access Gtk_Layout_Record) 
  121.        return Gtk.Adjustment.Gtk_Adjustment; 
  122.    procedure Set_Vadjustment 
  123.       (Layout     : access Gtk_Layout_Record; 
  124.        Adjustment : access Gtk.Adjustment.Gtk_Adjustment_Record'Class); 
  125.    --  Sets the vertical scroll adjustment for the layout. See 
  126.    --  Gtk.Scrolledwindow.Gtk_Scrolledwindow, Gtk.Scrollbar.Gtk_Scrollbar, 
  127.    --  Gtk.Adjustment.Gtk_Adjustment for details. 
  128.    --  "adjustment": new scroll adjustment 
  129.  
  130.    procedure Move 
  131.       (Layout       : access Gtk_Layout_Record; 
  132.        Child_Widget : access Gtk.Widget.Gtk_Widget_Record'Class; 
  133.        X            : Gint; 
  134.        Y            : Gint); 
  135.    --  Moves a current child of Layout to a new position. 
  136.    --  "child_widget": a current child of Layout 
  137.    --  "x": X position to move to 
  138.    --  "y": Y position to move to 
  139.  
  140.    procedure Put 
  141.       (Layout       : access Gtk_Layout_Record; 
  142.        Child_Widget : access Gtk.Widget.Gtk_Widget_Record'Class; 
  143.        X            : Gint; 
  144.        Y            : Gint); 
  145.    --  The child will be displayed on the screen only if at least part of it 
  146.    --  intersects the visible area of the layout. The layout does not resize 
  147.    --  itself to automatically show the widget. You also need to call Set_Size, 
  148.    --  if the size you initially defined is smaller than (X, Y), or the child 
  149.    --  will never be visible even if the layout is scrolled. 
  150.    --  "child_widget": child widget 
  151.    --  "x": X position of child widget 
  152.    --  "y": Y position of child widget 
  153.  
  154.    procedure Thaw (Layout : access Gtk_Layout_Record); 
  155.    --  This is a deprecated function, it doesn't do anything useful. 
  156.  
  157.    ---------------- 
  158.    -- Interfaces -- 
  159.    ---------------- 
  160.    --  This class implements several interfaces. See Glib.Types 
  161.    -- 
  162.    --  - "Buildable" 
  163.  
  164.    package Implements_Buildable is new Glib.Types.Implements 
  165.      (Gtk.Buildable.Gtk_Buildable, Gtk_Layout_Record, Gtk_Layout); 
  166.    function "+" 
  167.      (Widget : access Gtk_Layout_Record'Class) 
  168.    return Gtk.Buildable.Gtk_Buildable 
  169.    renames Implements_Buildable.To_Interface; 
  170.    function "-" 
  171.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  172.    return Gtk_Layout 
  173.    renames Implements_Buildable.To_Object; 
  174.  
  175.    ---------------- 
  176.    -- Properties -- 
  177.    ---------------- 
  178.    --  The following properties are defined for this widget. See 
  179.    --  Glib.Properties for more information on properties) 
  180.    -- 
  181.    --  Name: Hadjustment_Property 
  182.    --  Type: Gtk.Adjustment.Gtk_Adjustment 
  183.    --  Flags: read-write 
  184.    -- 
  185.    --  Name: Height_Property 
  186.    --  Type: Guint 
  187.    --  Flags: read-write 
  188.    -- 
  189.    --  Name: Vadjustment_Property 
  190.    --  Type: Gtk.Adjustment.Gtk_Adjustment 
  191.    --  Flags: read-write 
  192.    -- 
  193.    --  Name: Width_Property 
  194.    --  Type: Guint 
  195.    --  Flags: read-write 
  196.  
  197.    Hadjustment_Property : constant Glib.Properties.Property_Object; 
  198.    Height_Property : constant Glib.Properties.Property_Uint; 
  199.    Vadjustment_Property : constant Glib.Properties.Property_Object; 
  200.    Width_Property : constant Glib.Properties.Property_Uint; 
  201.  
  202.    ------------- 
  203.    -- Signals -- 
  204.    ------------- 
  205.    --  The following new signals are defined for this widget: 
  206.    -- 
  207.    --  "set-scroll-adjustments" 
  208.    --     procedure Handler 
  209.    --       (Self   : access Gtk_Layout_Record'Class; 
  210.    --        Object : Gtk.Adjustment.Gtk_Adjustment; 
  211.    --        P0     : Gtk.Adjustment.Gtk_Adjustment); 
  212.    --  Set the scroll adjustments for the layout. Usually scrolled containers 
  213.    --  like Gtk.Scrolledwindow.Gtk_Scrolledwindow will emit this signal to 
  214.    --  connect two instances of Gtk.Scrollbar.Gtk_Scrollbar to the scroll 
  215.    --  directions of the Gtk.Layout.Gtk_Layout. 
  216.  
  217.    Signal_Set_Scroll_Adjustments : constant Glib.Signal_Name := "set-scroll-adjustments"; 
  218.  
  219. private 
  220.    Hadjustment_Property : constant Glib.Properties.Property_Object := 
  221.      Glib.Properties.Build ("hadjustment"); 
  222.    Height_Property : constant Glib.Properties.Property_Uint := 
  223.      Glib.Properties.Build ("height"); 
  224.    Vadjustment_Property : constant Glib.Properties.Property_Object := 
  225.      Glib.Properties.Build ("vadjustment"); 
  226.    Width_Property : constant Glib.Properties.Property_Uint := 
  227.      Glib.Properties.Build ("width"); 
  228. end Gtk.Layout;