1 #ifndef BTANKS_MENU_CONTAINER_H__
2 #define BTANKS_MENU_CONTAINER_H__
3 
4 /* Battle Tanks Game
5  * Copyright (C) 2006-2009 Battle Tanks team
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20  */
21 
22 /*
23  * Additional rights can be granted beyond the GNU General Public License
24  * on the terms provided in the Exception. If you modify this file,
25  * you may extend this exception to your version of the file,
26  * but you are not obligated to do so. If you do not wish to provide this
27  * exception without modification, you must delete this exception statement
28  * from your version and license this file solely under the GPL without exception.
29 */
30 
31 #include "control.h"
32 #include <list>
33 #include <math/v2.h>
34 #include "export_btanks.h"
35 
36 class BTANKSAPI Container : public Control {
37 public:
Container()38 	Container() : _focus(NULL) {}
39 	virtual void tick(const float dt);
40 	virtual void render(sdlx::Surface &surface, const int x, const int y) const;
41 	virtual void get_size(int &w, int &h) const;
42 	virtual bool onKey(const SDL_keysym sym);
43 	virtual bool onMouse(const int button, const bool pressed, const int x, const int y);
44 	virtual bool onMouseMotion(const int state, const int x, const int y, const int xrel, const int yrel);
45 	virtual void activate(const bool active);
46 
47 	void add(const int x, const int y, Control *ctrl, Control *after = NULL);
48 	void remove(Control *ctrl);
49 
50 	virtual void clear();
51 
52 	~Container();
53 private:
54 	Container(const Container &);
55 	const Container& operator=(const Container &);
56 
57 protected:
58 	const bool in(const Control *c, const int x, const int y) const;
59 
60 	typedef std::list<Control *> ControlList;
61 	ControlList _controls;
62 	Control * _focus;
63 };
64 
65 #endif
66 
67