The Battle for Wesnoth  1.15.1+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 http://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 /** @file */
16 
17 #pragma once
18 
19 #include "scrollbar.hpp"
20 
21 namespace gui {
22 
23 class scrollarea : public widget
24 {
25 public:
26  /**
27  * Create a zone with automatic handling of scrollbar.
28  * @todo FIXME: parameterlist ??
29  */
30  //- \param d the display object
31  //- \param pane the widget where wheel events take place
32  scrollarea(CVideo &video, bool auto_join=true);
33 
34  virtual void hide(bool value = true);
35 
36 protected:
38  virtual void update_location(const SDL_Rect& rect);
39  virtual void handle_event(const SDL_Event& event);
40  virtual void process_event();
41  virtual void scroll(unsigned int pos) = 0;
42  virtual void set_inner_location(const SDL_Rect& rect) = 0;
43 
44  SDL_Rect inner_location() const;
45  unsigned scrollbar_width() const;
46 
47  unsigned get_position() const;
48  unsigned get_max_position() const;
49  void set_position(unsigned pos);
50  void adjust_position(unsigned pos);
51  void move_position(int dep);
52  void set_shown_size(unsigned h);
53  void set_full_size(unsigned h);
54  void set_scroll_rate(unsigned r);
55  bool has_scrollbar() const;
56 
57 private:
61  unsigned shown_size_;
62  unsigned full_size_;
63  int swipe_dy_;
64  struct {
65  int x;
66  int y;
67  } swipe_origin_;
68 
69  void test_scrollbar();
70 };
71 
72 } // end namespace gui
Scrollbar.
Definition: scrollbar.hpp:27
virtual void set_inner_location(const SDL_Rect &rect)=0
void set_shown_size(unsigned h)
Definition: scrollarea.cpp:109
void adjust_position(unsigned pos)
Definition: scrollarea.cpp:99
std::vector< events::sdl_handler * > sdl_handler_vector
Definition: events.hpp:189
unsigned scrollbar_width() const
Definition: scrollarea.cpp:145
virtual sdl_handler_vector handler_members()
Definition: scrollarea.cpp:39
Definition: video.hpp:31
General purpose widgets.
virtual void update_location(const SDL_Rect &rect)
Definition: scrollarea.cpp:46
#define h
void set_scroll_rate(unsigned r)
Definition: scrollarea.cpp:123
void test_scrollbar()
Definition: scrollarea.cpp:64
void move_position(int dep)
Definition: scrollarea.cpp:104
virtual void scroll(unsigned int pos)=0
void set_full_size(unsigned h)
Definition: scrollarea.cpp:116
bool has_scrollbar() const
Definition: scrollarea.cpp:34
void set_position(unsigned pos)
Definition: scrollarea.cpp:94
struct gui::scrollarea::@22 swipe_origin_
unsigned full_size_
Definition: scrollarea.hpp:62
scrollbar scrollbar_
Definition: scrollarea.hpp:58
virtual void handle_event(const SDL_Event &event)
Definition: scrollarea.cpp:150
SDL_Rect inner_location() const
Definition: scrollarea.cpp:137
unsigned get_max_position() const
Definition: scrollarea.cpp:89
virtual void hide(bool value=true)
Definition: scrollarea.cpp:77
CVideo & video() const
Definition: widget.hpp:83
unsigned shown_size_
Definition: scrollarea.hpp:61
scrollarea(CVideo &video, bool auto_join=true)
Create a zone with automatic handling of scrollbar.
Definition: scrollarea.cpp:26
virtual void process_event()
Definition: scrollarea.cpp:128
unsigned get_position() const
Definition: scrollarea.cpp:84