The Battle for Wesnoth  1.15.0+dev
vertical_scrollbar.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 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 
19 namespace gui2
20 {
21 namespace implementation
22 {
23 struct builder_vertical_scrollbar;
24 }
25 
26 // ------------ WIDGET -----------{
27 
28 /** A vertical scrollbar. */
30 {
32 
33 public:
35 
36 private:
37  /** Inherited from scrollbar_base. */
38  virtual unsigned get_length() const override
39  {
40  return get_height();
41  }
42 
43  /** Inherited from scrollbar_base. */
44  virtual unsigned minimum_positioner_length() const override;
45 
46  /** Inherited from scrollbar_base. */
47  virtual unsigned maximum_positioner_length() const override;
48 
49  /** Inherited from scrollbar_base. */
50  virtual unsigned offset_before() const override;
51 
52  /** Inherited from scrollbar_base. */
53  virtual unsigned offset_after() const override;
54 
55  /** Inherited from scrollbar_base. */
56  virtual bool on_positioner(const point& coordinate) const override;
57 
58  /** Inherited from scrollbar_base. */
59  virtual int on_bar(const point& coordinate) const override;
60 
61  /** Inherited from scrollbar_base. */
62  virtual bool in_orthogonal_range(const point& coordinate) const override;
63 
64  /** Inherited from scrollbar_base. */
65  virtual int get_length_difference(const point& original, const point& current) const override
66  {
67  return current.y - original.y;
68  }
69 
70 public:
71  /** Static type getter that does not rely on the widget being constructed. */
72  static const std::string& type();
73 
74 private:
75  /** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
76  virtual const std::string& get_control_type() const override;
77 };
78 
79 // }---------- DEFINITION ---------{
80 
82 {
83  explicit vertical_scrollbar_definition(const config& cfg);
84 
86  {
87  explicit resolution(const config& cfg);
88 
91 
92  unsigned top_offset;
93  unsigned bottom_offset;
94  };
95 };
96 
97 // }---------- BUILDER -----------{
98 
99 namespace implementation
100 {
101 
103 {
104  explicit builder_vertical_scrollbar(const config& cfg);
105 
107 
108  widget* build() const;
109 };
110 
111 } // namespace implementation
112 
113 // }------------ END --------------
114 
115 } // namespace gui2
Base class for a scroll bar.
Definition: scrollbar.hpp:40
Base class of a resolution, contains the common keys for a resolution.
virtual widget * build() const =0
virtual unsigned get_length() const override
Inherited from scrollbar_base.
Base class for all widgets.
Definition: widget.hpp:47
Generic file dialog.
Definition: field-fwd.hpp:22
window * build(const builder_window::window_resolution *definition)
Builds a window.
Holds a 2D point.
Definition: point.hpp:23
virtual int get_length_difference(const point &original, const point &current) const override
Inherited from scrollbar_base.
point resolution()
Definition: general.cpp:373
A vertical scrollbar.
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:92
int y
y coordinate.
Definition: point.hpp:47
Contains the implementation details for lexical_cast and shouldn&#39;t be used directly.