scrollpane.hpp

Go to the documentation of this file.
00001 /* $Id: scrollpane.hpp 23842 2008-02-16 08:47:16Z mordante $ */
00002 /*
00003    Copyright (C) 2004 - 2008 by Philippe Plantier <ayin@anathas.org>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License version 2
00008    or at your option any later version.
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY.
00011 
00012    See the COPYING file for more details.
00013 */
00014 
00015 //! @file widgets/scrollpane.hpp
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 //! Scrollpane.
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     //! Create a scrollpane.
00044 //! @todo FIXME: parameterlist ??
00045     //- @param d the display object
00046     //- @param pane the widget where wheel events take place
00047     //- @param callback a callback interface for warning that the grip has been moved
00048     scrollpane(CVideo &video);
00049 
00050     virtual void set_location(SDL_Rect const &rect);
00051 
00052     // VC++ doesn't like a 'using scrollarea::set_location' directive here,
00053     // so we declare an inline forwarding function instead.
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     //virtual void handle_event(const SDL_Event& event);
00064     //virtual void process_event();
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 } // namespace gui
00082 
00083 #endif

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs