The Battle for Wesnoth  1.19.7+dev
horizontal_scrollbar.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2024
3  by Mark de Wever <koraq@xs4all.nl>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
19 
21 
22 namespace gui2
23 {
24 namespace implementation
25 {
26 struct builder_horizontal_scrollbar;
27 }
28 
29 // ------------ WIDGET -----------{
30 
32 {
34 
35 public:
37 
38 private:
39  /** Inherited from scrollbar_base. */
40  virtual unsigned get_length() const override
41  {
42  return get_width();
43  }
44 
45  /** Inherited from scrollbar_base. */
46  virtual unsigned minimum_positioner_length() const override;
47 
48  /** Inherited from scrollbar_base. */
49  virtual unsigned maximum_positioner_length() const override;
50 
51  /** Inherited from scrollbar_base. */
52  virtual unsigned offset_before() const override;
53 
54  /** Inherited from scrollbar_base. */
55  virtual unsigned offset_after() const override;
56 
57  /** Inherited from scrollbar_base. */
58  virtual bool on_positioner(const point& coordinate) const override;
59 
60  /** Inherited from scrollbar_base. */
61  virtual int on_bar(const point& coordinate) const override;
62 
63  /** Inherited from scrollbar_base. */
64  virtual bool in_orthogonal_range(const point& coordinate) const override;
65 
66  /** Inherited from scrollbar_base. */
67  virtual int get_length_difference(const point& original, const point& current) const override
68  {
69  return current.x - original.x;
70  }
71 
72 public:
73  /** Static type getter that does not rely on the widget being constructed. */
74  static const std::string& type();
75 
76 private:
77  /** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
78  virtual const std::string& get_control_type() const override;
79 };
80 
81 // }---------- DEFINITION ---------{
82 
84 {
85  explicit horizontal_scrollbar_definition(const config& cfg);
86 
88  {
89  explicit resolution(const config& cfg);
90 
93 
94  unsigned left_offset;
95  unsigned right_offset;
96  };
97 };
98 
99 // }---------- BUILDER -----------{
100 
101 namespace implementation
102 {
103 
105 {
106  explicit builder_horizontal_scrollbar(const config& cfg);
107 
109 
110  virtual std::unique_ptr<widget> build() const override;
111 };
112 
113 } // namespace implementation
114 
115 // }------------ END --------------
116 
117 } // namespace gui2
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:172
virtual bool in_orthogonal_range(const point &coordinate) const override
Inherited from scrollbar_base.
virtual unsigned minimum_positioner_length() const override
Inherited from scrollbar_base.
virtual int on_bar(const point &coordinate) const override
Inherited from scrollbar_base.
virtual const std::string & get_control_type() const override
Inherited from styled_widget, implemented by REGISTER_WIDGET.
horizontal_scrollbar(const implementation::builder_horizontal_scrollbar &builder)
virtual unsigned offset_before() const override
Inherited from scrollbar_base.
virtual unsigned get_length() const override
Inherited from scrollbar_base.
static const std::string & type()
Static type getter that does not rely on the widget being constructed.
virtual bool on_positioner(const point &coordinate) const override
Inherited from scrollbar_base.
virtual unsigned maximum_positioner_length() const override
Inherited from scrollbar_base.
virtual unsigned offset_after() const override
Inherited from scrollbar_base.
virtual int get_length_difference(const point &original, const point &current) const override
Inherited from scrollbar_base.
Base class for a scroll bar.
Definition: scrollbar.hpp:39
unsigned get_width() const
Definition: widget.cpp:336
Generic file dialog.
Contains the implementation details for lexical_cast and shouldn't be used directly.
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
virtual std::unique_ptr< widget > build() const override
virtual std::unique_ptr< widget > build() const=0
Holds a 2D point.
Definition: point.hpp:25