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.HeaderBar;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gtk.Container;
31 private import gtk.Widget;
32 private import gtkc.gtk;
33 public  import gtkc.gtktypes;
34 
35 
36 /**
37  * GtkHeaderBar is similar to a horizontal #GtkBox. It allows children to
38  * be placed at the start or the end. In addition, it allows a title and
39  * subtitle to be displayed. The title will be centered with respect to
40  * the width of the box, even if the children at either side take up
41  * different amounts of space. The height of the titlebar will be
42  * set to provide sufficient space for the subtitle, even if none is
43  * currently set. If a subtitle is not needed, the space reservation
44  * can be turned off with gtk_header_bar_set_has_subtitle().
45  * 
46  * GtkHeaderBar can add typical window frame controls, such as minimize,
47  * maximize and close buttons, or the window icon.
48  */
49 public class HeaderBar : Container
50 {
51 	/** the main Gtk struct */
52 	protected GtkHeaderBar* gtkHeaderBar;
53 
54 	/** Get the main Gtk struct */
55 	public GtkHeaderBar* getHeaderBarStruct()
56 	{
57 		return gtkHeaderBar;
58 	}
59 
60 	/** the main Gtk struct as a void* */
61 	protected override void* getStruct()
62 	{
63 		return cast(void*)gtkHeaderBar;
64 	}
65 
66 	protected override void setStruct(GObject* obj)
67 	{
68 		gtkHeaderBar = cast(GtkHeaderBar*)obj;
69 		super.setStruct(obj);
70 	}
71 
72 	/**
73 	 * Sets our main struct and passes it to the parent class.
74 	 */
75 	public this (GtkHeaderBar* gtkHeaderBar, bool ownedRef = false)
76 	{
77 		this.gtkHeaderBar = gtkHeaderBar;
78 		super(cast(GtkContainer*)gtkHeaderBar, ownedRef);
79 	}
80 
81 	/**
82 	 */
83 
84 	public static GType getType()
85 	{
86 		return gtk_header_bar_get_type();
87 	}
88 
89 	/**
90 	 * Creates a new #GtkHeaderBar widget.
91 	 *
92 	 * Return: a new #GtkHeaderBar
93 	 *
94 	 * Since: 3.10
95 	 *
96 	 * Throws: ConstructionException GTK+ fails to create the object.
97 	 */
98 	public this()
99 	{
100 		auto p = gtk_header_bar_new();
101 		
102 		if(p is null)
103 		{
104 			throw new ConstructionException("null returned by new");
105 		}
106 		
107 		this(cast(GtkHeaderBar*) p);
108 	}
109 
110 	/**
111 	 * Retrieves the custom title widget of the header. See
112 	 * gtk_header_bar_set_custom_title().
113 	 *
114 	 * Return: the custom title widget
115 	 *     of the header, or %NULL if none has been set explicitly.
116 	 *
117 	 * Since: 3.10
118 	 */
119 	public Widget getCustomTitle()
120 	{
121 		auto p = gtk_header_bar_get_custom_title(gtkHeaderBar);
122 		
123 		if(p is null)
124 		{
125 			return null;
126 		}
127 		
128 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
129 	}
130 
131 	/**
132 	 * Gets the decoration layout set with
133 	 * gtk_header_bar_set_decoration_layout().
134 	 *
135 	 * Return: the decoration layout
136 	 *
137 	 * Since: 3.12
138 	 */
139 	public string getDecorationLayout()
140 	{
141 		return Str.toString(gtk_header_bar_get_decoration_layout(gtkHeaderBar));
142 	}
143 
144 	/**
145 	 * Retrieves whether the header bar reserves space for
146 	 * a subtitle, regardless if one is currently set or not.
147 	 *
148 	 * Return: %TRUE if the header bar reserves space
149 	 *     for a subtitle
150 	 *
151 	 * Since: 3.12
152 	 */
153 	public bool getHasSubtitle()
154 	{
155 		return gtk_header_bar_get_has_subtitle(gtkHeaderBar) != 0;
156 	}
157 
158 	/**
159 	 * Returns whether this header bar shows the standard window
160 	 * decorations.
161 	 *
162 	 * Return: %TRUE if the decorations are shown
163 	 *
164 	 * Since: 3.10
165 	 */
166 	public bool getShowCloseButton()
167 	{
168 		return gtk_header_bar_get_show_close_button(gtkHeaderBar) != 0;
169 	}
170 
171 	/**
172 	 * Retrieves the subtitle of the header. See gtk_header_bar_set_subtitle().
173 	 *
174 	 * Return: the subtitle of the header, or %NULL if none has
175 	 *     been set explicitly. The returned string is owned by the widget
176 	 *     and must not be modified or freed.
177 	 *
178 	 * Since: 3.10
179 	 */
180 	public string getSubtitle()
181 	{
182 		return Str.toString(gtk_header_bar_get_subtitle(gtkHeaderBar));
183 	}
184 
185 	/**
186 	 * Retrieves the title of the header. See gtk_header_bar_set_title().
187 	 *
188 	 * Return: the title of the header, or %NULL if none has
189 	 *     been set explicitly. The returned string is owned by the widget
190 	 *     and must not be modified or freed.
191 	 *
192 	 * Since: 3.10
193 	 */
194 	public string getTitle()
195 	{
196 		return Str.toString(gtk_header_bar_get_title(gtkHeaderBar));
197 	}
198 
199 	/**
200 	 * Adds @child to @bar, packed with reference to the
201 	 * end of the @bar.
202 	 *
203 	 * Params:
204 	 *     child = the #GtkWidget to be added to @bar
205 	 *
206 	 * Since: 3.10
207 	 */
208 	public void packEnd(Widget child)
209 	{
210 		gtk_header_bar_pack_end(gtkHeaderBar, (child is null) ? null : child.getWidgetStruct());
211 	}
212 
213 	/**
214 	 * Adds @child to @bar, packed with reference to the
215 	 * start of the @bar.
216 	 *
217 	 * Params:
218 	 *     child = the #GtkWidget to be added to @bar
219 	 *
220 	 * Since: 3.10
221 	 */
222 	public void packStart(Widget child)
223 	{
224 		gtk_header_bar_pack_start(gtkHeaderBar, (child is null) ? null : child.getWidgetStruct());
225 	}
226 
227 	/**
228 	 * Sets a custom title for the #GtkHeaderBar.
229 	 *
230 	 * The title should help a user identify the current view. This
231 	 * supersedes any title set by gtk_header_bar_set_title() or
232 	 * gtk_header_bar_set_subtitle(). To achieve the same style as
233 	 * the builtin title and subtitle, use the “title” and “subtitle”
234 	 * style classes.
235 	 *
236 	 * You should set the custom title to %NULL, for the header title
237 	 * label to be visible again.
238 	 *
239 	 * Params:
240 	 *     titleWidget = a custom widget to use for a title
241 	 *
242 	 * Since: 3.10
243 	 */
244 	public void setCustomTitle(Widget titleWidget)
245 	{
246 		gtk_header_bar_set_custom_title(gtkHeaderBar, (titleWidget is null) ? null : titleWidget.getWidgetStruct());
247 	}
248 
249 	/**
250 	 * Sets the decoration layout for this header bar, overriding
251 	 * the #GtkSettings:gtk-decoration-layout setting.
252 	 *
253 	 * There can be valid reasons for overriding the setting, such
254 	 * as a header bar design that does not allow for buttons to take
255 	 * room on the right, or only offers room for a single close button.
256 	 * Split header bars are another example for overriding the
257 	 * setting.
258 	 *
259 	 * The format of the string is button names, separated by commas.
260 	 * A colon separates the buttons that should appear on the left
261 	 * from those on the right. Recognized button names are minimize,
262 	 * maximize, close, icon (the window icon) and menu (a menu button
263 	 * for the fallback app menu).
264 	 *
265 	 * For example, “menu:minimize,maximize,close” specifies a menu
266 	 * on the left, and minimize, maximize and close buttons on the right.
267 	 *
268 	 * Params:
269 	 *     layout = a decoration layout, or %NULL to
270 	 *         unset the layout
271 	 *
272 	 * Since: 3.12
273 	 */
274 	public void setDecorationLayout(string layout)
275 	{
276 		gtk_header_bar_set_decoration_layout(gtkHeaderBar, Str.toStringz(layout));
277 	}
278 
279 	/**
280 	 * Sets whether the header bar should reserve space
281 	 * for a subtitle, even if none is currently set.
282 	 *
283 	 * Params:
284 	 *     setting = %TRUE to reserve space for a subtitle
285 	 *
286 	 * Since: 3.12
287 	 */
288 	public void setHasSubtitle(bool setting)
289 	{
290 		gtk_header_bar_set_has_subtitle(gtkHeaderBar, setting);
291 	}
292 
293 	/**
294 	 * Sets whether this header bar shows the standard window decorations,
295 	 * including close, maximize, and minimize.
296 	 *
297 	 * Params:
298 	 *     setting = %TRUE to show standard widow decorations
299 	 *
300 	 * Since: 3.10
301 	 */
302 	public void setShowCloseButton(bool setting)
303 	{
304 		gtk_header_bar_set_show_close_button(gtkHeaderBar, setting);
305 	}
306 
307 	/**
308 	 * Sets the subtitle of the #GtkHeaderBar. The title should give a user
309 	 * an additional detail to help him identify the current view.
310 	 *
311 	 * Note that GtkHeaderBar by default reserves room for the subtitle,
312 	 * even if none is currently set. If this is not desired, set the
313 	 * #GtkHeaderBar:has-subtitle property to %FALSE.
314 	 *
315 	 * Params:
316 	 *     subtitle = a subtitle, or %NULL
317 	 *
318 	 * Since: 3.10
319 	 */
320 	public void setSubtitle(string subtitle)
321 	{
322 		gtk_header_bar_set_subtitle(gtkHeaderBar, Str.toStringz(subtitle));
323 	}
324 
325 	/**
326 	 * Sets the title of the #GtkHeaderBar. The title should help a user
327 	 * identify the current view. A good title should not include the
328 	 * application name.
329 	 *
330 	 * Params:
331 	 *     title = a title, or %NULL
332 	 *
333 	 * Since: 3.10
334 	 */
335 	public void setTitle(string title)
336 	{
337 		gtk_header_bar_set_title(gtkHeaderBar, Str.toStringz(title));
338 	}
339 }