From 2e768d0c67318e3309c9ecea676bbeb743be9710 Mon Sep 17 00:00:00 2001 From: "simon.kagstrom" Date: Sun, 20 Dec 2009 09:31:46 +0000 Subject: [PATCH] Make GuiView a widget --- gui.hh | 18 +++--------------- virtual_keyboard.cpp | 10 +++++++++- virtual_keyboard.hh | 8 ++++++-- widget.cpp | 4 ++++ widget.hh | 2 +- 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/gui.hh b/gui.hh index 0e2a4ea..11a1243 100644 --- a/gui.hh +++ b/gui.hh @@ -6,24 +6,11 @@ #include "menu.hh" #include "font.hh" #include "timer.hh" +#include "gui_view.hh" -class Gui; class MainView; class DiscView; - -class GuiView -{ -public: - GuiView(); - - virtual void pushEvent(SDL_Event *ev) = 0; - - virtual void runLogic() = 0; - - virtual void updateTheme() = 0; - - virtual void draw(SDL_Surface *where) = 0; -}; +class KeyboardView; class Gui { @@ -83,6 +70,7 @@ public: MainView *mv; DiscView *dv; + KeyboardView *kv; GuiView **views; int n_views; diff --git a/virtual_keyboard.cpp b/virtual_keyboard.cpp index 0e705ef..1b4f4fc 100644 --- a/virtual_keyboard.cpp +++ b/virtual_keyboard.cpp @@ -70,7 +70,7 @@ static const char *shifted_names[KEY_COLS * KEY_ROWS] = { NULL, NULL, NULL, NULL, NULL, NULL, "f2", "f4", "f6", "f8", "Ins", NULL, NULL, NULL, NULL, }; -VirtualKeyboard::VirtualKeyboard(Font *font) : Widget() +VirtualKeyboard::VirtualKeyboard(Font *font) : GuiView() { this->font = font; this->sel_x = 0; @@ -349,5 +349,13 @@ void VirtualKeyboard::runLogic() } } +void VirtualKeyboard::draw(SDL_Surface *where) +{ +} + +void VirtualKeyboard::updateTheme() +{ +} + /* The singleton */ VirtualKeyboard *VirtualKeyboard::kbd; diff --git a/virtual_keyboard.hh b/virtual_keyboard.hh index 7ad7421..8035978 100644 --- a/virtual_keyboard.hh +++ b/virtual_keyboard.hh @@ -15,6 +15,7 @@ #include #include "widget.hh" +#include "gui_view.hh" #include "font.hh" struct virtkey; @@ -32,7 +33,7 @@ public: virtual void stringCallback(const char *str) = 0; }; -class VirtualKeyboard : public Widget +class VirtualKeyboard : public GuiView { public: VirtualKeyboard(Font *font); @@ -65,6 +66,10 @@ public: return this->is_active; } + virtual void updateTheme(); + + void draw(SDL_Surface *where); + void runLogic(); void draw(SDL_Surface *where, int x, int y, int w, int h); @@ -88,5 +93,4 @@ private: unsigned buf_head; }; - #endif /* __VIRTUAL_KEYBORD_HH__ */ diff --git a/widget.cpp b/widget.cpp index dad3df1..1a19833 100644 --- a/widget.cpp +++ b/widget.cpp @@ -70,3 +70,7 @@ void Widget::pushEvent(SDL_Event *ev) } } + +void Widget::draw(SDL_Surface *where, int x, int y, int w, int h) +{ +} diff --git a/widget.hh b/widget.hh index 5865b9d..23881be 100644 --- a/widget.hh +++ b/widget.hh @@ -30,7 +30,7 @@ public: virtual void runLogic() = 0; virtual void draw(SDL_Surface *where, - int x, int y, int w, int h) = 0; + int x, int y, int w, int h); virtual event_t popEvent();