The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
vertical_list.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 - 2017 by Mark de Wever <koraq@xs4all.nl>
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 vertical list.
18  */
19 
20 #pragma once
21 
22 #include "gui/core/placer.hpp"
23 
24 #include <vector>
25 
26 namespace gui2
27 {
28 
29 namespace implementation
30 {
31 
32 /**
33  * The placement class for a vertical list.
34  *
35  * See @ref placer_base for more information.
36  */
38 {
39 public:
40  /***** ***** Constructor, destructor, assignment. ***** *****/
41 
42  explicit placer_vertical_list(const unsigned maximum_columns);
43 
44 
45  /***** ***** Inherited operations. ***** *****/
46 
47  virtual void initialize();
48 
49  virtual void add_item(const point& size);
50 
51  virtual point get_size() const;
52 
53  virtual point get_origin(const unsigned index) const;
54 
55 
56  /***** ***** Members. ***** *****/
57 
58 private:
59  /**
60  * The maximum number of columns to use.
61  *
62  * This value is determined by the @p parallel_items parameter of
63  * @ref placer_base::build).
64  */
65  unsigned maximum_columns_;
66 
67  /**
68  * Holds the row sizes
69  *
70  * The pair contains the following values:
71  * * first The origin of a row.
72  * * second The height of a row.
73  */
74  std::vector<std::pair<int, int> > rows_;
75 
76  /** Holds the widths of the columns. */
77  std::vector<int> columns_;
78 
79  /** The row to add an item to. */
80  unsigned row_;
81 
82  /** The column to add an item to. */
83  unsigned column_;
84 };
85 
86 } // namespace implementation
87 
88 } // namespace gui2
Base class for the placement helper.
unsigned column_
The column to add an item to.
Base class for the placement helper.
Definition: placer.hpp:50
size_t index(const utf8::string &str, const size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
Definition: unicode.cpp:71
virtual void initialize()
Initialises the placer.
The placement class for a vertical list.
Holds a 2D point.
Definition: point.hpp:23
std::vector< int > columns_
Holds the widths of the columns.
Generic file dialog.
Definition: text.hpp:37
size_t size(const utf8::string &str)
Length in characters of a UTF-8 string.
Definition: unicode.cpp:86
std::vector< std::pair< int, int > > rows_
Holds the row sizes.
virtual point get_size() const
Gets the required size of all items.
virtual point get_origin(const unsigned index) const
Gets the origin for an item.
placer_vertical_list(const unsigned maximum_columns)
unsigned maximum_columns_
The maximum number of columns to use.
unsigned row_
The row to add an item to.
virtual void add_item(const point &size)
Adds a item to be placed.
Contains the implementation details for lexical_cast and shouldn't be used directly.