The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
walker.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2016 by Mark de Wever <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #ifndef GUI_WIDGETS_AUXILIARY_ITERATOR_WALKER_HPP_INCLUDED
16 #define GUI_WIDGETS_AUXILIARY_ITERATOR_WALKER_HPP_INCLUDED
17 
18 namespace gui2
19 {
20 
21 class twidget;
22 
23 namespace iterator
24 {
25 
26 /** The walker abstract base class. */
27 class twalker_
28 {
29 public:
30  virtual ~twalker_()
31  {
32  }
33 
34  /** The level to walk at. */
35  enum tlevel {
36  /** Visit the widget itself. */
38  /** Visit its nested grid. */
39  ,
41  /** Visit the children of its nested grid. */
42  ,
44  };
45 
46  /**
47  * The state of the walker.
48  *
49  * The enum is used to return the state of @ref next.
50  */
51  enum tstate {
52  /**
53  * When calling next the following it has the following results.
54  *
55  * @pre at_end == false
56  *
57  * @post the next widget became the current one.
58  * @post at_end == false
59  */
61 
62  /**
63  * When calling next the following it has the following results.
64  *
65  * @pre at_end == false
66  *
67  * @post there is no longer a current widget.
68  * @post at_end == true
69  */
70  ,
72 
73  /**
74  * When calling next the following it has the following results.
75  *
76  * @pre at_end == true
77  *
78  * @post at_end == true
79  */
80  ,
82  };
83 
84  /**
85  * Make the next widget the current one.
86  *
87  * @param level Determines on which level the next one should
88  * be selected.
89  *
90  * @returns The status of the operation.
91  */
92  virtual tstate next(const tlevel level) = 0;
93 
94  /**
95  * Returns whether the current widget is valid.
96  *
97  * @param level Determines on which level the test should be
98  * executed.
99  *
100  *
101  * @returns Whether the current widget is valid.
102  */
103  virtual bool at_end(const tlevel level) const = 0;
104 
105  /**
106  * Returns a pointer to the current widget.
107  *
108  * @pre The following assertion holds:
109  * @code at_end(level) == false @endcode
110  *
111  * @param level Determines from which level should the
112  * current widget be returned.
113  *
114  * @returns Pointer to the current widget.
115  */
116  virtual gui2::twidget* get(const tlevel level) = 0;
117 };
118 
119 } // namespace iterator
120 
121 } // namespace gui2
122 
123 #endif
Visit the widget itself.
Definition: walker.hpp:37
virtual tstate next(const tlevel level)=0
Make the next widget the current one.
GLint level
Definition: glew.h:1220
tstate
The state of the walker.
Definition: walker.hpp:51
virtual bool at_end(const tlevel level) const =0
Returns whether the current widget is valid.
A class inherited from ttext_box that displays its input as stars.
Definition: field-fwd.hpp:23
When calling next the following it has the following results.
Definition: walker.hpp:60
When calling next the following it has the following results.
Definition: walker.hpp:71
tlevel
The level to walk at.
Definition: walker.hpp:35
Base class for all widgets.
Definition: widget.hpp:49
The walker abstract base class.
Definition: walker.hpp:27
std::string::const_iterator iterator
Definition: tokenizer.hpp:21
Visit the children of its nested grid.
Definition: walker.hpp:40