• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

MyGUI_InputManager.h

Go to the documentation of this file.
00001 
00007 /*
00008     This file is part of MyGUI.
00009     
00010     MyGUI is free software: you can redistribute it and/or modify
00011     it under the terms of the GNU Lesser General Public License as published by
00012     the Free Software Foundation, either version 3 of the License, or
00013     (at your option) any later version.
00014     
00015     MyGUI is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018     GNU Lesser General Public License for more details.
00019     
00020     You should have received a copy of the GNU Lesser General Public License
00021     along with MyGUI.  If not, see <http://www.gnu.org/licenses/>.
00022 */
00023 #ifndef __MYGUI_INPUT_MANAGER_H__
00024 #define __MYGUI_INPUT_MANAGER_H__
00025 
00026 #include "MyGUI_Prerequest.h"
00027 #include "MyGUI_Common.h"
00028 #include "MyGUI_Macros.h"
00029 #include "MyGUI_Instance.h"
00030 #include "MyGUI_WidgetDefines.h"
00031 #include "MyGUI_IUnlinkWidget.h"
00032 #include "MyGUI_WidgetDefines.h"
00033 #include "MyGUI_XmlDocument.h"
00034 #include "MyGUI_InputDefine.h"
00035 #include "MyGUI_Timer.h"
00036 
00037 namespace MyGUI
00038 {
00039 
00040     class MYGUI_EXPORT InputManager : public IUnlinkWidget
00041     {
00042         MYGUI_INSTANCE_HEADER(InputManager);
00043 
00044     public:
00045         void initialise();
00046         void shutdown();
00047 
00051         bool injectMouseMove(int _absx, int _absy, int _absz);
00055         bool injectMousePress(int _absx, int _absy, MouseButton _id);
00059         bool injectMouseRelease(int _absx, int _absy, MouseButton _id);
00060 
00064         bool injectKeyPress(KeyCode _key, Char _text = 0);
00068         bool injectKeyRelease(KeyCode _key);
00069 
00071         bool isFocusMouse() { return mWidgetMouseFocus != nullptr; }
00073         bool isFocusKey() { return mWidgetKeyFocus != nullptr; }
00075         bool isCaptureMouse() { return mIsWidgetMouseCapture; }
00076 
00078         void setKeyFocusWidget(WidgetPtr _widget);
00080         void resetKeyFocusWidget(WidgetPtr _widget);
00082         void resetKeyFocusWidget() { setKeyFocusWidget(nullptr); }
00083 
00085         WidgetPtr getMouseFocusWidget() { return mWidgetMouseFocus; }
00087         WidgetPtr getKeyFocusWidget() { return mWidgetKeyFocus; }
00089         const IntPoint& getLastLeftPressed() { return mLastLeftPressed; }
00091         const IntPoint& getMousePosition() { return mMousePosition; }
00092 
00093         // тестовый вариант, очистка фокуса мыши
00095         void resetMouseFocusWidget();
00096 
00097         // работа с модальными окнами
00099         void addWidgetModal(WidgetPtr _widget);
00101         void removeWidgetModal(WidgetPtr _widget);
00102 
00104         bool isModalAny() { return !mVectorModalRootWidget.empty(); }
00105 
00107         bool isControlPressed() { return mIsControlPressed; }
00109         bool isShiftPressed() { return mIsShiftPressed; }
00110 
00114         void resetMouseCaptureWidget() { mIsWidgetMouseCapture = false; }
00115 
00116         void unlinkWidget(WidgetPtr _widget) { _unlinkWidget(_widget); }
00117 
00122         delegates::CMultiDelegate1<WidgetPtr>
00123             eventChangeMouseFocus;
00124 
00129         delegates::CMultiDelegate1<WidgetPtr>
00130             eventChangeKeyFocus;
00131 
00132     private:
00133         // удаляем данный виджет из всех возможных мест
00134         void _unlinkWidget(WidgetPtr _widget);
00135 
00136         void frameEntered(float _frame);
00137 
00138         void firstEncoding(KeyCode _key, bool bIsKeyPressed);
00139 
00140         // запоминает клавишу для поддержки повторения
00141         void storeKey(KeyCode _key, Char _text);
00142 
00143         // сбрасывает клавишу повторения
00144         void resetKey();
00145 
00146     private:
00147         // виджеты которым принадлежит фокус
00148         WidgetPtr mWidgetMouseFocus;
00149         WidgetPtr mWidgetKeyFocus;
00150         // захватил ли мышь активный виджет
00151         bool mIsWidgetMouseCapture;
00152         // таймер для двойного клика
00153         Timer mTimer; //used for double click timing
00154 
00155         // нажат ли шифт
00156         bool mIsShiftPressed;
00157         // нажат ли контрол
00158         bool mIsControlPressed;
00159         // там где была последний раз нажата левая кнопка
00160         IntPoint mLastLeftPressed;
00161         IntPoint mMousePosition;
00162         // клавиша для повтора
00163         KeyCode mHoldKey;
00164         Char mHoldChar;
00165         bool mFirstPressKey;
00166         float mTimerKey;
00167         int mOldAbsZ;
00168 
00169         // список виджетов с модальным режимом
00170         VectorWidgetPtr mVectorModalRootWidget;
00171 
00172     };
00173 
00174 } // namespace MyGUI
00175 
00176 #endif // __MYGUI_INPUT_MANAGER_H__

Generated on Sun Jan 30 2011 for MyGUI by  doxygen 1.7.1