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