Snoke
widget.h
Go to the documentation of this file.
1 #ifndef INTERFACE_H
2 #define INTERFACE_H
3 #include <functional>
4 #include <map>
5 #include <list>
6 #include <vector>
7 
14 #define EVENT_FOCUS 1
15 #define EVENT_UNFOCUS 2
16 #define EVENT_ACTIVE 4
17 
22 typedef std::function<void()> Listener;
23 
36 class Widget
37 {
38  public:
44  unsigned short length;
45  unsigned char events;
46  std::map<unsigned char, std::list<Listener>> listeners;
47 
48  public:
49  virtual void draw();
50  void _parent(Widget* parentWidget);
51  Widget* firstChild();
52  Widget* lastChild();
53  Widget* parent();
54  void _next(Widget* nextWidget);
55  Widget* next();
56  void _previous(Widget* previousWidget);
57  Widget* previous();
58  void add(Widget* child);
59  unsigned short childLength();
60  std::vector<Widget*> children();
61  bool event(unsigned char name);
62  void listener(unsigned char name, Listener function);
63  void dispatch(unsigned char name);
64  Widget();
65 };
66 
67 #endif
std::vector< Widget * > children()
Definition: widget.cpp:121
Widget * lastChild()
Definition: widget.cpp:41
bool event(unsigned char name)
Definition: widget.cpp:140
Widget * start
Definition: widget.h:40
std::function< void()> Listener
Definition: widget.h:22
void _previous(Widget *previousWidget)
Definition: widget.cpp:68
unsigned short childLength()
Definition: widget.cpp:112
Widget * ending
Definition: widget.h:41
Widget * parentWidget
Definition: widget.h:39
Widget * previous()
Definition: widget.cpp:77
unsigned short length
Definition: widget.h:44
virtual void draw()
Definition: widget.cpp:7
unsigned char events
Definition: widget.h:45
Widget * parent()
Definition: widget.cpp:23
void dispatch(unsigned char name)
Definition: widget.cpp:161
void _parent(Widget *parentWidget)
Definition: widget.cpp:14
Widget * previousWidget
Definition: widget.h:43
Widget * nextWidget
Definition: widget.h:42
void listener(unsigned char name, Listener function)
Definition: widget.cpp:150
Definition: widget.h:36
void _next(Widget *nextWidget)
Definition: widget.cpp:50
Widget()
Definition: widget.cpp:172
void add(Widget *child)
Definition: widget.cpp:86
Widget * next()
Definition: widget.cpp:59
std::map< unsigned char, std::list< Listener > > listeners
Definition: widget.h:46
Widget * firstChild()
Definition: widget.cpp:32