MyGUI  3.2.0
MyGUI_InputManager.h
Go to the documentation of this file.
00001 
00006 /*
00007     This file is part of MyGUI.
00008 
00009     MyGUI is free software: you can redistribute it and/or modify
00010     it under the terms of the GNU Lesser General Public License as published by
00011     the Free Software Foundation, either version 3 of the License, or
00012     (at your option) any later version.
00013 
00014     MyGUI is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017     GNU Lesser General Public License for more details.
00018 
00019     You should have received a copy of the GNU Lesser General Public License
00020     along with MyGUI.  If not, see <http://www.gnu.org/licenses/>.
00021 */
00022 #ifndef __MYGUI_INPUT_MANAGER_H__
00023 #define __MYGUI_INPUT_MANAGER_H__
00024 
00025 #include "MyGUI_Prerequest.h"
00026 #include "MyGUI_Macros.h"
00027 #include "MyGUI_Singleton.h"
00028 #include "MyGUI_WidgetDefines.h"
00029 #include "MyGUI_IUnlinkWidget.h"
00030 #include "MyGUI_WidgetDefines.h"
00031 #include "MyGUI_XmlDocument.h"
00032 #include "MyGUI_MouseButton.h"
00033 #include "MyGUI_KeyCode.h"
00034 #include "MyGUI_Timer.h"
00035 #include "MyGUI_ILayer.h"
00036 #include "MyGUI_Delegate.h"
00037 #include "MyGUI_BackwardCompatibility.h"
00038 
00039 namespace MyGUI
00040 {
00041 
00042     class MYGUI_EXPORT InputManager :
00043         public Singleton<InputManager>,
00044         public IUnlinkWidget,
00045         public MemberObsolete<InputManager>
00046     {
00047     public:
00048         InputManager();
00049 
00050         void initialise();
00051         void shutdown();
00052 
00056         bool injectMouseMove(int _absx, int _absy, int _absz);
00060         bool injectMousePress(int _absx, int _absy, MouseButton _id);
00064         bool injectMouseRelease(int _absx, int _absy, MouseButton _id);
00065 
00069         bool injectKeyPress(KeyCode _key, Char _text = 0);
00073         bool injectKeyRelease(KeyCode _key);
00074 
00076         bool isFocusMouse() const;
00078         bool isFocusKey() const;
00080         bool isCaptureMouse() const;
00081 
00083         void setKeyFocusWidget(Widget* _widget);
00085         void resetKeyFocusWidget(Widget* _widget);
00087         void resetKeyFocusWidget();
00088 
00090         Widget* getMouseFocusWidget() const;
00092         Widget* getKeyFocusWidget() const;
00093 
00097         const IntPoint& getLastPressedPosition(MouseButton _id) const;
00098 
00100         const IntPoint& getMousePosition() const;
00101 
00105         IntPoint getMousePositionByLayer();
00106 
00107         // работа с модальными окнами
00109         void addWidgetModal(Widget* _widget);
00111         void removeWidgetModal(Widget* _widget);
00112 
00114         bool isModalAny() const;
00115 
00117         bool isControlPressed() const;
00119         bool isShiftPressed() const;
00120 
00125         void resetMouseCaptureWidget();
00126 
00128         void unlinkWidget(Widget* _widget);
00129 
00134         delegates::CMultiDelegate1<Widget*>
00135             eventChangeMouseFocus;
00136 
00141         delegates::CMultiDelegate1<Widget*>
00142             eventChangeKeyFocus;
00143 
00144     /*internal:*/
00145         void _resetMouseFocusWidget();
00146 
00147     private:
00148         // удаляем данный виджет из всех возможных мест
00149         void _unlinkWidget(Widget* _widget);
00150 
00151         void frameEntered(float _frame);
00152 
00153         void firstEncoding(KeyCode _key, bool bIsKeyPressed);
00154 
00155         // запоминает клавишу для поддержки повторения
00156         void storeKey(KeyCode _key, Char _text);
00157 
00158         // сбрасывает клавишу повторения
00159         void resetKey();
00160 
00161     private:
00162         // виджеты которым принадлежит фокус
00163         Widget* mWidgetMouseFocus;
00164         Widget* mWidgetKeyFocus;
00165         ILayer* mLayerMouseFocus;
00166 
00167         // таймер для двойного клика
00168         Timer mTimer; //used for double click timing
00169 
00170         // нажат ли шифт
00171         bool mIsShiftPressed;
00172         // нажат ли контрол
00173         bool mIsControlPressed;
00174 
00175         IntPoint mMousePosition;
00176 
00177         // last mouse press position
00178         IntPoint mLastPressed[MouseButton::MAX];
00179 
00180         // is mouse button captured by active widget
00181         bool mMouseCapture[MouseButton::MAX];
00182 
00183         // клавиша для повтора
00184         KeyCode mHoldKey;
00185         Char mHoldChar;
00186         bool mFirstPressKey;
00187         float mTimerKey;
00188         int mOldAbsZ;
00189 
00190         // список виджетов с модальным режимом
00191         VectorWidgetPtr mVectorModalRootWidget;
00192 
00193         bool mIsInitialise;
00194     };
00195 
00196 } // namespace MyGUI
00197 
00198 #endif // __MYGUI_INPUT_MANAGER_H__