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
00295 void setSingleClickTimeout(double timeout);
00296
00297
00312 void setMultiClickTimeout(double timeout);
00313
00314
00328 void setMultiClickToleranceAreaSize(const Size& sz);
00329
00330
00339 const Image* getDefaultMouseCursor(void) const {return d_defaultMouseCursor;}
00340
00341
00353 void setDefaultMouseCursor(const Image* image);
00354
00355
00366 void setDefaultMouseCursor(MouseCursorImage image) {setDefaultMouseCursor((const Image*)image);}
00367
00368
00384 void setDefaultMouseCursor(const String& imageset, const String& image_name);
00385
00386
00394 Window* getWindowContainingMouse(void) const {return d_wndWithMouse;}
00395
00396
00404 ScriptModule* getScriptingModule(void) const;
00405
00416 void setScriptingModule(ScriptModule* scriptModule);
00417
00425 ResourceProvider* getResourceProvider(void) const;
00426
00437 void executeScriptFile(const String& filename, const String& resourceGroup = "") const;
00438
00439
00451 int executeScriptGlobal(const String& function_name) const;
00452
00453
00464 void executeScriptString(const String& str) const;
00465
00466
00474 float getMouseMoveScaling(void) const;
00475
00476
00487 void setMouseMoveScaling(float scaling);
00488
00489
00498 void notifyWindowDestroyed(const Window* window);
00499
00500
00508 uint getSystemKeys(void) const { return d_sysKeys; }
00509
00514 XMLParser* getXMLParser(void) const { return d_xmlParser; }
00515
00516
00530 void setDefaultTooltip(Tooltip* tooltip);
00531
00547 void setDefaultTooltip(const String& tooltipType);
00548
00557 Tooltip* getDefaultTooltip(void) const { return d_defaultTooltip; }
00558
00559
00568 void setModalTarget(Window* target) {d_modalTarget = target;}
00569
00577 Window* getModalTarget(void) const {return d_modalTarget;}
00578
00623 static void setDefaultXMLParserName(const String& parserName);
00624
00634 static const String getDefaultXMLParserName();
00635
00636
00637
00638
00653 bool injectMouseMove(float delta_x, float delta_y);
00654
00655
00664 bool injectMouseLeaves(void);
00665
00666
00678 bool injectMouseButtonDown(MouseButton button);
00679
00680
00692 bool injectMouseButtonUp(MouseButton button);
00693
00694
00706 bool injectKeyDown(uint key_code);
00707
00708
00720 bool injectKeyUp(uint key_code);
00721
00722
00734 bool injectChar(utf32 code_point);
00735
00736
00748 bool injectMouseWheelChange(float delta);
00749
00750
00765 bool injectMousePosition(float x_pos, float y_pos);
00766
00767
00778 bool injectTimePulse(float timeElapsed);
00779
00780
00781 private:
00782
00783 System(const System& obj);
00784 System& operator=(const System& obj);
00785
00786
00787
00788
00789 static const char CEGUIConfigSchemaName[];
00790
00791
00792
00793
00794
00805 Window* getTargetWindow(const Point& pt) const;
00806
00807
00815 Window* getKeyboardTargetWindow(void) const;
00816
00817
00828 Window* getNextTargetWindow(Window* w) const;
00829
00830
00841 SystemKey mouseButtonToSyskey(MouseButton btn) const;
00842
00843
00859 SystemKey keyCodeToSyskey(Key::Scan key, bool direction);
00860
00861
00866 bool handleDisplaySizeChange(const EventArgs& e);
00867
00869 void outputLogHeader();
00870
00872 void addStandardWindowFactories();
00873
00875 void createSingletons();
00876
00878 void destroySingletons();
00879
00881 void setupXMLParser();
00882
00884 void cleanupXMLParser();
00885
00886
00887
00888
00895 void onGUISheetChanged(WindowEventArgs& e);
00896
00897
00902 void onSingleClickTimeoutChanged(EventArgs& e);
00903
00904
00909 void onMultiClickTimeoutChanged(EventArgs& e);
00910
00911
00916 void onMultiClickAreaSizeChanged(EventArgs& e);
00917
00918
00923 void onDefaultFontChanged(EventArgs& e);
00924
00925
00930 void onDefaultMouseCursorChanged(EventArgs& e);
00931
00932
00937 void onMouseMoveScalingChanged(EventArgs& e);
00938
00939
00940
00941
00942
00943 Renderer* d_renderer;
00944 ResourceProvider* d_resourceProvider;
00945 Font* d_defaultFont;
00946 bool d_gui_redraw;
00947
00948 Window* d_wndWithMouse;
00949 Window* d_activeSheet;
00950 Window* d_modalTarget;
00951
00952 String d_strVersion;
00953
00954 uint d_sysKeys;
00955 bool d_lshift;
00956 bool d_rshift;
00957 bool d_lctrl;
00958 bool d_rctrl;
00959 bool d_lalt;
00960 bool d_ralt;
00961
00962 double d_click_timeout;
00963 double d_dblclick_timeout;
00964 Size d_dblclick_size;
00965
00966 MouseClickTrackerImpl* const d_clickTrackerPimpl;
00967
00968
00969 const Image* d_defaultMouseCursor;
00970
00971
00972 ScriptModule* d_scriptModule;
00973 String d_termScriptName;
00974
00975 float d_mouseScalingFactor;
00976
00977 XMLParser* d_xmlParser;
00978 bool d_ourXmlParser;
00979 DynamicModule* d_parserModule;
00980
00981 Tooltip* d_defaultTooltip;
00982 bool d_weOwnTooltip;
00983
00985 Event::Connection d_rendererCon;
00986
00987 static String d_defaultXMLParserName;
00988 };
00989
00990 }
00991
00992
00993 #if defined(_MSC_VER)
00994 # pragma warning(pop)
00995 #endif
00996
00997 #endif // end of guard _CEGUISystem_h_