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 https://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:
38  const builder_widget::replacements_map& replacements);
39 
40  ~viewport();
41 
42  /** See @ref widget::place. */
43  virtual void place(const point& origin, const point& size) override;
44 
45  /** See @ref widget::layout_initialize. */
46  virtual void layout_initialize(const bool full_initialization) override;
47 
48  /** See @ref widget::impl_draw_children. */
49  virtual void impl_draw_children() override;
50 
51  /** See @ref widget::request_reduce_width. */
52  virtual void request_reduce_width(const unsigned maximum_width) override;
53 
54  /** See @ref widget::find_at. */
55  virtual widget* find_at(const point& coordinate,
56  const bool must_be_active) override;
57 
58  /** See @ref widget::find_at. */
59  virtual const widget* find_at(const point& coordinate,
60  const bool must_be_active) const override;
61 
62  /** See @ref widget::find. */
63  widget* find(const std::string& id, const bool must_be_active) override;
64 
65  /** See @ref widget::find. */
66  const widget* find(const std::string& id,
67  const bool must_be_active) const override;
68 
69 private:
70  /** See @ref widget::calculate_best_size. */
71  virtual point calculate_best_size() const override;
72 
73 public:
74  /** See @ref widget::disable_click_dismiss. */
75  bool disable_click_dismiss() const override;
76 
77  /** See @ref widget::create_walker. */
78  virtual iteration::walker_ptr create_walker() override;
79 
80 private:
82 };
83 
84 // }---------- BUILDER -----------{
85 
86 namespace implementation
87 {
88 
90 {
91  explicit builder_viewport(const config& cfg);
92 
93  virtual widget_ptr build() const override;
94 
95  virtual widget_ptr build(const replacements_map& replacements) const override;
96 
98 };
99 
100 } // namespace implementation
101 
102 // }------------ END --------------
103 
104 } // namespace gui2
Contains the info needed to instantiate a widget.
std::unique_ptr< class walker_base > walker_ptr
Definition: widget.hpp:38
std::shared_ptr< builder_widget > builder_widget_ptr
Helper to implement private functions without modifying the header.
Definition: viewport.cpp:39
Base class for all widgets.
Definition: widget.hpp:48
widget_ptr widget_
Definition: viewport.hpp:81
std::map< std::string, std::shared_ptr< builder_widget > > replacements_map
The replacements type is used to define replacement types.
Generic file dialog.
Definition: field-fwd.hpp:22
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
Definition: unicode.cpp:86
std::shared_ptr< widget > widget_ptr
Definition: widget.hpp:732
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.