GLWWindowManager.h

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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         // All inherited from GameStateI
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         // Inherited from GLMenuI
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         // The collection that determines a windows visibility
00081         std::map<unsigned, bool> windowVisibility_;
00082         std::map<unsigned, GLWWindow *> idToWindow_;
00083 
00084         // The deque of windows in each state
00085         struct StateEntry
00086         {
00087                 unsigned state_;
00088                 std::list<std::pair<KeyboardKey *, GLWWindow *> > windowKeys_;
00089                 std::deque<GLWWindow *> windows_;
00090         };
00091         // The collection of states
00092         std::map<unsigned, StateEntry> stateEntrys_;
00093         StateEntry *currentStateEntry_;
00094 
00095         // To check for re-entrancy
00096         unsigned int changeEpoc_;
00097 
00098         void setCurrentEntry(const unsigned state);
00099 
00100 private:
00101         GLWWindowManager();
00102         virtual ~GLWWindowManager();
00103 
00104 };
00105 
00106 #endif

Generated on Mon Feb 16 15:14:46 2009 for Scorched3D by  doxygen 1.5.3