Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef SCROLLPANE_HPP_INCLUDED
00019 #define SCROLLPANE_HPP_INCLUDED
00020
00021 #include <map>
00022 #include <vector>
00023
00024 #include "SDL.h"
00025 #include "../sdl_utils.hpp"
00026 #include "scrollarea.hpp"
00027
00028 namespace gui {
00029
00030
00031 class scrollpane : public scrollarea
00032 {
00033 public:
00034 struct scrollpane_widget {
00035 scrollpane_widget(widget* w, int x=0, int y=0, int z_order=0)
00036 : w(w), x(x), y(y), z_order(z_order) {};
00037
00038 widget* w;
00039 int x;
00040 int y;
00041 int z_order;
00042 };
00043
00044
00045
00046
00047
00048
00049
00050
00051 scrollpane(CVideo &video);
00052
00053 virtual void set_location(SDL_Rect const &rect);
00054
00055
00056
00057 void set_location(int x, int y) { widget::set_location(x,y); }
00058
00059 virtual void hide(bool value=true);
00060
00061 void add_widget(widget* w, int x, int y, int z_order = 0);
00062 void remove_widget(widget* w);
00063 void clear();
00064
00065 protected:
00066
00067
00068 virtual void draw();
00069 virtual void set_inner_location(SDL_Rect const &rect);
00070 virtual void scroll(unsigned int pos);
00071
00072 private:
00073 void update_widget_positions();
00074 void position_widget(scrollpane_widget& spw);
00075 SDL_Rect client_area() const;
00076 void update_content_size();
00077
00078 int border_;
00079 typedef std::multimap<int, scrollpane_widget> widget_map;
00080 widget_map content_;
00081 SDL_Rect content_pos_;
00082 };
00083
00084 }
00085
00086 #endif