00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _CEGUISystem_h_
00031 #define _CEGUISystem_h_
00032
00033 #include "CEGUIBase.h"
00034 #include "CEGUIString.h"
00035 #include "CEGUISingleton.h"
00036 #include "CEGUIRenderer.h"
00037 #include "CEGUIMouseCursor.h"
00038 #include "CEGUIInputEvent.h"
00039 #include "CEGUIResourceProvider.h"
00040
00041
00042 #if defined(_MSC_VER)
00043 # pragma warning(push)
00044 # pragma warning(disable : 4275)
00045 # pragma warning(disable : 4251)
00046 #endif
00047
00048
00049
00050 namespace CEGUI
00051 {
00053 struct MouseClickTrackerImpl;
00054
00055
00064 class CEGUIEXPORT System : public Singleton<System>, public EventSet
00065 {
00066 public:
00067 static const String EventNamespace;
00068
00069
00070
00071
00072 static const double DefaultSingleClickTimeout;
00073 static const double DefaultMultiClickTimeout;
00074 static const Size DefaultMultiClickAreaSize;
00075
00076
00077 static const String EventGUISheetChanged;
00078 static const String EventSingleClickTimeoutChanged;
00079 static const String EventMultiClickTimeoutChanged;
00080 static const String EventMultiClickAreaSizeChanged;
00081 static const String EventDefaultFontChanged;
00082 static const String EventDefaultMouseCursorChanged;
00083 static const String EventMouseMoveScalingChanged;
00084
00085
00086
00087
00088
00114 System(Renderer* renderer, ResourceProvider* resourceProvider = 0, XMLParser* xmlParser = 0, ScriptModule* scriptModule = 0, const String& configFile = "", const String& logFile = "CEGUI.log");
00115
00120 ~System(void);
00121
00122
00130 Renderer* getRenderer(void) const {return d_renderer;}
00131
00132
00140 static System& getSingleton(void);
00141
00142
00150 static System* getSingletonPtr(void);
00151
00152
00163 void setDefaultFont(const String& name);
00164
00165
00176 void setDefaultFont(Font* font);
00177
00178
00186 Font* getDefaultFont(void) const {return d_defaultFont;}
00187
00188
00196 void signalRedraw() {d_gui_redraw = true;}
00197
00198
00206 bool isRedrawRequested() const {return d_gui_redraw;}
00207
00208
00218 void renderGUI(void);
00219
00220
00231 Window* setGUISheet(Window* sheet);
00232
00233
00241 Window* getGUISheet(void) const {return d_activeSheet;}
00242
00243
00253 double getSingleClickTimeout(void) const {return d_click_timeout;}
00254
00255
00267 double getMultiClickTimeout(void) const {return d_dblclick_timeout;}
00268
00269
00280 const Size& getMultiClickToleranceAreaSize(void) const {return d_dblclick_size;}
00281
00282
00302 void setSingleClickTimeout(double timeout);
00303
00304
00325 void setMultiClickTimeout(double timeout);
00326
00327
00341 void setMultiClickToleranceAreaSize(const Size& sz);
00342
00343
00352 const Image* getDefaultMouseCursor(void) const {return d_defaultMouseCursor;}
00353
00354
00366 void setDefaultMouseCursor(const Image* image);
00367
00368
00379 void setDefaultMouseCursor(MouseCursorImage image) {setDefaultMouseCursor((const Image*)image);}
00380
00381
00397 void setDefaultMouseCursor(const String& imageset, const String& image_name);
00398
00399
00407 Window* getWindowContainingMouse(void) const {return d_wndWithMouse;}
00408
00409
00417 ScriptModule* getScriptingModule(void) const;
00418
00429 void setScriptingModule(ScriptModule* scriptModule);
00430
00438 ResourceProvider* getResourceProvider(void) const;
00439
00450 void executeScriptFile(const String& filename, const String& resourceGroup = "") const;
00451
00452
00464 int executeScriptGlobal(const String& function_name) const;
00465
00466
00477 void executeScriptString(const String& str) const;
00478
00479
00487 float getMouseMoveScaling(void) const;
00488
00489
00500 void setMouseMoveScaling(float scaling);
00501
00502
00511 void notifyWindowDestroyed(const Window* window);
00512
00513
00521 uint getSystemKeys(void) const { return d_sysKeys; }
00522
00535 void setXMLParser(const String& parserName);
00536
00554 void setXMLParser(XMLParser* parser);
00555
00560 XMLParser* getXMLParser(void) const { return d_xmlParser; }
00561
00562
00576 void setDefaultTooltip(Tooltip* tooltip);
00577
00593 void setDefaultTooltip(const String& tooltipType);
00594
00603 Tooltip* getDefaultTooltip(void) const { return d_defaultTooltip; }
00604
00605
00614 void setModalTarget(Window* target) {d_modalTarget = target;}
00615
00623 Window* getModalTarget(void) const {return d_modalTarget;}
00624
00669 static void setDefaultXMLParserName(const String& parserName);
00670
00680 static const String getDefaultXMLParserName();
00681
00696 bool updateWindowContainingMouse();
00697
00698
00699
00700
00715 bool injectMouseMove(float delta_x, float delta_y);
00716
00717
00726 bool injectMouseLeaves(void);
00727
00728
00740 bool injectMouseButtonDown(MouseButton button);
00741
00742
00754 bool injectMouseButtonUp(MouseButton button);
00755
00756
00768 bool injectKeyDown(uint key_code);
00769
00770
00782 bool injectKeyUp(uint key_code);
00783
00784
00796 bool injectChar(utf32 code_point);
00797
00798
00810 bool injectMouseWheelChange(float delta);
00811
00812
00827 bool injectMousePosition(float x_pos, float y_pos);
00828
00829
00840 bool injectTimePulse(float timeElapsed);
00841
00842
00843 private:
00844
00845 System(const System& obj);
00846 System& operator=(const System& obj);
00847
00848
00849
00850
00851 static const char CEGUIConfigSchemaName[];
00852
00853
00854
00855
00856
00867 Window* getTargetWindow(const Point& pt) const;
00868
00869
00877 Window* getKeyboardTargetWindow(void) const;
00878
00879
00890 Window* getNextTargetWindow(Window* w) const;
00891
00892
00903 SystemKey mouseButtonToSyskey(MouseButton btn) const;
00904
00905
00921 SystemKey keyCodeToSyskey(Key::Scan key, bool direction);
00922
00923
00928 bool handleDisplaySizeChange(const EventArgs& e);
00929
00931 void outputLogHeader();
00932
00934 void addStandardWindowFactories();
00935
00937 void createSingletons();
00938
00940 void destroySingletons();
00941
00943 void setupXMLParser();
00944
00946 void cleanupXMLParser();
00947
00949 bool mouseMoveInjection_impl(MouseEventArgs& ma);
00950
00951
00952
00953
00960 void onGUISheetChanged(WindowEventArgs& e);
00961
00962
00967 void onSingleClickTimeoutChanged(EventArgs& e);
00968
00969
00974 void onMultiClickTimeoutChanged(EventArgs& e);
00975
00976
00981 void onMultiClickAreaSizeChanged(EventArgs& e);
00982
00983
00988 void onDefaultFontChanged(EventArgs& e);
00989
00990
00995 void onDefaultMouseCursorChanged(EventArgs& e);
00996
00997
01002 void onMouseMoveScalingChanged(EventArgs& e);
01003
01004
01005
01006
01007
01008 Renderer* d_renderer;
01009 ResourceProvider* d_resourceProvider;
01010 Font* d_defaultFont;
01011 bool d_gui_redraw;
01012
01013 Window* d_wndWithMouse;
01014 Window* d_activeSheet;
01015 Window* d_modalTarget;
01016
01017 String d_strVersion;
01018
01019 uint d_sysKeys;
01020 bool d_lshift;
01021 bool d_rshift;
01022 bool d_lctrl;
01023 bool d_rctrl;
01024 bool d_lalt;
01025 bool d_ralt;
01026
01027 double d_click_timeout;
01028 double d_dblclick_timeout;
01029 Size d_dblclick_size;
01030
01031 MouseClickTrackerImpl* const d_clickTrackerPimpl;
01032
01033
01034 const Image* d_defaultMouseCursor;
01035
01036
01037 ScriptModule* d_scriptModule;
01038 String d_termScriptName;
01039
01040 float d_mouseScalingFactor;
01041
01042 XMLParser* d_xmlParser;
01043 bool d_ourXmlParser;
01044 DynamicModule* d_parserModule;
01045
01046 Tooltip* d_defaultTooltip;
01047 bool d_weOwnTooltip;
01048
01050 Event::Connection d_rendererCon;
01051
01052 static String d_defaultXMLParserName;
01053 };
01054
01055 }
01056
01057
01058 #if defined(_MSC_VER)
01059 # pragma warning(pop)
01060 #endif
01061
01062 #endif // end of guard _CEGUISystem_h_