Crazy Eddies GUI System  0.7.2
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
117 
118  /*************************************************************************
119  Construction and Destruction
120  *************************************************************************/
150  static System& create(Renderer& renderer,
151  ResourceProvider* resourceProvider = 0,
152  XMLParser* xmlParser = 0,
153  ImageCodec* imageCodec = 0,
154  ScriptModule* scriptModule = 0,
155  const String& configFile = "",
156  const String& logFile = "CEGUI.log");
157 
159  static void destroy();
160 
168  Renderer* getRenderer(void) const {return d_renderer;}
169 
170 
178  static System& getSingleton(void);
179 
180 
188  static System* getSingletonPtr(void);
189 
190 
201  void setDefaultFont(const String& name);
202 
203 
214  void setDefaultFont(Font* font);
215 
216 
224  Font* getDefaultFont(void) const {return d_defaultFont;}
225 
226 
234  void signalRedraw() {d_gui_redraw = true;}
235 
236 
244  bool isRedrawRequested() const {return d_gui_redraw;}
245 
246 
256  void renderGUI(void);
257 
258 
269  Window* setGUISheet(Window* sheet);
270 
271 
279  Window* getGUISheet(void) const {return d_activeSheet;}
280 
281 
291  double getSingleClickTimeout(void) const {return d_click_timeout;}
292 
293 
305  double getMultiClickTimeout(void) const {return d_dblclick_timeout;}
306 
307 
318  const Size& getMultiClickToleranceAreaSize(void) const {return d_dblclick_size;}
319 
320 
340  void setSingleClickTimeout(double timeout);
341 
342 
363  void setMultiClickTimeout(double timeout);
364 
365 
379  void setMultiClickToleranceAreaSize(const Size& sz);
380 
394  bool isMouseClickEventGenerationEnabled() const;
395 
409  void setMouseClickEventGenerationEnabled(const bool enable);
410 
419  const Image* getDefaultMouseCursor(void) const {return d_defaultMouseCursor;}
420 
421 
433  void setDefaultMouseCursor(const Image* image);
434 
435 
447 
448 
464  void setDefaultMouseCursor(const String& imageset, const String& image_name);
465 
466 
474  Window* getWindowContainingMouse(void) const {return d_wndWithMouse;}
475 
476 
484  ScriptModule* getScriptingModule(void) const;
485 
496  void setScriptingModule(ScriptModule* scriptModule);
497 
505  ResourceProvider* getResourceProvider(void) const;
506 
517  void executeScriptFile(const String& filename, const String& resourceGroup = "") const;
518 
519 
531  int executeScriptGlobal(const String& function_name) const;
532 
533 
544  void executeScriptString(const String& str) const;
545 
546 
554  float getMouseMoveScaling(void) const;
555 
556 
567  void setMouseMoveScaling(float scaling);
568 
569 
578  void notifyWindowDestroyed(const Window* window);
579 
580 
588  uint getSystemKeys(void) const { return d_sysKeys; }
589 
602  void setXMLParser(const String& parserName);
603 
621  void setXMLParser(XMLParser* parser);
622 
627  XMLParser* getXMLParser(void) const { return d_xmlParser; }
628 
629 
643  void setDefaultTooltip(Tooltip* tooltip);
644 
660  void setDefaultTooltip(const String& tooltipType);
661 
670  Tooltip* getDefaultTooltip(void) const { return d_defaultTooltip; }
671 
672 
681  void setModalTarget(Window* target) {d_modalTarget = target;}
682 
690  Window* getModalTarget(void) const {return d_modalTarget;}
691 
736  static void setDefaultXMLParserName(const String& parserName);
737 
747  static const String getDefaultXMLParserName();
748 
763  bool updateWindowContainingMouse();
764 
769  ImageCodec& getImageCodec() const;
770 
775  void setImageCodec(const String& codecName);
776 
787  void setImageCodec(ImageCodec& codec);
788 
793  static void setDefaultImageCodecName(const String& codecName);
794 
799  static const String& getDefaultImageCodecName();
800 
818  void notifyDisplaySizeChanged(const Size& new_size);
819 
833  RenderedStringParser* getDefaultCustomRenderedStringParser() const;
834 
849  void setDefaultCustomRenderedStringParser(RenderedStringParser* parser);
850 
861  void invalidateAllCachedRendering();
862 
863  /*************************************************************************
864  Input injection interface
865  *************************************************************************/
880  bool injectMouseMove(float delta_x, float delta_y);
881 
882 
891  bool injectMouseLeaves(void);
892 
893 
905  bool injectMouseButtonDown(MouseButton button);
906 
907 
919  bool injectMouseButtonUp(MouseButton button);
920 
921 
933  bool injectKeyDown(uint key_code);
934 
935 
947  bool injectKeyUp(uint key_code);
948 
949 
961  bool injectChar(utf32 code_point);
962 
963 
975  bool injectMouseWheelChange(float delta);
976 
977 
992  bool injectMousePosition(float x_pos, float y_pos);
993 
994 
1005  bool injectTimePulse(float timeElapsed);
1006 
1031  bool injectMouseButtonClick(const MouseButton button);
1032 
1057  bool injectMouseButtonDoubleClick(const MouseButton button);
1058 
1083  bool injectMouseButtonTripleClick(const MouseButton button);
1084 
1085 private:
1086  // unimplemented constructors / assignment
1087  System(const System& obj);
1088  System& operator=(const System& obj);
1089 
1090  /*************************************************************************
1091  Implementation Functions
1092  *************************************************************************/
1122  System(Renderer& renderer, ResourceProvider* resourceProvider,
1123  XMLParser* xmlParser, ImageCodec* imageCodec,
1124  ScriptModule* scriptModule, const String& configFile,
1125  const String& logFile);
1126 
1131  ~System(void);
1132 
1146  Window* getTargetWindow(const Point& pt, const bool allow_disabled) const;
1147 
1148 
1156  Window* getKeyboardTargetWindow(void) const;
1157 
1158 
1169  Window* getNextTargetWindow(Window* w) const;
1170 
1171 
1182  SystemKey mouseButtonToSyskey(MouseButton btn) const;
1183 
1184 
1200  SystemKey keyCodeToSyskey(Key::Scan key, bool direction);
1201 
1203  void outputLogHeader();
1204 
1206  void addStandardWindowFactories();
1207 
1209  void createSingletons();
1210 
1212  void destroySingletons();
1213 
1215  void setupXMLParser();
1216 
1218  void cleanupXMLParser();
1219 
1221  bool mouseMoveInjection_impl(MouseEventArgs& ma);
1222 
1224  void setupImageCodec(const String& codecName);
1225 
1227  void cleanupImageCodec();
1228 
1230  void initialiseVersionString();
1231 
1233  void invalidateAllWindows();
1234 
1236  Window* getCommonAncestor(Window* w1, Window* w2);
1237 
1239  void notifyMouseTransition(Window* top, Window* bottom,
1240  void (Window::*func)(MouseEventArgs&),
1241  MouseEventArgs& args);
1242 
1243  /*************************************************************************
1244  Handlers for System events
1245  *************************************************************************/
1252  void onGUISheetChanged(WindowEventArgs& e);
1253 
1254 
1259  void onSingleClickTimeoutChanged(EventArgs& e);
1260 
1261 
1266  void onMultiClickTimeoutChanged(EventArgs& e);
1267 
1268 
1273  void onMultiClickAreaSizeChanged(EventArgs& e);
1274 
1275 
1280  void onDefaultFontChanged(EventArgs& e);
1281 
1282 
1287  void onDefaultMouseCursorChanged(EventArgs& e);
1288 
1289 
1294  void onMouseMoveScalingChanged(EventArgs& e);
1295 
1296 
1297  /*************************************************************************
1298  Implementation Data
1299  *************************************************************************/
1300  Renderer* d_renderer;
1301  ResourceProvider* d_resourceProvider;
1302  bool d_ourResourceProvider;
1303  Font* d_defaultFont;
1304  bool d_gui_redraw;
1305 
1306  Window* d_wndWithMouse;
1307  Window* d_activeSheet;
1308  Window* d_modalTarget;
1309 
1310  String d_strVersion;
1311 
1312  uint d_sysKeys;
1313  bool d_lshift;
1314  bool d_rshift;
1315  bool d_lctrl;
1316  bool d_rctrl;
1317  bool d_lalt;
1318  bool d_ralt;
1319 
1320  double d_click_timeout;
1321  double d_dblclick_timeout;
1322  Size d_dblclick_size;
1323 
1324  MouseClickTrackerImpl* const d_clickTrackerPimpl;
1325 
1326  // mouse cursor related
1327  const Image* d_defaultMouseCursor;
1328 
1329  // scripting
1330  ScriptModule* d_scriptModule;
1331  String d_termScriptName;
1332 
1333  float d_mouseScalingFactor;
1334 
1335  XMLParser* d_xmlParser;
1336  bool d_ourXmlParser;
1337  DynamicModule* d_parserModule;
1338 
1339  Tooltip* d_defaultTooltip;
1340  bool d_weOwnTooltip;
1341 
1342  static String d_defaultXMLParserName;
1343 
1345  ImageCodec* d_imageCodec;
1347  bool d_ourImageCodec;
1351  DynamicModule* d_imageCodecModule;
1353  static String d_defaultImageCodecName;
1355  bool d_ourLogger;
1357  RenderedStringParser* d_customRenderedStringParser;
1359  bool d_generateMouseClickEvents;
1360 };
1361 
1362 } // End of CEGUI namespace section
1363 
1364 
1365 #if defined(_MSC_VER)
1366 # pragma warning(pop)
1367 #endif
1368 
1369 #endif // end of guard _CEGUISystem_h_