Crazy Eddies GUI System  0.7.0
CEGUISystem.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 - 2009 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 "CEGUIBase.h"
34 #include "CEGUIString.h"
35 #include "CEGUISingleton.h"
36 #include "CEGUIRenderer.h"
37 #include "CEGUIMouseCursor.h"
38 #include "CEGUIInputEvent.h"
39 #include "CEGUIResourceProvider.h"
40 
41 
42 #if defined(_MSC_VER)
43 # pragma warning(push)
44 # pragma warning(disable : 4275)
45 # pragma warning(disable : 4251)
46 #endif
47 
48 
49 // Start of CEGUI namespace section
50 namespace CEGUI
51 {
53 struct MouseClickTrackerImpl;
54 
55 
64 class CEGUIEXPORT System : public Singleton<System>, public EventSet
65 {
66 public:
67  static const String EventNamespace;
68 
69  /*************************************************************************
70  Constants
71  *************************************************************************/
72  static const double DefaultSingleClickTimeout;
73  static const double DefaultMultiClickTimeout;
75 
76  // event names
84 
86 
87  /*************************************************************************
88  Construction and Destruction
89  *************************************************************************/
119  static System& create(Renderer& renderer,
120  ResourceProvider* resourceProvider = 0,
121  XMLParser* xmlParser = 0,
122  ImageCodec* imageCodec = 0,
123  ScriptModule* scriptModule = 0,
124  const String& configFile = "",
125  const String& logFile = "CEGUI.log");
126 
128  static void destroy();
129 
137  Renderer* getRenderer(void) const {return d_renderer;}
138 
139 
147  static System& getSingleton(void);
148 
149 
157  static System* getSingletonPtr(void);
158 
159 
170  void setDefaultFont(const String& name);
171 
172 
183  void setDefaultFont(Font* font);
184 
185 
193  Font* getDefaultFont(void) const {return d_defaultFont;}
194 
195 
203  void signalRedraw() {d_gui_redraw = true;}
204 
205 
213  bool isRedrawRequested() const {return d_gui_redraw;}
214 
215 
225  void renderGUI(void);
226 
227 
238  Window* setGUISheet(Window* sheet);
239 
240 
248  Window* getGUISheet(void) const {return d_activeSheet;}
249 
250 
260  double getSingleClickTimeout(void) const {return d_click_timeout;}
261 
262 
274  double getMultiClickTimeout(void) const {return d_dblclick_timeout;}
275 
276 
287  const Size& getMultiClickToleranceAreaSize(void) const {return d_dblclick_size;}
288 
289 
309  void setSingleClickTimeout(double timeout);
310 
311 
332  void setMultiClickTimeout(double timeout);
333 
334 
348  void setMultiClickToleranceAreaSize(const Size& sz);
349 
350 
359  const Image* getDefaultMouseCursor(void) const {return d_defaultMouseCursor;}
360 
361 
373  void setDefaultMouseCursor(const Image* image);
374 
375 
387 
388 
404  void setDefaultMouseCursor(const String& imageset, const String& image_name);
405 
406 
414  Window* getWindowContainingMouse(void) const {return d_wndWithMouse;}
415 
416 
424  ScriptModule* getScriptingModule(void) const;
425 
436  void setScriptingModule(ScriptModule* scriptModule);
437 
445  ResourceProvider* getResourceProvider(void) const;
446 
457  void executeScriptFile(const String& filename, const String& resourceGroup = "") const;
458 
459 
471  int executeScriptGlobal(const String& function_name) const;
472 
473 
484  void executeScriptString(const String& str) const;
485 
486 
494  float getMouseMoveScaling(void) const;
495 
496 
507  void setMouseMoveScaling(float scaling);
508 
509 
518  void notifyWindowDestroyed(const Window* window);
519 
520 
528  uint getSystemKeys(void) const { return d_sysKeys; }
529 
542  void setXMLParser(const String& parserName);
543 
561  void setXMLParser(XMLParser* parser);
562 
567  XMLParser* getXMLParser(void) const { return d_xmlParser; }
568 
569 
583  void setDefaultTooltip(Tooltip* tooltip);
584 
600  void setDefaultTooltip(const String& tooltipType);
601 
610  Tooltip* getDefaultTooltip(void) const { return d_defaultTooltip; }
611 
612 
621  void setModalTarget(Window* target) {d_modalTarget = target;}
622 
630  Window* getModalTarget(void) const {return d_modalTarget;}
631 
676  static void setDefaultXMLParserName(const String& parserName);
677 
687  static const String getDefaultXMLParserName();
688 
703  bool updateWindowContainingMouse();
704 
709  ImageCodec& getImageCodec() const;
710 
715  void setImageCodec(const String& codecName);
716 
727  void setImageCodec(ImageCodec& codec);
728 
733  static void setDefaultImageCodecName(const String& codecName);
734 
739  static const String& getDefaultImageCodecName();
740 
758  void notifyDisplaySizeChanged(const Size& new_size);
759 
760  /*************************************************************************
761  Input injection interface
762  *************************************************************************/
777  bool injectMouseMove(float delta_x, float delta_y);
778 
779 
788  bool injectMouseLeaves(void);
789 
790 
802  bool injectMouseButtonDown(MouseButton button);
803 
804 
816  bool injectMouseButtonUp(MouseButton button);
817 
818 
830  bool injectKeyDown(uint key_code);
831 
832 
844  bool injectKeyUp(uint key_code);
845 
846 
858  bool injectChar(utf32 code_point);
859 
860 
872  bool injectMouseWheelChange(float delta);
873 
874 
889  bool injectMousePosition(float x_pos, float y_pos);
890 
891 
902  bool injectTimePulse(float timeElapsed);
903 
904 
905 private:
906  // unimplemented constructors / assignment
907  System(const System& obj);
908  System& operator=(const System& obj);
909 
910  /*************************************************************************
911  Implementation Functions
912  *************************************************************************/
942  System(Renderer& renderer, ResourceProvider* resourceProvider,
943  XMLParser* xmlParser, ImageCodec* imageCodec,
944  ScriptModule* scriptModule, const String& configFile,
945  const String& logFile);
946 
951  ~System(void);
952 
966  Window* getTargetWindow(const Point& pt, const bool allow_disabled) const;
967 
968 
976  Window* getKeyboardTargetWindow(void) const;
977 
978 
989  Window* getNextTargetWindow(Window* w) const;
990 
991 
1002  SystemKey mouseButtonToSyskey(MouseButton btn) const;
1003 
1004 
1020  SystemKey keyCodeToSyskey(Key::Scan key, bool direction);
1021 
1023  void outputLogHeader();
1024 
1026  void addStandardWindowFactories();
1027 
1029  void createSingletons();
1030 
1032  void destroySingletons();
1033 
1035  void setupXMLParser();
1036 
1038  void cleanupXMLParser();
1039 
1041  bool mouseMoveInjection_impl(MouseEventArgs& ma);
1042 
1044  void setupImageCodec(const String& codecName);
1045 
1047  void cleanupImageCodec();
1048 
1050  void initialiseVersionString();
1051 
1052  /*************************************************************************
1053  Handlers for System events
1054  *************************************************************************/
1061  void onGUISheetChanged(WindowEventArgs& e);
1062 
1063 
1068  void onSingleClickTimeoutChanged(EventArgs& e);
1069 
1070 
1075  void onMultiClickTimeoutChanged(EventArgs& e);
1076 
1077 
1082  void onMultiClickAreaSizeChanged(EventArgs& e);
1083 
1084 
1089  void onDefaultFontChanged(EventArgs& e);
1090 
1091 
1096  void onDefaultMouseCursorChanged(EventArgs& e);
1097 
1098 
1103  void onMouseMoveScalingChanged(EventArgs& e);
1104 
1105 
1106  /*************************************************************************
1107  Implementation Data
1108  *************************************************************************/
1109  Renderer* d_renderer;
1110  ResourceProvider* d_resourceProvider;
1111  bool d_ourResourceProvider;
1112  Font* d_defaultFont;
1113  bool d_gui_redraw;
1114 
1115  Window* d_wndWithMouse;
1116  Window* d_activeSheet;
1117  Window* d_modalTarget;
1118 
1119  String d_strVersion;
1120 
1121  uint d_sysKeys;
1122  bool d_lshift;
1123  bool d_rshift;
1124  bool d_lctrl;
1125  bool d_rctrl;
1126  bool d_lalt;
1127  bool d_ralt;
1128 
1129  double d_click_timeout;
1130  double d_dblclick_timeout;
1131  Size d_dblclick_size;
1132 
1133  MouseClickTrackerImpl* const d_clickTrackerPimpl;
1134 
1135  // mouse cursor related
1136  const Image* d_defaultMouseCursor;
1137 
1138  // scripting
1139  ScriptModule* d_scriptModule;
1140  String d_termScriptName;
1141 
1142  float d_mouseScalingFactor;
1143 
1144  XMLParser* d_xmlParser;
1145  bool d_ourXmlParser;
1146  DynamicModule* d_parserModule;
1147 
1148  Tooltip* d_defaultTooltip;
1149  bool d_weOwnTooltip;
1150 
1151  static String d_defaultXMLParserName;
1152 
1154  ImageCodec* d_imageCodec;
1158  DynamicModule* d_imageCodecModule;
1160  static String d_defaultImageCodecName;
1162  bool d_ourLogger;
1163 };
1164 
1165 } // End of CEGUI namespace section
1166 
1167 
1168 #if defined(_MSC_VER)
1169 # pragma warning(pop)
1170 #endif
1171 
1172 #endif // end of guard _CEGUISystem_h_