scrollbar.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2013 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 ** Harry Storbacka
28 ** Kenneth Gangstoe
29 */
30 
31 
32 #pragma once
33 
34 #include "../api_gui.h"
35 #include "../gui_component.h"
36 #include "../../Core/Signals/callback_v0.h"
37 
38 namespace clan
39 {
42 
43 class ScrollBar_Impl;
44 
46 class CL_API_GUI ScrollBar : public GUIComponent
47 {
50 public:
51 
55  ScrollBar(GUIComponent *parent);
56 
57  virtual ~ScrollBar();
58 
62 public:
64 
68  static ScrollBar *get_named_item(GUIComponent *reference_component, const std::string &id);
69 
73  bool is_vertical() const;
74 
78  bool is_horizontal() const;
79 
83  int get_min() const;
84 
88  int get_max() const;
89 
93  int get_line_step() const;
94 
98  int get_page_step() const;
99 
103  int get_position() const;
104 
108 public:
109 
111  void set_vertical();
112 
114  void set_horizontal();
115 
119  void set_min(int scroll_min);
120 
124  void set_max(int scroll_max);
125 
129  void set_line_step(int step);
130 
134  void set_page_step(int step);
135 
142  void set_ranges(int scroll_min, int scroll_max, int line_step, int page_step);
143 
145 
149  void calculate_ranges(int view_size, int total_size);
150 
154  void set_position(int pos);
155 
159  float get_preferred_content_width();
160 
164  float get_preferred_content_height(float width);
165 
169 public:
171  Callback_v0 &func_scroll();
172 
174  Callback_v0 &func_scroll_min();
175 
177  Callback_v0 &func_scroll_max();
178 
180  Callback_v0 &func_scroll_line_decrement();
181 
183  Callback_v0 &func_scroll_line_increment();
184 
186  Callback_v0 &func_scroll_page_decrement();
187 
189  Callback_v0 &func_scroll_page_increment();
190 
192  Callback_v0 &func_scroll_thumb_release();
193 
195  Callback_v0 &func_scroll_thumb_track();
196 
198  Callback_v0 &func_scroll_end();
199 
203 
204 private:
205  std::shared_ptr<ScrollBar_Impl> impl;
207 };
208 
209 }
210 
GUI base component class.
Definition: gui_component.h:80
GUIComponent * get_named_item(const std::string &id)
Find child component with the specified component ID name.
Scroll bar component.
Definition: scrollbar.h:46
int step(int edge, int x)
Definition: cl_math.h:156
Callback_v0.
Definition: callback_v0.h:152