The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
horizontal_list.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 - 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 /**
16  * @file
17  * Placement helper for the horizontal list.
18  */
19 
20 #ifndef GUI_AUXILIARY_PLACER_HORIZONTAL_LIST_HPP_INCLUDED
21 #define GUI_AUXILIARY_PLACER_HORIZONTAL_LIST_HPP_INCLUDED
22 
23 #include "gui/core/placer.hpp"
24 
25 #include <vector>
26 
27 namespace gui2
28 {
29 
30 namespace implementation
31 {
32 
33 /**
34  * The placement class for a horizontal list.
35  *
36  * See @ref tplacer_ for more information.
37  */
39 {
40 
41 public:
42  /***** ***** Constructor, destructor, assignment. ***** *****/
43 
44  explicit tplacer_horizontal_list(const unsigned maximum_rows);
45 
46 
47  /***** ***** Inherited operations. ***** *****/
48 
49  virtual void initialise();
50 
51  virtual void add_item(const tpoint& size);
52 
53  virtual tpoint get_size() const;
54 
55  virtual tpoint get_origin(const unsigned index) const;
56 
57 
58  /***** ***** Members. ***** *****/
59 
60 private:
61  /**
62  * The maximum number of rows to use.
63  *
64  * This value is determined by the @p parallel_items parameter of
65  * @ref tplacer_::build).
66  */
67  unsigned maximum_rows_;
68 
69  /** Holds the heights of the rows. */
70  std::vector<int> rows_;
71 
72  /**
73  * Holds the column sizes
74  *
75  * The pair contains the following values:
76  * * first The origin of a column.
77  * * second The width of a column.
78  */
79  std::vector<std::pair<int, int> > columns_;
80 
81  /** The row to add an item to. */
82  unsigned row_;
83 
84  /** The column to add an item to. */
85  unsigned column_;
86 };
87 
88 } // namespace implementation
89 
90 } // namespace gui2
91 
92 #endif
Base class for the placement helper.
unsigned maximum_rows_
The maximum number of rows to use.
The placement class for a horizontal list.
std::vector< int > rows_
Holds the heights of the rows.
Base class for the placement helper.
Definition: placer.hpp:52
tplacer_horizontal_list(const unsigned maximum_rows)
unsigned column_
The column to add an item to.
A class inherited from ttext_box that displays its input as stars.
Definition: field-fwd.hpp:23
virtual tpoint get_size() const
Gets the required size of all items.
unsigned row_
The row to add an item to.
virtual tpoint get_origin(const unsigned index) const
Gets the origin for an item.
virtual void initialise()
Initialises the placer.
GLuint index
Definition: glew.h:1782
virtual void add_item(const tpoint &size)
Adds a item to be placed.
Holds a 2D point.
Definition: point.hpp:24
std::vector< std::pair< int, int > > columns_
Holds the column sizes.
GLsizeiptr size
Definition: glew.h:1649
Contains the implementation details for lexical_cast and shouldn't be used directly.