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 
295  void setSingleClickTimeout(double timeout);
296 
297 
312  void setMultiClickTimeout(double timeout);
313 
314 
328  void setMultiClickToleranceAreaSize(const Size& sz);
329 
330 
339  const Image* getDefaultMouseCursor(void) const {return d_defaultMouseCursor;}
340 
341 
353  void setDefaultMouseCursor(const Image* image);
354 
355 
367 
368 
384  void setDefaultMouseCursor(const String& imageset, const String& image_name);
385 
386 
394  Window* getWindowContainingMouse(void) const {return d_wndWithMouse;}
395 
396 
404  ScriptModule* getScriptingModule(void) const;
405 
416  void setScriptingModule(ScriptModule* scriptModule);
417 
425  ResourceProvider* getResourceProvider(void) const;
426 
437  void executeScriptFile(const String& filename, const String& resourceGroup = "") const;
438 
439 
451  int executeScriptGlobal(const String& function_name) const;
452 
453 
464  void executeScriptString(const String& str) const;
465 
466 
474  float getMouseMoveScaling(void) const;
475 
476 
487  void setMouseMoveScaling(float scaling);
488 
489 
498  void notifyWindowDestroyed(const Window* window);
499 
500 
508  uint getSystemKeys(void) const { return d_sysKeys; }
509 
514  XMLParser* getXMLParser(void) const { return d_xmlParser; }
515 
516 
530  void setDefaultTooltip(Tooltip* tooltip);
531 
547  void setDefaultTooltip(const String& tooltipType);
548 
557  Tooltip* getDefaultTooltip(void) const { return d_defaultTooltip; }
558 
559 
568  void setModalTarget(Window* target) {d_modalTarget = target;}
569 
577  Window* getModalTarget(void) const {return d_modalTarget;}
578 
623  static void setDefaultXMLParserName(const String& parserName);
624 
634  static const String getDefaultXMLParserName();
635 
636  /*************************************************************************
637  Input injection interface
638  *************************************************************************/
653  bool injectMouseMove(float delta_x, float delta_y);
654 
655 
664  bool injectMouseLeaves(void);
665 
666 
678  bool injectMouseButtonDown(MouseButton button);
679 
680 
692  bool injectMouseButtonUp(MouseButton button);
693 
694 
706  bool injectKeyDown(uint key_code);
707 
708 
720  bool injectKeyUp(uint key_code);
721 
722 
734  bool injectChar(utf32 code_point);
735 
736 
748  bool injectMouseWheelChange(float delta);
749 
750 
765  bool injectMousePosition(float x_pos, float y_pos);
766 
767 
778  bool injectTimePulse(float timeElapsed);
779 
780 
781 private:
782  // unimplemented constructors / assignment
783  System(const System& obj);
784  System& operator=(const System& obj);
785 
786  /*************************************************************************
787  Implementation Constants
788  *************************************************************************/
789  static const char CEGUIConfigSchemaName[];
790 
791 
792  /*************************************************************************
793  Implementation Functions
794  *************************************************************************/
805  Window* getTargetWindow(const Point& pt) const;
806 
807 
815  Window* getKeyboardTargetWindow(void) const;
816 
817 
828  Window* getNextTargetWindow(Window* w) const;
829 
830 
841  SystemKey mouseButtonToSyskey(MouseButton btn) const;
842 
843 
859  SystemKey keyCodeToSyskey(Key::Scan key, bool direction);
860 
861 
866  bool handleDisplaySizeChange(const EventArgs& e);
867 
869  void outputLogHeader();
870 
872  void addStandardWindowFactories();
873 
875  void createSingletons();
876 
878  void destroySingletons();
879 
881  void setupXMLParser();
882 
884  void cleanupXMLParser();
885 
886  /*************************************************************************
887  Handlers for System events
888  *************************************************************************/
895  void onGUISheetChanged(WindowEventArgs& e);
896 
897 
902  void onSingleClickTimeoutChanged(EventArgs& e);
903 
904 
909  void onMultiClickTimeoutChanged(EventArgs& e);
910 
911 
916  void onMultiClickAreaSizeChanged(EventArgs& e);
917 
918 
923  void onDefaultFontChanged(EventArgs& e);
924 
925 
930  void onDefaultMouseCursorChanged(EventArgs& e);
931 
932 
937  void onMouseMoveScalingChanged(EventArgs& e);
938 
939 
940  /*************************************************************************
941  Implementation Data
942  *************************************************************************/
943  Renderer* d_renderer;
944  ResourceProvider* d_resourceProvider;
945  Font* d_defaultFont;
946  bool d_gui_redraw;
947 
948  Window* d_wndWithMouse;
949  Window* d_activeSheet;
950  Window* d_modalTarget;
951 
952  String d_strVersion;
953 
954  uint d_sysKeys;
955  bool d_lshift;
956  bool d_rshift;
957  bool d_lctrl;
958  bool d_rctrl;
959  bool d_lalt;
960  bool d_ralt;
961 
962  double d_click_timeout;
963  double d_dblclick_timeout;
964  Size d_dblclick_size;
965 
966  MouseClickTrackerImpl* const d_clickTrackerPimpl;
967 
968  // mouse cursor related
969  const Image* d_defaultMouseCursor;
970 
971  // scripting
972  ScriptModule* d_scriptModule;
973  String d_termScriptName;
974 
975  float d_mouseScalingFactor;
976 
977  XMLParser* d_xmlParser;
978  bool d_ourXmlParser;
979  DynamicModule* d_parserModule;
980 
981  Tooltip* d_defaultTooltip;
982  bool d_weOwnTooltip;
983 
985  Event::Connection d_rendererCon;
986 
987  static String d_defaultXMLParserName;
988 };
989 
990 } // End of CEGUI namespace section
991 
992 
993 #if defined(_MSC_VER)
994 # pragma warning(pop)
995 #endif
996 
997 #endif // end of guard _CEGUISystem_h_