Crazy Eddie's GUI System  0.8.7
System.h
1 /***********************************************************************
2  created: 20/2/2004
3  author: Paul D Turner
4 
5  purpose: Defines interface for main GUI system class
6 *************************************************************************/
7 /***************************************************************************
8  * Copyright (C) 2004 - 2012 Paul D Turner & The CEGUI Development Team
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining
11  * a copy of this software and associated documentation files (the
12  * "Software"), to deal in the Software without restriction, including
13  * without limitation the rights to use, copy, modify, merge, publish,
14  * distribute, sublicense, and/or sell copies of the Software, and to
15  * permit persons to whom the Software is furnished to do so, subject to
16  * the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be
19  * included in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27  * OTHER DEALINGS IN THE SOFTWARE.
28  ***************************************************************************/
29 #ifndef _CEGUISystem_h_
30 #define _CEGUISystem_h_
31 
32 #include "CEGUI/Base.h"
33 #include "CEGUI/String.h"
34 #include "CEGUI/Singleton.h"
35 #include "CEGUI/EventSet.h"
36 #include "CEGUI/Renderer.h"
37 #include "CEGUI/InputEvent.h"
38 #include "CEGUI/ResourceProvider.h"
39 #include <vector>
40 
41 #if defined(__WIN32__) || defined(_WIN32)
42 # include "CEGUI/Win32StringTranscoder.h"
43 #else
44 # include "CEGUI/IconvStringTranscoder.h"
45 #endif
46 
47 #if defined(_MSC_VER)
48 # pragma warning(push)
49 # pragma warning(disable : 4275)
50 # pragma warning(disable : 4251)
51 #endif
52 
53 
54 // Start of CEGUI namespace section
55 namespace CEGUI
56 {
65 class CEGUIEXPORT System :
66  public Singleton<System>,
67  public EventSet,
68  public AllocatedObject<System>
69 {
70 public:
71  static const String EventNamespace;
72 
73  /*************************************************************************
74  Constants
75  *************************************************************************/
76  // event names
87 
88  /*************************************************************************
89  Construction and Destruction
90  *************************************************************************/
123  static System& create(Renderer& renderer,
124  ResourceProvider* resourceProvider = 0,
125  XMLParser* xmlParser = 0,
126  ImageCodec* imageCodec = 0,
127  ScriptModule* scriptModule = 0,
128  const String& configFile = "",
129  const String& logFile = "CEGUI.log",
130  const int abi = CEGUI_VERSION_ABI);
131 
133  static void destroy();
134 
143  static unsigned int getMajorVersion();
144 
153  static unsigned int getMinorVersion();
154 
163  static unsigned int getPatchVersion();
164 
173  static const String& getVersion();
174 
183  static const String& getVerboseVersion();
184 
192  Renderer* getRenderer(void) const {return d_renderer;}
193 
194 
202  static System& getSingleton(void);
203 
204 
212  static System* getSingletonPtr(void);
213 
218  Clipboard* getClipboard() const {return d_clipboard;}
219 
220  GUIContext& getDefaultGUIContext() const;
221 
229 
230 
239 
250  void setScriptingModule(ScriptModule* scriptModule);
251 
260 
271  void executeScriptFile(const String& filename, const String& resourceGroup = "") const;
272 
273 
285  int executeScriptGlobal(const String& function_name) const;
286 
287 
298  void executeScriptString(const String& str) const;
299 
300 
313  void setXMLParser(const String& parserName);
314 
332  void setXMLParser(XMLParser* parser);
333 
338  XMLParser* getXMLParser(void) const { return d_xmlParser; }
339 
340 
385  static void setDefaultXMLParserName(const String& parserName);
386 
397 
403 
408  void setImageCodec(const String& codecName);
409 
420  void setImageCodec(ImageCodec& codec);
421 
426  static void setDefaultImageCodecName(const String& codecName);
427 
433 
451  void notifyDisplaySizeChanged(const Sizef& new_size);
452 
467 
483 
495 
510 
513 
515  bool injectTimePulse(float timeElapsed);
516 
517  GUIContext& createGUIContext(RenderTarget& rt);
518  void destroyGUIContext(GUIContext& context);
519 
529 
532 
534  static void performVersionTest(const int expected, const int received,
535  const String& func);
536 
537 private:
538  // unimplemented constructors / assignment
539  System(const System& obj);
540  System& operator=(const System& obj);
541 
542 protected:
543  /*************************************************************************
544  Implementation Functions
545  *************************************************************************/
575  System(Renderer& renderer, ResourceProvider* resourceProvider,
576  XMLParser* xmlParser, ImageCodec* imageCodec,
577  ScriptModule* scriptModule, const String& configFile,
578  const String& logFile);
579 
584  ~System(void);
585 
588 
591 
594 
597 
600 
602  void setupImageCodec(const String& codecName);
603 
606 
609 
610  /*************************************************************************
611  Implementation Data
612  *************************************************************************/
615  bool d_ourResourceProvider;
616 
618 
619  // scripting
622 
625  DynamicModule* d_parserModule;
626 
628 
643 
644  typedef std::vector<GUIContext* CEGUI_VECTOR_ALLOC(GUIContext*)> GUIContextCollection;
645  GUIContextCollection d_guiContexts;
647 #if defined(__WIN32__) || defined(_WIN32)
648  static const Win32StringTranscoder d_stringTranscoder;
649 #else
651 #endif
652 };
653 
654 } // End of CEGUI namespace section
655 
656 
657 #if defined(_MSC_VER)
658 # pragma warning(pop)
659 #endif
660 
661 #endif // end of guard _CEGUISystem_h_
CEGUI::Clipboard
Defines a clipboard handling class.
Definition: Clipboard.h:84
CEGUI::System::addStandardWindowFactories
void addStandardWindowFactories()
adds factories for all the basic window types
CEGUI::System::invalidateAllCachedRendering
void invalidateAllCachedRendering()
Invalidate all imagery and geometry caches for CEGUI managed elements.
CEGUI::System::d_ourXmlParser
bool d_ourXmlParser
true when we created the xml parser.
Definition: System.h:624
CEGUI::System::d_renderer
Renderer * d_renderer
Holds the pointer to the Renderer object given to us in the constructor.
Definition: System.h:613
CEGUI::ResourceProvider
Abstract class that defines the required interface for all resource provider sub-classes.
Definition: ResourceProvider.h:49
CEGUI::System::getVersion
static const String & getVersion()
Retrieves CEGUI's "short" version ("1.2.3" for example)
CEGUI::Singleton
Definition: Singleton.h:56
CEGUI::System::setDefaultCustomRenderedStringParser
void setDefaultCustomRenderedStringParser(RenderedStringParser *parser)
Set the global default custom RenderedStringParser object. This change is reflected the next time an ...
CEGUI::DynamicModule
Class that wraps and gives access to a dynamically linked module (.dll, .so, etc.....
Definition: DynamicModule.h:43
CEGUI::System::getImageCodec
ImageCodec & getImageCodec() const
Retrieve the image codec to be used by the system.
CEGUI::System::d_stringTranscoder
static const IconvStringTranscoder d_stringTranscoder
instance of class that can convert string encodings
Definition: System.h:650
CEGUI::System::d_termScriptName
String d_termScriptName
Name of the script to run upon system shutdown.
Definition: System.h:621
CEGUI::System::getDefaultCustomRenderedStringParser
RenderedStringParser * getDefaultCustomRenderedStringParser() const
Return pointer to the currently set global default custom RenderedStringParser object.
CEGUI::System::~System
~System(void)
Destructor for System objects.
CEGUI::System::createRegexMatcher
RegexMatcher * createRegexMatcher() const
Create a RegexMatcher instance if support is available.
CEGUI::System::getResourceProvider
ResourceProvider * getResourceProvider(void) const
Return a pointer to the ResourceProvider being used within the GUI system.
CEGUI::System::notifyDisplaySizeChanged
void notifyDisplaySizeChanged(const Sizef &new_size)
Notification function to be called when the main display changes size. Client code should call this f...
CEGUI::System::setupXMLParser
void setupXMLParser()
handle creation and initialisation of the XML parser.
CEGUI::System::setImageCodec
void setImageCodec(ImageCodec &codec)
Set the image codec to use from an existing image codec.
CEGUI::System::create
static System & create(Renderer &renderer, ResourceProvider *resourceProvider=0, XMLParser *xmlParser=0, ImageCodec *imageCodec=0, ScriptModule *scriptModule=0, const String &configFile="", const String &logFile="CEGUI.log", const int abi=CEGUI_VERSION_ABI)
Create the System object and return a reference to it.
CEGUI::System::performVersionTest
static void performVersionTest(const int expected, const int received, const String &func)
Internal CEGUI version validation function.
CEGUI::System::d_imageCodec
ImageCodec * d_imageCodec
Holds a pointer to the image codec to use.
Definition: System.h:630
CEGUI::System::setDefaultImageCodecName
static void setDefaultImageCodecName(const String &codecName)
Set the name of the default image codec to be used.
CEGUI::System::getRenderer
Renderer * getRenderer(void) const
Return a pointer to the Renderer object being used by the system.
Definition: System.h:192
CEGUI
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
CEGUI::EventSet
Interface providing event signaling and handling.
Definition: EventSet.h:167
CEGUI::System::getDefaultImageCodecName
static const String & getDefaultImageCodecName()
Get the name of the default image codec.
CEGUI::System::d_xmlParser
XMLParser * d_xmlParser
XMLParser object we use to process xml files.
Definition: System.h:623
CEGUI::RegexMatcher
Interface for Regex matching support classes.
Definition: RegexMatcher.h:41
CEGUI::System::d_customRenderedStringParser
RenderedStringParser * d_customRenderedStringParser
currently set global RenderedStringParser.
Definition: System.h:642
CEGUI::System::setImageCodec
void setImageCodec(const String &codecName)
Set the image codec to be used by the system.
CEGUI::System::getPatchVersion
static unsigned int getPatchVersion()
Retrieves CEGUI's patch version as an integer.
CEGUI::System::System
System(Renderer &renderer, ResourceProvider *resourceProvider, XMLParser *xmlParser, ImageCodec *imageCodec, ScriptModule *scriptModule, const String &configFile, const String &logFile)
Construct a new System object.
CEGUI::AllocatedObject
Definition: MemoryAllocatedObject.h:110
CEGUI::System::renderAllGUIContexts
void renderAllGUIContexts()
Depending upon the internal state, for each GUIContext this may either re-use cached rendering from l...
CEGUI::System::getScriptingModule
ScriptModule * getScriptingModule(void) const
Return a pointer to the ScriptModule being used for scripting within the GUI system.
CEGUI::System::getSingleton
static System & getSingleton(void)
Return singleton System object.
CEGUI::System::cleanupXMLParser
void cleanupXMLParser()
handle cleanup of the XML parser
CEGUI::System::cleanupImageCodec
void cleanupImageCodec()
cleanup image codec
CEGUI::System::d_scriptModule
ScriptModule * d_scriptModule
Points to the scripting support module.
Definition: System.h:620
CEGUI::System::getVerboseVersion
static const String & getVerboseVersion()
Retrieves CEGUI's "verbose" version, includes info about compiler, platform, etc.....
CEGUI::System::EventDisplaySizeChanged
static const String EventDisplaySizeChanged
Definition: System.h:82
CEGUI::System::getMajorVersion
static unsigned int getMajorVersion()
Retrieves CEGUI's major version as an integer.
CEGUI::System::getStringTranscoder
static const StringTranscoder & getStringTranscoder()
Return the system StringTranscoder object.
CEGUI::System::d_ourImageCodec
bool d_ourImageCodec
true when we created the image codec.
Definition: System.h:632
CEGUI::System::destroy
static void destroy()
Destroy the System object.
CEGUI::System::setXMLParser
void setXMLParser(XMLParser *parser)
Sets the XMLParser object to be used by the system.
CEGUI::System::d_ourLogger
bool d_ourLogger
true when we created the CEGUI::Logger based object.
Definition: System.h:640
CEGUI::XMLParser
This is an abstract class that is used by CEGUI to interface with XML parser libraries.
Definition: XMLParser.h:44
CEGUI::System::getSingletonPtr
static System * getSingletonPtr(void)
Return pointer to singleton System object.
CEGUI::System::setScriptingModule
void setScriptingModule(ScriptModule *scriptModule)
Set the ScriptModule to be used for scripting within the GUI system.
CEGUI::System::getXMLParser
XMLParser * getXMLParser(void) const
Return the XMLParser object.
Definition: System.h:338
CEGUI::System::d_clipboard
Clipboard * d_clipboard
Internal clipboard with optional sync with native clipboard.
Definition: System.h:617
CEGUI::System::destroyRegexMatcher
void destroyRegexMatcher(RegexMatcher *rm) const
destroy a RegexMatcher instance returned by System::createRegexMatcher.
CEGUI::System::outputLogHeader
void outputLogHeader()
output the standard log header
CEGUI::System::setDefaultXMLParserName
static void setDefaultXMLParserName(const String &parserName)
Static member to set the name of the default XML parser module that should be used.
CEGUI::ImageCodec
Abstract ImageLoader class. An image loader encapsulate the loading of a texture.
Definition: ImageCodec.h:47
CEGUI::System::setXMLParser
void setXMLParser(const String &parserName)
Set a new XML parser module to be used.
CEGUI::System::EventNamespace
static const String EventNamespace
Namespace for global events.
Definition: System.h:71
CEGUI::System::d_defaultImageCodecName
static String d_defaultImageCodecName
Holds the name of the default codec to use.
Definition: System.h:638
CEGUI::System::executeScriptGlobal
int executeScriptGlobal(const String &function_name) const
Execute a scripted global function if possible. The function should not take any parameters and shoul...
CEGUI::RenderedStringParser
Specifies interface for classes that parse text into RenderedString objects.
Definition: RenderedStringParser.h:39
CEGUI::System::getDefaultXMLParserName
static const String getDefaultXMLParserName()
Return the name of the currently set default xml parser module.
CEGUI::StringTranscoder
Interface for a string transcoding utility. Instances of classes that implement this interface can be...
Definition: StringTranscoder.h:43
CEGUI::Win32StringTranscoder
Implementation of StringTranscoder that uses Win32.
Definition: Win32StringTranscoder.h:37
CEGUI::RenderTarget
Defines interface to some surface that can be rendered to. Concrete instances of objects that impleme...
Definition: RenderTarget.h:60
CEGUI::System::injectTimePulse
bool injectTimePulse(float timeElapsed)
call this to ensure system-level time based updates occur.
CEGUI::Size< float >
CEGUI::System::invalidateAllWindows
void invalidateAllWindows()
invalidate all windows and any rendering surfaces they may be using.
CEGUI::GUIContext
Definition: GUIContext.h:70
CEGUI::System
The System class is the CEGUI class that provides access to all other elements in this system.
Definition: System.h:69
CEGUI::System::d_resourceProvider
ResourceProvider * d_resourceProvider
Holds the pointer to the ResourceProvider object given to us by the renderer or the System constructo...
Definition: System.h:614
CEGUI::String
String class used within the GUI system.
Definition: String.h:64
CEGUI::System::getMinorVersion
static unsigned int getMinorVersion()
Retrieves CEGUI's minor version as an integer.
CEGUI::System::d_defaultXMLParserName
static String d_defaultXMLParserName
pointer to parser module.
Definition: System.h:627
CEGUI::System::destroySingletons
void destroySingletons()
cleanup the core system singleton objects
CEGUI::IconvStringTranscoder
Implementation of StringTranscoder that uses iconv.
Definition: IconvStringTranscoder.h:37
CEGUI::System::createSingletons
void createSingletons()
create the other core system singleton objects (except the logger)
CEGUI::System::executeScriptFile
void executeScriptFile(const String &filename, const String &resourceGroup="") const
Execute a script file if possible.
CEGUI::Renderer
Abstract class defining the basic required interface for Renderer objects.
Definition: Renderer.h:84
CEGUI::System::d_imageCodecModule
DynamicModule * d_imageCodecModule
Definition: System.h:636
CEGUI::System::getClipboard
Clipboard * getClipboard() const
Retrieves internal CEGUI clipboard, optionally synced with system wide clipboard.
Definition: System.h:218
CEGUI::System::EventRenderedStringParserChanged
static const String EventRenderedStringParserChanged
Definition: System.h:86
CEGUI::ScriptModule
Abstract interface required for all scripting support modules to be used with the CEGUI system.
Definition: ScriptModule.h:47
CEGUI::System::setupImageCodec
void setupImageCodec(const String &codecName)
setup image codec
CEGUI::System::executeScriptString
void executeScriptString(const String &str) const
If possible, execute script code contained in the given CEGUI::String object.