The Battle for Wesnoth  1.17.4+dev
walker_tree_node.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2022
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::iteration
23 {
24 
25 /** A walker for a @ref gui2::tree_view_node. */
26 class tree_node : public walker_base
27 {
28 public:
29  /**
30  * Constructor.
31  *
32  * @param node The tree view node which the walker is attached to.
33  * @param children The node's children.
34  */
36 
37  /** Inherited from @ref gui2::iteration::walker_base. */
38  virtual state_t next(const level level);
39 
40  /** Inherited from @ref gui2::iteration::walker_base. */
41  virtual bool at_end(const level level) const;
42 
43  /** Inherited from @ref gui2::iteration::walker_base. */
44  virtual gui2::widget* get(const level level);
45 
46 private:
47  /** The children of the node which the walker is attached to. */
49 
50  /**
51  * The node which the walker is attached to.
52  *
53  * This variable is used to track whether the
54  * gui2::iteration::walker_base::widget level has been visited.
55  */
57 
58  /**
59  * The iterator to the children of the node.
60  *
61  * This variable is used to track where the @ref
62  * gui2::iteration::walker_base::child level visiting is.
63  */
65 };
66 
67 } // namespace gui2::iteration
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.
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.