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