Crazy Eddies GUI System  0.6.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 - 2006 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 
85 
86  /*************************************************************************
87  Construction and Destruction
88  *************************************************************************/
114  System(Renderer* renderer, ResourceProvider* resourceProvider = 0, XMLParser* xmlParser = 0, ScriptModule* scriptModule = 0, const String& configFile = "", const String& logFile = "CEGUI.log");
115 
120  ~System(void);
121 
122 
130  Renderer* getRenderer(void) const {return d_renderer;}
131 
132 
140  static System& getSingleton(void);
141 
142 
150  static System* getSingletonPtr(void);
151 
152 
163  void setDefaultFont(const String& name);
164 
165 
176  void setDefaultFont(Font* font);
177 
178 
186  Font* getDefaultFont(void) const {return d_defaultFont;}
187 
188 
196  void signalRedraw() {d_gui_redraw = true;}
197 
198 
206  bool isRedrawRequested() const {return d_gui_redraw;}
207 
208 
218  void renderGUI(void);
219 
220 
231  Window* setGUISheet(Window* sheet);
232 
233 
241  Window* getGUISheet(void) const {return d_activeSheet;}
242 
243 
253  double getSingleClickTimeout(void) const {return d_click_timeout;}
254 
255 
267  double getMultiClickTimeout(void) const {return d_dblclick_timeout;}
268 
269 
280  const Size& getMultiClickToleranceAreaSize(void) const {return d_dblclick_size;}
281 
282 
302  void setSingleClickTimeout(double timeout);
303 
304 
325  void setMultiClickTimeout(double timeout);
326 
327 
341  void setMultiClickToleranceAreaSize(const Size& sz);
342 
343 
352  const Image* getDefaultMouseCursor(void) const {return d_defaultMouseCursor;}
353 
354 
366  void setDefaultMouseCursor(const Image* image);
367 
368 
380 
381 
397  void setDefaultMouseCursor(const String& imageset, const String& image_name);
398 
399 
407  Window* getWindowContainingMouse(void) const {return d_wndWithMouse;}
408 
409 
417  ScriptModule* getScriptingModule(void) const;
418 
429  void setScriptingModule(ScriptModule* scriptModule);
430 
438  ResourceProvider* getResourceProvider(void) const;
439 
450  void executeScriptFile(const String& filename, const String& resourceGroup = "") const;
451 
452 
464  int executeScriptGlobal(const String& function_name) const;
465 
466 
477  void executeScriptString(const String& str) const;
478 
479 
487  float getMouseMoveScaling(void) const;
488 
489 
500  void setMouseMoveScaling(float scaling);
501 
502 
511  void notifyWindowDestroyed(const Window* window);
512 
513 
521  uint getSystemKeys(void) const { return d_sysKeys; }
522 
535  void setXMLParser(const String& parserName);
536 
554  void setXMLParser(XMLParser* parser);
555 
560  XMLParser* getXMLParser(void) const { return d_xmlParser; }
561 
562 
576  void setDefaultTooltip(Tooltip* tooltip);
577 
593  void setDefaultTooltip(const String& tooltipType);
594 
603  Tooltip* getDefaultTooltip(void) const { return d_defaultTooltip; }
604 
605 
614  void setModalTarget(Window* target) {d_modalTarget = target;}
615 
623  Window* getModalTarget(void) const {return d_modalTarget;}
624 
669  static void setDefaultXMLParserName(const String& parserName);
670 
680  static const String getDefaultXMLParserName();
681 
682  /*************************************************************************
683  Input injection interface
684  *************************************************************************/
699  bool injectMouseMove(float delta_x, float delta_y);
700 
701 
710  bool injectMouseLeaves(void);
711 
712 
724  bool injectMouseButtonDown(MouseButton button);
725 
726 
738  bool injectMouseButtonUp(MouseButton button);
739 
740 
752  bool injectKeyDown(uint key_code);
753 
754 
766  bool injectKeyUp(uint key_code);
767 
768 
780  bool injectChar(utf32 code_point);
781 
782 
794  bool injectMouseWheelChange(float delta);
795 
796 
811  bool injectMousePosition(float x_pos, float y_pos);
812 
813 
824  bool injectTimePulse(float timeElapsed);
825 
826 
827 private:
828  // unimplemented constructors / assignment
829  System(const System& obj);
830  System& operator=(const System& obj);
831 
832  /*************************************************************************
833  Implementation Constants
834  *************************************************************************/
835  static const char CEGUIConfigSchemaName[];
836 
837 
838  /*************************************************************************
839  Implementation Functions
840  *************************************************************************/
851  Window* getTargetWindow(const Point& pt) const;
852 
853 
861  Window* getKeyboardTargetWindow(void) const;
862 
863 
874  Window* getNextTargetWindow(Window* w) const;
875 
876 
887  SystemKey mouseButtonToSyskey(MouseButton btn) const;
888 
889 
905  SystemKey keyCodeToSyskey(Key::Scan key, bool direction);
906 
907 
912  bool handleDisplaySizeChange(const EventArgs& e);
913 
915  void outputLogHeader();
916 
918  void addStandardWindowFactories();
919 
921  void createSingletons();
922 
924  void destroySingletons();
925 
927  void setupXMLParser();
928 
930  void cleanupXMLParser();
931 
933  bool mouseMoveInjection_impl(MouseEventArgs& ma);
934 
935  /*************************************************************************
936  Handlers for System events
937  *************************************************************************/
944  void onGUISheetChanged(WindowEventArgs& e);
945 
946 
951  void onSingleClickTimeoutChanged(EventArgs& e);
952 
953 
958  void onMultiClickTimeoutChanged(EventArgs& e);
959 
960 
965  void onMultiClickAreaSizeChanged(EventArgs& e);
966 
967 
972  void onDefaultFontChanged(EventArgs& e);
973 
974 
979  void onDefaultMouseCursorChanged(EventArgs& e);
980 
981 
986  void onMouseMoveScalingChanged(EventArgs& e);
987 
988 
989  /*************************************************************************
990  Implementation Data
991  *************************************************************************/
992  Renderer* d_renderer;
993  ResourceProvider* d_resourceProvider;
994  Font* d_defaultFont;
995  bool d_gui_redraw;
996 
997  Window* d_wndWithMouse;
998  Window* d_activeSheet;
999  Window* d_modalTarget;
1000 
1001  String d_strVersion;
1002 
1003  uint d_sysKeys;
1004  bool d_lshift;
1005  bool d_rshift;
1006  bool d_lctrl;
1007  bool d_rctrl;
1008  bool d_lalt;
1009  bool d_ralt;
1010 
1011  double d_click_timeout;
1012  double d_dblclick_timeout;
1013  Size d_dblclick_size;
1014 
1015  MouseClickTrackerImpl* const d_clickTrackerPimpl;
1016 
1017  // mouse cursor related
1018  const Image* d_defaultMouseCursor;
1019 
1020  // scripting
1021  ScriptModule* d_scriptModule;
1022  String d_termScriptName;
1023 
1024  float d_mouseScalingFactor;
1025 
1026  XMLParser* d_xmlParser;
1027  bool d_ourXmlParser;
1028  DynamicModule* d_parserModule;
1029 
1030  Tooltip* d_defaultTooltip;
1031  bool d_weOwnTooltip;
1032 
1034  Event::Connection d_rendererCon;
1035 
1036  static String d_defaultXMLParserName;
1037 };
1038 
1039 } // End of CEGUI namespace section
1040 
1041 
1042 #if defined(_MSC_VER)
1043 # pragma warning(pop)
1044 #endif
1045 
1046 #endif // end of guard _CEGUISystem_h_