The Battle for Wesnoth  1.15.11+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 /**
33  * @ingroup GUIWidgetWML
34  *
35  * A viewport is an special widget used to view only a part of the widget it 'holds'.
36  *
37  * List with the viewport specific variables:
38  * Key |Type |Default |Description
39  * ---------------|------------------------------------------------|---------|-----------
40  * grow_direction | @ref guivartype_grow_direction "grow_direction"|mandatory|The direction in which new items grow.
41  * parallel_items | @ref guivartype_unsigned "unsigned" |mandatory|The number of items that are growing in parallel.
42  * item_definition| @ref guivartype_section "section" |mandatory|The definition of a new item.
43  */
44 class viewport : public widget
45 {
46  friend struct viewport_implementation;
47 
48 private:
50  const builder_widget::replacements_map& replacements);
51 
52 public:
53  static viewport* build(const implementation::builder_viewport& builder,
54  const builder_widget::replacements_map& replacements);
55 
56  ~viewport();
57 
58  /** See @ref widget::place. */
59  virtual void place(const point& origin, const point& size) override;
60 
61  /** See @ref widget::layout_initialize. */
62  virtual void layout_initialize(const bool full_initialization) override;
63 
64  /** See @ref widget::impl_draw_children. */
65  virtual void impl_draw_children(surface& frame_buffer,
66  int x_offset,
67  int y_offset) override;
68 
69  /** See @ref widget::child_populate_dirty_list. */
70  virtual void
71  child_populate_dirty_list(window& caller,
72  const std::vector<widget*>& call_stack) override;
73 
74  /** See @ref widget::request_reduce_width. */
75  virtual void request_reduce_width(const unsigned maximum_width) override;
76 
77  /** See @ref widget::find_at. */
78  virtual widget* find_at(const point& coordinate,
79  const bool must_be_active) override;
80 
81  /** See @ref widget::find_at. */
82  virtual const widget* find_at(const point& coordinate,
83  const bool must_be_active) const override;
84 
85  /** See @ref widget::find. */
86  widget* find(const std::string& id, const bool must_be_active) override;
87 
88  /** See @ref widget::find. */
89  const widget* find(const std::string& id,
90  const bool must_be_active) const override;
91 
92 private:
93  /** See @ref widget::calculate_best_size. */
94  virtual point calculate_best_size() const override;
95 
96 public:
97  /** See @ref widget::disable_click_dismiss. */
98  bool disable_click_dismiss() const override;
99 
100  /** See @ref widget::create_walker. */
101  virtual iteration::walker_base* create_walker() override;
102 
103 private:
105 
107 };
108 
109 // }---------- BUILDER -----------{
110 
111 namespace implementation
112 {
113 
115 {
116  explicit builder_viewport(const config& cfg);
117 
118  virtual widget* build() const override;
119 
120  virtual widget* build(const replacements_map& replacements) const override;
121 
123 };
124 
125 } // namespace implementation
126 
127 // }------------ END --------------
128 
129 } // 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:49
std::shared_ptr< builder_widget > builder_widget_ptr
Generic file dialog.
Definition: field-fwd.hpp:22
widget & widget_
Definition: viewport.hpp:104
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
static thread_local std::deque< std::string > call_stack
For printing error messages when WFL parsing or evaluation fails, this contains the names of the WFL ...
Definition: function.cpp:46
A viewport is an special widget used to view only a part of the widget it &#39;holds&#39;.
Definition: viewport.hpp:44
Holds a 2D point.
Definition: point.hpp:23
bool grid()
Definition: general.cpp:519
std::unique_ptr< window > build(const builder_window::window_resolution &definition)
Builds a window.
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:59
base class of top level items, the only item which needs to store the final canvases to draw on...
Definition: window.hpp:64
Contains the implementation details for lexical_cast and shouldn&#39;t be used directly.