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 	/**
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(GtkBin*)gtkFrame, ownedRef);
106 	}
107 
108 	/**
109 	 * Creates frame with label and set it's child widget
110 	 */
111 	public this(Widget widget, string label)
112 	{
113 		this(label);
114 		add(widget);
115 	}
116 
117 	/**
118 	 */
119 
120 	/** */
121 	public static GType getType()
122 	{
123 		return gtk_frame_get_type();
124 	}
125 
126 	/**
127 	 * Creates a new #GtkFrame, with optional label @label.
128 	 * If @label is %NULL, the label is omitted.
129 	 *
130 	 * Params:
131 	 *     label = the text to use as the label of the frame
132 	 *
133 	 * Returns: a new #GtkFrame widget
134 	 *
135 	 * Throws: ConstructionException GTK+ fails to create the object.
136 	 */
137 	public this(string label)
138 	{
139 		auto p = gtk_frame_new(Str.toStringz(label));
140 
141 		if(p is null)
142 		{
143 			throw new ConstructionException("null returned by new");
144 		}
145 
146 		this(cast(GtkFrame*) p);
147 	}
148 
149 	/**
150 	 * If the frame’s label widget is a #GtkLabel, returns the
151 	 * text in the label widget. (The frame will have a #GtkLabel
152 	 * for the label widget if a non-%NULL argument was passed
153 	 * to gtk_frame_new().)
154 	 *
155 	 * Returns: the text in the label, or %NULL if there
156 	 *     was no label widget or the lable widget was not
157 	 *     a #GtkLabel. This string is owned by GTK+ and
158 	 *     must not be modified or freed.
159 	 */
160 	public string getLabel()
161 	{
162 		return Str.toString(gtk_frame_get_label(gtkFrame));
163 	}
164 
165 	/**
166 	 * Retrieves the X and Y alignment of the frame’s label. See
167 	 * gtk_frame_set_label_align().
168 	 *
169 	 * Params:
170 	 *     xalign = location to store X alignment of
171 	 *         frame’s label, or %NULL
172 	 *     yalign = location to store X alignment of
173 	 *         frame’s label, or %NULL
174 	 */
175 	public void getLabelAlign(out float xalign, out float yalign)
176 	{
177 		gtk_frame_get_label_align(gtkFrame, &xalign, &yalign);
178 	}
179 
180 	/**
181 	 * Retrieves the label widget for the frame. See
182 	 * gtk_frame_set_label_widget().
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 	 * Retrieves the shadow type of the frame. See
201 	 * gtk_frame_set_shadow_type().
202 	 *
203 	 * Returns: the current shadow type of the frame.
204 	 */
205 	public GtkShadowType getShadowType()
206 	{
207 		return gtk_frame_get_shadow_type(gtkFrame);
208 	}
209 
210 	/**
211 	 * Removes the current #GtkFrame:label-widget. If @label is not %NULL, creates a
212 	 * new #GtkLabel with that text and adds it as the #GtkFrame: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 alignment of the frame widget’s label. The
224 	 * default values for a newly created frame are 0.0 and 0.5.
225 	 *
226 	 * Params:
227 	 *     xalign = The position of the label along the top edge
228 	 *         of the widget. A value of 0.0 represents left alignment;
229 	 *         1.0 represents right alignment.
230 	 *     yalign = The y alignment of the label. A value of 0.0 aligns under
231 	 *         the frame; 1.0 aligns above the frame. If the values are exactly
232 	 *         0.0 or 1.0 the gap in the frame won’t be painted because the label
233 	 *         will be completely above or below the frame.
234 	 */
235 	public void setLabelAlign(float xalign, float yalign)
236 	{
237 		gtk_frame_set_label_align(gtkFrame, xalign, yalign);
238 	}
239 
240 	/**
241 	 * Sets the #GtkFrame:label-widget for the frame. This is the widget that
242 	 * will appear embedded in the top edge of the frame as a title.
243 	 *
244 	 * Params:
245 	 *     labelWidget = the new label widget
246 	 */
247 	public void setLabelWidget(Widget labelWidget)
248 	{
249 		gtk_frame_set_label_widget(gtkFrame, (labelWidget is null) ? null : labelWidget.getWidgetStruct());
250 	}
251 
252 	/**
253 	 * Sets the #GtkFrame:shadow-type for @frame, i.e. whether it is drawn without
254 	 * (%GTK_SHADOW_NONE) or with (other values) a visible border. Values other than
255 	 * %GTK_SHADOW_NONE are treated identically by GtkFrame. The chosen type is
256 	 * applied by removing or adding the .flat class to the CSS node named border.
257 	 *
258 	 * Params:
259 	 *     type = the new #GtkShadowType
260 	 */
261 	public void setShadowType(GtkShadowType type)
262 	{
263 		gtk_frame_set_shadow_type(gtkFrame, type);
264 	}
265 }