Crazy Eddie's GUI System  0.8.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
System.h
1 /***********************************************************************
2  filename: CEGUISystem.h
3  created: 20/2/2004
4  author: Paul D Turner
5 
6  purpose: Defines interface for main GUI system class
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2012 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUISystem_h_
31 #define _CEGUISystem_h_
32 
33 #include "CEGUI/Base.h"
34 #include "CEGUI/String.h"
35 #include "CEGUI/Singleton.h"
36 #include "CEGUI/EventSet.h"
37 #include "CEGUI/Renderer.h"
38 #include "CEGUI/InputEvent.h"
39 #include "CEGUI/ResourceProvider.h"
40 #include <vector>
41 
42 #if defined(__WIN32__) || defined(_WIN32)
43 # include "CEGUI/Win32StringTranscoder.h"
44 #else
45 # include "CEGUI/IconvStringTranscoder.h"
46 #endif
47 
48 #if defined(_MSC_VER)
49 # pragma warning(push)
50 # pragma warning(disable : 4275)
51 # pragma warning(disable : 4251)
52 #endif
53 
54 
55 // Start of CEGUI namespace section
56 namespace CEGUI
57 {
66 class CEGUIEXPORT System :
67  public Singleton<System>,
68  public EventSet,
69  public AllocatedObject<System>
70 {
71 public:
72  static const String EventNamespace;
73 
74  /*************************************************************************
75  Constants
76  *************************************************************************/
77  // event names
88 
89  /*************************************************************************
90  Construction and Destruction
91  *************************************************************************/
124  static System& create(Renderer& renderer,
125  ResourceProvider* resourceProvider = 0,
126  XMLParser* xmlParser = 0,
127  ImageCodec* imageCodec = 0,
128  ScriptModule* scriptModule = 0,
129  const String& configFile = "",
130  const String& logFile = "CEGUI.log",
131  const int abi = CEGUI_VERSION_ABI);
132 
134  static void destroy();
135 
144  static unsigned int getMajorVersion();
145 
154  static unsigned int getMinorVersion();
155 
164  static unsigned int getPatchVersion();
165 
174  static const String& getVersion();
175 
184  static const String& getVerboseVersion();
185 
193  Renderer* getRenderer(void) const {return d_renderer;}
194 
195 
203  static System& getSingleton(void);
204 
205 
213  static System* getSingletonPtr(void);
214 
219  Clipboard* getClipboard() const {return d_clipboard;}
220 
221  GUIContext& getDefaultGUIContext() const;
222 
229  void renderAllGUIContexts();
230 
231 
239  ScriptModule* getScriptingModule(void) const;
240 
251  void setScriptingModule(ScriptModule* scriptModule);
252 
260  ResourceProvider* getResourceProvider(void) const;
261 
272  void executeScriptFile(const String& filename, const String& resourceGroup = "") const;
273 
274 
286  int executeScriptGlobal(const String& function_name) const;
287 
288 
299  void executeScriptString(const String& str) const;
300 
301 
314  void setXMLParser(const String& parserName);
315 
333  void setXMLParser(XMLParser* parser);
334 
339  XMLParser* getXMLParser(void) const { return d_xmlParser; }
340 
341 
386  static void setDefaultXMLParserName(const String& parserName);
387 
397  static const String getDefaultXMLParserName();
398 
403  ImageCodec& getImageCodec() const;
404 
409  void setImageCodec(const String& codecName);
410 
421  void setImageCodec(ImageCodec& codec);
422 
427  static void setDefaultImageCodecName(const String& codecName);
428 
433  static const String& getDefaultImageCodecName();
434 
452  void notifyDisplaySizeChanged(const Sizef& new_size);
453 
467  RenderedStringParser* getDefaultCustomRenderedStringParser() const;
468 
483  void setDefaultCustomRenderedStringParser(RenderedStringParser* parser);
484 
495  void invalidateAllCachedRendering();
496 
510  RegexMatcher* createRegexMatcher() const;
511 
513  void destroyRegexMatcher(RegexMatcher* rm) const;
514 
516  bool injectTimePulse(float timeElapsed);
517 
518  GUIContext& createGUIContext(RenderTarget& rt);
519  void destroyGUIContext(GUIContext& context);
520 
529  void addStandardWindowFactories();
530 
532  static const StringTranscoder& getStringTranscoder();
533 
535  static void performVersionTest(const int expected, const int received,
536  const String& func);
537 
538 private:
539  // unimplemented constructors / assignment
540  System(const System& obj);
541  System& operator=(const System& obj);
542 
543 protected:
544  /*************************************************************************
545  Implementation Functions
546  *************************************************************************/
576  System(Renderer& renderer, ResourceProvider* resourceProvider,
577  XMLParser* xmlParser, ImageCodec* imageCodec,
578  ScriptModule* scriptModule, const String& configFile,
579  const String& logFile);
580 
585  ~System(void);
586 
588  void outputLogHeader();
589 
591  void createSingletons();
592 
594  void destroySingletons();
595 
597  void setupXMLParser();
598 
600  void cleanupXMLParser();
601 
603  void setupImageCodec(const String& codecName);
604 
606  void cleanupImageCodec();
607 
609  void invalidateAllWindows();
610 
611  /*************************************************************************
612  Implementation Data
613  *************************************************************************/
616  bool d_ourResourceProvider;
617 
619 
620  // scripting
623 
626  DynamicModule* d_parserModule;
627 
629 
644 
645  typedef std::vector<GUIContext* CEGUI_VECTOR_ALLOC(GUIContext*)> GUIContextCollection;
646  GUIContextCollection d_guiContexts;
648 #if defined(__WIN32__) || defined(_WIN32)
649  static const Win32StringTranscoder d_stringTranscoder;
650 #else
652 #endif
653 };
654 
655 } // End of CEGUI namespace section
656 
657 
658 #if defined(_MSC_VER)
659 # pragma warning(pop)
660 #endif
661 
662 #endif // end of guard _CEGUISystem_h_