1/*
2 * Copyright (C) 2013 The gtkmm Development Team
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18
19#include <gtkmm/container.h>
20#include <gtkmm/enums.h>
21
22_DEFS(gtkmm,gtk)
23_PINCLUDE(gtkmm/private/container_p.h)
24
25namespace Gtk
26{
27_CC_INCLUDE(gtk/gtk.h)
28
29/** A container that shows only one child at a time.
30 *
31 * Gtk::Stack does not provide a means for users to change the visible
32 * child. Instead, the Gtk::StackSwitcher or Gtk::StackSidebar widget can be used with
33 * Gtk::Stack to provide this functionality.
34 *
35 * @ingroup Widgets
36 * @ingroup Containers
37 * @newin{3,10}
38 */
39class Stack
40  : public Container
41{
42  _CLASS_GTKOBJECT(Stack,GtkStack,GTK_STACK,Gtk::Container,GtkContainer)
43public:
44  _CTOR_DEFAULT
45
46  _WRAP_METHOD(void add(Widget& child, const Glib::ustring& name), gtk_stack_add_named)
47
48  _WRAP_METHOD(void add(Widget& child, const Glib::ustring& name, const Glib::ustring& title), gtk_stack_add_titled)
49
50  //TODO: Remove this method overload when we can break ABI and API, and Container::add()
51  //has been made non-virtual. It's not very useful in Stack. It's needed only to
52  //avoid a compilation error when compiling with -Woverloaded-virtual -Werror.
53  //See https://bugzilla.gnome.org/show_bug.cgi?id=724732
54  /** Adds a child.
55   *
56   * @newin{3,14}
57   *
58   * @deprecated Use one of the other add() methods instead. This method was added only to avoid a compilation error.
59   */
60  void add(Widget& child) override;
61
62  _WRAP_METHOD(void set_visible_child(Widget& child), gtk_stack_set_visible_child)
63
64  _WRAP_METHOD(Widget* get_visible_child(), gtk_stack_get_visible_child)
65  _WRAP_METHOD(const Widget* get_visible_child() const, gtk_stack_get_visible_child, constversion)
66
67  _WRAP_METHOD(void set_visible_child(const Glib::ustring& name), gtk_stack_set_visible_child_name)
68  _WRAP_METHOD(void set_visible_child(const Glib::ustring& name, StackTransitionType transition), gtk_stack_set_visible_child_full)
69  _WRAP_METHOD(Glib::ustring get_visible_child_name() const, gtk_stack_get_visible_child_name)
70
71  _WRAP_METHOD(void set_homogeneous(bool homogeneous = true), gtk_stack_set_homogeneous)
72  _WRAP_METHOD(bool get_homogeneous() const, gtk_stack_get_homogeneous)
73
74  _WRAP_METHOD(void set_hhomogeneous(bool hhomogeneous = true), gtk_stack_set_hhomogeneous)
75  _WRAP_METHOD(bool get_hhomogeneous() const, gtk_stack_get_hhomogeneous)
76
77  _WRAP_METHOD(void set_vhomogeneous(bool vhomogeneous = true), gtk_stack_set_vhomogeneous)
78  _WRAP_METHOD(bool get_vhomogeneous() const, gtk_stack_get_vhomogeneous)
79
80  _WRAP_METHOD(void set_transition_duration(guint duration), gtk_stack_set_transition_duration)
81  _WRAP_METHOD(guint get_transition_duration() const, gtk_stack_get_transition_duration)
82
83  _WRAP_METHOD(void set_transition_type(StackTransitionType transition), gtk_stack_set_transition_type)
84  _WRAP_METHOD(StackTransitionType get_transition_type(), gtk_stack_get_transition_type, deprecated "Use the const method instead.")
85  _WRAP_METHOD(StackTransitionType get_transition_type() const, gtk_stack_get_transition_type)
86
87  _WRAP_METHOD(bool get_transition_running() const, gtk_stack_get_transition_running)
88
89  _WRAP_METHOD(Widget* get_child_by_name(const Glib::ustring& name), gtk_stack_get_child_by_name)
90  _WRAP_METHOD(const Widget* get_child_by_name(const Glib::ustring& name) const, gtk_stack_get_child_by_name, constversion)
91
92  _WRAP_METHOD(void set_interpolate_size(bool interpolate_size), gtk_stack_set_interpolate_size, newin "3,20")
93  _WRAP_METHOD(bool get_interpolate_size() const, gtk_stack_get_interpolate_size, newin "3,20")
94
95  _WRAP_PROPERTY("homogeneous", bool)
96  _WRAP_PROPERTY("hhomogeneous", bool)
97  _WRAP_PROPERTY("transition-duration", unsigned int)
98  _WRAP_PROPERTY("transition-running", bool)
99  _WRAP_PROPERTY("transition-type", StackTransitionType)
100  _WRAP_PROPERTY("vhomogeneous", bool)
101  _WRAP_PROPERTY("visible-child", Widget*)
102  _WRAP_PROPERTY("visible-child-name", Glib::ustring)
103  _WRAP_PROPERTY("interpolate-size", bool, newin "3,20")
104
105  _WRAP_CHILD_PROPERTY("name", Glib::ustring)
106  _WRAP_CHILD_PROPERTY("title", Glib::ustring)
107  _WRAP_CHILD_PROPERTY("icon-name", Glib::ustring)
108  _WRAP_CHILD_PROPERTY("position", int)
109  _WRAP_CHILD_PROPERTY("needs-attention", bool)
110
111  // There are no signals or vfuncs.
112};
113
114} //namespace Gtk
115