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 position of each overlay
40  * widget is determined by its #GtkWidget:halign and #GtkWidget:valign
41  * properties. E.g. a widget with both alignments set to %GTK_ALIGN_START
42  * will be placed at the top left corner of the GtkOverlay container,
43  * whereas an overlay with halign set to %GTK_ALIGN_CENTER and valign set
44  * to %GTK_ALIGN_END will be placed a the bottom edge of the GtkOverlay,
45  * horizontally centered. The position can be adjusted by setting the margin
46  * 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 	public static GType getType()
92 	{
93 		return gtk_overlay_get_type();
94 	}
95 
96 	/**
97 	 * Creates a new #GtkOverlay.
98 	 *
99 	 * Return: a new #GtkOverlay object.
100 	 *
101 	 * Since: 3.2
102 	 *
103 	 * Throws: ConstructionException GTK+ fails to create the object.
104 	 */
105 	public this()
106 	{
107 		auto p = gtk_overlay_new();
108 		
109 		if(p is null)
110 		{
111 			throw new ConstructionException("null returned by new");
112 		}
113 		
114 		this(cast(GtkOverlay*) p);
115 	}
116 
117 	/**
118 	 * Adds @widget to @overlay.
119 	 *
120 	 * The widget will be stacked on top of the main widget
121 	 * added with gtk_container_add().
122 	 *
123 	 * The position at which @widget is placed is determined
124 	 * from its #GtkWidget:halign and #GtkWidget:valign properties.
125 	 *
126 	 * Params:
127 	 *     widget = a #GtkWidget to be added to the container
128 	 *
129 	 * Since: 3.2
130 	 */
131 	public void addOverlay(Widget widget)
132 	{
133 		gtk_overlay_add_overlay(gtkOverlay, (widget is null) ? null : widget.getWidgetStruct());
134 	}
135 
136 	/**
137 	 * Convenience function to get the value of the #GtkOverlay:pass-through
138 	 * child property for @widget.
139 	 *
140 	 * Params:
141 	 *     widget = an overlay child of #GtkOverlay
142 	 *
143 	 * Return: whether the widget is a pass through child.
144 	 *
145 	 * Since: 3.18
146 	 */
147 	public bool getOverlayPassThrough(Widget widget)
148 	{
149 		return gtk_overlay_get_overlay_pass_through(gtkOverlay, (widget is null) ? null : widget.getWidgetStruct()) != 0;
150 	}
151 
152 	/**
153 	 * Moves @child to a new @index in the list of @overlay children.
154 	 * The list contains overlays in the order that these were
155 	 * added to @overlay.
156 	 *
157 	 * A widget’s index in the @overlay children list determines which order
158 	 * the children are drawn if they overlap. The first child is drawn at
159 	 * the bottom. It also affects the default focus chain order.
160 	 *
161 	 * Params:
162 	 *     child = the overlaid #GtkWidget to move
163 	 *     position = the new index for @child in the list of overlay children
164 	 *         of @overlay, starting from 0. If negative, indicates the end of
165 	 *         the list
166 	 */
167 	public void reorderOverlay(Widget child, int position)
168 	{
169 		gtk_overlay_reorder_overlay(gtkOverlay, (child is null) ? null : child.getWidgetStruct(), position);
170 	}
171 
172 	/**
173 	 * Convenience function to set the value of the #GtkOverlay:pass-through
174 	 * child property for @widget.
175 	 *
176 	 * Params:
177 	 *     widget = an overlay child of #GtkOverlay
178 	 *     passThrough = whether the child should pass the input through
179 	 *
180 	 * Since: 3.18
181 	 */
182 	public void setOverlayPassThrough(Widget widget, bool passThrough)
183 	{
184 		gtk_overlay_set_overlay_pass_through(gtkOverlay, (widget is null) ? null : widget.getWidgetStruct(), passThrough);
185 	}
186 
187 	int[string] connectedSignals;
188 
189 	bool delegate(Widget, GdkRectangle*, Overlay)[] onGetChildPositionListeners;
190 	/**
191 	 * The ::get-child-position signal is emitted to determine
192 	 * the position and size of any overlay child widgets. A
193 	 * handler for this signal should fill @allocation with
194 	 * the desired position and size for @widget, relative to
195 	 * the 'main' child of @overlay.
196 	 *
197 	 * The default handler for this signal uses the @widget's
198 	 * halign and valign properties to determine the position
199 	 * and gives the widget its natural size (except that an
200 	 * alignment of %GTK_ALIGN_FILL will cause the overlay to
201 	 * be full-width/height). If the main child is a
202 	 * #GtkScrolledWindow, the overlays are placed relative
203 	 * to its contents.
204 	 *
205 	 * Params:
206 	 *     widget = the child widget to position
207 	 *     allocation = return
208 	 *         location for the allocation
209 	 *
210 	 * Return: %TRUE if the @allocation has been filled
211 	 */
212 	void addOnGetChildPosition(bool delegate(Widget, GdkRectangle*, Overlay) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
213 	{
214 		if ( "get-child-position" !in connectedSignals )
215 		{
216 			Signals.connectData(
217 				this,
218 				"get-child-position",
219 				cast(GCallback)&callBackGetChildPosition,
220 				cast(void*)this,
221 				null,
222 				connectFlags);
223 			connectedSignals["get-child-position"] = 1;
224 		}
225 		onGetChildPositionListeners ~= dlg;
226 	}
227 	extern(C) static int callBackGetChildPosition(GtkOverlay* overlayStruct, GtkWidget* widget, GdkRectangle* allocation, Overlay _overlay)
228 	{
229 		foreach ( bool delegate(Widget, GdkRectangle*, Overlay) dlg; _overlay.onGetChildPositionListeners )
230 		{
231 			if ( dlg(ObjectG.getDObject!(Widget)(widget), allocation, _overlay) )
232 			{
233 				return 1;
234 			}
235 		}
236 		
237 		return 0;
238 	}
239 }