The Battle for Wesnoth  1.15.2+dev
horizontal_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 
21 
22 namespace gui2
23 {
24 namespace implementation
25 {
26 struct builder_horizontal_scrollbar;
27 }
28 
29 // ------------ WIDGET -----------{
30 
31 /** A horizontal scrollbar. */
33 {
35 
36 public:
38 
39 private:
40  /** Inherited from scrollbar_base. */
41  virtual unsigned get_length() const override
42  {
43  return get_width();
44  }
45 
46  /** Inherited from scrollbar_base. */
47  virtual unsigned minimum_positioner_length() const override;
48 
49  /** Inherited from scrollbar_base. */
50  virtual unsigned maximum_positioner_length() const override;
51 
52  /** Inherited from scrollbar_base. */
53  virtual unsigned offset_before() const override;
54 
55  /** Inherited from scrollbar_base. */
56  virtual unsigned offset_after() const override;
57 
58  /** Inherited from scrollbar_base. */
59  virtual bool on_positioner(const point& coordinate) const override;
60 
61  /** Inherited from scrollbar_base. */
62  virtual int on_bar(const point& coordinate) const override;
63 
64  /** Inherited from scrollbar_base. */
65  virtual bool in_orthogonal_range(const point& coordinate) const override;
66 
67  /** Inherited from scrollbar_base. */
68  virtual int get_length_difference(const point& original, const point& current) const override
69  {
70  return current.x - original.x;
71  }
72 
73 public:
74  /** Static type getter that does not rely on the widget being constructed. */
75  static const std::string& type();
76 
77 private:
78  /** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
79  virtual const std::string& get_control_type() const override;
80 };
81 
82 // }---------- DEFINITION ---------{
83 
85 {
86  explicit horizontal_scrollbar_definition(const config& cfg);
87 
89  {
90  explicit resolution(const config& cfg);
91 
94 
95  unsigned left_offset;
96  unsigned right_offset;
97  };
98 };
99 
100 // }---------- BUILDER -----------{
101 
102 namespace implementation
103 {
104 
106 {
107  explicit builder_horizontal_scrollbar(const config& cfg);
108 
110 
111  widget* build() const;
112 };
113 
114 } // namespace implementation
115 
116 // }------------ END --------------
117 
118 } // 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
A horizontal scrollbar.
Base class for all widgets.
Definition: widget.hpp:47
int x
x coordinate.
Definition: point.hpp:44
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.
virtual unsigned get_length() const override
Inherited from scrollbar_base.
point resolution()
Definition: general.cpp:373
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.