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 glib.c.functions;
30 private import gobject.ObjectG;
31 private import gtk.Widget;
32 private import gtk.c.functions;
33 public  import gtk.c.types;
34 
35 
36 /**
37  * `GtkFrame` is a widget that surrounds its child with a decorative
38  * frame and an optional label.
39  * 
40  * ![An example GtkFrame](frame.png)
41  * 
42  * If present, the label is drawn inside the top edge of the frame.
43  * The horizontal position of the label can be controlled with
44  * [method@Gtk.Frame.set_label_align].
45  * 
46  * `GtkFrame` clips its child. You can use this to add rounded corners
47  * to widgets, but be aware that it also cuts off shadows.
48  * 
49  * # GtkFrame as GtkBuildable
50  * 
51  * The `GtkFrame` implementation of the `GtkBuildable` interface supports
52  * placing a child in the label position by specifying “label” as the
53  * “type” attribute of a <child> element. A normal content child can
54  * be specified without specifying a <child> type attribute.
55  * 
56  * An example of a UI definition fragment with GtkFrame:
57  * ```xml
58  * <object class="GtkFrame">
59  * <child type="label">
60  * <object class="GtkLabel" id="frame_label"/>
61  * </child>
62  * <child>
63  * <object class="GtkEntry" id="frame_content"/>
64  * </child>
65  * </object>
66  * ```
67  * 
68  * # CSS nodes
69  * 
70  * ```
71  * frame
72  * ├── <label widget>
73  * ╰── <child>
74  * ```
75  * 
76  * `GtkFrame` has a main CSS node with name “frame”, which is used to draw the
77  * visible border. You can set the appearance of the border using CSS properties
78  * like “border-style” on this node.
79  */
80 public class Frame : Widget
81 {
82 	/** the main Gtk struct */
83 	protected GtkFrame* gtkFrame;
84 
85 	/** Get the main Gtk struct */
86 	public GtkFrame* getFrameStruct(bool transferOwnership = false)
87 	{
88 		if (transferOwnership)
89 			ownedRef = false;
90 		return gtkFrame;
91 	}
92 
93 	/** the main Gtk struct as a void* */
94 	protected override void* getStruct()
95 	{
96 		return cast(void*)gtkFrame;
97 	}
98 
99 	/**
100 	 * Sets our main struct and passes it to the parent class.
101 	 */
102 	public this (GtkFrame* gtkFrame, bool ownedRef = false)
103 	{
104 		this.gtkFrame = gtkFrame;
105 		super(cast(GtkWidget*)gtkFrame, ownedRef);
106 	}
107 
108 
109 	/** */
110 	public static GType getType()
111 	{
112 		return gtk_frame_get_type();
113 	}
114 
115 	/**
116 	 * Creates a new `GtkFrame`, with optional label @label.
117 	 *
118 	 * If @label is %NULL, the label is omitted.
119 	 *
120 	 * Params:
121 	 *     label = the text to use as the label of the frame
122 	 *
123 	 * Returns: a new `GtkFrame` widget
124 	 *
125 	 * Throws: ConstructionException GTK+ fails to create the object.
126 	 */
127 	public this(string label)
128 	{
129 		auto __p = gtk_frame_new(Str.toStringz(label));
130 
131 		if(__p is null)
132 		{
133 			throw new ConstructionException("null returned by new");
134 		}
135 
136 		this(cast(GtkFrame*) __p);
137 	}
138 
139 	/**
140 	 * Gets the child widget of @frame.
141 	 *
142 	 * Returns: the child widget of @frame
143 	 */
144 	public Widget getChild()
145 	{
146 		auto __p = gtk_frame_get_child(gtkFrame);
147 
148 		if(__p is null)
149 		{
150 			return null;
151 		}
152 
153 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p);
154 	}
155 
156 	/**
157 	 * Returns the frame labels text.
158 	 *
159 	 * If the frame's label widget is not a `GtkLabel`, %NULL
160 	 * is returned.
161 	 *
162 	 * Returns: the text in the label, or %NULL if there
163 	 *     was no label widget or the label widget was not a `GtkLabel`.
164 	 *     This string is owned by GTK and must not be modified or freed.
165 	 */
166 	public string getLabel()
167 	{
168 		return Str.toString(gtk_frame_get_label(gtkFrame));
169 	}
170 
171 	/**
172 	 * Retrieves the X alignment of the frame’s label.
173 	 *
174 	 * Returns: the frames X alignment
175 	 */
176 	public float getLabelAlign()
177 	{
178 		return gtk_frame_get_label_align(gtkFrame);
179 	}
180 
181 	/**
182 	 * Retrieves the label widget for the frame.
183 	 *
184 	 * Returns: the label widget, or %NULL if
185 	 *     there is none.
186 	 */
187 	public Widget getLabelWidget()
188 	{
189 		auto __p = gtk_frame_get_label_widget(gtkFrame);
190 
191 		if(__p is null)
192 		{
193 			return null;
194 		}
195 
196 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p);
197 	}
198 
199 	/**
200 	 * Sets the child widget of @frame.
201 	 *
202 	 * Params:
203 	 *     child = the child widget
204 	 */
205 	public void setChild(Widget child)
206 	{
207 		gtk_frame_set_child(gtkFrame, (child is null) ? null : child.getWidgetStruct());
208 	}
209 
210 	/**
211 	 * Creates a new `GtkLabel` with the @label and sets it as the frame's
212 	 * label widget.
213 	 *
214 	 * Params:
215 	 *     label = the text to use as the label of the frame
216 	 */
217 	public void setLabel(string label)
218 	{
219 		gtk_frame_set_label(gtkFrame, Str.toStringz(label));
220 	}
221 
222 	/**
223 	 * Sets the X alignment of the frame widget’s label.
224 	 *
225 	 * The default value for a newly created frame is 0.0.
226 	 *
227 	 * Params:
228 	 *     xalign = The position of the label along the top edge
229 	 *         of the widget. A value of 0.0 represents left alignment;
230 	 *         1.0 represents right alignment.
231 	 */
232 	public void setLabelAlign(float xalign)
233 	{
234 		gtk_frame_set_label_align(gtkFrame, xalign);
235 	}
236 
237 	/**
238 	 * Sets the label widget for the frame.
239 	 *
240 	 * This is the widget that will appear embedded in the top edge
241 	 * of the frame as a 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 }