00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FIFE_VIDEO_GUI_GUIMANAGER_H
00023 #define FIFE_VIDEO_GUI_GUIMANAGER_H
00024
00025
00026 #include <set>
00027
00028
00029 #include <guichan.hpp>
00030
00031
00032
00033
00034
00035 #include "util/base/singleton.h"
00036 #include "eventchannel/sdl/ec_isdleventlistener.h"
00037
00038
00039
00040 namespace gcn {
00041
00042 class Gui;
00043 class Container;
00044 class Widget;
00045 class SDLInput;
00046 class FocusHandler;
00047
00048 }
00049
00050
00051 namespace FIFE {
00052
00053 class ImagePool;
00054 class GuiImageLoader;
00055 class Console;
00056 class KeyEvent;
00057 class MouseEvent;
00058 class AbstractFont;
00059 class GuiFont;
00060
00061
00062
00063
00064
00065 class GUIManager :
00066 public DynamicSingleton<GUIManager>,
00067 public ISdlEventListener
00068 {
00069 public:
00072 GUIManager(ImagePool& pool);
00075 virtual ~GUIManager();
00076
00081 gcn::Gui* getGuichanGUI() const;
00082
00087 void turn();
00088
00094 void init(gcn::Graphics* graphics, int screenWidth, int screenHeight);
00095
00103 void resizeTopContainer(unsigned int x, unsigned int y, unsigned int width, unsigned int height);
00104
00109 void add(gcn::Widget* widget);
00114 void remove(gcn::Widget* widget);
00119 gcn::Container* getTopContainer() const { return m_gcn_topcontainer; }
00120
00125 Console* getConsole() const { return m_console; };
00126
00129 GuiFont* setDefaultFont(const std::string& path, unsigned int size, const std::string& glyphs);
00130
00133 GuiFont* createFont(const std::string& path = "", unsigned int size = 0, const std::string& glyphs = "");
00134
00137 void releaseFont(GuiFont* font);
00138
00139 bool onSdlEvent(SDL_Event& evt);
00140
00141 KeyEvent translateKeyEvent(const gcn::KeyEvent& evt);
00142 MouseEvent translateMouseEvent(const gcn::MouseEvent& evt);
00143
00144 protected:
00145 static int convertGuichanKeyToFifeKey(int value);
00146
00147 private:
00148
00149 gcn::Gui* m_gcn_gui;
00150
00151 gcn::FocusHandler* m_focushandler;
00152
00153 gcn::Container* m_gcn_topcontainer;
00154
00155 GuiImageLoader* m_imgloader;
00156
00157 gcn::SDLInput *m_input;
00158
00159 Console *m_console;
00160
00161 std::vector<GuiFont*> m_fonts;
00162
00163 std::set<gcn::Widget*> m_widgets;
00164
00165
00166 bool m_had_mouse;
00167
00168
00169 ImagePool& m_pool;
00170
00171
00172 std::string m_fontpath;
00173 std::string m_fontglyphs;
00174 int m_fontsize;
00175
00176
00177 bool m_logic_executed;
00178 };
00179
00180 }
00181
00182 #endif