The Battle for Wesnoth  1.19.0-dev
walker_grid.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2024
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 
20 #include "gui/widgets/grid.hpp"
21 
22 namespace gui2::iteration
23 {
24 
25 /** A walker for a @ref gui2::grid. */
26 class grid : public walker_base
27 {
28 public:
29  /**
30  * Constructor.
31  *
32  * @param grid The grid which the walker is attached to.
33  */
34  explicit grid(gui2::grid& grid);
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 grid which the walker is attached to. */
48 
49  /**
50  * The grid 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  * The iterator to the children of @ref grid_.
59  *
60  * This variable is used to track where the
61  * gui2::iteration::walker_base::child level visiting is.
62  */
64 };
65 
66 } // namespace gui2::iteration
Iterator for the child items.
Definition: grid.hpp:438
Base container class.
Definition: grid.hpp:32
A walker for a gui2::grid.
Definition: walker_grid.hpp:27
gui2::widget * widget_
The grid which the walker is attached to.
Definition: walker_grid.hpp:55
grid(gui2::grid &grid)
Constructor.
Definition: walker_grid.cpp:25
virtual gui2::widget * get(const level level)
Inherited from gui2::iteration::walker_base.
Definition: walker_grid.cpp:72
virtual bool at_end(const level level) const
Inherited from gui2::iteration::walker_base.
Definition: walker_grid.cpp:57
virtual state_t next(const level level)
Inherited from gui2::iteration::walker_base.
Definition: walker_grid.cpp:30
gui2::grid & grid_
The grid which the walker is attached to.
Definition: walker_grid.hpp:47
gui2::grid::iterator itor_
The iterator to the children of grid_.
Definition: walker_grid.hpp:63
The walker abstract base class.
Definition: walker.hpp:28
level
The level to walk at.
Definition: walker.hpp:35
state_t
The state of the walker.
Definition: walker.hpp:49
Base class for all widgets.
Definition: widget.hpp:53