Crazy Eddie's GUI System
0.8.4
|
00001 /*********************************************************************** 00002 created: 20/2/2004 00003 author: Paul D Turner 00004 00005 purpose: Defines interface for main GUI system class 00006 *************************************************************************/ 00007 /*************************************************************************** 00008 * Copyright (C) 2004 - 2012 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 _CEGUISystem_h_ 00030 #define _CEGUISystem_h_ 00031 00032 #include "CEGUI/Base.h" 00033 #include "CEGUI/String.h" 00034 #include "CEGUI/Singleton.h" 00035 #include "CEGUI/EventSet.h" 00036 #include "CEGUI/Renderer.h" 00037 #include "CEGUI/InputEvent.h" 00038 #include "CEGUI/ResourceProvider.h" 00039 #include <vector> 00040 00041 #if defined(__WIN32__) || defined(_WIN32) 00042 # include "CEGUI/Win32StringTranscoder.h" 00043 #else 00044 # include "CEGUI/IconvStringTranscoder.h" 00045 #endif 00046 00047 #if defined(_MSC_VER) 00048 # pragma warning(push) 00049 # pragma warning(disable : 4275) 00050 # pragma warning(disable : 4251) 00051 #endif 00052 00053 00054 // Start of CEGUI namespace section 00055 namespace CEGUI 00056 { 00065 class CEGUIEXPORT System : 00066 public Singleton<System>, 00067 public EventSet, 00068 public AllocatedObject<System> 00069 { 00070 public: 00071 static const String EventNamespace; 00072 00073 /************************************************************************* 00074 Constants 00075 *************************************************************************/ 00076 // event names 00082 static const String EventDisplaySizeChanged; 00086 static const String EventRenderedStringParserChanged; 00087 00088 /************************************************************************* 00089 Construction and Destruction 00090 *************************************************************************/ 00123 static System& create(Renderer& renderer, 00124 ResourceProvider* resourceProvider = 0, 00125 XMLParser* xmlParser = 0, 00126 ImageCodec* imageCodec = 0, 00127 ScriptModule* scriptModule = 0, 00128 const String& configFile = "", 00129 const String& logFile = "CEGUI.log", 00130 const int abi = CEGUI_VERSION_ABI); 00131 00133 static void destroy(); 00134 00143 static unsigned int getMajorVersion(); 00144 00153 static unsigned int getMinorVersion(); 00154 00163 static unsigned int getPatchVersion(); 00164 00173 static const String& getVersion(); 00174 00183 static const String& getVerboseVersion(); 00184 00192 Renderer* getRenderer(void) const {return d_renderer;} 00193 00194 00202 static System& getSingleton(void); 00203 00204 00212 static System* getSingletonPtr(void); 00213 00218 Clipboard* getClipboard() const {return d_clipboard;} 00219 00220 GUIContext& getDefaultGUIContext() const; 00221 00228 void renderAllGUIContexts(); 00229 00230 00238 ScriptModule* getScriptingModule(void) const; 00239 00250 void setScriptingModule(ScriptModule* scriptModule); 00251 00259 ResourceProvider* getResourceProvider(void) const; 00260 00271 void executeScriptFile(const String& filename, const String& resourceGroup = "") const; 00272 00273 00285 int executeScriptGlobal(const String& function_name) const; 00286 00287 00298 void executeScriptString(const String& str) const; 00299 00300 00313 void setXMLParser(const String& parserName); 00314 00332 void setXMLParser(XMLParser* parser); 00333 00338 XMLParser* getXMLParser(void) const { return d_xmlParser; } 00339 00340 00385 static void setDefaultXMLParserName(const String& parserName); 00386 00396 static const String getDefaultXMLParserName(); 00397 00402 ImageCodec& getImageCodec() const; 00403 00408 void setImageCodec(const String& codecName); 00409 00420 void setImageCodec(ImageCodec& codec); 00421 00426 static void setDefaultImageCodecName(const String& codecName); 00427 00432 static const String& getDefaultImageCodecName(); 00433 00451 void notifyDisplaySizeChanged(const Sizef& new_size); 00452 00466 RenderedStringParser* getDefaultCustomRenderedStringParser() const; 00467 00482 void setDefaultCustomRenderedStringParser(RenderedStringParser* parser); 00483 00494 void invalidateAllCachedRendering(); 00495 00509 RegexMatcher* createRegexMatcher() const; 00510 00512 void destroyRegexMatcher(RegexMatcher* rm) const; 00513 00515 bool injectTimePulse(float timeElapsed); 00516 00517 GUIContext& createGUIContext(RenderTarget& rt); 00518 void destroyGUIContext(GUIContext& context); 00519 00528 void addStandardWindowFactories(); 00529 00531 static const StringTranscoder& getStringTranscoder(); 00532 00534 static void performVersionTest(const int expected, const int received, 00535 const String& func); 00536 00537 private: 00538 // unimplemented constructors / assignment 00539 System(const System& obj); 00540 System& operator=(const System& obj); 00541 00542 protected: 00543 /************************************************************************* 00544 Implementation Functions 00545 *************************************************************************/ 00575 System(Renderer& renderer, ResourceProvider* resourceProvider, 00576 XMLParser* xmlParser, ImageCodec* imageCodec, 00577 ScriptModule* scriptModule, const String& configFile, 00578 const String& logFile); 00579 00584 ~System(void); 00585 00587 void outputLogHeader(); 00588 00590 void createSingletons(); 00591 00593 void destroySingletons(); 00594 00596 void setupXMLParser(); 00597 00599 void cleanupXMLParser(); 00600 00602 void setupImageCodec(const String& codecName); 00603 00605 void cleanupImageCodec(); 00606 00608 void invalidateAllWindows(); 00609 00610 /************************************************************************* 00611 Implementation Data 00612 *************************************************************************/ 00613 Renderer* d_renderer; 00614 ResourceProvider* d_resourceProvider; 00615 bool d_ourResourceProvider; 00616 00617 Clipboard* d_clipboard; 00618 00619 // scripting 00620 ScriptModule* d_scriptModule; 00621 String d_termScriptName; 00622 00623 XMLParser* d_xmlParser; 00624 bool d_ourXmlParser; 00625 DynamicModule* d_parserModule; 00626 00627 static String d_defaultXMLParserName; 00628 00630 ImageCodec* d_imageCodec; 00632 bool d_ourImageCodec; 00636 DynamicModule* d_imageCodecModule; 00638 static String d_defaultImageCodecName; 00640 bool d_ourLogger; 00642 RenderedStringParser* d_customRenderedStringParser; 00643 00644 typedef std::vector<GUIContext* CEGUI_VECTOR_ALLOC(GUIContext*)> GUIContextCollection; 00645 GUIContextCollection d_guiContexts; 00647 #if defined(__WIN32__) || defined(_WIN32) 00648 static const Win32StringTranscoder d_stringTranscoder; 00649 #else 00650 static const IconvStringTranscoder d_stringTranscoder; 00651 #endif 00652 }; 00653 00654 } // End of CEGUI namespace section 00655 00656 00657 #if defined(_MSC_VER) 00658 # pragma warning(pop) 00659 #endif 00660 00661 #endif // end of guard _CEGUISystem_h_