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.Frame;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gtk.Bin;
31 private import gtk.Widget;
32 private import gtkc.gtk;
33 public  import gtkc.gtktypes;
34 
35 
36 /**
37  * The frame widget is a Bin that surrounds its child
38  * with a decorative frame and an optional label.
39  * If present, the label is drawn in a gap in the
40  * top side of the frame. The position of the
41  * label can be controlled with gtk_frame_set_label_align().
42  * 
43  * # GtkFrame as GtkBuildable
44  * 
45  * The GtkFrame implementation of the GtkBuildable interface supports
46  * placing a child in the label position by specifying “label” as the
47  * “type” attribute of a <child> element. A normal content child can
48  * be specified without specifying a <child> type attribute.
49  * 
50  * An example of a UI definition fragment with GtkFrame:
51  * |[
52  * <object class="GtkFrame">
53  * <child type="label">
54  * <object class="GtkLabel" id="frame-label"/>
55  * </child>
56  * <child>
57  * <object class="GtkEntry" id="frame-content"/>
58  * </child>
59  * </object>
60  * ]|
61  */
62 public class Frame : Bin
63 {
64 	/** the main Gtk struct */
65 	protected GtkFrame* gtkFrame;
66 
67 	/** Get the main Gtk struct */
68 	public GtkFrame* getFrameStruct()
69 	{
70 		return gtkFrame;
71 	}
72 
73 	/** the main Gtk struct as a void* */
74 	protected override void* getStruct()
75 	{
76 		return cast(void*)gtkFrame;
77 	}
78 
79 	protected override void setStruct(GObject* obj)
80 	{
81 		gtkFrame = cast(GtkFrame*)obj;
82 		super.setStruct(obj);
83 	}
84 
85 	/**
86 	 * Sets our main struct and passes it to the parent class.
87 	 */
88 	public this (GtkFrame* gtkFrame, bool ownedRef = false)
89 	{
90 		this.gtkFrame = gtkFrame;
91 		super(cast(GtkBin*)gtkFrame, ownedRef);
92 	}
93 
94 	/**
95 	 * Creates frame with label and set it's child widget
96 	 */
97 	public this(Widget widget, string label)
98 	{
99 		this(label);
100 		add(widget);
101 	}
102 
103 	/**
104 	 */
105 
106 	/** */
107 	public static GType getType()
108 	{
109 		return gtk_frame_get_type();
110 	}
111 
112 	/**
113 	 * Creates a new #GtkFrame, with optional label @label.
114 	 * If @label is %NULL, the label is omitted.
115 	 *
116 	 * Params:
117 	 *     label = the text to use as the label of the frame
118 	 *
119 	 * Return: a new #GtkFrame widget
120 	 *
121 	 * Throws: ConstructionException GTK+ fails to create the object.
122 	 */
123 	public this(string label)
124 	{
125 		auto p = gtk_frame_new(Str.toStringz(label));
126 		
127 		if(p is null)
128 		{
129 			throw new ConstructionException("null returned by new");
130 		}
131 		
132 		this(cast(GtkFrame*) p);
133 	}
134 
135 	/**
136 	 * If the frame’s label widget is a #GtkLabel, returns the
137 	 * text in the label widget. (The frame will have a #GtkLabel
138 	 * for the label widget if a non-%NULL argument was passed
139 	 * to gtk_frame_new().)
140 	 *
141 	 * Return: the text in the label, or %NULL if there
142 	 *     was no label widget or the lable widget was not
143 	 *     a #GtkLabel. This string is owned by GTK+ and
144 	 *     must not be modified or freed.
145 	 */
146 	public string getLabel()
147 	{
148 		return Str.toString(gtk_frame_get_label(gtkFrame));
149 	}
150 
151 	/**
152 	 * Retrieves the X and Y alignment of the frame’s label. See
153 	 * gtk_frame_set_label_align().
154 	 *
155 	 * Params:
156 	 *     xalign = location to store X alignment of
157 	 *         frame’s label, or %NULL
158 	 *     yalign = location to store X alignment of
159 	 *         frame’s label, or %NULL
160 	 */
161 	public void getLabelAlign(out float xalign, out float yalign)
162 	{
163 		gtk_frame_get_label_align(gtkFrame, &xalign, &yalign);
164 	}
165 
166 	/**
167 	 * Retrieves the label widget for the frame. See
168 	 * gtk_frame_set_label_widget().
169 	 *
170 	 * Return: the label widget, or %NULL if
171 	 *     there is none.
172 	 */
173 	public Widget getLabelWidget()
174 	{
175 		auto p = gtk_frame_get_label_widget(gtkFrame);
176 		
177 		if(p is null)
178 		{
179 			return null;
180 		}
181 		
182 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
183 	}
184 
185 	/**
186 	 * Retrieves the shadow type of the frame. See
187 	 * gtk_frame_set_shadow_type().
188 	 *
189 	 * Return: the current shadow type of the frame.
190 	 */
191 	public GtkShadowType getShadowType()
192 	{
193 		return gtk_frame_get_shadow_type(gtkFrame);
194 	}
195 
196 	/**
197 	 * Sets the text of the label. If @label is %NULL,
198 	 * the current label is removed.
199 	 *
200 	 * Params:
201 	 *     label = the text to use as the label of the frame
202 	 */
203 	public void setLabel(string label)
204 	{
205 		gtk_frame_set_label(gtkFrame, Str.toStringz(label));
206 	}
207 
208 	/**
209 	 * Sets the alignment of the frame widget’s label. The
210 	 * default values for a newly created frame are 0.0 and 0.5.
211 	 *
212 	 * Params:
213 	 *     xalign = The position of the label along the top edge
214 	 *         of the widget. A value of 0.0 represents left alignment;
215 	 *         1.0 represents right alignment.
216 	 *     yalign = The y alignment of the label. A value of 0.0 aligns under
217 	 *         the frame; 1.0 aligns above the frame. If the values are exactly
218 	 *         0.0 or 1.0 the gap in the frame won’t be painted because the label
219 	 *         will be completely above or below the frame.
220 	 */
221 	public void setLabelAlign(float xalign, float yalign)
222 	{
223 		gtk_frame_set_label_align(gtkFrame, xalign, yalign);
224 	}
225 
226 	/**
227 	 * Sets the label widget for the frame. This is the widget that
228 	 * will appear embedded in the top edge of the frame as a
229 	 * title.
230 	 *
231 	 * Params:
232 	 *     labelWidget = the new label widget
233 	 */
234 	public void setLabelWidget(Widget labelWidget)
235 	{
236 		gtk_frame_set_label_widget(gtkFrame, (labelWidget is null) ? null : labelWidget.getWidgetStruct());
237 	}
238 
239 	/**
240 	 * Sets the shadow type for @frame.
241 	 *
242 	 * Params:
243 	 *     type = the new #GtkShadowType
244 	 */
245 	public void setShadowType(GtkShadowType type)
246 	{
247 		gtk_frame_set_shadow_type(gtkFrame, type);
248 	}
249 }