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 homogeneous. 170 * See gtk_stack_set_homogeneous(). 171 * 172 * Return: whether @stack is homogeneous. 173 * 174 * Since: 3.10 175 */ 176 public bool getHomogeneous() 177 { 178 return gtk_stack_get_homogeneous(gtkStack) != 0; 179 } 180 181 /** 182 * Returns the amount of time (in milliseconds) that 183 * transitions between pages in @stack will take. 184 * 185 * Return: the transition duration 186 * 187 * Since: 3.10 188 */ 189 public uint getTransitionDuration() 190 { 191 return gtk_stack_get_transition_duration(gtkStack); 192 } 193 194 /** 195 * Returns whether the @stack is currently in a transition from one page to 196 * another. 197 * 198 * Return: %TRUE if the transition is currently running, %FALSE otherwise. 199 * 200 * Since: 3.12 201 */ 202 public bool getTransitionRunning() 203 { 204 return gtk_stack_get_transition_running(gtkStack) != 0; 205 } 206 207 /** 208 * Gets the type of animation that will be used 209 * for transitions between pages in @stack. 210 * 211 * Return: the current transition type of @stack 212 * 213 * Since: 3.10 214 */ 215 public GtkStackTransitionType getTransitionType() 216 { 217 return gtk_stack_get_transition_type(gtkStack); 218 } 219 220 /** 221 * Gets the currently visible child of @stack, or %NULL if 222 * there are no visible children. 223 * 224 * Return: the visible child of the #GtkStack 225 * 226 * Since: 3.10 227 */ 228 public Widget getVisibleChild() 229 { 230 auto p = gtk_stack_get_visible_child(gtkStack); 231 232 if(p is null) 233 { 234 return null; 235 } 236 237 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 238 } 239 240 /** 241 * Returns the name of the currently visible child of @stack, or 242 * %NULL if there is no visible child. 243 * 244 * Return: the name of the visible child of the #GtkStack 245 * 246 * Since: 3.10 247 */ 248 public string getVisibleChildName() 249 { 250 return Str.toString(gtk_stack_get_visible_child_name(gtkStack)); 251 } 252 253 /** 254 * Sets the #GtkStack to be homogeneous or not. If it 255 * is homogeneous, the #GtkStack will request the same 256 * size for all its children. If it isn't, the stack 257 * may change size when a different child becomes visible. 258 * 259 * Params: 260 * homogeneous = %TRUE to make @stack homogeneous 261 * 262 * Since: 3.10 263 */ 264 public void setHomogeneous(bool homogeneous) 265 { 266 gtk_stack_set_homogeneous(gtkStack, homogeneous); 267 } 268 269 /** 270 * Sets the duration that transitions between pages in @stack 271 * will take. 272 * 273 * Params: 274 * duration = the new duration, in milliseconds 275 * 276 * Since: 3.10 277 */ 278 public void setTransitionDuration(uint duration) 279 { 280 gtk_stack_set_transition_duration(gtkStack, duration); 281 } 282 283 /** 284 * Sets the type of animation that will be used for 285 * transitions between pages in @stack. Available 286 * types include various kinds of fades and slides. 287 * 288 * The transition type can be changed without problems 289 * at runtime, so it is possible to change the animation 290 * based on the page that is about to become current. 291 * 292 * Params: 293 * transition = the new transition type 294 * 295 * Since: 3.10 296 */ 297 public void setTransitionType(GtkStackTransitionType transition) 298 { 299 gtk_stack_set_transition_type(gtkStack, transition); 300 } 301 302 /** 303 * Makes @child the visible child of @stack. 304 * 305 * If @child is different from the currently 306 * visible child, the transition between the 307 * two will be animated with the current 308 * transition type of @stack. 309 * 310 * Note that the @child widget has to be visible itself 311 * (see gtk_widget_show()) in order to become the visible 312 * child of @stack. 313 * 314 * Params: 315 * child = a child of @stack 316 * 317 * Since: 3.10 318 */ 319 public void setVisibleChild(Widget child) 320 { 321 gtk_stack_set_visible_child(gtkStack, (child is null) ? null : child.getWidgetStruct()); 322 } 323 324 /** 325 * Makes the child with the given name visible. 326 * 327 * Note that the child widget has to be visible itself 328 * (see gtk_widget_show()) in order to become the visible 329 * child of @stack. 330 * 331 * Params: 332 * name = the name of the child to make visible 333 * transition = the transition type to use 334 * 335 * Since: 3.10 336 */ 337 public void setVisibleChildFull(string name, GtkStackTransitionType transition) 338 { 339 gtk_stack_set_visible_child_full(gtkStack, Str.toStringz(name), transition); 340 } 341 342 /** 343 * Makes the child with the given name visible. 344 * 345 * If @child is different from the currently 346 * visible child, the transition between the 347 * two will be animated with the current 348 * transition type of @stack. 349 * 350 * Note that the child widget has to be visible itself 351 * (see gtk_widget_show()) in order to become the visible 352 * child of @stack. 353 * 354 * Params: 355 * name = the name of the child to make visible 356 * 357 * Since: 3.10 358 */ 359 public void setVisibleChildName(string name) 360 { 361 gtk_stack_set_visible_child_name(gtkStack, Str.toStringz(name)); 362 } 363 }