summaryrefslogtreecommitdiff
path: root/src/interface/DropDown.h
blob: 3aba97156b5aad5511d3e700a109a800be5a4c9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
 * DropDown.h
 *
 *  Created on: Apr 16, 2012
 *      Author: Simon
 */

#ifndef DROPDOWN_H_
#define DROPDOWN_H_

#include <utility>
#include "Component.h"
#include "Colour.h"

namespace ui {

class DropDown;
class DropDownWindow;
class DropDownAction
{
public:
	virtual void OptionChanged(DropDown * sender, std::pair<std::string, int> newOption) {}
	virtual ~DropDownAction() {}
};
class DropDown: public ui::Component {
	friend class DropDownWindow;
	bool isMouseInside;
	int optionIndex;
	DropDownAction * callback;
	std::vector<std::pair<std::string, int> > options;
public:
	DropDown(Point position, Point size);
	std::pair<std::string, int> GetOption();
	void SetOption(int option);
	void SetOption(std::string option);
	void AddOption(std::pair<std::string, int> option);
	void RemoveOption(std::string option);
	void SetOptions(std::vector<std::pair<std::string, int> > options);
	void SetActionCallback(DropDownAction * action) { callback = action;}
	virtual void Draw(const Point& screenPos);
	virtual void OnMouseClick(int x, int y, unsigned int button);
	virtual void OnMouseEnter(int x, int y);
	virtual void OnMouseLeave(int x, int y);
	virtual ~DropDown();
};

} /* namespace ui */
#endif /* DROPDOWN_H_ */