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