Boost.UI
User Interface Boost library
slider.hpp
Go to the documentation of this file.
1 // Copyright (c) 2017 Kolya Kosenko
2 
3 // Distributed under the Boost Software License, Version 1.0.
4 // See http://www.boost.org/LICENSE_1_0.txt
5 
7 
8 #ifndef BOOST_UI_SLIDER_HPP
9 #define BOOST_UI_SLIDER_HPP
10 
11 #include <boost/ui/config.hpp>
12 
13 #ifdef BOOST_HAS_PRAGMA_ONCE
14 #pragma once
15 #endif
16 
17 #include <boost/ui/widget.hpp>
18 
19 namespace boost {
20 namespace ui {
21 
25 
26 class BOOST_UI_DECL slider : public widget
27 {
28 public:
30  typedef int value_type;
31 
33  value_type value() const;
34 
36  value_type min() const;
37 
39  value_type max() const;
40 
42  BOOST_UI_DETAIL_HANDLER(slide, slider);
43 
45  BOOST_UI_DETAIL_HANDLER(slide_end, slider);
46 
47 protected:
48  slider() {}
49 
50 #ifndef DOXYGEN
51  void detail_create(widget& parent, bool horizontal, value_type initial,
52  value_type min, value_type max);
53 #endif
54 
55 private:
56  void check_range(value_type value) const
57  { check_range(value, min(), max()); }
58  static void check_range(value_type value, value_type min, value_type max);
59 
60  void on_slide_raw(const boost::function<void()>& handler);
61  void on_slide_end_raw(const boost::function<void()>& handler);
62 
63  class detail_impl;
64  detail_impl* get_impl();
65  const detail_impl* get_impl() const;
66 };
67 
70 
71 class BOOST_UI_DECL hslider : public slider
72 {
73 public:
74  hslider() {}
75 
78  explicit hslider(widget& parent, value_type initial,
79  value_type min, value_type max)
80  { create(parent, initial, min, max); }
81  explicit hslider(widget& parent, value_type initial = 0)
82  { create(parent, initial); }
83  hslider& create(widget& parent, value_type initial,
84  value_type min, value_type max)
85  { detail_create(parent, true, initial, min, max); return *this; }
86  hslider& create(widget& parent, value_type initial = 0)
87  { return create(parent, initial, 0, 100); }
89 };
90 
93 
94 class BOOST_UI_DECL vslider : public slider
95 {
96 public:
97  vslider() {}
98 
101  explicit vslider(widget& parent, value_type initial,
102  value_type min, value_type max)
103  { create(parent, initial, min, max); }
104  explicit vslider(widget& parent, value_type initial = 0)
105  { create(parent, initial); }
106  vslider& create(widget& parent, value_type initial,
107  value_type min, value_type max)
108  { detail_create(parent, false, initial, min, max); return *this; }
109  vslider& create(widget& parent, value_type initial = 0)
110  { return create(parent, initial, 0, 100); }
112 };
113 
114 } // namespace ui
115 } // namespace boost
116 
117 #endif // BOOST_UI_SLIDER_HPP
boost::ui::vslider::create
vslider & create(widget &parent, value_type initial, value_type min, value_type max)
Creates vertical slider.
Definition: slider.hpp:106
boost::ui::vslider::vslider
vslider(widget &parent, value_type initial, value_type min, value_type max)
Creates vertical slider.
Definition: slider.hpp:101
config.hpp
Configuration options.
boost::ui::hslider
Horizontal slider widget.
Definition: slider.hpp:71
boost::ui::hslider::create
hslider & create(widget &parent, value_type initial=0)
Creates horizontal slider.
Definition: slider.hpp:86
widget.hpp
Widget class.
boost
Boost C++ libraries namespace.
Definition: window.hpp:19
boost::ui::vslider
Vertical slider widget.
Definition: slider.hpp:94
boost::ui::slider
Slider widget base class.
Definition: slider.hpp:26
boost::ui::slider::value_type
int value_type
Slider value type.
Definition: slider.hpp:30
boost::ui::hslider::create
hslider & create(widget &parent, value_type initial, value_type min, value_type max)
Creates horizontal slider.
Definition: slider.hpp:83
boost::ui::vslider::create
vslider & create(widget &parent, value_type initial=0)
Creates vertical slider.
Definition: slider.hpp:109
boost::ui::vslider::vslider
vslider(widget &parent, value_type initial=0)
Creates vertical slider.
Definition: slider.hpp:104
boost::ui::hslider::hslider
hslider(widget &parent, value_type initial, value_type min, value_type max)
Creates horizontal slider.
Definition: slider.hpp:78
boost::ui::widget
Base class for all widgets.
Definition: widget.hpp:45
boost::ui::hslider::hslider
hslider(widget &parent, value_type initial=0)
Creates horizontal slider.
Definition: slider.hpp:81