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_GUICHANMANAGER_H
00023 #define FIFE_VIDEO_GUI_GUICHANMANAGER_H
00024
00025
00026 #include <set>
00027
00028
00029 #include <guichan.hpp>
00030
00031
00032
00033
00034
00035 #include "util/base/fife_stdint.h"
00036 #include "util/base/singleton.h"
00037 #include "eventchannel/sdl/ec_isdleventlistener.h"
00038
00039 #include "gui/guimanager.h"
00040
00041 namespace gcn {
00042
00043 class Gui;
00044 class Container;
00045 class Widget;
00046 class SDLInput;
00047 class FocusHandler;
00048
00049 }
00050
00051
00052 namespace FIFE {
00053
00054 class GuiImageLoader;
00055 class Console;
00056 class KeyEvent;
00057 class MouseEvent;
00058 class IFont;
00059 class GuiFont;
00060
00061
00062
00063
00064
00065
00066 class GUIChanManager :
00067 public IGUIManager,
00068 public DynamicSingleton<GUIChanManager>
00069 {
00070 public:
00073 GUIChanManager();
00076 virtual ~GUIChanManager();
00077
00082 gcn::Gui* getGuichanGUI() const;
00083
00088 virtual void turn();
00089
00095 void init(const std::string& backend, int32_t screenWidth, int32_t screenHeight);
00096
00104 void resizeTopContainer(uint32_t x, uint32_t y, uint32_t width, uint32_t height);
00105
00110 void add(gcn::Widget* widget);
00115 void remove(gcn::Widget* widget);
00120 gcn::Container* getTopContainer() const { return m_gcn_topcontainer; }
00121
00126 Console* getConsole() const { return m_console; };
00127
00130 GuiFont* setDefaultFont(const std::string& path, uint32_t size, const std::string& glyphs);
00131
00134 GuiFont* getDefaultFont() { return m_defaultfont; };
00135
00138 GuiFont* createFont(const std::string& path = "", uint32_t size = 0, const std::string& glyphs = "");
00139
00142 void releaseFont(GuiFont* font);
00143
00144 void invalidateFonts();
00145
00146 virtual bool onSdlEvent(SDL_Event& evt);
00147
00148 KeyEvent translateKeyEvent(const gcn::KeyEvent& evt);
00149 MouseEvent translateMouseEvent(const gcn::MouseEvent& evt);
00150
00151 protected:
00152 static int32_t convertGuichanKeyToFifeKey(int32_t value);
00153
00154 private:
00155
00156 gcn::Gui* m_gcn_gui;
00157
00158 gcn::Graphics* m_gui_graphics;
00159
00160 gcn::FocusHandler* m_focushandler;
00161
00162 gcn::Container* m_gcn_topcontainer;
00163
00164 GuiImageLoader* m_imgloader;
00165
00166 gcn::SDLInput *m_input;
00167
00168 Console *m_console;
00169
00170 GuiFont* m_defaultfont;
00171
00172 std::vector<GuiFont*> m_fonts;
00173
00174 std::set<gcn::Widget*> m_widgets;
00175
00176
00177 bool m_had_mouse;
00178 bool m_had_widget;
00179
00180
00181 std::string m_fontpath;
00182 std::string m_fontglyphs;
00183 int32_t m_fontsize;
00184
00185
00186 bool m_logic_executed;
00187 };
00188
00189 }
00190
00191 #endif