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;
671 
680  void setModalTarget(Window* target) {d_modalTarget = target;}
681 
689  Window* getModalTarget(void) const {return d_modalTarget;}
690 
735  static void setDefaultXMLParserName(const String& parserName);
736 
746  static const String getDefaultXMLParserName();
747 
762  bool updateWindowContainingMouse();
763 
768  ImageCodec& getImageCodec() const;
769 
774  void setImageCodec(const String& codecName);
775 
786  void setImageCodec(ImageCodec& codec);
787 
792  static void setDefaultImageCodecName(const String& codecName);
793 
798  static const String& getDefaultImageCodecName();
799 
817  void notifyDisplaySizeChanged(const Size& new_size);
818 
832  RenderedStringParser* getDefaultCustomRenderedStringParser() const;
833 
848  void setDefaultCustomRenderedStringParser(RenderedStringParser* parser);
849 
860  void invalidateAllCachedRendering();
861 
862  /*************************************************************************
863  Input injection interface
864  *************************************************************************/
879  bool injectMouseMove(float delta_x, float delta_y);
880 
881 
890  bool injectMouseLeaves(void);
891 
892 
904  bool injectMouseButtonDown(MouseButton button);
905 
906 
918  bool injectMouseButtonUp(MouseButton button);
919 
920 
932  bool injectKeyDown(uint key_code);
933 
934 
946  bool injectKeyUp(uint key_code);
947 
948 
960  bool injectChar(utf32 code_point);
961 
962 
974  bool injectMouseWheelChange(float delta);
975 
976 
991  bool injectMousePosition(float x_pos, float y_pos);
992 
993 
1004  bool injectTimePulse(float timeElapsed);
1005 
1030  bool injectMouseButtonClick(const MouseButton button);
1031 
1056  bool injectMouseButtonDoubleClick(const MouseButton button);
1057 
1082  bool injectMouseButtonTripleClick(const MouseButton button);
1083 
1084 private:
1085  // unimplemented constructors / assignment
1086  System(const System& obj);
1087  System& operator=(const System& obj);
1088 
1089  /*************************************************************************
1090  Implementation Functions
1091  *************************************************************************/
1121  System(Renderer& renderer, ResourceProvider* resourceProvider,
1122  XMLParser* xmlParser, ImageCodec* imageCodec,
1123  ScriptModule* scriptModule, const String& configFile,
1124  const String& logFile);
1125 
1130  ~System(void);
1131 
1145  Window* getTargetWindow(const Point& pt, const bool allow_disabled) const;
1146 
1147 
1155  Window* getKeyboardTargetWindow(void) const;
1156 
1157 
1168  Window* getNextTargetWindow(Window* w) const;
1169 
1170 
1181  SystemKey mouseButtonToSyskey(MouseButton btn) const;
1182 
1183 
1199  SystemKey keyCodeToSyskey(Key::Scan key, bool direction);
1200 
1202  void outputLogHeader();
1203 
1205  void addStandardWindowFactories();
1206 
1208  void createSingletons();
1209 
1211  void destroySingletons();
1212 
1214  void setupXMLParser();
1215 
1217  void cleanupXMLParser();
1218 
1220  bool mouseMoveInjection_impl(MouseEventArgs& ma);
1221 
1223  void setupImageCodec(const String& codecName);
1224 
1226  void cleanupImageCodec();
1227 
1229  void initialiseVersionString();
1230 
1232  void invalidateAllWindows();
1233 
1235  Window* getCommonAncestor(Window* w1, Window* w2);
1236 
1238  void notifyMouseTransition(Window* top, Window* bottom,
1239  void (Window::*func)(MouseEventArgs&),
1240  MouseEventArgs& args);
1242  void createSystemOwnedDefaultTooltipWindow() const;
1244  void destroySystemOwnedDefaultTooltipWindow();
1245 
1246  /*************************************************************************
1247  Handlers for System events
1248  *************************************************************************/
1255  void onGUISheetChanged(WindowEventArgs& e);
1256 
1257 
1262  void onSingleClickTimeoutChanged(EventArgs& e);
1263 
1264 
1269  void onMultiClickTimeoutChanged(EventArgs& e);
1270 
1271 
1276  void onMultiClickAreaSizeChanged(EventArgs& e);
1277 
1278 
1283  void onDefaultFontChanged(EventArgs& e);
1284 
1285 
1290  void onDefaultMouseCursorChanged(EventArgs& e);
1291 
1292 
1297  void onMouseMoveScalingChanged(EventArgs& e);
1298 
1299 
1300  /*************************************************************************
1301  Implementation Data
1302  *************************************************************************/
1303  Renderer* d_renderer;
1304  ResourceProvider* d_resourceProvider;
1305  bool d_ourResourceProvider;
1306  Font* d_defaultFont;
1307  bool d_gui_redraw;
1308 
1309  Window* d_wndWithMouse;
1310  Window* d_activeSheet;
1311  Window* d_modalTarget;
1312 
1313  String d_strVersion;
1314 
1315  uint d_sysKeys;
1316  bool d_lshift;
1317  bool d_rshift;
1318  bool d_lctrl;
1319  bool d_rctrl;
1320  bool d_lalt;
1321  bool d_ralt;
1322 
1323  double d_click_timeout;
1324  double d_dblclick_timeout;
1325  Size d_dblclick_size;
1326 
1327  MouseClickTrackerImpl* const d_clickTrackerPimpl;
1328 
1329  // mouse cursor related
1330  const Image* d_defaultMouseCursor;
1331 
1332  // scripting
1333  ScriptModule* d_scriptModule;
1334  String d_termScriptName;
1335 
1336  float d_mouseScalingFactor;
1337 
1338  XMLParser* d_xmlParser;
1339  bool d_ourXmlParser;
1340  DynamicModule* d_parserModule;
1341 
1343  mutable Tooltip* d_defaultTooltip;
1345  mutable bool d_weOwnTooltip;
1347  String d_defaultTooltipType;
1348 
1349  static String d_defaultXMLParserName;
1350 
1352  ImageCodec* d_imageCodec;
1354  bool d_ourImageCodec;
1358  DynamicModule* d_imageCodecModule;
1360  static String d_defaultImageCodecName;
1362  bool d_ourLogger;
1364  RenderedStringParser* d_customRenderedStringParser;
1366  bool d_generateMouseClickEvents;
1367 };
1368 
1369 } // End of CEGUI namespace section
1370 
1371 
1372 #if defined(_MSC_VER)
1373 # pragma warning(pop)
1374 #endif
1375 
1376 #endif // end of guard _CEGUISystem_h_