The Battle for Wesnoth  1.17.0-dev
walker_tree_node.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2021
3  by Mark de Wever <koraq@xs4all.nl>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
19 
21 
22 namespace gui2
23 {
24 
25 class tree_view_node;
26 
27 namespace iteration
28 {
29 
30 /** A walker for a @ref gui2::tree_view_node. */
31 class tree_node : public walker_base
32 {
33 public:
34  /**
35  * Constructor.
36  *
37  * @param node The tree view node which the walker is attached to.
38  * @param children The node's children.
39  */
41 
42  /** Inherited from @ref gui2::iteration::walker_base. */
43  virtual state_t next(const level level);
44 
45  /** Inherited from @ref gui2::iteration::walker_base. */
46  virtual bool at_end(const level level) const;
47 
48  /** Inherited from @ref gui2::iteration::walker_base. */
49  virtual gui2::widget* get(const level level);
50 
51 private:
52  /** The children of the node which the walker is attached to. */
54 
55  /**
56  * The node which the walker is attached to.
57  *
58  * This variable is used to track whether the
59  * gui2::iteration::walker_base::widget level has been visited.
60  */
62 
63  /**
64  * The iterator to the children of the node.
65  *
66  * This variable is used to track where the @ref
67  * gui2::iteration::walker_base::child level visiting is.
68  */
70 };
71 
72 } // namespace iteration
73 
74 } // namespace gui2
std::vector< std::shared_ptr< tree_view_node > > node_children_vector
virtual bool at_end(const level level) const
Inherited from gui2::iteration::walker_base.
level
The level to walk at.
Definition: walker.hpp:35
Base class for all widgets.
Definition: widget.hpp:49
tree_node(gui2::tree_view_node &node, tree_view_node::node_children_vector &children)
Constructor.
Generic file dialog.
Definition: field-fwd.hpp:23
gui2::widget * widget_
The node which the walker is attached to.
A walker for a gui2::tree_view_node.
state_t
The state of the walker.
Definition: walker.hpp:49
The walker abstract base class.
Definition: walker.hpp:27
virtual state_t next(const level level)
Inherited from gui2::iteration::walker_base.
tree_view_node::node_children_vector & children_
The children of the node which the walker is attached to.
std::string::const_iterator iterator
Definition: tokenizer.hpp:25
tree_view_node::node_children_vector::iterator itor_
The iterator to the children of the node.