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.AspectFrame;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gtk.Frame;
31 private import gtk.Widget;
32 private import gtkc.gtk;
33 public  import gtkc.gtktypes;
34 
35 
36 /**
37  * The #GtkAspectFrame is useful when you want
38  * pack a widget so that it can resize but always retains
39  * the same aspect ratio. For instance, one might be
40  * drawing a small preview of a larger image. #GtkAspectFrame
41  * derives from #GtkFrame, so it can draw a label and
42  * a frame around the child. The frame will be
43  * “shrink-wrapped” to the size of the child.
44  * 
45  * # CSS nodes
46  * 
47  * GtkAspectFrame uses a CSS node with name frame.
48  */
49 public class AspectFrame : Frame
50 {
51 	/** the main Gtk struct */
52 	protected GtkAspectFrame* gtkAspectFrame;
53 
54 	/** Get the main Gtk struct */
55 	public GtkAspectFrame* getAspectFrameStruct(bool transferOwnership = false)
56 	{
57 		if (transferOwnership)
58 			ownedRef = false;
59 		return gtkAspectFrame;
60 	}
61 
62 	/** the main Gtk struct as a void* */
63 	protected override void* getStruct()
64 	{
65 		return cast(void*)gtkAspectFrame;
66 	}
67 
68 	protected override void setStruct(GObject* obj)
69 	{
70 		gtkAspectFrame = cast(GtkAspectFrame*)obj;
71 		super.setStruct(obj);
72 	}
73 
74 	/**
75 	 * Sets our main struct and passes it to the parent class.
76 	 */
77 	public this (GtkAspectFrame* gtkAspectFrame, bool ownedRef = false)
78 	{
79 		this.gtkAspectFrame = gtkAspectFrame;
80 		super(cast(GtkFrame*)gtkAspectFrame, ownedRef);
81 	}
82 
83 
84 	/** */
85 	public static GType getType()
86 	{
87 		return gtk_aspect_frame_get_type();
88 	}
89 
90 	/**
91 	 * Create a new #GtkAspectFrame.
92 	 *
93 	 * Params:
94 	 *     label = Label text.
95 	 *     xalign = Horizontal alignment of the child within the allocation of
96 	 *         the #GtkAspectFrame. This ranges from 0.0 (left aligned)
97 	 *         to 1.0 (right aligned)
98 	 *     yalign = Vertical alignment of the child within the allocation of
99 	 *         the #GtkAspectFrame. This ranges from 0.0 (top aligned)
100 	 *         to 1.0 (bottom aligned)
101 	 *     ratio = The desired aspect ratio.
102 	 *     obeyChild = If %TRUE, @ratio is ignored, and the aspect
103 	 *         ratio is taken from the requistion of the child.
104 	 *
105 	 * Returns: the new #GtkAspectFrame.
106 	 *
107 	 * Throws: ConstructionException GTK+ fails to create the object.
108 	 */
109 	public this(string label, float xalign, float yalign, float ratio, bool obeyChild)
110 	{
111 		auto p = gtk_aspect_frame_new(Str.toStringz(label), xalign, yalign, ratio, obeyChild);
112 		
113 		if(p is null)
114 		{
115 			throw new ConstructionException("null returned by new");
116 		}
117 		
118 		this(cast(GtkAspectFrame*) p);
119 	}
120 
121 	/**
122 	 * Set parameters for an existing #GtkAspectFrame.
123 	 *
124 	 * Params:
125 	 *     xalign = Horizontal alignment of the child within the allocation of
126 	 *         the #GtkAspectFrame. This ranges from 0.0 (left aligned)
127 	 *         to 1.0 (right aligned)
128 	 *     yalign = Vertical alignment of the child within the allocation of
129 	 *         the #GtkAspectFrame. This ranges from 0.0 (top aligned)
130 	 *         to 1.0 (bottom aligned)
131 	 *     ratio = The desired aspect ratio.
132 	 *     obeyChild = If %TRUE, @ratio is ignored, and the aspect
133 	 *         ratio is taken from the requistion of the child.
134 	 */
135 	public void set(float xalign, float yalign, float ratio, bool obeyChild)
136 	{
137 		gtk_aspect_frame_set(gtkAspectFrame, xalign, yalign, ratio, obeyChild);
138 	}
139 }