The Battle for Wesnoth  1.17.6+dev
walker_container.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::container_base. */
26 class container : public walker_base
27 {
28 public:
29  /**
30  * Constructor.
31  *
32  * @param container The grid which the walker is attached to.
33  */
35 
36  /** Inherited from @ref gui2::iteration::walker_base. */
37  virtual state_t next(const level level);
38 
39  /** Inherited from @ref gui2::iteration::walker_base. */
40  virtual bool at_end(const level level) const;
41 
42  /** Inherited from @ref gui2::iteration::walker_base. */
43  virtual gui2::widget* get(const level level);
44 
45 private:
46  /** The container which the walker is attached to. */
48 
49  /**
50  * The widget which the walker is attached to.
51  *
52  * This variable is used to track whether the
53  * gui2::iteration::walker_base::widget level has been visited.
54  */
56 
57  /**
58  * Whether the grid has been yielded
59  *
60  * This variable is used to track whether the
61  * gui2::iteration::walker_base::internal level has been visited.
62  */
63  bool entered_grid = false, in_grid = false;
64 
65  /**
66  * The iterator to the children of @ref container_.
67  *
68  * This variable is used to track where the
69  * gui2::iteration::walker_base::child level visiting is.
70  */
72 };
73 
74 } // namespace gui2::iteration
level
The level to walk at.
Definition: walker.hpp:35
gui2::container_base & container_
The container which the walker is attached to.
gui2::grid::iterator itor_
The iterator to the children of container_.
Base class for all widgets.
Definition: widget.hpp:53
state_t
The state of the walker.
Definition: walker.hpp:49
The walker abstract base class.
Definition: walker.hpp:27
Iterator for the child items.
Definition: grid.hpp:437
virtual bool at_end(const level level) const
Inherited from gui2::iteration::walker_base.
gui2::widget * widget_
The widget which the walker is attached to.
virtual state_t next(const level level)
Inherited from gui2::iteration::walker_base.
A walker for a gui2::container_base.
bool entered_grid
Whether the grid has been yielded.
A generic container base class.
container(gui2::container_base &container)
Constructor.