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