MyGUI  3.2.0
MyGUI_InputManager.h
Go to the documentation of this file.
1 
6 /*
7  This file is part of MyGUI.
8 
9  MyGUI is free software: you can redistribute it and/or modify
10  it under the terms of the GNU Lesser General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  MyGUI is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public License
20  along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
21 */
22 #ifndef __MYGUI_INPUT_MANAGER_H__
23 #define __MYGUI_INPUT_MANAGER_H__
24 
25 #include "MyGUI_Prerequest.h"
26 #include "MyGUI_Macros.h"
27 #include "MyGUI_Singleton.h"
28 #include "MyGUI_WidgetDefines.h"
29 #include "MyGUI_IUnlinkWidget.h"
30 #include "MyGUI_WidgetDefines.h"
31 #include "MyGUI_XmlDocument.h"
32 #include "MyGUI_MouseButton.h"
33 #include "MyGUI_KeyCode.h"
34 #include "MyGUI_Timer.h"
35 #include "MyGUI_ILayer.h"
36 #include "MyGUI_Delegate.h"
38 
39 namespace MyGUI
40 {
41 
43  public Singleton<InputManager>,
44  public IUnlinkWidget,
45  public MemberObsolete<InputManager>
46  {
47  public:
48  InputManager();
49 
50  void initialise();
51  void shutdown();
52 
56  bool injectMouseMove(int _absx, int _absy, int _absz);
60  bool injectMousePress(int _absx, int _absy, MouseButton _id);
64  bool injectMouseRelease(int _absx, int _absy, MouseButton _id);
65 
69  bool injectKeyPress(KeyCode _key, Char _text = 0);
73  bool injectKeyRelease(KeyCode _key);
74 
76  bool isFocusMouse() const;
78  bool isFocusKey() const;
80  bool isCaptureMouse() const;
81 
83  void setKeyFocusWidget(Widget* _widget);
85  void resetKeyFocusWidget(Widget* _widget);
87  void resetKeyFocusWidget();
88 
90  Widget* getMouseFocusWidget() const;
92  Widget* getKeyFocusWidget() const;
93 
97  const IntPoint& getLastPressedPosition(MouseButton _id) const;
98 
100  const IntPoint& getMousePosition() const;
101 
105  IntPoint getMousePositionByLayer();
106 
107  // работа с модальными окнами
109  void addWidgetModal(Widget* _widget);
111  void removeWidgetModal(Widget* _widget);
112 
114  bool isModalAny() const;
115 
117  bool isControlPressed() const;
119  bool isShiftPressed() const;
120 
125  void resetMouseCaptureWidget();
126 
128  void unlinkWidget(Widget* _widget);
129 
136 
143 
144  /*internal:*/
145  void _resetMouseFocusWidget();
146 
147  private:
148  // удаляем данный виджет из всех возможных мест
149  void _unlinkWidget(Widget* _widget);
150 
151  void frameEntered(float _frame);
152 
153  void firstEncoding(KeyCode _key, bool bIsKeyPressed);
154 
155  // запоминает клавишу для поддержки повторения
156  void storeKey(KeyCode _key, Char _text);
157 
158  // сбрасывает клавишу повторения
159  void resetKey();
160 
161  private:
162  // виджеты которым принадлежит фокус
163  Widget* mWidgetMouseFocus;
164  Widget* mWidgetKeyFocus;
165  ILayer* mLayerMouseFocus;
166 
167  // таймер для двойного клика
168  Timer mTimer; //used for double click timing
169 
170  // нажат ли шифт
171  bool mIsShiftPressed;
172  // нажат ли контрол
173  bool mIsControlPressed;
174 
175  IntPoint mMousePosition;
176 
177  // last mouse press position
178  IntPoint mLastPressed[MouseButton::MAX];
179 
180  // is mouse button captured by active widget
181  bool mMouseCapture[MouseButton::MAX];
182 
183  // клавиша для повтора
184  KeyCode mHoldKey;
185  Char mHoldChar;
186  bool mFirstPressKey;
187  float mTimerKey;
188  int mOldAbsZ;
189 
190  // список виджетов с модальным режимом
191  VectorWidgetPtr mVectorModalRootWidget;
192 
193  bool mIsInitialise;
194  };
195 
196 } // namespace MyGUI
197 
198 #endif // __MYGUI_INPUT_MANAGER_H__
#define MYGUI_EXPORT
std::vector< Widget * > VectorWidgetPtr
unsigned int Char
Definition: MyGUI_Types.h:66
delegates::CMultiDelegate1< Widget * > eventChangeKeyFocus
delegates::CMultiDelegate1< Widget * > eventChangeMouseFocus