The Battle for Wesnoth
1.19.5+dev
widgets
scrollbar.hpp
Go to the documentation of this file.
1
/*
2
Copyright (C) 2004 - 2024
3
by Guillaume Melquiond <guillaume.melquiond@gmail.com>
4
Copyright (C) 2003 by David White <dave@whitevine.net>
5
Part of the Battle for Wesnoth Project https://www.wesnoth.org/
6
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY.
13
14
See the COPYING file for more details.
15
*/
16
17
#pragma once
18
19
#include "
button.hpp
"
20
21
namespace
gui
{
22
23
24
/** Scrollbar */
25
class
scrollbar
:
public
widget
26
{
27
public
:
28
/**
29
* Create a scrollbar.
30
* @todo FIXME: parameterlist ??
31
*/
32
//- @param d the display object
33
//- @param pane the widget where wheel events take place
34
//- @param callback a callback interface for warning that the grip has been moved
35
scrollbar
();
36
37
/**
38
* Determine where the scrollbar is.
39
*
40
* @return the position.
41
* @retval returns 0 if the scrollbar is at the top or (full_size - shown_size) if it is at the bottom.
42
*/
43
unsigned
get_position
()
const
;
44
45
unsigned
get_max_position
()
const
;
46
47
/** Manually update the scrollbar. */
48
void
set_position
(
unsigned
pos);
49
50
/** Ensure the viewport contains the position. */
51
void
adjust_position
(
unsigned
pos);
52
53
/** Move the scrollbar. */
54
void
move_position
(
int
dep);
55
56
/** Set the relative size of the grip. */
57
void
set_shown_size
(
unsigned
h
);
58
59
/** Set the relative size of the scrollbar. */
60
void
set_full_size
(
unsigned
h
);
61
62
/** Set scroll rate. */
63
void
set_scroll_rate
(
unsigned
r);
64
65
/** Scrolls down one step */
66
void
scroll_down
();
67
68
/** Scrolls up one step */
69
void
scroll_up
();
70
71
protected
:
72
virtual
void
handle_event
(
const
SDL_Event& event);
73
virtual
void
draw_contents
();
74
75
private
:
76
SDL_Rect
grip_area
()
const
;
77
78
enum
STATE
{
UNINIT
,
NORMAL
,
ACTIVE
,
DRAGGED
};
79
STATE
state_
;
80
81
int
minimum_grip_height_
,
mousey_on_grip_
;
82
// Relative data
83
unsigned
int
grip_position_
,
grip_height_
,
full_height_
;
84
int
scroll_rate_
;
85
86
};
87
88
}
// end namespace gui
gui::scrollbar
Scrollbar.
Definition:
scrollbar.hpp:26
gui::scrollbar::grip_area
SDL_Rect grip_area() const
Definition:
scrollbar.cpp:144
gui::scrollbar::scrollbar
scrollbar()
Create a scrollbar.
Definition:
scrollbar.cpp:46
gui::scrollbar::set_shown_size
void set_shown_size(unsigned h)
Set the relative size of the grip.
Definition:
scrollbar.cpp:102
gui::scrollbar::draw_contents
virtual void draw_contents()
Definition:
scrollbar.cpp:156
gui::scrollbar::set_scroll_rate
void set_scroll_rate(unsigned r)
Set scroll rate.
Definition:
scrollbar.cpp:129
gui::scrollbar::state_
STATE state_
Definition:
scrollbar.hpp:79
gui::scrollbar::grip_position_
unsigned int grip_position_
Definition:
scrollbar.hpp:83
gui::scrollbar::scroll_up
void scroll_up()
Scrolls up one step.
Definition:
scrollbar.cpp:139
gui::scrollbar::move_position
void move_position(int dep)
Move the scrollbar.
Definition:
scrollbar.cpp:93
gui::scrollbar::minimum_grip_height_
int minimum_grip_height_
Definition:
scrollbar.hpp:81
gui::scrollbar::set_position
void set_position(unsigned pos)
Manually update the scrollbar.
Definition:
scrollbar.cpp:75
gui::scrollbar::scroll_rate_
int scroll_rate_
Definition:
scrollbar.hpp:84
gui::scrollbar::mousey_on_grip_
int mousey_on_grip_
Definition:
scrollbar.hpp:81
gui::scrollbar::scroll_down
void scroll_down()
Scrolls down one step.
Definition:
scrollbar.cpp:134
gui::scrollbar::set_full_size
void set_full_size(unsigned h)
Set the relative size of the scrollbar.
Definition:
scrollbar.cpp:116
gui::scrollbar::get_position
unsigned get_position() const
Determine where the scrollbar is.
Definition:
scrollbar.cpp:65
gui::scrollbar::STATE
STATE
Definition:
scrollbar.hpp:78
gui::scrollbar::UNINIT
@ UNINIT
Definition:
scrollbar.hpp:78
gui::scrollbar::NORMAL
@ NORMAL
Definition:
scrollbar.hpp:78
gui::scrollbar::DRAGGED
@ DRAGGED
Definition:
scrollbar.hpp:78
gui::scrollbar::ACTIVE
@ ACTIVE
Definition:
scrollbar.hpp:78
gui::scrollbar::full_height_
unsigned int full_height_
Definition:
scrollbar.hpp:83
gui::scrollbar::grip_height_
unsigned int grip_height_
Definition:
scrollbar.hpp:83
gui::scrollbar::get_max_position
unsigned get_max_position() const
Definition:
scrollbar.cpp:70
gui::scrollbar::adjust_position
void adjust_position(unsigned pos)
Ensure the viewport contains the position.
Definition:
scrollbar.cpp:85
gui::scrollbar::handle_event
virtual void handle_event(const SDL_Event &event)
Definition:
scrollbar.cpp:219
gui::widget
Definition:
widget.hpp:28
gui
General purpose widgets.
Definition:
tristate_button.cpp:30
button.hpp
h
#define h
Generated by
1.9.1