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