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 #ifndef _CEGUISystem_h_
00027 #define _CEGUISystem_h_
00028
00029 #include "CEGUIBase.h"
00030 #include "CEGUIString.h"
00031 #include "CEGUISingleton.h"
00032 #include "CEGUIRenderer.h"
00033 #include "CEGUIMouseCursor.h"
00034 #include "CEGUIInputEvent.h"
00035 #include "CEGUIResourceProvider.h"
00036
00037
00038 #if defined(_MSC_VER)
00039 # pragma warning(push)
00040 # pragma warning(disable : 4275)
00041 # pragma warning(disable : 4251)
00042 #endif
00043
00044
00045
00046 namespace CEGUI
00047 {
00048
00049 struct MouseClickTrackerImpl;
00050
00051
00060 class CEGUIBASE_API System : public Singleton<System>, public EventSet
00061 {
00062 public:
00063 static const String EventNamespace;
00064
00065
00066
00067
00068 static const double DefaultSingleClickTimeout;
00069 static const double DefaultMultiClickTimeout;
00070 static const Size DefaultMultiClickAreaSize;
00071
00072
00073 static const String EventGUISheetChanged;
00074 static const String EventSingleClickTimeoutChanged;
00075 static const String EventMultiClickTimeoutChanged;
00076 static const String EventMultiClickAreaSizeChanged;
00077 static const String EventDefaultFontChanged;
00078 static const String EventDefaultMouseCursorChanged;
00079 static const String EventMouseMoveScalingChanged;
00080
00081
00082
00083
00084
00095 System(Renderer* renderer, utf8* logFile = (utf8*)"CEGUI.log");
00096
00110 System(Renderer* renderer, ResourceProvider* resourceProvider, utf8* logFile = (utf8*)"CEGUI.log");
00111
00112
00126 System(Renderer* renderer, ScriptModule* scriptModule, utf8* configFile = (utf8*)"cegui.config");
00127
00128
00145 System(Renderer* renderer, ScriptModule* scriptModule, ResourceProvider* resourceProvider, utf8* configFile = (utf8*)"cegui.config");
00146
00147
00152 ~System(void);
00153
00154
00162 Renderer* getRenderer(void) const {return d_renderer;}
00163
00164
00172 static System& getSingleton(void);
00173
00174
00182 static System* getSingletonPtr(void);
00183
00184
00195 void setDefaultFont(const String& name);
00196
00197
00208 void setDefaultFont(Font* font);
00209
00210
00218 Font* getDefaultFont(void) const {return d_defaultFont;}
00219
00220
00228 void signalRedraw() {d_gui_redraw = true;}
00229
00230
00240 void renderGUI(void);
00241
00242
00253 Window* setGUISheet(Window* sheet);
00254
00255
00263 Window* getGUISheet(void) const {return d_activeSheet;}
00264
00265
00275 double getSingleClickTimeout(void) const {return d_click_timeout;}
00276
00277
00289 double getMultiClickTimeout(void) const {return d_dblclick_timeout;}
00290
00291
00302 const Size& getMultiClickToleranceAreaSize(void) const {return d_dblclick_size;}
00303
00304
00317 void setSingleClickTimeout(double timeout);
00318
00319
00334 void setMultiClickTimeout(double timeout);
00335
00336
00350 void setMultiClickToleranceAreaSize(const Size& sz);
00351
00352
00361 const Image* getDefaultMouseCursor(void) const {return d_defaultMouseCursor;}
00362
00363
00375 void setDefaultMouseCursor(const Image* image);
00376
00377
00388 void setDefaultMouseCursor(MouseCursorImage image) {setDefaultMouseCursor((const Image*)image);}
00389
00390
00406 void setDefaultMouseCursor(const String& imageset, const String& image_name);
00407
00408
00416 Window* getWindowContainingMouse(void) const {return d_wndWithMouse;}
00417
00418
00426 ScriptModule* getScriptingModule(void) const;
00427
00435 ResourceProvider* getResourceProvider(void) const;
00436
00444 void executeScriptFile(const String& filename) const;
00445
00446
00458 int executeScriptGloabl(const String& function_name) const;
00459
00460
00468 float getMouseMoveScaling(void) const;
00469
00470
00481 void setMouseMoveScaling(float scaling);
00482
00483
00492 void notifyWindowDestroyed(const Window* window);
00493
00494
00502 uint getSystemKeys(void) const { return d_sysKeys; }
00503
00504
00505
00506
00507
00522 bool injectMouseMove(float delta_x, float delta_y);
00523
00524
00536 bool injectMouseButtonDown(MouseButton button);
00537
00538
00550 bool injectMouseButtonUp(MouseButton button);
00551
00552
00564 bool injectKeyDown(uint key_code);
00565
00566
00578 bool injectKeyUp(uint key_code);
00579
00580
00592 bool injectChar(utf32 code_point);
00593
00594
00606 bool injectMouseWheelChange(float delta);
00607
00608
00623 bool injectMousePosition(float x_pos, float y_pos);
00624
00625
00636 bool injectTimePulse(float timeElapsed);
00637
00638
00639 private:
00640
00641
00642
00643 static const char CEGUIConfigSchemaName[];
00644
00645
00646
00647
00648
00659 Window* getTargetWindow(const Point& pt) const;
00660
00661
00672 SystemKey mouseButtonToSyskey(MouseButton btn) const;
00673
00674
00690 SystemKey keyCodeToSyskey(Key::Scan key, bool direction);
00691
00692
00697 void constructor_impl(Renderer* renderer, ResourceProvider* resourceProvider, ScriptModule* scriptModule, const String& configFile, const String& logFile);
00698
00699
00704 void addSystemEvents(void);
00705
00706
00711 bool handleDisplaySizeChange(const EventArgs& e);
00712
00713
00714
00715
00716
00723 void onGUISheetChanged(WindowEventArgs& e);
00724
00725
00730 void onSingleClickTimeoutChanged(EventArgs& e);
00731
00732
00737 void onMultiClickTimeoutChanged(EventArgs& e);
00738
00739
00744 void onMultiClickAreaSizeChanged(EventArgs& e);
00745
00746
00751 void onDefaultFontChanged(EventArgs& e);
00752
00753
00758 void onDefaultMouseCursorChanged(EventArgs& e);
00759
00760
00765 void onMouseMoveScalingChanged(EventArgs& e);
00766
00767
00768
00769
00770
00771 Renderer* d_renderer;
00772 ResourceProvider* d_resourceProvider;
00773 Font* d_defaultFont;
00774 bool d_gui_redraw;
00775
00776 Window* d_wndWithMouse;
00777 Window* d_activeSheet;
00778
00779 uint d_sysKeys;
00780 bool d_lshift;
00781 bool d_rshift;
00782 bool d_lctrl;
00783 bool d_rctrl;
00784
00785 double d_click_timeout;
00786 double d_dblclick_timeout;
00787 Size d_dblclick_size;
00788
00789 MouseClickTrackerImpl* const d_clickTrackerPimpl;
00790
00791
00792 const Image* d_defaultMouseCursor;
00793
00794
00795 ScriptModule* d_scriptModule;
00796 String d_termScriptName;
00797
00798 float d_mouseScalingFactor;
00799 };
00800
00801 }
00802
00803
00804 #if defined(_MSC_VER)
00805 # pragma warning(pop)
00806 #endif
00807
00808 #endif // end of guard _CEGUISystem_h_