MyGUI
3.2.1
|
00001 /* 00002 * This source file is part of MyGUI. For the latest info, see http://mygui.info/ 00003 * Distributed under the MIT License 00004 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 00005 */ 00006 00007 #ifndef __MYGUI_INPUT_MANAGER_H__ 00008 #define __MYGUI_INPUT_MANAGER_H__ 00009 00010 #include "MyGUI_Prerequest.h" 00011 #include "MyGUI_Macros.h" 00012 #include "MyGUI_Singleton.h" 00013 #include "MyGUI_WidgetDefines.h" 00014 #include "MyGUI_IUnlinkWidget.h" 00015 #include "MyGUI_WidgetDefines.h" 00016 #include "MyGUI_XmlDocument.h" 00017 #include "MyGUI_MouseButton.h" 00018 #include "MyGUI_KeyCode.h" 00019 #include "MyGUI_Timer.h" 00020 #include "MyGUI_ILayer.h" 00021 #include "MyGUI_Delegate.h" 00022 #include "MyGUI_BackwardCompatibility.h" 00023 00024 namespace MyGUI 00025 { 00026 00027 class MYGUI_EXPORT InputManager : 00028 public Singleton<InputManager>, 00029 public IUnlinkWidget, 00030 public MemberObsolete<InputManager> 00031 { 00032 public: 00033 InputManager(); 00034 00035 void initialise(); 00036 void shutdown(); 00037 00041 bool injectMouseMove(int _absx, int _absy, int _absz); 00045 bool injectMousePress(int _absx, int _absy, MouseButton _id); 00049 bool injectMouseRelease(int _absx, int _absy, MouseButton _id); 00050 00054 bool injectKeyPress(KeyCode _key, Char _text = 0); 00058 bool injectKeyRelease(KeyCode _key); 00059 00061 bool isFocusMouse() const; 00063 bool isFocusKey() const; 00065 bool isCaptureMouse() const; 00066 00068 void setKeyFocusWidget(Widget* _widget); 00070 void resetKeyFocusWidget(Widget* _widget); 00072 void resetKeyFocusWidget(); 00073 00075 Widget* getMouseFocusWidget() const; 00077 Widget* getKeyFocusWidget() const; 00078 00082 const IntPoint& getLastPressedPosition(MouseButton _id) const; 00083 00085 const IntPoint& getMousePosition() const; 00086 00090 IntPoint getMousePositionByLayer(); 00091 00092 // работа с модальными окнами 00094 void addWidgetModal(Widget* _widget); 00096 void removeWidgetModal(Widget* _widget); 00097 00099 bool isModalAny() const; 00100 00102 bool isControlPressed() const; 00104 bool isShiftPressed() const; 00105 00110 void resetMouseCaptureWidget(); 00111 00113 void unlinkWidget(Widget* _widget); 00114 00119 delegates::CMultiDelegate1<Widget*> eventChangeMouseFocus; 00120 00125 delegates::CMultiDelegate1<Widget*> eventChangeKeyFocus; 00126 00127 /*internal:*/ 00128 void _resetMouseFocusWidget(); 00129 00130 private: 00131 // удаляем данный виджет из всех возможных мест 00132 void _unlinkWidget(Widget* _widget); 00133 00134 void frameEntered(float _frame); 00135 00136 void firstEncoding(KeyCode _key, bool bIsKeyPressed); 00137 00138 // запоминает клавишу для поддержки повторения 00139 void storeKey(KeyCode _key, Char _text); 00140 00141 // сбрасывает клавишу повторения 00142 void resetKey(); 00143 00144 private: 00145 // виджеты которым принадлежит фокус 00146 Widget* mWidgetMouseFocus; 00147 Widget* mWidgetKeyFocus; 00148 ILayer* mLayerMouseFocus; 00149 00150 //used for double click timing 00151 float mTimerDoubleClick; // time since the last click 00152 00153 // нажат ли шифт 00154 bool mIsShiftPressed; 00155 // нажат ли контрол 00156 bool mIsControlPressed; 00157 00158 IntPoint mMousePosition; 00159 00160 // last mouse press position 00161 IntPoint mLastPressed[MouseButton::MAX]; 00162 00163 // is mouse button captured by active widget 00164 bool mMouseCapture[MouseButton::MAX]; 00165 00166 // клавиша для повтора 00167 KeyCode mHoldKey; 00168 Char mHoldChar; 00169 bool mFirstPressKey; 00170 float mTimerKey; 00171 int mOldAbsZ; 00172 00173 // список виджетов с модальным режимом 00174 VectorWidgetPtr mVectorModalRootWidget; 00175 00176 bool mIsInitialise; 00177 }; 00178 00179 } // namespace MyGUI 00180 00181 #endif // __MYGUI_INPUT_MANAGER_H__