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.TreeExpander;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gtk.TreeListRow;
30 private import gtk.Widget;
31 private import gtk.c.functions;
32 public  import gtk.c.types;
33 
34 
35 /**
36  * `GtkTreeExpander` is a widget that provides an expander for a list.
37  * 
38  * It is typically placed as a bottommost child into a `GtkListView`
39  * to allow users to expand and collapse children in a list with a
40  * [class@Gtk.TreeListModel]. `GtkTreeExpander` provides the common UI
41  * elements, gestures and keybindings for this purpose.
42  * 
43  * On top of this, the "listitem.expand", "listitem.collapse" and
44  * "listitem.toggle-expand" actions are provided to allow adding custom
45  * UI for managing expanded state.
46  * 
47  * The `GtkTreeListModel` must be set to not be passthrough. Then it
48  * will provide [class@Gtk.TreeListRow] items which can be set via
49  * [method@Gtk.TreeExpander.set_list_row] on the expander.
50  * The expander will then watch that row item automatically.
51  * [method@Gtk.TreeExpander.set_child] sets the widget that displays
52  * the actual row contents.
53  * 
54  * # CSS nodes
55  * 
56  * ```
57  * treeexpander
58  * ├── [indent]*
59  * ├── [expander]
60  * ╰── <child>
61  * ```
62  * 
63  * `GtkTreeExpander` has zero or one CSS nodes with the name "expander" that
64  * should display the expander icon. The node will be `:checked` when it
65  * is expanded. If the node is not expandable, an "indent" node will be
66  * displayed instead.
67  * 
68  * For every level of depth, another "indent" node is prepended.
69  * 
70  * # Accessibility
71  * 
72  * `GtkTreeExpander` uses the %GTK_ACCESSIBLE_ROLE_GROUP role. The expander icon
73  * is represented as a %GTK_ACCESSIBLE_ROLE_BUTTON, labelled by the expander's
74  * child, and toggling it will change the %GTK_ACCESSIBLE_STATE_EXPANDED state.
75  */
76 public class TreeExpander : Widget
77 {
78 	/** the main Gtk struct */
79 	protected GtkTreeExpander* gtkTreeExpander;
80 
81 	/** Get the main Gtk struct */
82 	public GtkTreeExpander* getTreeExpanderStruct(bool transferOwnership = false)
83 	{
84 		if (transferOwnership)
85 			ownedRef = false;
86 		return gtkTreeExpander;
87 	}
88 
89 	/** the main Gtk struct as a void* */
90 	protected override void* getStruct()
91 	{
92 		return cast(void*)gtkTreeExpander;
93 	}
94 
95 	/**
96 	 * Sets our main struct and passes it to the parent class.
97 	 */
98 	public this (GtkTreeExpander* gtkTreeExpander, bool ownedRef = false)
99 	{
100 		this.gtkTreeExpander = gtkTreeExpander;
101 		super(cast(GtkWidget*)gtkTreeExpander, ownedRef);
102 	}
103 
104 
105 	/** */
106 	public static GType getType()
107 	{
108 		return gtk_tree_expander_get_type();
109 	}
110 
111 	/**
112 	 * Creates a new `GtkTreeExpander`
113 	 *
114 	 * Returns: a new `GtkTreeExpander`
115 	 *
116 	 * Throws: ConstructionException GTK+ fails to create the object.
117 	 */
118 	public this()
119 	{
120 		auto __p = gtk_tree_expander_new();
121 
122 		if(__p is null)
123 		{
124 			throw new ConstructionException("null returned by new");
125 		}
126 
127 		this(cast(GtkTreeExpander*) __p);
128 	}
129 
130 	/**
131 	 * Gets the child widget displayed by @self.
132 	 *
133 	 * Returns: The child displayed by @self
134 	 */
135 	public Widget getChild()
136 	{
137 		auto __p = gtk_tree_expander_get_child(gtkTreeExpander);
138 
139 		if(__p is null)
140 		{
141 			return null;
142 		}
143 
144 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p);
145 	}
146 
147 	/**
148 	 * Forwards the item set on the `GtkTreeListRow` that @self is managing.
149 	 *
150 	 * This call is essentially equivalent to calling:
151 	 *
152 	 * ```c
153 	 * gtk_tree_list_row_get_item (gtk_tree_expander_get_list_row (@self));
154 	 * ```
155 	 *
156 	 * Returns: The item of the row
157 	 */
158 	public ObjectG getItem()
159 	{
160 		auto __p = gtk_tree_expander_get_item(gtkTreeExpander);
161 
162 		if(__p is null)
163 		{
164 			return null;
165 		}
166 
167 		return ObjectG.getDObject!(ObjectG)(cast(GObject*) __p, true);
168 	}
169 
170 	/**
171 	 * Gets the list row managed by @self.
172 	 *
173 	 * Returns: The list row displayed by @self
174 	 */
175 	public TreeListRow getListRow()
176 	{
177 		auto __p = gtk_tree_expander_get_list_row(gtkTreeExpander);
178 
179 		if(__p is null)
180 		{
181 			return null;
182 		}
183 
184 		return ObjectG.getDObject!(TreeListRow)(cast(GtkTreeListRow*) __p);
185 	}
186 
187 	/**
188 	 * Sets the content widget to display.
189 	 *
190 	 * Params:
191 	 *     child = a `GtkWidget`, or %NULL
192 	 */
193 	public void setChild(Widget child)
194 	{
195 		gtk_tree_expander_set_child(gtkTreeExpander, (child is null) ? null : child.getWidgetStruct());
196 	}
197 
198 	/**
199 	 * Sets the tree list row that this expander should manage.
200 	 *
201 	 * Params:
202 	 *     listRow = a `GtkTreeListRow`, or %NULL
203 	 */
204 	public void setListRow(TreeListRow listRow)
205 	{
206 		gtk_tree_expander_set_list_row(gtkTreeExpander, (listRow is null) ? null : listRow.getTreeListRowStruct());
207 	}
208 }