The Battle for Wesnoth  1.13.11+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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(surface& frame_buffer,
58  int x_offset,
59  int y_offset) override;
60 
61  /** See @ref widget::child_populate_dirty_list. */
62  virtual void
64  const std::vector<widget*>& call_stack) override;
65 
66  /** See @ref widget::request_reduce_width. */
67  virtual void request_reduce_width(const unsigned maximum_width) override;
68 
69  /** See @ref widget::find_at. */
70  virtual widget* find_at(const point& coordinate,
71  const bool must_be_active) override;
72 
73  /** See @ref widget::find_at. */
74  virtual const widget* find_at(const point& coordinate,
75  const bool must_be_active) const override;
76 
77  /** See @ref widget::find. */
78  widget* find(const std::string& id, const bool must_be_active) override;
79 
80  /** See @ref widget::find. */
81  const widget* find(const std::string& id,
82  const bool must_be_active) const override;
83 
84 private:
85  /** See @ref widget::calculate_best_size. */
86  virtual point calculate_best_size() const override;
87 
88 public:
89  /** See @ref widget::disable_click_dismiss. */
90  bool disable_click_dismiss() const override;
91 
92  /** See @ref widget::create_walker. */
93  virtual iteration::walker_base* create_walker() override;
94 
95 private:
97 
99 };
100 
101 // }---------- BUILDER -----------{
102 
103 namespace implementation
104 {
105 
107 {
108  explicit builder_viewport(const config& cfg);
109 
110  widget* build() const;
111 
112  widget* build(const replacements_map& replacements) const;
113 
115 };
116 
117 } // namespace implementation
118 
119 // }------------ END --------------
120 
121 } // namespace gui2
Contains the info needed to instantiate a widget.
std::vector< char_t > string
Helper to implement private functions without modifying the header.
Definition: viewport.cpp:38
Base class for all widgets.
Definition: widget.hpp:48
std::shared_ptr< builder_widget > builder_widget_ptr
virtual void request_reduce_width(const unsigned maximum_width) override
See widget::request_reduce_width.
Definition: viewport.cpp:145
Generic file dialog.
Definition: field-fwd.hpp:22
widget & widget_
Definition: viewport.hpp:96
std::map< std::string, std::shared_ptr< builder_widget > > replacements_map
The replacements type is used to define replacement types.
widget * find(const std::string &id, const bool must_be_active) override
See widget::find.
Definition: viewport.cpp:160
virtual void place(const point &origin, const point &size) override
See widget::place.
Definition: viewport.cpp:107
static viewport * build(const implementation::builder_viewport &builder, const builder_widget::replacements_map &replacements)
Definition: viewport.cpp:101
The walker abstract base class.
Definition: walker.hpp:26
virtual widget * find_at(const point &coordinate, const bool must_be_active) override
See widget::find_at.
Definition: viewport.cpp:149
virtual void impl_draw_children(surface &frame_buffer, int x_offset, int y_offset) override
See widget::impl_draw_children.
Definition: viewport.cpp:124
size_t size(const utf8::string &str)
Length in characters of a UTF-8 string.
Definition: unicode.cpp:86
virtual void child_populate_dirty_list(window &caller, const std::vector< widget * > &call_stack) override
See widget::child_populate_dirty_list.
Definition: viewport.cpp:138
virtual iteration::walker_base * create_walker() override
See widget::create_walker.
Definition: viewport.cpp:181
viewport(widget &widget)
Definition: viewport.cpp:80
Holds a 2D point.
Definition: point.hpp:23
bool grid()
Definition: general.cpp:507
virtual void layout_initialize(const bool full_initialization) override
See widget::layout_initialize.
Definition: viewport.cpp:114
bool disable_click_dismiss() const override
See widget::disable_click_dismiss.
Definition: viewport.cpp:176
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:93
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:62
static std::deque< std::string > call_stack
Definition: function.cpp:39
virtual point calculate_best_size() const override
See widget::calculate_best_size.
Definition: viewport.cpp:171
Contains the implementation details for lexical_cast and shouldn't be used directly.
bool owns_widget_
Definition: viewport.hpp:98