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 public class AspectFrame : Frame
46 {
47 	/** the main Gtk struct */
48 	protected GtkAspectFrame* gtkAspectFrame;
49 
50 	/** Get the main Gtk struct */
51 	public GtkAspectFrame* getAspectFrameStruct()
52 	{
53 		return gtkAspectFrame;
54 	}
55 
56 	/** the main Gtk struct as a void* */
57 	protected override void* getStruct()
58 	{
59 		return cast(void*)gtkAspectFrame;
60 	}
61 
62 	protected override void setStruct(GObject* obj)
63 	{
64 		gtkAspectFrame = cast(GtkAspectFrame*)obj;
65 		super.setStruct(obj);
66 	}
67 
68 	/**
69 	 * Sets our main struct and passes it to the parent class.
70 	 */
71 	public this (GtkAspectFrame* gtkAspectFrame, bool ownedRef = false)
72 	{
73 		this.gtkAspectFrame = gtkAspectFrame;
74 		super(cast(GtkFrame*)gtkAspectFrame, ownedRef);
75 	}
76 
77 	/**
78 	 */
79 
80 	public static GType getType()
81 	{
82 		return gtk_aspect_frame_get_type();
83 	}
84 
85 	/**
86 	 * Create a new #GtkAspectFrame.
87 	 *
88 	 * Params:
89 	 *     label = Label text.
90 	 *     xalign = Horizontal alignment of the child within the allocation of
91 	 *         the #GtkAspectFrame. This ranges from 0.0 (left aligned)
92 	 *         to 1.0 (right aligned)
93 	 *     yalign = Vertical alignment of the child within the allocation of
94 	 *         the #GtkAspectFrame. This ranges from 0.0 (top aligned)
95 	 *         to 1.0 (bottom aligned)
96 	 *     ratio = The desired aspect ratio.
97 	 *     obeyChild = If %TRUE, @ratio is ignored, and the aspect
98 	 *         ratio is taken from the requistion of the child.
99 	 *
100 	 * Return: the new #GtkAspectFrame.
101 	 *
102 	 * Throws: ConstructionException GTK+ fails to create the object.
103 	 */
104 	public this(string label, float xalign, float yalign, float ratio, bool obeyChild)
105 	{
106 		auto p = gtk_aspect_frame_new(Str.toStringz(label), xalign, yalign, ratio, obeyChild);
107 		
108 		if(p is null)
109 		{
110 			throw new ConstructionException("null returned by new");
111 		}
112 		
113 		this(cast(GtkAspectFrame*) p);
114 	}
115 
116 	/**
117 	 * Set parameters for an existing #GtkAspectFrame.
118 	 *
119 	 * Params:
120 	 *     xalign = Horizontal alignment of the child within the allocation of
121 	 *         the #GtkAspectFrame. This ranges from 0.0 (left aligned)
122 	 *         to 1.0 (right aligned)
123 	 *     yalign = Vertical alignment of the child within the allocation of
124 	 *         the #GtkAspectFrame. This ranges from 0.0 (top aligned)
125 	 *         to 1.0 (bottom aligned)
126 	 *     ratio = The desired aspect ratio.
127 	 *     obeyChild = If %TRUE, @ratio is ignored, and the aspect
128 	 *         ratio is taken from the requistion of the child.
129 	 */
130 	public void set(float xalign, float yalign, float ratio, bool obeyChild)
131 	{
132 		gtk_aspect_frame_set(gtkAspectFrame, xalign, yalign, ratio, obeyChild);
133 	}
134 }