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 glib.c.functions;
30 private import gobject.ObjectG;
31 private import gtk.Widget;
32 private import gtk.c.functions;
33 public  import gtk.c.types;
34 
35 
36 /**
37  * `GtkHeaderBar` is a widget for creating custom title bars for windows.
38  * 
39  * ![An example GtkHeaderBar](headerbar.png)
40  * 
41  * `GtkHeaderBar` is similar to a horizontal `GtkCenterBox`. It allows
42  * children to be placed at the start or the end. In addition, it allows
43  * the window title to be displayed. The title will be centered with respect
44  * to the width of the box, even if the children at either side take up
45  * different amounts of space.
46  * 
47  * `GtkHeaderBar` can add typical window frame controls, such as minimize,
48  * maximize and close buttons, or the window icon.
49  * 
50  * For these reasons, `GtkHeaderBar` is the natural choice for use as the
51  * custom titlebar widget of a `GtkWindow (see [method@Gtk.Window.set_titlebar]),
52  * as it gives features typical of titlebars while allowing the addition of
53  * child widgets.
54  * 
55  * ## GtkHeaderBar as GtkBuildable
56  * 
57  * The `GtkHeaderBar` implementation of the `GtkBuildable` interface supports
58  * adding children at the start or end sides by specifying “start” or “end” as
59  * the “type” attribute of a <child> element, or setting the title widget by
60  * specifying “title” value.
61  * 
62  * By default the `GtkHeaderBar` uses a `GtkLabel` displaying the title of the
63  * window it is contained in as the title widget, equivalent to the following
64  * UI definition:
65  * 
66  * ```xml
67  * <object class="GtkHeaderBar">
68  * <property name="title-widget">
69  * <object class="GtkLabel">
70  * <property name="label" translatable="yes">Label</property>
71  * <property name="single-line-mode">True</property>
72  * <property name="ellipsize">end</property>
73  * <property name="width-chars">5</property>
74  * <style>
75  * <class name="title"/>
76  * </style>
77  * </object>
78  * </property>
79  * </object>
80  * ```
81  * 
82  * # CSS nodes
83  * 
84  * ```
85  * headerbar
86  * ╰── windowhandle
87  * ╰── box
88  * ├── box.start
89  * │   ├── windowcontrols.start
90  * │   ╰── [other children]
91  * ├── [Title Widget]
92  * ╰── box.end
93  * ├── [other children]
94  * ╰── windowcontrols.end
95  * ```
96  * 
97  * A `GtkHeaderBar`'s CSS node is called `headerbar`. It contains a `windowhandle`
98  * subnode, which contains a `box` subnode, which contains two `box` subnodes at
99  * the start and end of the header bar, as well as a center node that represents
100  * the title.
101  * 
102  * Each of the boxes contains a `windowcontrols` subnode, see
103  * [class@Gtk.WindowControls] for details, as well as other children.
104  * 
105  * # Accessibility
106  * 
107  * `GtkHeaderBar` uses the %GTK_ACCESSIBLE_ROLE_GROUP role.
108  */
109 public class HeaderBar : Widget
110 {
111 	/** the main Gtk struct */
112 	protected GtkHeaderBar* gtkHeaderBar;
113 
114 	/** Get the main Gtk struct */
115 	public GtkHeaderBar* getHeaderBarStruct(bool transferOwnership = false)
116 	{
117 		if (transferOwnership)
118 			ownedRef = false;
119 		return gtkHeaderBar;
120 	}
121 
122 	/** the main Gtk struct as a void* */
123 	protected override void* getStruct()
124 	{
125 		return cast(void*)gtkHeaderBar;
126 	}
127 
128 	/**
129 	 * Sets our main struct and passes it to the parent class.
130 	 */
131 	public this (GtkHeaderBar* gtkHeaderBar, bool ownedRef = false)
132 	{
133 		this.gtkHeaderBar = gtkHeaderBar;
134 		super(cast(GtkWidget*)gtkHeaderBar, ownedRef);
135 	}
136 
137 
138 	/** */
139 	public static GType getType()
140 	{
141 		return gtk_header_bar_get_type();
142 	}
143 
144 	/**
145 	 * Creates a new `GtkHeaderBar` widget.
146 	 *
147 	 * Returns: a new `GtkHeaderBar`
148 	 *
149 	 * Throws: ConstructionException GTK+ fails to create the object.
150 	 */
151 	public this()
152 	{
153 		auto __p = gtk_header_bar_new();
154 
155 		if(__p is null)
156 		{
157 			throw new ConstructionException("null returned by new");
158 		}
159 
160 		this(cast(GtkHeaderBar*) __p);
161 	}
162 
163 	/**
164 	 * Gets the decoration layout of the `GtkHeaderBar`.
165 	 *
166 	 * Returns: the decoration layout
167 	 */
168 	public string getDecorationLayout()
169 	{
170 		return Str.toString(gtk_header_bar_get_decoration_layout(gtkHeaderBar));
171 	}
172 
173 	/**
174 	 * Returns whether this header bar shows the standard window
175 	 * title buttons.
176 	 *
177 	 * Returns: %TRUE if title buttons are shown
178 	 */
179 	public bool getShowTitleButtons()
180 	{
181 		return gtk_header_bar_get_show_title_buttons(gtkHeaderBar) != 0;
182 	}
183 
184 	/**
185 	 * Retrieves the title widget of the header.
186 	 *
187 	 * See [method@Gtk.HeaderBar.set_title_widget].
188 	 *
189 	 * Returns: the title widget
190 	 *     of the header, or %NULL if none has been set explicitly.
191 	 */
192 	public Widget getTitleWidget()
193 	{
194 		auto __p = gtk_header_bar_get_title_widget(gtkHeaderBar);
195 
196 		if(__p is null)
197 		{
198 			return null;
199 		}
200 
201 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p);
202 	}
203 
204 	/**
205 	 * Adds @child to @bar, packed with reference to the
206 	 * end of the @bar.
207 	 *
208 	 * Params:
209 	 *     child = the #GtkWidget to be added to @bar
210 	 */
211 	public void packEnd(Widget child)
212 	{
213 		gtk_header_bar_pack_end(gtkHeaderBar, (child is null) ? null : child.getWidgetStruct());
214 	}
215 
216 	/**
217 	 * Adds @child to @bar, packed with reference to the
218 	 * start of the @bar.
219 	 *
220 	 * Params:
221 	 *     child = the #GtkWidget to be added to @bar
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 	 * Removes a child from the `GtkHeaderBar`.
230 	 *
231 	 * The child must have been added with
232 	 * [method@Gtk.HeaderBar.pack_start],
233 	 * [method@Gtk.HeaderBar.pack_end] or
234 	 * [method@Gtk.HeaderBar.set_title_widget].
235 	 *
236 	 * Params:
237 	 *     child = the child to remove
238 	 */
239 	public void remove(Widget child)
240 	{
241 		gtk_header_bar_remove(gtkHeaderBar, (child is null) ? null : child.getWidgetStruct());
242 	}
243 
244 	/**
245 	 * Sets the decoration layout for this header bar.
246 	 *
247 	 * This property overrides the
248 	 * [property@Gtk.Settings:gtk-decoration-layout] setting.
249 	 *
250 	 * There can be valid reasons for overriding the setting, such
251 	 * as a header bar design that does not allow for buttons to take
252 	 * room on the right, or only offers room for a single close button.
253 	 * Split header bars are another example for overriding the setting.
254 	 *
255 	 * The format of the string is button names, separated by commas.
256 	 * A colon separates the buttons that should appear on the left
257 	 * from those on the right. Recognized button names are minimize,
258 	 * maximize, close and icon (the window icon).
259 	 *
260 	 * For example, “icon:minimize,maximize,close” specifies a icon
261 	 * on the left, and minimize, maximize and close buttons on the right.
262 	 *
263 	 * Params:
264 	 *     layout = a decoration layout, or %NULL to
265 	 *         unset the layout
266 	 */
267 	public void setDecorationLayout(string layout)
268 	{
269 		gtk_header_bar_set_decoration_layout(gtkHeaderBar, Str.toStringz(layout));
270 	}
271 
272 	/**
273 	 * Sets whether this header bar shows the standard window
274 	 * title buttons.
275 	 *
276 	 * Params:
277 	 *     setting = %TRUE to show standard title buttons
278 	 */
279 	public void setShowTitleButtons(bool setting)
280 	{
281 		gtk_header_bar_set_show_title_buttons(gtkHeaderBar, setting);
282 	}
283 
284 	/**
285 	 * Sets the title for the `GtkHeaderBar`.
286 	 *
287 	 * When set to %NULL, the headerbar will display the title of
288 	 * the window it is contained in.
289 	 *
290 	 * The title should help a user identify the current view.
291 	 * To achieve the same style as the builtin title, use the
292 	 * “title” style class.
293 	 *
294 	 * You should set the title widget to %NULL, for the window
295 	 * title label to be visible again.
296 	 *
297 	 * Params:
298 	 *     titleWidget = a widget to use for a title
299 	 */
300 	public void setTitleWidget(Widget titleWidget)
301 	{
302 		gtk_header_bar_set_title_widget(gtkHeaderBar, (titleWidget is null) ? null : titleWidget.getWidgetStruct());
303 	}
304 }