Add widget base class

This commit is contained in:
simon.kagstrom 2009-12-19 15:46:15 +00:00
parent d0f0dc3b50
commit 39db099cd4
4 changed files with 35 additions and 17 deletions

View File

@ -6,7 +6,7 @@ all: menu
%.oo: %.cpp
g++ -Wall -g -c `sdl-config --cflags` -o $@ $<
menu.oo: menu.cpp menu.hh utils.hh font.hh Makefile
menu.oo: menu.cpp menu.hh utils.hh font.hh widget.hh Makefile
gui.oo: gui.cpp gui.hh Makefile font.hh menu.hh sdl_ttf_font.hh \
dialogue_box.hh help_box.hh main_menu.cpp disc_menu.cpp \

17
menu.hh
View File

@ -17,20 +17,7 @@
#include <stdint.h>
#include "font.hh"
enum {
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,
};
#include "widget.hh"
typedef struct
{
@ -41,7 +28,7 @@ typedef struct
typedef int event_t;
class Menu
class Menu : public Widget
{
public:
Menu(Font *font);

View File

@ -24,7 +24,7 @@ class StringListener
void stringCallback(const char *str);
};
class VirtualKeyboard
class VirtualKeyboard : public Widget
{
public:
VirtualKeyboard(TTF_Font *font);

31
widget.hh Normal file
View File

@ -0,0 +1,31 @@
#ifndef WIDGET_HH
#define WIDGET_HH
#include <SDL.h>
enum {
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,
};
class Widget
{
public:
virtual void pushEvent(SDL_Event *ev) = 0;
virtual void runLogic() = 0;
virtual void draw(SDL_Surface *where,
int x, int y, int w, int h) = 0;
};
#endif