1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.Overlay;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gobject.Signals;
30 private import gtk.Bin;
31 private import gtk.Widget;
32 public  import gtkc.gdktypes;
33 private import gtkc.gtk;
34 public  import gtkc.gtktypes;
35 
36 
37 /**
38  * GtkOverlay is a container which contains a single main child, on top
39  * of which it can place “overlay” widgets. The
40  * position of each overlay widget is determined by its #GtkWidget:halign
41  * and #GtkWidget:valign properties. E.g. a widget with both alignments
42  * set to %GTK_ALIGN_START will be placed at the top left corner of the
43  * main widget, whereas an overlay with halign set to %GTK_ALIGN_CENTER
44  * and valign set to %GTK_ALIGN_END will be placed a the bottom edge of
45  * the main widget, horizontally centered. The position can be adjusted
46  * by setting the margin properties of the child to non-zero values.
47  * 
48  * More complicated placement of overlays is possible by connecting
49  * to the #GtkOverlay::get-child-position signal.
50  * 
51  * # GtkOverlay as GtkBuildable
52  * 
53  * The GtkOverlay implementation of the GtkBuildable interface
54  * supports placing a child as an overlay by specifying “overlay” as
55  * the “type” attribute of a `<child>` element.
56  */
57 public class Overlay : Bin
58 {
59 	/** the main Gtk struct */
60 	protected GtkOverlay* gtkOverlay;
61 
62 	/** Get the main Gtk struct */
63 	public GtkOverlay* getOverlayStruct()
64 	{
65 		return gtkOverlay;
66 	}
67 
68 	/** the main Gtk struct as a void* */
69 	protected override void* getStruct()
70 	{
71 		return cast(void*)gtkOverlay;
72 	}
73 
74 	protected override void setStruct(GObject* obj)
75 	{
76 		gtkOverlay = cast(GtkOverlay*)obj;
77 		super.setStruct(obj);
78 	}
79 
80 	/**
81 	 * Sets our main struct and passes it to the parent class.
82 	 */
83 	public this (GtkOverlay* gtkOverlay, bool ownedRef = false)
84 	{
85 		this.gtkOverlay = gtkOverlay;
86 		super(cast(GtkBin*)gtkOverlay, ownedRef);
87 	}
88 
89 	/**
90 	 */
91 
92 	public static GType getType()
93 	{
94 		return gtk_overlay_get_type();
95 	}
96 
97 	/**
98 	 * Creates a new #GtkOverlay.
99 	 *
100 	 * Return: a new #GtkOverlay object.
101 	 *
102 	 * Since: 3.2
103 	 *
104 	 * Throws: ConstructionException GTK+ fails to create the object.
105 	 */
106 	public this()
107 	{
108 		auto p = gtk_overlay_new();
109 		
110 		if(p is null)
111 		{
112 			throw new ConstructionException("null returned by new");
113 		}
114 		
115 		this(cast(GtkOverlay*) p);
116 	}
117 
118 	/**
119 	 * Adds @widget to @overlay.
120 	 *
121 	 * The widget will be stacked on top of the main widget
122 	 * added with gtk_container_add().
123 	 *
124 	 * The position at which @widget is placed is determined
125 	 * from its #GtkWidget:halign and #GtkWidget:valign properties.
126 	 *
127 	 * Params:
128 	 *     widget = a #GtkWidget to be added to the container
129 	 *
130 	 * Since: 3.2
131 	 */
132 	public void addOverlay(Widget widget)
133 	{
134 		gtk_overlay_add_overlay(gtkOverlay, (widget is null) ? null : widget.getWidgetStruct());
135 	}
136 
137 	int[string] connectedSignals;
138 
139 	bool delegate(Widget, GdkRectangle*, Overlay)[] onGetChildPositionListeners;
140 	/**
141 	 * The ::get-child-position signal is emitted to determine
142 	 * the position and size of any overlay child widgets. A
143 	 * handler for this signal should fill @allocation with
144 	 * the desired position and size for @widget, relative to
145 	 * the 'main' child of @overlay.
146 	 *
147 	 * The default handler for this signal uses the @widget's
148 	 * halign and valign properties to determine the position
149 	 * and gives the widget its natural size (except that an
150 	 * alignment of %GTK_ALIGN_FILL will cause the overlay to
151 	 * be full-width/height). If the main child is a
152 	 * #GtkScrolledWindow, the overlays are placed relative
153 	 * to its contents.
154 	 *
155 	 * Params:
156 	 *     widget = the child widget to position
157 	 *     allocation = return
158 	 *         location for the allocation
159 	 *
160 	 * Return: %TRUE if the @allocation has been filled
161 	 */
162 	void addOnGetChildPosition(bool delegate(Widget, GdkRectangle*, Overlay) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
163 	{
164 		if ( "get-child-position" !in connectedSignals )
165 		{
166 			Signals.connectData(
167 				this,
168 				"get-child-position",
169 				cast(GCallback)&callBackGetChildPosition,
170 				cast(void*)this,
171 				null,
172 				connectFlags);
173 			connectedSignals["get-child-position"] = 1;
174 		}
175 		onGetChildPositionListeners ~= dlg;
176 	}
177 	extern(C) static int callBackGetChildPosition(GtkOverlay* overlayStruct, GtkWidget* widget, GdkRectangle* allocation, Overlay _overlay)
178 	{
179 		foreach ( bool delegate(Widget, GdkRectangle*, Overlay) dlg; _overlay.onGetChildPositionListeners )
180 		{
181 			if ( dlg(ObjectG.getDObject!(Widget)(widget), allocation, _overlay) )
182 			{
183 				return 1;
184 			}
185 		}
186 		
187 		return 0;
188 	}
189 }