The Battle for Wesnoth  1.19.7+dev
scrollarea.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2004 - 2024
3  by Guillaume Melquiond <guillaume.melquiond@gmail.com>
4  Part of the Battle for Wesnoth Project https://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 #pragma once
17 
18 #include "scrollbar.hpp"
19 
20 namespace gui {
21 
22 class scrollarea : public widget
23 {
24 public:
25  /**
26  * Create a zone with automatic handling of scrollbar.
27  * @todo FIXME: parameterlist ??
28  */
29  //- \param d the display object
30  //- \param pane the widget where wheel events take place
31  scrollarea(bool auto_join=true);
32 
33  virtual void hide(bool value = true);
34 
35 protected:
37  virtual void update_location(const SDL_Rect& rect);
38  virtual void handle_event(const SDL_Event& event);
39  virtual void process_event();
40  virtual void scroll(unsigned int pos) = 0;
41  virtual void set_inner_location(const SDL_Rect& rect) = 0;
42 
43  rect inner_location() const;
44  unsigned scrollbar_width() const;
45 
46  unsigned get_position() const;
47  unsigned get_max_position() const;
48  void set_position(unsigned pos);
49  void adjust_position(unsigned pos);
50  void move_position(int dep);
51  void set_shown_size(unsigned h);
52  void set_full_size(unsigned h);
53  void set_scroll_rate(unsigned r);
54  bool has_scrollbar() const;
55 
56 private:
60  unsigned shown_size_;
61  unsigned full_size_;
62  int swipe_dy_;
63  struct {
64  int x;
65  int y;
67 
68  void test_scrollbar();
69 };
70 
71 } // end namespace gui
unsigned get_max_position() const
Definition: scrollarea.cpp:86
void test_scrollbar()
Definition: scrollarea.cpp:63
bool has_scrollbar() const
Definition: scrollarea.cpp:33
void set_shown_size(unsigned h)
Definition: scrollarea.cpp:106
virtual void hide(bool value=true)
Definition: scrollarea.cpp:74
void adjust_position(unsigned pos)
Definition: scrollarea.cpp:96
scrollarea(bool auto_join=true)
Create a zone with automatic handling of scrollbar.
Definition: scrollarea.cpp:25
unsigned get_position() const
Definition: scrollarea.cpp:81
struct gui::scrollarea::@8 swipe_origin_
void set_full_size(unsigned h)
Definition: scrollarea.cpp:113
void set_position(unsigned pos)
Definition: scrollarea.cpp:91
virtual void update_location(const SDL_Rect &rect)
Definition: scrollarea.cpp:45
virtual void scroll(unsigned int pos)=0
scrollbar scrollbar_
Definition: scrollarea.hpp:57
virtual void process_event()
Definition: scrollarea.cpp:125
virtual sdl_handler_vector handler_members()
Definition: scrollarea.cpp:38
unsigned full_size_
Definition: scrollarea.hpp:61
rect inner_location() const
Definition: scrollarea.cpp:134
void move_position(int dep)
Definition: scrollarea.cpp:101
virtual void set_inner_location(const SDL_Rect &rect)=0
virtual void handle_event(const SDL_Event &event)
Definition: scrollarea.cpp:147
unsigned scrollbar_width() const
Definition: scrollarea.cpp:142
unsigned shown_size_
Definition: scrollarea.hpp:60
void set_scroll_rate(unsigned r)
Definition: scrollarea.cpp:120
Scrollbar.
Definition: scrollbar.hpp:26
std::vector< events::sdl_handler * > sdl_handler_vector
Definition: events.hpp:182
General purpose widgets.
An abstract description of a rectangle with integer coordinates.
Definition: rect.hpp:47
#define h