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