The Battle for Wesnoth  1.15.12+dev
scrollarea.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2004 - 2018 by Guillaume Melquiond <guillaume.melquiond@gmail.com>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #pragma once
16 
17 #include "scrollbar.hpp"
18 
19 namespace gui {
20 
21 class scrollarea : public widget
22 {
23 public:
24  /**
25  * Create a zone with automatic handling of scrollbar.
26  * @todo FIXME: parameterlist ??
27  */
28  //- \param d the display object
29  //- \param pane the widget where wheel events take place
30  scrollarea(CVideo &video, bool auto_join=true);
31 
32  virtual void hide(bool value = true);
33 
34 protected:
36  virtual void update_location(const SDL_Rect& rect);
37  virtual void handle_event(const SDL_Event& event);
38  virtual void process_event();
39  virtual void scroll(unsigned int pos) = 0;
40  virtual void set_inner_location(const SDL_Rect& rect) = 0;
41 
42  SDL_Rect inner_location() const;
43  unsigned scrollbar_width() const;
44 
45  unsigned get_position() const;
46  unsigned get_max_position() const;
47  void set_position(unsigned pos);
48  void adjust_position(unsigned pos);
49  void move_position(int dep);
50  void set_shown_size(unsigned h);
51  void set_full_size(unsigned h);
52  void set_scroll_rate(unsigned r);
53  bool has_scrollbar() const;
54 
55 private:
59  unsigned shown_size_;
60  unsigned full_size_;
61  int swipe_dy_;
62  struct {
63  int x;
64  int y;
65  } swipe_origin_;
66 
67  void test_scrollbar();
68 };
69 
70 } // end namespace gui
Scrollbar.
Definition: scrollbar.hpp:25
virtual void set_inner_location(const SDL_Rect &rect)=0
void set_shown_size(unsigned h)
Definition: scrollarea.cpp:107
void adjust_position(unsigned pos)
Definition: scrollarea.cpp:97
std::vector< events::sdl_handler * > sdl_handler_vector
Definition: events.hpp:189
unsigned scrollbar_width() const
Definition: scrollarea.cpp:143
virtual sdl_handler_vector handler_members()
Definition: scrollarea.cpp:37
Definition: video.hpp:31
General purpose widgets.
virtual void update_location(const SDL_Rect &rect)
Definition: scrollarea.cpp:44
#define h
void set_scroll_rate(unsigned r)
Definition: scrollarea.cpp:121
void test_scrollbar()
Definition: scrollarea.cpp:62
void move_position(int dep)
Definition: scrollarea.cpp:102
struct gui::scrollarea::@29 swipe_origin_
virtual void scroll(unsigned int pos)=0
void set_full_size(unsigned h)
Definition: scrollarea.cpp:114
bool has_scrollbar() const
Definition: scrollarea.cpp:32
void set_position(unsigned pos)
Definition: scrollarea.cpp:92
unsigned full_size_
Definition: scrollarea.hpp:60
scrollbar scrollbar_
Definition: scrollarea.hpp:56
virtual void handle_event(const SDL_Event &event)
Definition: scrollarea.cpp:148
SDL_Rect inner_location() const
Definition: scrollarea.cpp:135
unsigned get_max_position() const
Definition: scrollarea.cpp:87
virtual void hide(bool value=true)
Definition: scrollarea.cpp:75
CVideo & video() const
Definition: widget.hpp:83
unsigned shown_size_
Definition: scrollarea.hpp:59
scrollarea(CVideo &video, bool auto_join=true)
Create a zone with automatic handling of scrollbar.
Definition: scrollarea.cpp:24
virtual void process_event()
Definition: scrollarea.cpp:126
unsigned get_position() const
Definition: scrollarea.cpp:82