Crazy Eddies GUI System  0.6.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 - 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 
696  bool updateWindowContainingMouse();
697 
698  /*************************************************************************
699  Input injection interface
700  *************************************************************************/
715  bool injectMouseMove(float delta_x, float delta_y);
716 
717 
726  bool injectMouseLeaves(void);
727 
728 
740  bool injectMouseButtonDown(MouseButton button);
741 
742 
754  bool injectMouseButtonUp(MouseButton button);
755 
756 
768  bool injectKeyDown(uint key_code);
769 
770 
782  bool injectKeyUp(uint key_code);
783 
784 
796  bool injectChar(utf32 code_point);
797 
798 
810  bool injectMouseWheelChange(float delta);
811 
812 
827  bool injectMousePosition(float x_pos, float y_pos);
828 
829 
840  bool injectTimePulse(float timeElapsed);
841 
842 
843 private:
844  // unimplemented constructors / assignment
845  System(const System& obj);
846  System& operator=(const System& obj);
847 
848  /*************************************************************************
849  Implementation Constants
850  *************************************************************************/
851  static const char CEGUIConfigSchemaName[];
852 
853 
854  /*************************************************************************
855  Implementation Functions
856  *************************************************************************/
867  Window* getTargetWindow(const Point& pt) const;
868 
869 
877  Window* getKeyboardTargetWindow(void) const;
878 
879 
890  Window* getNextTargetWindow(Window* w) const;
891 
892 
903  SystemKey mouseButtonToSyskey(MouseButton btn) const;
904 
905 
921  SystemKey keyCodeToSyskey(Key::Scan key, bool direction);
922 
923 
928  bool handleDisplaySizeChange(const EventArgs& e);
929 
931  void outputLogHeader();
932 
934  void addStandardWindowFactories();
935 
937  void createSingletons();
938 
940  void destroySingletons();
941 
943  void setupXMLParser();
944 
946  void cleanupXMLParser();
947 
949  bool mouseMoveInjection_impl(MouseEventArgs& ma);
950 
951  /*************************************************************************
952  Handlers for System events
953  *************************************************************************/
960  void onGUISheetChanged(WindowEventArgs& e);
961 
962 
967  void onSingleClickTimeoutChanged(EventArgs& e);
968 
969 
974  void onMultiClickTimeoutChanged(EventArgs& e);
975 
976 
981  void onMultiClickAreaSizeChanged(EventArgs& e);
982 
983 
988  void onDefaultFontChanged(EventArgs& e);
989 
990 
995  void onDefaultMouseCursorChanged(EventArgs& e);
996 
997 
1002  void onMouseMoveScalingChanged(EventArgs& e);
1003 
1004 
1005  /*************************************************************************
1006  Implementation Data
1007  *************************************************************************/
1008  Renderer* d_renderer;
1009  ResourceProvider* d_resourceProvider;
1010  Font* d_defaultFont;
1011  bool d_gui_redraw;
1012 
1013  Window* d_wndWithMouse;
1014  Window* d_activeSheet;
1015  Window* d_modalTarget;
1016 
1017  String d_strVersion;
1018 
1019  uint d_sysKeys;
1020  bool d_lshift;
1021  bool d_rshift;
1022  bool d_lctrl;
1023  bool d_rctrl;
1024  bool d_lalt;
1025  bool d_ralt;
1026 
1027  double d_click_timeout;
1028  double d_dblclick_timeout;
1029  Size d_dblclick_size;
1030 
1031  MouseClickTrackerImpl* const d_clickTrackerPimpl;
1032 
1033  // mouse cursor related
1034  const Image* d_defaultMouseCursor;
1035 
1036  // scripting
1037  ScriptModule* d_scriptModule;
1038  String d_termScriptName;
1039 
1040  float d_mouseScalingFactor;
1041 
1042  XMLParser* d_xmlParser;
1043  bool d_ourXmlParser;
1044  DynamicModule* d_parserModule;
1045 
1046  Tooltip* d_defaultTooltip;
1047  bool d_weOwnTooltip;
1048 
1050  Event::Connection d_rendererCon;
1051 
1052  static String d_defaultXMLParserName;
1053 };
1054 
1055 } // End of CEGUI namespace section
1056 
1057 
1058 #if defined(_MSC_VER)
1059 # pragma warning(pop)
1060 #endif
1061 
1062 #endif // end of guard _CEGUISystem_h_