The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
scrollpane.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2004 - 2016 by Philippe Plantier <[email protected]>
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 #ifndef SCROLLPANE_HPP_INCLUDED
18 #define SCROLLPANE_HPP_INCLUDED
19 
20 #include <map>
21 #include <vector>
22 
23 #include <SDL.h>
24 #include "sdl/utils.hpp"
25 #include "scrollarea.hpp"
26 
27 namespace gui {
28 
29 /** Scrollpane. */
30 class scrollpane : public scrollarea
31 {
32 public:
34  scrollpane_widget(widget* w, int x=0, int y=0, int z_order=0)
35  : w(w), x(x), y(y), z_order(z_order) {}
36 
38  int x;
39  int y;
40  int z_order;
41  };
42 
43  /**
44  * Create a scrollpane.
45  * @todo FIXME: parameterlist ??
46  */
47  //- @param d the display object
48  //- @param pane the widget where wheel events take place
49  //- @param callback a callback interface for warning that the grip has been moved
51 
52  virtual void set_location(SDL_Rect const &rect);
53 
54  // VC++ doesn't like a 'using scrollarea::set_location' directive here,
55  // so we declare an inline forwarding function instead.
56  void set_location(int x, int y) { widget::set_location(x,y); }
57 
58  virtual void hide(bool value=true);
59 
60  void add_widget(widget* w, int x, int y, int z_order = 0);
61  void remove_widget(widget* w);
62  void clear();
63 
64 protected:
65  //virtual void handle_event(const SDL_Event& event);
66  //virtual void process_event();
67  virtual void draw();
68  virtual void set_inner_location(SDL_Rect const &rect);
69  virtual void scroll(unsigned int pos);
70 
71 private:
73  void position_widget(scrollpane_widget& spw);
74  SDL_Rect client_area() const;
75  void update_content_size();
76 
77  int border_;
78  typedef std::multimap<int, scrollpane_widget> widget_map;
79  widget_map content_;
80  SDL_Rect content_pos_;
81 };
82 
83 } // namespace gui
84 
85 #endif
void position_widget(scrollpane_widget &spw)
Definition: scrollpane.cpp:145
SDL_Rect content_pos_
Definition: scrollpane.hpp:80
void set_location(int x, int y)
Definition: scrollpane.hpp:56
int pos
Definition: formula.cpp:800
scrollpane_widget(widget *w, int x=0, int y=0, int z_order=0)
Definition: scrollpane.hpp:34
Definition: video.hpp:58
virtual void set_inner_location(SDL_Rect const &rect)
Definition: scrollpane.cpp:101
CVideo & video() const
Definition: widget.hpp:83
General purpose widgets.
Scrollpane.
Definition: scrollpane.hpp:30
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1220
virtual void set_location(SDL_Rect const &rect)
Definition: scrollpane.cpp:57
scrollpane(CVideo &video)
Create a scrollpane.
Definition: scrollpane.cpp:43
void update_content_size()
Definition: scrollpane.cpp:163
GLubyte GLubyte GLubyte GLubyte w
Definition: glew.h:1858
GLsizei const GLfloat * value
Definition: glew.h:1817
void update_widget_positions()
Definition: scrollpane.cpp:122
void remove_widget(widget *w)
Definition: scrollpane.cpp:91
virtual void draw()
Definition: scrollpane.cpp:108
GLint GLint GLint GLint GLint x
Definition: glew.h:1220
SDL_Rect client_area() const
Definition: scrollpane.cpp:151
virtual void hide(bool value=true)
Definition: scrollpane.cpp:64
widget_map content_
Definition: scrollpane.hpp:79
virtual void scroll(unsigned int pos)
Definition: scrollpane.cpp:113
virtual void set_location(SDL_Rect const &rect)
Definition: widget.cpp:85
std::multimap< int, scrollpane_widget > widget_map
Definition: scrollpane.hpp:78
void add_widget(widget *w, int x, int y, int z_order=0)
Definition: scrollpane.cpp:71