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