2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit 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
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = glib-N-ary-Trees.html
53 private import glib
.glibtypes
;
55 private import lib
.glib
;
57 private import glib
.BBTree
;
61 * The GNode struct and its associated functions provide a N-ary tree data
62 * structure, where nodes in the tree can contain arbitrary data.
63 * To create a new tree use g_node_new().
64 * To insert a node into a tree use g_node_insert(), g_node_insert_before(),
65 * g_node_append() and g_node_prepend().
66 * To create a new node and insert it into a tree use g_node_insert_data(),
67 * g_node_insert_data_before(), g_node_append_data() and g_node_prepend_data().
68 * To reverse the children of a node use g_node_reverse_children().
69 * To find a node use g_node_get_root(), g_node_find(), g_node_find_child(),
70 * g_node_child_index(), g_node_child_position(),
71 * g_node_first_child(), g_node_last_child(),
72 * g_node_nth_child(), g_node_first_sibling(), g_node_prev_sibling(),
73 * g_node_next_sibling() or g_node_last_sibling().
74 * To get information about a node or tree use G_NODE_IS_LEAF(),
75 * G_NODE_IS_ROOT(), g_node_depth(), g_node_n_nodes(), g_node_n_children(),
76 * g_node_is_ancestor() or g_node_max_height().
77 * To traverse a tree, calling a function for each node visited in the
78 * traversal, use g_node_traverse() or g_node_children_foreach().
79 * To remove a node or subtree from a tree use g_node_unlink() or
85 /** the main Gtk struct */
86 protected GNode
* gNode
;
89 public GNode
* getNodeStruct()
95 /** the main Gtk struct as a void* */
96 protected void* getStruct()
98 return cast(void*)gNode
;
102 * Sets our main struct and passes it to the parent class
104 public this (GNode
* gNode
)
114 * Creates a new GNode containing the given data.
115 * Used to create the first node in a tree.
117 * the data of the new node.
121 public this (void* data
)
123 // GNode* g_node_new (gpointer data);
124 this(cast(GNode
*)g_node_new(data
) );
128 * Recursively copies a GNode (but does not deep-copy the data inside the nodes,
129 * see g_node_copy_deep() if you need that).
133 * a new GNode containing the same data pointers.
137 // GNode* g_node_copy (GNode *node);
138 return new Node( g_node_copy(gNode
) );
143 * Recursively copies a GNode and its data.
147 * the function which is called to copy the data inside each node,
148 * or NULL to use the original data.
150 * data to pass to copy_func
152 * a new GNode containing copies of the data in node.
155 public Node
copyDeep(GCopyFunc copyFunc
, void* data
)
157 // GNode* g_node_copy_deep (GNode *node, GCopyFunc copy_func, gpointer data);
158 return new Node( g_node_copy_deep(gNode
, copyFunc
, data
) );
162 * Inserts a GNode beneath the parent at the given position.
164 * the GNode to place node under.
166 * the position to place node at, with respect to its siblings.
167 * If position is -1, node is inserted as the last child of parent.
169 * the GNode to insert.
171 * the inserted GNode.
173 public Node
insert(int position
, Node node
)
175 // GNode* g_node_insert (GNode *parent, gint position, GNode *node);
176 return new Node( g_node_insert(gNode
, position
, (node
is null) ?
null : node
.getNodeStruct()) );
180 * Inserts a GNode beneath the parent before the given sibling.
182 * the GNode to place node under.
184 * the sibling GNode to place node before. If sibling is NULL,
185 * the node is inserted as the last child of parent.
187 * the GNode to insert.
189 * the inserted GNode.
191 public Node
insertBefore(Node sibling
, Node node
)
193 // GNode* g_node_insert_before (GNode *parent, GNode *sibling, GNode *node);
194 return new Node( g_node_insert_before(gNode
, (sibling
is null) ?
null : sibling
.getNodeStruct(), (node
is null) ?
null : node
.getNodeStruct()) );
198 * Inserts a GNode beneath the parent after the given sibling.
200 * the GNode to place node under.
202 * the sibling GNode to place node after. If sibling is NULL,
203 * the node is inserted as the first child of parent.
205 * the GNode to insert.
207 * the inserted GNode.
209 public Node
insertAfter(Node sibling
, Node node
)
211 // GNode* g_node_insert_after (GNode *parent, GNode *sibling, GNode *node);
212 return new Node( g_node_insert_after(gNode
, (sibling
is null) ?
null : sibling
.getNodeStruct(), (node
is null) ?
null : node
.getNodeStruct()) );
217 * Inserts a GNode as the first child of the given parent.
219 * the GNode to place the new GNode under.
221 * the GNode to insert.
223 * the inserted GNode.
225 public Node
prepend(Node node
)
227 // GNode* g_node_prepend (GNode *parent, GNode *node);
228 return new Node( g_node_prepend(gNode
, (node
is null) ?
null : node
.getNodeStruct()) );
236 * Reverses the order of the children of a GNode.
237 * (It doesn't change the order of the grandchildren.)
241 public void reverseChildren()
243 // void g_node_reverse_children (GNode *node);
244 g_node_reverse_children(gNode
);
248 * Traverses a tree starting at the given root GNode.
249 * It calls the given function for each node visited.
250 * The traversal can be halted at any point by returning TRUE from func.
252 * the root GNode of the tree to traverse.
254 * the order in which nodes are visited - G_IN_ORDER, G_PRE_ORDER,
255 * G_POST_ORDER, or G_LEVEL_ORDER.
257 * which types of children are to be visited, one of G_TRAVERSE_ALL,
258 * G_TRAVERSE_LEAVES and G_TRAVERSE_NON_LEAVES.
260 * the maximum depth of the traversal. Nodes below this
261 * depth will not be visited. If max_depth is -1 all nodes in the tree are
262 * visited. If depth is 1, only the root is visited. If depth is 2, the root
263 * and its children are visited. And so on.
265 * the function to call for each visited GNode.
267 * user data to pass to the function.
269 public void traverse(GTraverseType order
, GTraverseFlags flags
, int maxDepth
, GNodeTraverseFunc func
, void* data
)
271 // void g_node_traverse (GNode *root, GTraverseType order, GTraverseFlags flags, gint max_depth, GNodeTraverseFunc func, gpointer data);
272 g_node_traverse(gNode
, order
, flags
, maxDepth
, func
, data
);
278 * Calls a function for each of the children of a GNode.
279 * Note that it doesn't descend beneath the child nodes.
283 * which types of children are to be visited, one of G_TRAVERSE_ALL,
284 * G_TRAVERSE_LEAVES and G_TRAVERSE_NON_LEAVES.
286 * the function to call for each visited node.
288 * user data to pass to the function.
290 public void childrenForeach(GTraverseFlags flags
, GNodeForeachFunc func
, void* data
)
292 // void g_node_children_foreach (GNode *node, GTraverseFlags flags, GNodeForeachFunc func, gpointer data);
293 g_node_children_foreach(gNode
, flags
, func
, data
);
298 * Gets the root of a tree.
302 * the root of the tree.
304 public Node
getRoot()
306 // GNode* g_node_get_root (GNode *node);
307 return new Node( g_node_get_root(gNode
) );
311 * Finds a GNode in a tree.
313 * the root GNode of the tree to search.
315 * the order in which nodes are visited - G_IN_ORDER, G_PRE_ORDER,
316 * G_POST_ORDER, or G_LEVEL_ORDER.
318 * which types of children are to be searched, one of G_TRAVERSE_ALL,
319 * G_TRAVERSE_LEAVES and G_TRAVERSE_NON_LEAVES.
323 * the found GNode, or NULL if the data is not found.
325 public Node
find(GTraverseType order
, GTraverseFlags flags
, void* data
)
327 // GNode* g_node_find (GNode *root, GTraverseType order, GTraverseFlags flags, gpointer data);
328 return new Node( g_node_find(gNode
, order
, flags
, data
) );
332 * Finds the first child of a GNode with the given data.
336 * which types of children are to be searched, one of G_TRAVERSE_ALL,
337 * G_TRAVERSE_LEAVES and G_TRAVERSE_NON_LEAVES.
341 * the found child GNode, or NULL if the data is not found.
343 public Node
findChild(GTraverseFlags flags
, void* data
)
345 // GNode* g_node_find_child (GNode *node, GTraverseFlags flags, gpointer data);
346 return new Node( g_node_find_child(gNode
, flags
, data
) );
350 * Gets the position of the first child of a GNode which contains the given data.
356 * the index of the child of node which contains data, or -1
357 * if the data is not found.
359 public int childIndex(void* data
)
361 // gint g_node_child_index (GNode *node, gpointer data);
362 return g_node_child_index(gNode
, data
);
366 * Gets the position of a GNode with respect to its siblings.
367 * child must be a child of node.
368 * The first child is numbered 0, the second 1, and so on.
374 * the position of child with respect to its siblings.
376 public int childPosition(Node child
)
378 // gint g_node_child_position (GNode *node, GNode *child);
379 return g_node_child_position(gNode
, (child
is null) ?
null : child
.getNodeStruct());
384 * Gets the last child of a GNode.
386 * a GNode (must not be NULL).
388 * the last child of node, or NULL if node has no children.
390 public Node
lastChild()
392 // GNode* g_node_last_child (GNode *node);
393 return new Node( g_node_last_child(gNode
) );
397 * Gets a child of a GNode, using the given index.
398 * The first child is at index 0. If the index is too big, NULL is returned.
402 * the index of the desired child.
404 * the child of node at index n.
406 public Node
nthChild(uint n
)
408 // GNode* g_node_nth_child (GNode *node, guint n);
409 return new Node( g_node_nth_child(gNode
, n
) );
413 * Gets the first sibling of a GNode.
414 * This could possibly be the node itself.
418 * the first sibling of node.
420 public Node
firstSibling()
422 // GNode* g_node_first_sibling (GNode *node);
423 return new Node( g_node_first_sibling(gNode
) );
429 * Gets the last sibling of a GNode.
430 * This could possibly be the node itself.
434 * the last sibling of node.
436 public Node
lastSibling()
438 // GNode* g_node_last_sibling (GNode *node);
439 return new Node( g_node_last_sibling(gNode
) );
445 * Gets the depth of a GNode.
446 * If node is NULL the depth is 0.
447 * The root node has a depth of 1.
448 * For the children of the root node the depth is 2. And so on.
452 * the depth of the GNode.
456 // guint g_node_depth (GNode *node);
457 return g_node_depth(gNode
);
461 * Gets the number of nodes in a tree.
465 * which types of children are to be counted, one of G_TRAVERSE_ALL,
466 * G_TRAVERSE_LEAVES and G_TRAVERSE_NON_LEAVES.
468 * the number of nodes in the tree.
470 public uint nNodes(GTraverseFlags flags
)
472 // guint g_node_n_nodes (GNode *root, GTraverseFlags flags);
473 return g_node_n_nodes(gNode
, flags
);
477 * Gets the number of children of a GNode.
481 * the number of children of node.
483 public uint nChildren()
485 // guint g_node_n_children (GNode *node);
486 return g_node_n_children(gNode
);
490 * Returns TRUE if node is an ancestor of descendant.
491 * This is true if node is the parent of descendant, or if node is the
492 * grandparent of descendant etc.
498 * TRUE if node is an ancestor of descendant.
500 public int isAncestor(Node descendant
)
502 // gboolean g_node_is_ancestor (GNode *node, GNode *descendant);
503 return g_node_is_ancestor(gNode
, (descendant
is null) ?
null : descendant
.getNodeStruct());
507 * Gets the maximum height of all branches beneath a GNode.
508 * This is the maximum distance from the GNode to all leaf nodes.
509 * If root is NULL, 0 is returned. If root has no children, 1 is returned.
510 * If root has children, 2 is returned. And so on.
514 * the maximum height of the tree beneath root.
516 public uint maxHeight()
518 // guint g_node_max_height (GNode *root);
519 return g_node_max_height(gNode
);
523 * Unlinks a GNode from a tree, resulting in two separate trees.
525 * the GNode to unlink, which becomes the root of a new tree.
529 // void g_node_unlink (GNode *node);
530 g_node_unlink(gNode
);
534 * Removes the GNode and its children from the tree, freeing any memory
537 * the root of the tree/subtree to destroy.
539 public void destroy()
541 // void g_node_destroy (GNode *root);
542 g_node_destroy(gNode
);
547 * g_node_push_allocator has been deprecated since version 2.10 and should not be used in newly-written code. It does nothing, since GNode has been converted
548 * to the slice allocator
549 * Sets the allocator to use to allocate GNode elements.
550 * Use g_node_pop_allocator() to restore the previous allocator.
551 * Note that this function is not available if GLib has been compiled
552 * with --disable-mem-pools
554 * the GAllocator to use when allocating GNode elements.
556 public static void pushAllocator(void* dummy
)
558 // void g_node_push_allocator (gpointer dummy);
559 g_node_push_allocator(dummy
);
564 * g_node_pop_allocator has been deprecated since version 2.10 and should not be used in newly-written code. It does nothing, since GNode has been converted
565 * to the slice allocator
566 * Restores the previous GAllocator, used when allocating GNode elements.
567 * Note that this function is not available if GLib has been compiled
568 * with --disable-mem-pools
570 public static void popAllocator()
572 // void g_node_pop_allocator (void);
573 g_node_pop_allocator();