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 	public static GType getType()
107 	{
108 		return gtk_frame_get_type();
109 	}
110 
111 	/**
112 	 * Creates a new #GtkFrame, with optional label @label.
113 	 * If @label is %NULL, the label is omitted.
114 	 *
115 	 * Params:
116 	 *     label = the text to use as the label of the frame
117 	 *
118 	 * Return: a new #GtkFrame widget
119 	 *
120 	 * Throws: ConstructionException GTK+ fails to create the object.
121 	 */
122 	public this(string label)
123 	{
124 		auto p = gtk_frame_new(Str.toStringz(label));
125 		
126 		if(p is null)
127 		{
128 			throw new ConstructionException("null returned by new");
129 		}
130 		
131 		this(cast(GtkFrame*) p);
132 	}
133 
134 	/**
135 	 * If the frame’s label widget is a #GtkLabel, returns the
136 	 * text in the label widget. (The frame will have a #GtkLabel
137 	 * for the label widget if a non-%NULL argument was passed
138 	 * to gtk_frame_new().)
139 	 *
140 	 * Return: the text in the label, or %NULL if there
141 	 *     was no label widget or the lable widget was not
142 	 *     a #GtkLabel. This string is owned by GTK+ and
143 	 *     must not be modified or freed.
144 	 */
145 	public string getLabel()
146 	{
147 		return Str.toString(gtk_frame_get_label(gtkFrame));
148 	}
149 
150 	/**
151 	 * Retrieves the X and Y alignment of the frame’s label. See
152 	 * gtk_frame_set_label_align().
153 	 *
154 	 * Params:
155 	 *     xalign = location to store X alignment of
156 	 *         frame’s label, or %NULL
157 	 *     yalign = location to store X alignment of
158 	 *         frame’s label, or %NULL
159 	 */
160 	public void getLabelAlign(out float xalign, out float yalign)
161 	{
162 		gtk_frame_get_label_align(gtkFrame, &xalign, &yalign);
163 	}
164 
165 	/**
166 	 * Retrieves the label widget for the frame. See
167 	 * gtk_frame_set_label_widget().
168 	 *
169 	 * Return: the label widget, or %NULL if
170 	 *     there is none.
171 	 */
172 	public Widget getLabelWidget()
173 	{
174 		auto p = gtk_frame_get_label_widget(gtkFrame);
175 		
176 		if(p is null)
177 		{
178 			return null;
179 		}
180 		
181 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
182 	}
183 
184 	/**
185 	 * Retrieves the shadow type of the frame. See
186 	 * gtk_frame_set_shadow_type().
187 	 *
188 	 * Return: the current shadow type of the frame.
189 	 */
190 	public GtkShadowType getShadowType()
191 	{
192 		return gtk_frame_get_shadow_type(gtkFrame);
193 	}
194 
195 	/**
196 	 * Sets the text of the label. If @label is %NULL,
197 	 * the current label is removed.
198 	 *
199 	 * Params:
200 	 *     label = the text to use as the label of the frame
201 	 */
202 	public void setLabel(string label)
203 	{
204 		gtk_frame_set_label(gtkFrame, Str.toStringz(label));
205 	}
206 
207 	/**
208 	 * Sets the alignment of the frame widget’s label. The
209 	 * default values for a newly created frame are 0.0 and 0.5.
210 	 *
211 	 * Params:
212 	 *     xalign = The position of the label along the top edge
213 	 *         of the widget. A value of 0.0 represents left alignment;
214 	 *         1.0 represents right alignment.
215 	 *     yalign = The y alignment of the label. A value of 0.0 aligns under
216 	 *         the frame; 1.0 aligns above the frame. If the values are exactly
217 	 *         0.0 or 1.0 the gap in the frame won’t be painted because the label
218 	 *         will be completely above or below the frame.
219 	 */
220 	public void setLabelAlign(float xalign, float yalign)
221 	{
222 		gtk_frame_set_label_align(gtkFrame, xalign, yalign);
223 	}
224 
225 	/**
226 	 * Sets the label widget for the frame. This is the widget that
227 	 * will appear embedded in the top edge of the frame as a
228 	 * title.
229 	 *
230 	 * Params:
231 	 *     labelWidget = the new label widget
232 	 */
233 	public void setLabelWidget(Widget labelWidget)
234 	{
235 		gtk_frame_set_label_widget(gtkFrame, (labelWidget is null) ? null : labelWidget.getWidgetStruct());
236 	}
237 
238 	/**
239 	 * Sets the shadow type for @frame.
240 	 *
241 	 * Params:
242 	 *     type = the new #GtkShadowType
243 	 */
244 	public void setShadowType(GtkShadowType type)
245 	{
246 		gtk_frame_set_shadow_type(gtkFrame, type);
247 	}
248 }