00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #if !defined(__INCLUDE_GLWWindowManagerh_INCLUDE__)
00022 #define __INCLUDE_GLWWindowManagerh_INCLUDE__
00023
00024 #include <map>
00025 #include <deque>
00026 #include <engine/GameStateI.h>
00027 #include <common/KeyboardKey.h>
00028 #include <GLW/GLWWindow.h>
00029 #include <GLEXT/GLMenuI.h>
00030
00031 class GLWWindowManager :
00032 public GameStateI,
00033 public GLMenuI
00034 {
00035 public:
00036 static GLWWindowManager *instance();
00037
00038 void addWindow(const unsigned state, GLWWindow *window,
00039 KeyboardKey *key = 0, bool visible = false);
00040 bool showWindow(unsigned id);
00041 bool hideWindow(unsigned id);
00042 bool windowVisible(unsigned id);
00043 bool moveToFront(unsigned id);
00044 bool windowInCurrentState(unsigned id);
00045 void sortWindowLevels();
00046 unsigned int getFocus(int x, int y);
00047
00048 void loadPositions();
00049 void savePositions();
00050 void clear();
00051
00052 GLWWindow *getWindowByName(const char *name);
00053
00054
00055 virtual void enterState(const unsigned state);
00056 virtual void draw(const unsigned state);
00057 virtual void simulate(const unsigned state, float simTime);
00058 virtual void keyboardCheck(const unsigned state, float frameTime,
00059 char *buffer, unsigned int keyState,
00060 KeyboardHistory::HistoryElement *history, int hisCount,
00061 bool &skipRest);
00062 virtual void mouseDown(const unsigned state, GameState::MouseButton button,
00063 int x, int y, bool &skipRest);
00064 virtual void mouseUp(const unsigned state, GameState::MouseButton button,
00065 int x, int y, bool &skipRest);
00066 virtual void mouseDrag(const unsigned state, GameState::MouseButton button,
00067 int x, int y, int dx, int dy, bool &skipRest);
00068 virtual void mouseWheel(const unsigned state,
00069 int x, int y, int z, bool &skipRest);
00070
00071
00072 virtual bool getMenuItems(const char* menuName,
00073 std::list<GLMenuItem> &result);
00074 virtual void menuSelection(const char* menuName,
00075 const int position, GLMenuItem &item);
00076
00077 protected:
00078 static GLWWindowManager *instance_;
00079
00080
00081 std::map<unsigned, bool> windowVisibility_;
00082 std::map<unsigned, GLWWindow *> idToWindow_;
00083
00084
00085 struct StateEntry
00086 {
00087 unsigned state_;
00088 std::list<std::pair<KeyboardKey *, GLWWindow *> > windowKeys_;
00089 std::deque<GLWWindow *> windows_;
00090 };
00091
00092 std::map<unsigned, StateEntry> stateEntrys_;
00093 StateEntry *currentStateEntry_;
00094
00095
00096 unsigned int changeEpoc_;
00097
00098 void setCurrentEntry(const unsigned state);
00099
00100 private:
00101 GLWWindowManager();
00102 virtual ~GLWWindowManager();
00103
00104 };
00105
00106 #endif