/
DropDown.h
41 lines (37 loc) · 1.09 KB
/
DropDown.h
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
#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<String, int> newOption) {}
virtual ~DropDownAction() {}
};
class DropDown: public ui::Component {
friend class DropDownWindow;
bool isMouseInside;
int optionIndex;
DropDownAction * callback;
std::vector<std::pair<String, int> > options;
public:
DropDown(Point position, Point size);
std::pair<String, int> GetOption();
void SetOption(int option);
void SetOption(String option);
void AddOption(std::pair<String, int> option);
void RemoveOption(String option);
void SetOptions(std::vector<std::pair<String, int> > options);
void SetActionCallback(DropDownAction * action) { callback = action;}
void Draw(const Point& screenPos) override;
void OnMouseClick(int x, int y, unsigned int button) override;
void OnMouseEnter(int x, int y) override;
void OnMouseLeave(int x, int y) override;
virtual ~DropDown();
};
} /* namespace ui */
#endif /* DROPDOWN_H_ */