Crazy Eddies GUI System  0.7.1
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 
88 
89  /*************************************************************************
90  Construction and Destruction
91  *************************************************************************/
121  static System& create(Renderer& renderer,
122  ResourceProvider* resourceProvider = 0,
123  XMLParser* xmlParser = 0,
124  ImageCodec* imageCodec = 0,
125  ScriptModule* scriptModule = 0,
126  const String& configFile = "",
127  const String& logFile = "CEGUI.log");
128 
130  static void destroy();
131 
139  Renderer* getRenderer(void) const {return d_renderer;}
140 
141 
149  static System& getSingleton(void);
150 
151 
159  static System* getSingletonPtr(void);
160 
161 
172  void setDefaultFont(const String& name);
173 
174 
185  void setDefaultFont(Font* font);
186 
187 
195  Font* getDefaultFont(void) const {return d_defaultFont;}
196 
197 
205  void signalRedraw() {d_gui_redraw = true;}
206 
207 
215  bool isRedrawRequested() const {return d_gui_redraw;}
216 
217 
227  void renderGUI(void);
228 
229 
240  Window* setGUISheet(Window* sheet);
241 
242 
250  Window* getGUISheet(void) const {return d_activeSheet;}
251 
252 
262  double getSingleClickTimeout(void) const {return d_click_timeout;}
263 
264 
276  double getMultiClickTimeout(void) const {return d_dblclick_timeout;}
277 
278 
289  const Size& getMultiClickToleranceAreaSize(void) const {return d_dblclick_size;}
290 
291 
311  void setSingleClickTimeout(double timeout);
312 
313 
334  void setMultiClickTimeout(double timeout);
335 
336 
350  void setMultiClickToleranceAreaSize(const Size& sz);
351 
365  bool isMouseClickEventGenerationEnabled() const;
366 
380  void setMouseClickEventGenerationEnabled(const bool enable);
381 
390  const Image* getDefaultMouseCursor(void) const {return d_defaultMouseCursor;}
391 
392 
404  void setDefaultMouseCursor(const Image* image);
405 
406 
418 
419 
435  void setDefaultMouseCursor(const String& imageset, const String& image_name);
436 
437 
445  Window* getWindowContainingMouse(void) const {return d_wndWithMouse;}
446 
447 
455  ScriptModule* getScriptingModule(void) const;
456 
467  void setScriptingModule(ScriptModule* scriptModule);
468 
476  ResourceProvider* getResourceProvider(void) const;
477 
488  void executeScriptFile(const String& filename, const String& resourceGroup = "") const;
489 
490 
502  int executeScriptGlobal(const String& function_name) const;
503 
504 
515  void executeScriptString(const String& str) const;
516 
517 
525  float getMouseMoveScaling(void) const;
526 
527 
538  void setMouseMoveScaling(float scaling);
539 
540 
549  void notifyWindowDestroyed(const Window* window);
550 
551 
559  uint getSystemKeys(void) const { return d_sysKeys; }
560 
573  void setXMLParser(const String& parserName);
574 
592  void setXMLParser(XMLParser* parser);
593 
598  XMLParser* getXMLParser(void) const { return d_xmlParser; }
599 
600 
614  void setDefaultTooltip(Tooltip* tooltip);
615 
631  void setDefaultTooltip(const String& tooltipType);
632 
641  Tooltip* getDefaultTooltip(void) const { return d_defaultTooltip; }
642 
643 
652  void setModalTarget(Window* target) {d_modalTarget = target;}
653 
661  Window* getModalTarget(void) const {return d_modalTarget;}
662 
707  static void setDefaultXMLParserName(const String& parserName);
708 
718  static const String getDefaultXMLParserName();
719 
734  bool updateWindowContainingMouse();
735 
740  ImageCodec& getImageCodec() const;
741 
746  void setImageCodec(const String& codecName);
747 
758  void setImageCodec(ImageCodec& codec);
759 
764  static void setDefaultImageCodecName(const String& codecName);
765 
770  static const String& getDefaultImageCodecName();
771 
789  void notifyDisplaySizeChanged(const Size& new_size);
790 
804  RenderedStringParser* getDefaultCustomRenderedStringParser() const;
805 
820  void setDefaultCustomRenderedStringParser(RenderedStringParser* parser);
821 
822  /*************************************************************************
823  Input injection interface
824  *************************************************************************/
839  bool injectMouseMove(float delta_x, float delta_y);
840 
841 
850  bool injectMouseLeaves(void);
851 
852 
864  bool injectMouseButtonDown(MouseButton button);
865 
866 
878  bool injectMouseButtonUp(MouseButton button);
879 
880 
892  bool injectKeyDown(uint key_code);
893 
894 
906  bool injectKeyUp(uint key_code);
907 
908 
920  bool injectChar(utf32 code_point);
921 
922 
934  bool injectMouseWheelChange(float delta);
935 
936 
951  bool injectMousePosition(float x_pos, float y_pos);
952 
953 
964  bool injectTimePulse(float timeElapsed);
965 
990  bool injectMouseButtonClick(const MouseButton button);
991 
1016  bool injectMouseButtonDoubleClick(const MouseButton button);
1017 
1042  bool injectMouseButtonTripleClick(const MouseButton button);
1043 
1044 private:
1045  // unimplemented constructors / assignment
1046  System(const System& obj);
1047  System& operator=(const System& obj);
1048 
1049  /*************************************************************************
1050  Implementation Functions
1051  *************************************************************************/
1081  System(Renderer& renderer, ResourceProvider* resourceProvider,
1082  XMLParser* xmlParser, ImageCodec* imageCodec,
1083  ScriptModule* scriptModule, const String& configFile,
1084  const String& logFile);
1085 
1090  ~System(void);
1091 
1105  Window* getTargetWindow(const Point& pt, const bool allow_disabled) const;
1106 
1107 
1115  Window* getKeyboardTargetWindow(void) const;
1116 
1117 
1128  Window* getNextTargetWindow(Window* w) const;
1129 
1130 
1141  SystemKey mouseButtonToSyskey(MouseButton btn) const;
1142 
1143 
1159  SystemKey keyCodeToSyskey(Key::Scan key, bool direction);
1160 
1162  void outputLogHeader();
1163 
1165  void addStandardWindowFactories();
1166 
1168  void createSingletons();
1169 
1171  void destroySingletons();
1172 
1174  void setupXMLParser();
1175 
1177  void cleanupXMLParser();
1178 
1180  bool mouseMoveInjection_impl(MouseEventArgs& ma);
1181 
1183  void setupImageCodec(const String& codecName);
1184 
1186  void cleanupImageCodec();
1187 
1189  void initialiseVersionString();
1190 
1191  /*************************************************************************
1192  Handlers for System events
1193  *************************************************************************/
1200  void onGUISheetChanged(WindowEventArgs& e);
1201 
1202 
1207  void onSingleClickTimeoutChanged(EventArgs& e);
1208 
1209 
1214  void onMultiClickTimeoutChanged(EventArgs& e);
1215 
1216 
1221  void onMultiClickAreaSizeChanged(EventArgs& e);
1222 
1223 
1228  void onDefaultFontChanged(EventArgs& e);
1229 
1230 
1235  void onDefaultMouseCursorChanged(EventArgs& e);
1236 
1237 
1242  void onMouseMoveScalingChanged(EventArgs& e);
1243 
1244 
1245  /*************************************************************************
1246  Implementation Data
1247  *************************************************************************/
1248  Renderer* d_renderer;
1249  ResourceProvider* d_resourceProvider;
1250  bool d_ourResourceProvider;
1251  Font* d_defaultFont;
1252  bool d_gui_redraw;
1253 
1254  Window* d_wndWithMouse;
1255  Window* d_activeSheet;
1256  Window* d_modalTarget;
1257 
1258  String d_strVersion;
1259 
1260  uint d_sysKeys;
1261  bool d_lshift;
1262  bool d_rshift;
1263  bool d_lctrl;
1264  bool d_rctrl;
1265  bool d_lalt;
1266  bool d_ralt;
1267 
1268  double d_click_timeout;
1269  double d_dblclick_timeout;
1270  Size d_dblclick_size;
1271 
1272  MouseClickTrackerImpl* const d_clickTrackerPimpl;
1273 
1274  // mouse cursor related
1275  const Image* d_defaultMouseCursor;
1276 
1277  // scripting
1278  ScriptModule* d_scriptModule;
1279  String d_termScriptName;
1280 
1281  float d_mouseScalingFactor;
1282 
1283  XMLParser* d_xmlParser;
1284  bool d_ourXmlParser;
1285  DynamicModule* d_parserModule;
1286 
1287  Tooltip* d_defaultTooltip;
1288  bool d_weOwnTooltip;
1289 
1290  static String d_defaultXMLParserName;
1291 
1293  ImageCodec* d_imageCodec;
1295  bool d_ourImageCodec;
1299  DynamicModule* d_imageCodecModule;
1301  static String d_defaultImageCodecName;
1303  bool d_ourLogger;
1305  RenderedStringParser* d_customRenderedStringParser;
1307  bool d_generateMouseClickEvents;
1308 };
1309 
1310 } // End of CEGUI namespace section
1311 
1312 
1313 #if defined(_MSC_VER)
1314 # pragma warning(pop)
1315 #endif
1316 
1317 #endif // end of guard _CEGUISystem_h_