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