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  * Conversion parameters:
26  * inFile  = GtkOverlay.html
27  * outPack = gtk
28  * outFile = Overlay
29  * strct   = GtkOverlay
30  * realStrct=
31  * ctorStrct=
32  * clss    = Overlay
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_overlay_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- gtk.Widget
47  * structWrap:
48  * 	- GtkWidget* -> Widget
49  * module aliases:
50  * local aliases:
51  * overrides:
52  */
53 
54 module gtk.Overlay;
55 
56 public  import gtkc.gtktypes;
57 
58 private import gtkc.gtk;
59 private import glib.ConstructionException;
60 private import gobject.ObjectG;
61 
62 private import gobject.Signals;
63 public  import gtkc.gdktypes;
64 private import gtk.Widget;
65 
66 
67 private import gtk.Bin;
68 
69 /**
70  * GtkOverlay is a container which contains a single main child, on top
71  * of which it can place overlay widgets. The
72  * position of each overlay widget is determined by its "halign"
73  * and "valign" properties. E.g. a widget with both alignments
74  * set to GTK_ALIGN_START will be placed at the top left corner of the
75  * main widget, whereas an overlay with halign set to GTK_ALIGN_CENTER
76  * and valign set to GTK_ALIGN_END will be placed a the bottom edge of
77  * the main widget, horizontally centered. The position can be adjusted
78  * by setting the margin properties of the child to non-zero values.
79  *
80  * More complicated placement of overlays is possible by connecting
81  * to the "get-child-position" signal.
82  *
83  * GtkOverlay as GtkBuildable
84  *
85  * The GtkOverlay implementation of the GtkBuildable interface
86  * supports placing a child as an overlay by specifying "overlay" as
87  * the "type" attribute of a <child> element.
88  */
89 public class Overlay : Bin
90 {
91 	
92 	/** the main Gtk struct */
93 	protected GtkOverlay* gtkOverlay;
94 	
95 	
96 	/** Get the main Gtk struct */
97 	public GtkOverlay* getOverlayStruct()
98 	{
99 		return gtkOverlay;
100 	}
101 	
102 	
103 	/** the main Gtk struct as a void* */
104 	protected override void* getStruct()
105 	{
106 		return cast(void*)gtkOverlay;
107 	}
108 	
109 	/**
110 	 * Sets our main struct and passes it to the parent class
111 	 */
112 	public this (GtkOverlay* gtkOverlay)
113 	{
114 		super(cast(GtkBin*)gtkOverlay);
115 		this.gtkOverlay = gtkOverlay;
116 	}
117 	
118 	protected override void setStruct(GObject* obj)
119 	{
120 		super.setStruct(obj);
121 		gtkOverlay = cast(GtkOverlay*)obj;
122 	}
123 	
124 	/**
125 	 */
126 	int[string] connectedSignals;
127 	
128 	bool delegate(Widget, GdkRectangle*, Overlay)[] onGetChildPositionListeners;
129 	/**
130 	 * The ::get-child-position signal is emitted to determine
131 	 * the position and size of any overlay child widgets. A
132 	 * handler for this signal should fill allocation with
133 	 * the desired position and size for widget, relative to
134 	 * the 'main' child of overlay.
135 	 * The default handler for this signal uses the widget's
136 	 * halign and valign properties to determine the position
137 	 * and gives the widget its natural size (except that an
138 	 * alignment of GTK_ALIGN_FILL will cause the overlay to
139 	 * be full-width/height). If the main child is a
140 	 * GtkScrolledWindow, the overlays are placed relative
141 	 * to its contents.
142 	 * Return: TRUE if the allocation has been filled
143 	 */
144 	void addOnGetChildPosition(bool delegate(Widget, GdkRectangle*, Overlay) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
145 	{
146 		if ( !("get-child-position" in connectedSignals) )
147 		{
148 			Signals.connectData(
149 			getStruct(),
150 			"get-child-position",
151 			cast(GCallback)&callBackGetChildPosition,
152 			cast(void*)this,
153 			null,
154 			connectFlags);
155 			connectedSignals["get-child-position"] = 1;
156 		}
157 		onGetChildPositionListeners ~= dlg;
158 	}
159 	extern(C) static gboolean callBackGetChildPosition(GtkOverlay* overlayStruct, GtkWidget* widget, GdkRectangle* allocation, Overlay _overlay)
160 	{
161 		foreach ( bool delegate(Widget, GdkRectangle*, Overlay) dlg ; _overlay.onGetChildPositionListeners )
162 		{
163 			if ( dlg(ObjectG.getDObject!(Widget)(widget), allocation, _overlay) )
164 			{
165 				return 1;
166 			}
167 		}
168 		
169 		return 0;
170 	}
171 	
172 	
173 	/**
174 	 * Creates a new GtkOverlay.
175 	 * Throws: ConstructionException GTK+ fails to create the object.
176 	 */
177 	public this ()
178 	{
179 		// GtkWidget * gtk_overlay_new (void);
180 		auto p = gtk_overlay_new();
181 		if(p is null)
182 		{
183 			throw new ConstructionException("null returned by gtk_overlay_new()");
184 		}
185 		this(cast(GtkOverlay*) p);
186 	}
187 	
188 	/**
189 	 * Adds widget to overlay.
190 	 * The widget will be stacked on top of the main widget
191 	 * added with gtk_container_add().
192 	 * The position at which widget is placed is determined
193 	 * from its "halign" and "valign" properties.
194 	 * Params:
195 	 * widget = a GtkWidget to be added to the container
196 	 * Since 3.2
197 	 * Signal Details
198 	 * The "get-child-position" signal
199 	 * gboolean user_function (GtkOverlay *overlay,
200 	 *  GtkWidget *widget,
201 	 *  GdkRectangle *allocation,
202 	 *  gpointer user_data) : Run Last
203 	 * The ::get-child-position signal is emitted to determine
204 	 * the position and size of any overlay child widgets. A
205 	 * handler for this signal should fill allocation with
206 	 * the desired position and size for widget, relative to
207 	 * the 'main' child of overlay.
208 	 * The default handler for this signal uses the widget's
209 	 * halign and valign properties to determine the position
210 	 * and gives the widget its natural size (except that an
211 	 * alignment of GTK_ALIGN_FILL will cause the overlay to
212 	 * be full-width/height). If the main child is a
213 	 * GtkScrolledWindow, the overlays are placed relative
214 	 * to its contents.
215 	 * Return: TRUE if the allocation has been filled
216 	 * widget = the child widget to position
217 	 */
218 	public void addOverlay(Widget widget)
219 	{
220 		// void gtk_overlay_add_overlay (GtkOverlay *overlay,  GtkWidget *widget);
221 		gtk_overlay_add_overlay(gtkOverlay, (widget is null) ? null : widget.getWidgetStruct());
222 	}
223 }