2009-12-19 16:46:15 +01:00
|
|
|
#ifndef WIDGET_HH
|
|
|
|
#define WIDGET_HH
|
|
|
|
|
|
|
|
#include <SDL.h>
|
|
|
|
|
2009-12-19 18:58:28 +01:00
|
|
|
enum key_event {
|
2009-12-19 16:46:15 +01:00
|
|
|
EVENT_NONE = 0,
|
|
|
|
KEY_UP = 1,
|
|
|
|
KEY_DOWN = 2,
|
|
|
|
KEY_LEFT = 4,
|
|
|
|
KEY_RIGHT = 8,
|
|
|
|
KEY_SELECT = 16,
|
|
|
|
KEY_ESCAPE = 32,
|
|
|
|
KEY_PAGEDOWN = 64,
|
|
|
|
KEY_PAGEUP = 128,
|
|
|
|
KEY_HELP = 256,
|
|
|
|
};
|
|
|
|
|
2009-12-19 18:58:28 +01:00
|
|
|
typedef enum key_event event_t;
|
2009-12-19 16:46:15 +01:00
|
|
|
|
|
|
|
class Widget
|
|
|
|
{
|
|
|
|
public:
|
2009-12-19 19:33:18 +01:00
|
|
|
Widget();
|
|
|
|
|
2009-12-19 18:58:28 +01:00
|
|
|
virtual void pushEvent(event_t ev);
|
|
|
|
|
|
|
|
virtual void pushEvent(SDL_Event *ev);
|
2009-12-19 16:46:15 +01:00
|
|
|
|
|
|
|
virtual void runLogic() = 0;
|
|
|
|
|
|
|
|
virtual void draw(SDL_Surface *where,
|
2009-12-20 10:31:46 +01:00
|
|
|
int x, int y, int w, int h);
|
2009-12-19 18:58:28 +01:00
|
|
|
|
|
|
|
virtual event_t popEvent();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int ev_head, ev_tail;
|
|
|
|
event_t event_stack[8];
|
2009-12-19 16:46:15 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|