The Battle for Wesnoth  1.13.10+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 - 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 horizontal 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 horizontal list.
34  *
35  * See @ref placer_base for more information.
36  */
38 {
39 
40 public:
41  /***** ***** Constructor, destructor, assignment. ***** *****/
42 
43  explicit placer_horizontal_list(const unsigned maximum_rows);
44 
45 
46  /***** ***** Inherited operations. ***** *****/
47 
48  virtual void initialize();
49 
50  virtual void add_item(const point& size);
51 
52  virtual point get_size() const;
53 
54  virtual point get_origin(const unsigned index) const;
55 
56 
57  /***** ***** Members. ***** *****/
58 
59 private:
60  /**
61  * The maximum number of rows to use.
62  *
63  * This value is determined by the @p parallel_items parameter of
64  * @ref placer_base::build).
65  */
66  unsigned maximum_rows_;
67 
68  /** Holds the heights of the rows. */
69  std::vector<int> rows_;
70 
71  /**
72  * Holds the column sizes
73  *
74  * The pair contains the following values:
75  * * first The origin of a column.
76  * * second The width of a column.
77  */
78  std::vector<std::pair<int, int> > columns_;
79 
80  /** The row to add an item to. */
81  unsigned row_;
82 
83  /** The column to add an item to. */
84  unsigned column_;
85 };
86 
87 } // namespace implementation
88 
89 } // namespace gui2
Base class for the placement helper.
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
unsigned column_
The column to add an item to.
virtual void initialize()
Initialises the placer.
virtual point get_size() const
Gets the required size of all items.
unsigned maximum_rows_
The maximum number of rows to use.
placer_horizontal_list(const unsigned maximum_rows)
virtual void add_item(const point &size)
Adds a item to be placed.
Generic file dialog.
Definition: field-fwd.hpp:22
std::vector< std::pair< int, int > > columns_
Holds the column sizes.
virtual point get_origin(const unsigned index) const
Gets the origin for an item.
size_t size(const utf8::string &str)
Length in characters of a UTF-8 string.
Definition: unicode.cpp:86
std::vector< int > rows_
Holds the heights of the rows.
The placement class for a horizontal list.
Holds a 2D point.
Definition: point.hpp:22
unsigned row_
The row to add an item to.
Contains the implementation details for lexical_cast and shouldn't be used directly.