Crazy Eddie's GUI System
0.8.4
|
00001 /*********************************************************************** 00002 created: 21/2/2004 00003 author: Paul D Turner 00004 00005 purpose: Defines the interface for the WindowManager object 00006 *************************************************************************/ 00007 /*************************************************************************** 00008 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team 00009 * 00010 * Permission is hereby granted, free of charge, to any person obtaining 00011 * a copy of this software and associated documentation files (the 00012 * "Software"), to deal in the Software without restriction, including 00013 * without limitation the rights to use, copy, modify, merge, publish, 00014 * distribute, sublicense, and/or sell copies of the Software, and to 00015 * permit persons to whom the Software is furnished to do so, subject to 00016 * the following conditions: 00017 * 00018 * The above copyright notice and this permission notice shall be 00019 * included in all copies or substantial portions of the Software. 00020 * 00021 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00022 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00023 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00024 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00025 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00026 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00027 * OTHER DEALINGS IN THE SOFTWARE. 00028 ***************************************************************************/ 00029 #ifndef _CEGUIWindowManager_h_ 00030 #define _CEGUIWindowManager_h_ 00031 00032 #include "CEGUI/Base.h" 00033 #include "CEGUI/String.h" 00034 #include "CEGUI/Singleton.h" 00035 #include "CEGUI/Logger.h" 00036 #include "CEGUI/IteratorBase.h" 00037 #include "CEGUI/EventSet.h" 00038 #include <map> 00039 #include <vector> 00040 00041 #if defined(_MSC_VER) 00042 # pragma warning(push) 00043 # pragma warning(disable : 4275) 00044 # pragma warning(disable : 4251) 00045 #endif 00046 00047 00048 // Start of CEGUI namespace section 00049 namespace CEGUI 00050 { 00060 class CEGUIEXPORT WindowManager : public Singleton<WindowManager>, 00061 public EventSet, 00062 public AllocatedObject<WindowManager> 00063 { 00064 public: 00065 /************************************************************************* 00066 Public static data 00067 *************************************************************************/ 00068 static const String GeneratedWindowNameBase; 00069 00070 static const String EventNamespace; 00075 static const String EventWindowCreated; 00080 static const String EventWindowDestroyed; 00081 00082 static const String GUILayoutSchemaName; 00083 00105 typedef bool PropertyCallback(Window* window, String& propname, String& propvalue, void* userdata); 00106 00107 /************************************************************************* 00108 Construction and Destruction 00109 *************************************************************************/ 00118 WindowManager(void); 00119 00120 00128 ~WindowManager(void); 00129 00130 00131 /************************************************************************* 00132 Window Related Methods 00133 *************************************************************************/ 00153 Window* createWindow(const String& type, const String& name = ""); 00154 00155 00168 void destroyWindow(Window* window); 00169 00170 00180 void destroyAllWindows(void); 00181 00183 bool isAlive(const Window* window) const; 00184 00203 Window* loadLayoutFromContainer(const RawDataContainer& source, PropertyCallback* callback = 0, void* userdata = 0); 00204 00229 Window* loadLayoutFromFile(const String& filename, const String& resourceGroup = "", PropertyCallback* callback = 0, void* userdata = 0); 00230 00249 Window* loadLayoutFromString(const String& source, PropertyCallback* callback = 0, void* userdata = 0); 00250 00259 bool isDeadPoolEmpty(void) const; 00260 00272 void cleanDeadPool(void); 00273 00287 void writeLayoutToStream(const Window& window, OutStream& out_stream) const; 00288 00303 String getLayoutAsString(const Window& window) const; 00304 00319 void saveLayoutToFile(const Window& window, const String& filename) const; 00320 00329 static const String& getDefaultResourceGroup() 00330 { return d_defaultResourceGroup; } 00331 00342 static void setDefaultResourceGroup(const String& resourceGroup) 00343 { d_defaultResourceGroup = resourceGroup; } 00344 00358 void lock(); 00359 00373 void unlock(); 00374 00391 bool isLocked() const; 00392 00393 private: 00394 /************************************************************************* 00395 Implementation Methods 00396 *************************************************************************/ 00401 String generateUniqueWindowName(); 00402 00404 void initialiseRenderEffect(Window* wnd, const String& effect) const; 00405 00406 /************************************************************************* 00407 Implementation Data 00408 *************************************************************************/ 00409 typedef std::vector<Window* 00410 CEGUI_VECTOR_ALLOC(Window*)> WindowVector; 00411 00413 WindowVector d_windowRegistry; 00414 WindowVector d_deathrow; 00415 00416 unsigned long d_uid_counter; 00417 static String d_defaultResourceGroup; 00418 00419 uint d_lockCount; 00420 00421 public: 00422 /************************************************************************* 00423 Iterator stuff 00424 *************************************************************************/ 00425 typedef ConstVectorIterator<WindowVector> WindowIterator; 00426 00431 WindowIterator getIterator(void) const; 00432 00443 void DEBUG_dumpWindowNames(String zone) const; 00444 }; 00445 00446 } // End of CEGUI namespace section 00447 00448 #if defined(_MSC_VER) 00449 # pragma warning(pop) 00450 #endif 00451 00452 #endif // end of guard _CEGUIWindowManager_h_