The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
scrollbar.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 by David White <[email protected]>
3  2004 - 2015 by Guillaume Melquiond <[email protected]>
4  Part of the Battle for Wesnoth Project http://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 /** @file */
17 
18 #ifndef SCROLLBAR_HPP_INCLUDED
19 #define SCROLLBAR_HPP_INCLUDED
20 
21 #include "button.hpp"
22 
23 namespace gui {
24 
25 class scrollarea;
26 
27 /** Scrollbar */
28 class scrollbar : public widget
29 {
30 public:
31  /**
32  * Create a scrollbar.
33  * @todo FIXME: parameterlist ??
34  */
35  //- @param d the display object
36  //- @param pane the widget where wheel events take place
37  //- @param callback a callback interface for warning that the grip has been moved
39 
40  virtual void hide(bool value = true);
41 
42  /**
43  * Determine where the scrollbar is.
44  *
45  * @return the position.
46  * @retval returns 0 if the scrollbar is at the top,
47  * @retval returns (full_size - shown_size) if it is at the bottom.
48  */
49  unsigned get_position() const;
50 
51  unsigned get_max_position() const;
52 
53  /** Manually update the scrollbar. */
54  void set_position(unsigned pos);
55 
56  /** Ensure the viewport contains the position. */
57  void adjust_position(unsigned pos);
58 
59  /** Move the scrollbar. */
60  void move_position(int dep);
61 
62  /** Set the relative size of the grip. */
63  void set_shown_size(unsigned h);
64 
65  /** Set the relative size of the scrollbar. */
66  void set_full_size(unsigned h);
67 
68  /** Set scroll rate. */
69  void set_scroll_rate(unsigned r);
70 
71  /** Return true if the scrollbar has a valid size. */
72  bool is_valid_height(int height) const;
73 
74  /** Scrolls down one step */
75  void scroll_down();
76 
77  /** Scrolls up one step */
78  void scroll_up();
79 
80 protected:
82  virtual void update_location(SDL_Rect const &rect);
83  virtual void handle_event(const SDL_Event& event);
84  virtual void process_event();
85  virtual void draw_contents();
86 
87 private:
88  SDL_Rect grip_area() const;
89  SDL_Rect groove_area() const;
91 
93 
96 
98  // Relative data
101 
102 };
103 
104 } // end namespace gui
105 
106 #endif
Scrollbar.
Definition: scrollbar.hpp:28
std::vector< events::sdl_handler * > sdl_handler_vector
Definition: events.hpp:163
int pos
Definition: formula.cpp:800
virtual void handle_event(const SDL_Event &event)
Definition: scrollbar.cpp:322
Definition: video.hpp:58
button downarrow_
Definition: scrollbar.hpp:92
surface groove_scaled_
Definition: scrollbar.hpp:90
int minimum_grip_height_
Definition: scrollbar.hpp:97
unsigned int full_height_
Definition: scrollbar.hpp:99
CVideo & video() const
Definition: widget.hpp:83
General purpose widgets.
bool is_valid_height(int height) const
Return true if the scrollbar has a valid size.
Definition: scrollbar.cpp:179
virtual void process_event()
Definition: scrollbar.cpp:200
SDL_Rect groove_area() const
Definition: scrollbar.cpp:209
button uparrow_
Definition: scrollbar.hpp:92
void scroll_down()
Scrolls down one step.
Definition: scrollbar.cpp:190
SDL_Rect grip_area() const
Definition: scrollbar.cpp:223
GLsizei const GLfloat * value
Definition: glew.h:1817
virtual void hide(bool value=true)
Definition: scrollbar.cpp:100
void set_position(unsigned pos)
Manually update the scrollbar.
Definition: scrollbar.cpp:117
unsigned int grip_height_
Definition: scrollbar.hpp:99
virtual void update_location(SDL_Rect const &rect)
Definition: scrollbar.cpp:86
void adjust_position(unsigned pos)
Ensure the viewport contains the position.
Definition: scrollbar.cpp:129
virtual void draw_contents()
Definition: scrollbar.cpp:235
GLfloat GLfloat GLfloat GLfloat h
Definition: glew.h:5910
GLdouble GLdouble GLdouble r
Definition: glew.h:1374
virtual sdl_handler_vector handler_members()
Definition: scrollbar.cpp:78
void scroll_up()
Scrolls up one step.
Definition: scrollbar.cpp:195
GLint GLint GLint GLint GLint GLint GLsizei GLsizei height
Definition: glew.h:1220
unsigned get_max_position() const
Definition: scrollbar.cpp:112
void set_shown_size(unsigned h)
Set the relative size of the grip.
Definition: scrollbar.cpp:146
cl_event event
Definition: glew.h:3070
surface mid_scaled_
Definition: scrollbar.hpp:90
scrollbar(CVideo &video)
Create a scrollbar.
Definition: scrollbar.cpp:50
void set_full_size(unsigned h)
Set the relative size of the scrollbar.
Definition: scrollbar.cpp:160
void set_scroll_rate(unsigned r)
Set scroll rate.
Definition: scrollbar.cpp:174
unsigned int grip_position_
Definition: scrollbar.hpp:99
void move_position(int dep)
Move the scrollbar.
Definition: scrollbar.cpp:137
unsigned get_position() const
Determine where the scrollbar is.
Definition: scrollbar.cpp:107