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.Stack; 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 * The GtkStack widget is a container which only shows 38 * one of its children at a time. In contrast to GtkNotebook, 39 * GtkStack does not provide a means for users to change the 40 * visible child. Instead, the #GtkStackSwitcher widget can be 41 * used with GtkStack to provide this functionality. 42 * 43 * Transitions between pages can be animated as slides or 44 * fades. This can be controlled with gtk_stack_set_transition_type(). 45 * These animations respect the #GtkSettings:gtk-enable-animations 46 * setting. 47 * 48 * The GtkStack widget was added in GTK+ 3.10. 49 * 50 * # CSS nodes 51 * 52 * GtkStack has a single CSS node named stack. 53 */ 54 public class Stack : Container 55 { 56 /** the main Gtk struct */ 57 protected GtkStack* gtkStack; 58 59 /** Get the main Gtk struct */ 60 public GtkStack* getStackStruct(bool transferOwnership = false) 61 { 62 if (transferOwnership) 63 ownedRef = false; 64 return gtkStack; 65 } 66 67 /** the main Gtk struct as a void* */ 68 protected override void* getStruct() 69 { 70 return cast(void*)gtkStack; 71 } 72 73 protected override void setStruct(GObject* obj) 74 { 75 gtkStack = cast(GtkStack*)obj; 76 super.setStruct(obj); 77 } 78 79 /** 80 * Sets our main struct and passes it to the parent class. 81 */ 82 public this (GtkStack* gtkStack, bool ownedRef = false) 83 { 84 this.gtkStack = gtkStack; 85 super(cast(GtkContainer*)gtkStack, ownedRef); 86 } 87 88 89 /** */ 90 public static GType getType() 91 { 92 return gtk_stack_get_type(); 93 } 94 95 /** 96 * Creates a new #GtkStack container. 97 * 98 * Returns: a new #GtkStack 99 * 100 * Since: 3.10 101 * 102 * Throws: ConstructionException GTK+ fails to create the object. 103 */ 104 public this() 105 { 106 auto p = gtk_stack_new(); 107 108 if(p is null) 109 { 110 throw new ConstructionException("null returned by new"); 111 } 112 113 this(cast(GtkStack*) p); 114 } 115 116 /** 117 * Adds a child to @stack. 118 * The child is identified by the @name. 119 * 120 * Params: 121 * child = the widget to add 122 * name = the name for @child 123 * 124 * Since: 3.10 125 */ 126 public void addNamed(Widget child, string name) 127 { 128 gtk_stack_add_named(gtkStack, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(name)); 129 } 130 131 /** 132 * Adds a child to @stack. 133 * The child is identified by the @name. The @title 134 * will be used by #GtkStackSwitcher to represent 135 * @child in a tab bar, so it should be short. 136 * 137 * Params: 138 * child = the widget to add 139 * name = the name for @child 140 * title = a human-readable title for @child 141 * 142 * Since: 3.10 143 */ 144 public void addTitled(Widget child, string name, string title) 145 { 146 gtk_stack_add_titled(gtkStack, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(name), Str.toStringz(title)); 147 } 148 149 /** 150 * Finds the child of the #GtkStack with the name given as 151 * the argument. Returns %NULL if there is no child with this 152 * name. 153 * 154 * Params: 155 * name = the name of the child to find 156 * 157 * Returns: the requested child of the #GtkStack 158 * 159 * Since: 3.12 160 */ 161 public Widget getChildByName(string name) 162 { 163 auto p = gtk_stack_get_child_by_name(gtkStack, Str.toStringz(name)); 164 165 if(p is null) 166 { 167 return null; 168 } 169 170 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 171 } 172 173 /** 174 * Gets whether @stack is horizontally homogeneous. 175 * See gtk_stack_set_hhomogeneous(). 176 * 177 * Returns: whether @stack is horizontally homogeneous. 178 * 179 * Since: 3.16 180 */ 181 public bool getHhomogeneous() 182 { 183 return gtk_stack_get_hhomogeneous(gtkStack) != 0; 184 } 185 186 /** 187 * Gets whether @stack is homogeneous. 188 * See gtk_stack_set_homogeneous(). 189 * 190 * Returns: whether @stack is homogeneous. 191 * 192 * Since: 3.10 193 */ 194 public bool getHomogeneous() 195 { 196 return gtk_stack_get_homogeneous(gtkStack) != 0; 197 } 198 199 /** 200 * Returns wether the #GtkStack is set up to interpolate between 201 * the sizes of children on page switch. 202 * 203 * Returns: %TRUE if child sizes are interpolated 204 * 205 * Since: 3.18 206 */ 207 public bool getInterpolateSize() 208 { 209 return gtk_stack_get_interpolate_size(gtkStack) != 0; 210 } 211 212 /** 213 * Returns the amount of time (in milliseconds) that 214 * transitions between pages in @stack will take. 215 * 216 * Returns: the transition duration 217 * 218 * Since: 3.10 219 */ 220 public uint getTransitionDuration() 221 { 222 return gtk_stack_get_transition_duration(gtkStack); 223 } 224 225 /** 226 * Returns whether the @stack is currently in a transition from one page to 227 * another. 228 * 229 * Returns: %TRUE if the transition is currently running, %FALSE otherwise. 230 * 231 * Since: 3.12 232 */ 233 public bool getTransitionRunning() 234 { 235 return gtk_stack_get_transition_running(gtkStack) != 0; 236 } 237 238 /** 239 * Gets the type of animation that will be used 240 * for transitions between pages in @stack. 241 * 242 * Returns: the current transition type of @stack 243 * 244 * Since: 3.10 245 */ 246 public GtkStackTransitionType getTransitionType() 247 { 248 return gtk_stack_get_transition_type(gtkStack); 249 } 250 251 /** 252 * Gets whether @stack is vertically homogeneous. 253 * See gtk_stack_set_vhomogeneous(). 254 * 255 * Returns: whether @stack is vertically homogeneous. 256 * 257 * Since: 3.16 258 */ 259 public bool getVhomogeneous() 260 { 261 return gtk_stack_get_vhomogeneous(gtkStack) != 0; 262 } 263 264 /** 265 * Gets the currently visible child of @stack, or %NULL if 266 * there are no visible children. 267 * 268 * Returns: the visible child of the #GtkStack 269 * 270 * Since: 3.10 271 */ 272 public Widget getVisibleChild() 273 { 274 auto p = gtk_stack_get_visible_child(gtkStack); 275 276 if(p is null) 277 { 278 return null; 279 } 280 281 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 282 } 283 284 /** 285 * Returns the name of the currently visible child of @stack, or 286 * %NULL if there is no visible child. 287 * 288 * Returns: the name of the visible child of the #GtkStack 289 * 290 * Since: 3.10 291 */ 292 public string getVisibleChildName() 293 { 294 return Str.toString(gtk_stack_get_visible_child_name(gtkStack)); 295 } 296 297 /** 298 * Sets the #GtkStack to be horizontally homogeneous or not. 299 * If it is homogeneous, the #GtkStack will request the same 300 * width for all its children. If it isn't, the stack 301 * may change width when a different child becomes visible. 302 * 303 * Params: 304 * hhomogeneous = %TRUE to make @stack horizontally homogeneous 305 * 306 * Since: 3.16 307 */ 308 public void setHhomogeneous(bool hhomogeneous) 309 { 310 gtk_stack_set_hhomogeneous(gtkStack, hhomogeneous); 311 } 312 313 /** 314 * Sets the #GtkStack to be homogeneous or not. If it 315 * is homogeneous, the #GtkStack will request the same 316 * size for all its children. If it isn't, the stack 317 * may change size when a different child becomes visible. 318 * 319 * Since 3.16, homogeneity can be controlled separately 320 * for horizontal and vertical size, with the 321 * #GtkStack:hhomogeneous and #GtkStack:vhomogeneous. 322 * 323 * Params: 324 * homogeneous = %TRUE to make @stack homogeneous 325 * 326 * Since: 3.10 327 */ 328 public void setHomogeneous(bool homogeneous) 329 { 330 gtk_stack_set_homogeneous(gtkStack, homogeneous); 331 } 332 333 /** 334 * Sets whether or not @stack will interpolate its size when 335 * changing the visible child. If the #GtkStack:interpolate-size 336 * property is set to %TRUE, @stack will interpolate its size between 337 * the current one and the one it'll take after changing the 338 * visible child, according to the set transition duration. 339 * 340 * Params: 341 * interpolateSize = the new value 342 * 343 * Since: 3.18 344 */ 345 public void setInterpolateSize(bool interpolateSize) 346 { 347 gtk_stack_set_interpolate_size(gtkStack, interpolateSize); 348 } 349 350 /** 351 * Sets the duration that transitions between pages in @stack 352 * will take. 353 * 354 * Params: 355 * duration = the new duration, in milliseconds 356 * 357 * Since: 3.10 358 */ 359 public void setTransitionDuration(uint duration) 360 { 361 gtk_stack_set_transition_duration(gtkStack, duration); 362 } 363 364 /** 365 * Sets the type of animation that will be used for 366 * transitions between pages in @stack. Available 367 * types include various kinds of fades and slides. 368 * 369 * The transition type can be changed without problems 370 * at runtime, so it is possible to change the animation 371 * based on the page that is about to become current. 372 * 373 * Params: 374 * transition = the new transition type 375 * 376 * Since: 3.10 377 */ 378 public void setTransitionType(GtkStackTransitionType transition) 379 { 380 gtk_stack_set_transition_type(gtkStack, transition); 381 } 382 383 /** 384 * Sets the #GtkStack to be vertically homogeneous or not. 385 * If it is homogeneous, the #GtkStack will request the same 386 * height for all its children. If it isn't, the stack 387 * may change height when a different child becomes visible. 388 * 389 * Params: 390 * vhomogeneous = %TRUE to make @stack vertically homogeneous 391 * 392 * Since: 3.16 393 */ 394 public void setVhomogeneous(bool vhomogeneous) 395 { 396 gtk_stack_set_vhomogeneous(gtkStack, vhomogeneous); 397 } 398 399 /** 400 * Makes @child the visible child of @stack. 401 * 402 * If @child is different from the currently 403 * visible child, the transition between the 404 * two will be animated with the current 405 * transition type of @stack. 406 * 407 * Note that the @child widget has to be visible itself 408 * (see gtk_widget_show()) in order to become the visible 409 * child of @stack. 410 * 411 * Params: 412 * child = a child of @stack 413 * 414 * Since: 3.10 415 */ 416 public void setVisibleChild(Widget child) 417 { 418 gtk_stack_set_visible_child(gtkStack, (child is null) ? null : child.getWidgetStruct()); 419 } 420 421 /** 422 * Makes the child with the given name visible. 423 * 424 * Note that the child widget has to be visible itself 425 * (see gtk_widget_show()) in order to become the visible 426 * child of @stack. 427 * 428 * Params: 429 * name = the name of the child to make visible 430 * transition = the transition type to use 431 * 432 * Since: 3.10 433 */ 434 public void setVisibleChildFull(string name, GtkStackTransitionType transition) 435 { 436 gtk_stack_set_visible_child_full(gtkStack, Str.toStringz(name), transition); 437 } 438 439 /** 440 * Makes the child with the given name visible. 441 * 442 * If @child is different from the currently 443 * visible child, the transition between the 444 * two will be animated with the current 445 * transition type of @stack. 446 * 447 * Note that the child widget has to be visible itself 448 * (see gtk_widget_show()) in order to become the visible 449 * child of @stack. 450 * 451 * Params: 452 * name = the name of the child to make visible 453 * 454 * Since: 3.10 455 */ 456 public void setVisibleChildName(string name) 457 { 458 gtk_stack_set_visible_child_name(gtkStack, Str.toStringz(name)); 459 } 460 }