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