The Battle for Wesnoth  1.15.0-dev
viewport.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 - 2018 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 #pragma once
16 
18 #include "gui/widgets/widget.hpp"
19 
20 namespace gui2
21 {
22 
23 // ------------ WIDGET -----------{
24 
25 namespace implementation
26 {
27 struct builder_viewport;
28 } // namespace implementation
29 
30 class grid;
31 
32 class viewport : public widget
33 {
34  friend struct viewport_implementation;
35 
36 public:
37  /** @deprecated use the second overload. */
38  explicit viewport(widget& widget);
39 
40 private:
42  const builder_widget::replacements_map& replacements);
43 
44 public:
45  static viewport* build(const implementation::builder_viewport& builder,
46  const builder_widget::replacements_map& replacements);
47 
48  ~viewport();
49 
50  /** See @ref widget::place. */
51  virtual void place(const point& origin, const point& size) override;
52 
53  /** See @ref widget::layout_initialize. */
54  virtual void layout_initialize(const bool full_initialization) override;
55 
56  /** See @ref widget::impl_draw_children. */
57  virtual void impl_draw_children() override;
58 
59  /** See @ref widget::request_reduce_width. */
60  virtual void request_reduce_width(const unsigned maximum_width) override;
61 
62  /** See @ref widget::find_at. */
63  virtual widget* find_at(const point& coordinate,
64  const bool must_be_active) override;
65 
66  /** See @ref widget::find_at. */
67  virtual const widget* find_at(const point& coordinate,
68  const bool must_be_active) const override;
69 
70  /** See @ref widget::find. */
71  widget* find(const std::string& id, const bool must_be_active) override;
72 
73  /** See @ref widget::find. */
74  const widget* find(const std::string& id,
75  const bool must_be_active) const override;
76 
77 private:
78  /** See @ref widget::calculate_best_size. */
79  virtual point calculate_best_size() const override;
80 
81 public:
82  /** See @ref widget::disable_click_dismiss. */
83  bool disable_click_dismiss() const override;
84 
85  /** See @ref widget::create_walker. */
86  virtual iteration::walker_base* create_walker() override;
87 
88 private:
90 
92 };
93 
94 // }---------- BUILDER -----------{
95 
96 namespace implementation
97 {
98 
100 {
101  explicit builder_viewport(const config& cfg);
102 
103  widget* build() const;
104 
105  widget* build(const replacements_map& replacements) const;
106 
108 };
109 
110 } // namespace implementation
111 
112 // }------------ END --------------
113 
114 } // namespace gui2
Contains the info needed to instantiate a widget.
Helper to implement private functions without modifying the header.
Definition: viewport.cpp:38
Base class for all widgets.
Definition: widget.hpp:47
std::shared_ptr< builder_widget > builder_widget_ptr
Generic file dialog.
Definition: field-fwd.hpp:22
widget & widget_
Definition: viewport.hpp:89
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
Definition: unicode.cpp:86
std::map< std::string, std::shared_ptr< builder_widget > > replacements_map
The replacements type is used to define replacement types.
The walker abstract base class.
Definition: walker.hpp:26
Holds a 2D point.
Definition: point.hpp:23
bool grid()
Definition: general.cpp:507
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:68
Contains the implementation details for lexical_cast and shouldn&#39;t be used directly.
bool owns_widget_
Definition: viewport.hpp:91