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