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 gtk.c.functions;
33 public  import gtk.c.types;
34 public  import gtkc.gtktypes;
35 
36 
37 /**
38  * The frame widget is a bin that surrounds its child with a decorative
39  * frame and an optional label. If present, the label is drawn in a gap
40  * in the top side of the frame. The position of the label can be
41  * 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  * # CSS nodes
63  * 
64  * |[<!-- language="plain" -->
65  * frame
66  * ├── border[.flat]
67  * ├── <label widget>
68  * ╰── <child>
69  * ]|
70  * 
71  * GtkFrame has a main CSS node named “frame” and a subnode named “border”. The
72  * “border” node is used to draw the visible border. You can set the appearance
73  * of the border using CSS properties like “border-style” on the “border” node.
74  * 
75  * The border node can be given the style class “.flat”, which is used by themes
76  * to disable drawing of the border. To do this from code, call
77  * gtk_frame_set_shadow_type() with %GTK_SHADOW_NONE to add the “.flat” class or
78  * any other shadow type to remove it.
79  */
80 public class Frame : Bin
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 	protected override void setStruct(GObject* obj)
100 	{
101 		gtkFrame = cast(GtkFrame*)obj;
102 		super.setStruct(obj);
103 	}
104 
105 	/**
106 	 * Sets our main struct and passes it to the parent class.
107 	 */
108 	public this (GtkFrame* gtkFrame, bool ownedRef = false)
109 	{
110 		this.gtkFrame = gtkFrame;
111 		super(cast(GtkBin*)gtkFrame, ownedRef);
112 	}
113 
114 	/**
115 	 * Creates frame with label and set it's child widget
116 	 */
117 	public this(Widget widget, string label)
118 	{
119 		this(label);
120 		add(widget);
121 	}
122 
123 	/**
124 	 */
125 
126 	/** */
127 	public static GType getType()
128 	{
129 		return gtk_frame_get_type();
130 	}
131 
132 	/**
133 	 * Creates a new #GtkFrame, with optional label @label.
134 	 * If @label is %NULL, the label is omitted.
135 	 *
136 	 * Params:
137 	 *     label = the text to use as the label of the frame
138 	 *
139 	 * Returns: a new #GtkFrame widget
140 	 *
141 	 * Throws: ConstructionException GTK+ fails to create the object.
142 	 */
143 	public this(string label)
144 	{
145 		auto p = gtk_frame_new(Str.toStringz(label));
146 
147 		if(p is null)
148 		{
149 			throw new ConstructionException("null returned by new");
150 		}
151 
152 		this(cast(GtkFrame*) p);
153 	}
154 
155 	/**
156 	 * If the frame’s label widget is a #GtkLabel, returns the
157 	 * text in the label widget. (The frame will have a #GtkLabel
158 	 * for the label widget if a non-%NULL argument was passed
159 	 * to gtk_frame_new().)
160 	 *
161 	 * Returns: the text in the label, or %NULL if there
162 	 *     was no label widget or the lable widget was not
163 	 *     a #GtkLabel. This string is owned by GTK+ and
164 	 *     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 and Y alignment of the frame’s label. See
173 	 * gtk_frame_set_label_align().
174 	 *
175 	 * Params:
176 	 *     xalign = location to store X alignment of
177 	 *         frame’s label, or %NULL
178 	 *     yalign = location to store X alignment of
179 	 *         frame’s label, or %NULL
180 	 */
181 	public void getLabelAlign(out float xalign, out float yalign)
182 	{
183 		gtk_frame_get_label_align(gtkFrame, &xalign, &yalign);
184 	}
185 
186 	/**
187 	 * Retrieves the label widget for the frame. See
188 	 * gtk_frame_set_label_widget().
189 	 *
190 	 * Returns: the label widget, or %NULL if
191 	 *     there is none.
192 	 */
193 	public Widget getLabelWidget()
194 	{
195 		auto p = gtk_frame_get_label_widget(gtkFrame);
196 
197 		if(p is null)
198 		{
199 			return null;
200 		}
201 
202 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
203 	}
204 
205 	/**
206 	 * Retrieves the shadow type of the frame. See
207 	 * gtk_frame_set_shadow_type().
208 	 *
209 	 * Returns: the current shadow type of the frame.
210 	 */
211 	public GtkShadowType getShadowType()
212 	{
213 		return gtk_frame_get_shadow_type(gtkFrame);
214 	}
215 
216 	/**
217 	 * Removes the current #GtkFrame:label-widget. If @label is not %NULL, creates a
218 	 * new #GtkLabel with that text and adds it as the #GtkFrame:label-widget.
219 	 *
220 	 * Params:
221 	 *     label = the text to use as the label of the frame
222 	 */
223 	public void setLabel(string label)
224 	{
225 		gtk_frame_set_label(gtkFrame, Str.toStringz(label));
226 	}
227 
228 	/**
229 	 * Sets the alignment of the frame widget’s label. The
230 	 * default values for a newly created frame are 0.0 and 0.5.
231 	 *
232 	 * Params:
233 	 *     xalign = The position of the label along the top edge
234 	 *         of the widget. A value of 0.0 represents left alignment;
235 	 *         1.0 represents right alignment.
236 	 *     yalign = The y alignment of the label. A value of 0.0 aligns under
237 	 *         the frame; 1.0 aligns above the frame. If the values are exactly
238 	 *         0.0 or 1.0 the gap in the frame won’t be painted because the label
239 	 *         will be completely above or below the frame.
240 	 */
241 	public void setLabelAlign(float xalign, float yalign)
242 	{
243 		gtk_frame_set_label_align(gtkFrame, xalign, yalign);
244 	}
245 
246 	/**
247 	 * Sets the #GtkFrame:label-widget for the frame. This is the widget that
248 	 * will appear embedded in the top edge of the frame as a title.
249 	 *
250 	 * Params:
251 	 *     labelWidget = the new label widget
252 	 */
253 	public void setLabelWidget(Widget labelWidget)
254 	{
255 		gtk_frame_set_label_widget(gtkFrame, (labelWidget is null) ? null : labelWidget.getWidgetStruct());
256 	}
257 
258 	/**
259 	 * Sets the #GtkFrame:shadow-type for @frame, i.e. whether it is drawn without
260 	 * (%GTK_SHADOW_NONE) or with (other values) a visible border. Values other than
261 	 * %GTK_SHADOW_NONE are treated identically by GtkFrame. The chosen type is
262 	 * applied by removing or adding the .flat class to the CSS node named border.
263 	 *
264 	 * Params:
265 	 *     type = the new #GtkShadowType
266 	 */
267 	public void setShadowType(GtkShadowType type)
268 	{
269 		gtk_frame_set_shadow_type(gtkFrame, type);
270 	}
271 }