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