mygui-MyGUI3.4.1+dfsg/0000775000175000017500000000000014017025067013447 5ustar psi29apsi29amygui-MyGUI3.4.1+dfsg/Common/0000775000175000017500000000000014017025067014677 5ustar psi29apsi29amygui-MyGUI3.4.1+dfsg/Common/Precompiled.cpp0000664000175000017500000000003114017025067017640 0ustar psi29apsi29a#include "Precompiled.h" mygui-MyGUI3.4.1+dfsg/Common/Precompiled.h0000664000175000017500000000002314017025067017306 0ustar psi29apsi29a#include mygui-MyGUI3.4.1+dfsg/Common/ItemBox/0000775000175000017500000000000014017025067016246 5ustar psi29apsi29amygui-MyGUI3.4.1+dfsg/Common/ItemBox/BaseCellView.h0000664000175000017500000000073414017025067020730 0ustar psi29apsi29a/*! @file @author Albert Semenov @date 07/2008 @module */ #ifndef BASE_CELL_VIEW_H_ #define BASE_CELL_VIEW_H_ #include #include "BaseLayout/BaseLayout.h" namespace wraps { template class BaseCellView : public BaseLayout { public: typedef DataType Type; protected: BaseCellView(const std::string& _layout, MyGUI::Widget* _parent) : BaseLayout(_layout, _parent) { } }; } // namespace wraps #endif // BASE_CELL_VIEW_H_ mygui-MyGUI3.4.1+dfsg/Common/ItemBox/BaseItemBox.h0000664000175000017500000001176314017025067020571 0ustar psi29apsi29a/*! @file @author Albert Semenov @date 07/2008 @module */ #ifndef BASE_ITEM_BOX_H_ #define BASE_ITEM_BOX_H_ #include #include "BaseLayout/BaseLayout.h" #include "ItemDropInfo.h" namespace wraps { template class BaseItemBox : public BaseLayout { public: typedef typename CellType::Type DataType; public: BaseItemBox(MyGUI::Widget* _parent) : BaseLayout("", _parent) { mBoxItems = mMainWidget->castType(); mBoxItems->setUserData(static_cast(this)); mBoxItems->requestCreateWidgetItem = MyGUI::newDelegate(this, &BaseItemBox::requestCreateWidgetItem); mBoxItems->requestCoordItem = MyGUI::newDelegate(this, &BaseItemBox::requestCoordWidgetItem); mBoxItems->requestDrawItem = MyGUI::newDelegate(this, &BaseItemBox::requestUpdateWidgetItem); mBoxItems->eventStartDrag += MyGUI::newDelegate(this, &BaseItemBox::notifyStartDrop); mBoxItems->eventRequestDrop += MyGUI::newDelegate(this, &BaseItemBox::notifyRequestDrop); mBoxItems->eventDropResult += MyGUI::newDelegate(this, &BaseItemBox::notifyEndDrop); mBoxItems->eventChangeDDState += MyGUI::newDelegate(this, &BaseItemBox::notifyDropState); mBoxItems->eventNotifyItem += MyGUI::newDelegate(this, &BaseItemBox::notifyNotifyItem); mBoxItems->eventToolTip += MyGUI::newDelegate(this, &BaseItemBox::notifyToolTip); } ~BaseItemBox() override { mBoxItems->requestCreateWidgetItem = nullptr; mBoxItems->requestCoordItem = nullptr; mBoxItems->requestDrawItem = nullptr; mBoxItems->eventStartDrag -= MyGUI::newDelegate(this, &BaseItemBox::notifyStartDrop); mBoxItems->eventRequestDrop -= MyGUI::newDelegate(this, &BaseItemBox::notifyRequestDrop); mBoxItems->eventDropResult -= MyGUI::newDelegate(this, &BaseItemBox::notifyEndDrop); mBoxItems->eventChangeDDState -= MyGUI::newDelegate(this, &BaseItemBox::notifyDropState); mBoxItems->eventNotifyItem -= MyGUI::newDelegate(this, &BaseItemBox::notifyNotifyItem); mBoxItems->eventToolTip -= MyGUI::newDelegate(this, &BaseItemBox::notifyToolTip); for (typename VectorCellView::iterator iter = mListCellView.begin(); iter != mListCellView.end(); ++iter) { delete *iter; } mListCellView.clear(); } void addItem(DataType _data) { mBoxItems->addItem(_data); } void removeItem(size_t _index) { mBoxItems->removeItemAt(_index); } void removeAllItems() { mBoxItems->removeAllItems(); } void setItemData(size_t _index, DataType _data) { mBoxItems->setItemDataAt(_index, _data); } template ValueType* getItemDataAt(size_t _index, bool _throw = true) { return mBoxItems->getItemDataAt(_index, _throw); } private: void requestCreateWidgetItem(MyGUI::ItemBox* _sender, MyGUI::Widget* _item) { CellType* cell = new CellType(_item); _item->setUserData(cell); mListCellView.push_back(cell); } void requestCoordWidgetItem(MyGUI::ItemBox* _sender, MyGUI::IntCoord& _coord, bool _drop) { CellType::getCellDimension(_sender, _coord, _drop); } void requestUpdateWidgetItem(MyGUI::ItemBox* _sender, MyGUI::Widget* _item, const MyGUI::IBDrawItemInfo& _data) { CellType* cell = *_item->getUserData(); cell->update(_data, *mBoxItems->getItemDataAt(_data.index)); } void notifyStartDrop(MyGUI::DDContainer* _sender, const MyGUI::DDItemInfo& _info, bool& _result) { eventStartDrag(this, DDItemInfo(_info), _result); } void notifyRequestDrop(MyGUI::DDContainer* _sender, const MyGUI::DDItemInfo& _info, bool& _result) { eventRequestDrop(this, DDItemInfo(_info), _result); } void notifyEndDrop(MyGUI::DDContainer* _sender, const MyGUI::DDItemInfo& _info, bool _result) { eventDropResult(this, DDItemInfo(_info), _result); } void notifyDropState(MyGUI::DDContainer* _sender, MyGUI::DDItemState _state) { eventChangeDDState(this, _state); } void notifyNotifyItem(MyGUI::ItemBox* _sender, const MyGUI::IBNotifyItemData& _info) { eventNotifyItem(this, _info); } void notifyToolTip(MyGUI::Widget* _sender, const MyGUI::ToolTipInfo& _info) { if (_info.index == MyGUI::ITEM_NONE) eventToolTip(this, _info, DataType()); else eventToolTip(this, _info, *mBoxItems->getItemDataAt(_info.index)); } public: MyGUI::delegates::CDelegate3 eventStartDrag; MyGUI::delegates::CDelegate3 eventRequestDrop; MyGUI::delegates::CDelegate3 eventDropResult; MyGUI::delegates::CDelegate2 eventChangeDDState; MyGUI::delegates::CDelegate2 eventNotifyItem; MyGUI::delegates::CDelegate3 eventToolTip; MyGUI::ItemBox* getItemBox() const { return mBoxItems; } private: typedef std::vector VectorCellView; VectorCellView mListCellView; MyGUI::ItemBox* mBoxItems; }; } // namespace wraps #endif // BASE_ITEM_BOX_H_ mygui-MyGUI3.4.1+dfsg/Common/ItemBox/ItemDropInfo.h0000664000175000017500000000122714017025067020760 0ustar psi29apsi29a/*! @file @author Albert Semenov @date 07/2008 @module */ #ifndef ITEM_DROP_INFO_H_ #define ITEM_DROP_INFO_H_ #include #include "BaseLayout/BaseLayout.h" namespace wraps { struct DDItemInfo { DDItemInfo(const MyGUI::DDItemInfo& _info) : sender(*_info.sender->getUserData()), sender_index(_info.sender_index), receiver(_info.receiver ? *_info.receiver->getUserData() : nullptr), receiver_index(_info.receiver_index) { } wraps::BaseLayout* sender; size_t sender_index; wraps::BaseLayout* receiver; size_t receiver_index; }; } // namespace wraps #endif // ITEM_DROP_INFO_H_ mygui-MyGUI3.4.1+dfsg/Common/PanelView/0000775000175000017500000000000014017025067016571 5ustar psi29apsi29amygui-MyGUI3.4.1+dfsg/Common/PanelView/BasePanelView.h0000664000175000017500000001362014017025067021431 0ustar psi29apsi29a/*! @file @author Albert Semenov @date 08/2008 @module */ #ifndef BASE_PANEL_VIEW_H_ #define BASE_PANEL_VIEW_H_ #include #include "BaseLayout/BaseLayout.h" #include "PanelView/BasePanelViewItem.h" namespace wraps { template class BasePanelView : public BaseLayout { public: typedef std::vector VectorCell; public: BasePanelView(const std::string& _layout, MyGUI::Widget* _parent) : BaseLayout(_layout, _parent), mNeedUpdate(false), mOldClientWidth(0), mFirstInitialise(false) { mScrollView = mMainWidget->castType(); // потом перенести в лейаут mScrollView->setCanvasAlign(MyGUI::Align::HCenter | MyGUI::Align::Top); mScrollView->setVisibleHScroll(false); mNeedUpdate = false; mOldClientWidth = mScrollView->getViewCoord().width; MyGUI::Gui::getInstance().eventFrameStart += MyGUI::newDelegate(this, &BasePanelView::frameEnteredCheck); } ~BasePanelView() override { MyGUI::Gui::getInstance().eventFrameStart -= MyGUI::newDelegate(this, &BasePanelView::frameEnteredCheck); removeAllItems(); if (mNeedUpdate) MyGUI::Gui::getInstance().eventFrameStart -= MyGUI::newDelegate(this, &BasePanelView::frameEntered); } //! Get number of items size_t getItemCount() { return mItems.size(); } //! Insert an item into a list at a specified position void insertItem(size_t _index, BasePanelViewItem* _item) { MYGUI_ASSERT_RANGE_INSERT(_index, mItems.size(), "BasePanelView::insertItem"); if (_index == MyGUI::ITEM_NONE) _index = mItems.size(); MYGUI_ASSERT(findItem(_item) == MyGUI::ITEM_NONE, "panel allready exist"); // создаем лейаут базовой ячейки BasePanelViewCell* cell = new TypeCell(mScrollView); cell->eventUpdatePanel = MyGUI::newDelegate(this, &BasePanelView::notifyUpdatePanel); // теперь основной лейаут ячейки _item->_initialise(cell); mItems.insert(mItems.begin() + _index, _item); setNeedUpdate(); mFirstInitialise = true; } //! Add an item to the end of a list void addItem(BasePanelViewItem* _item) { insertItem(MyGUI::ITEM_NONE, _item); } //! Get item from specified position BasePanelViewItem* getItem(size_t _index) { MYGUI_ASSERT_RANGE(_index, mItems.size(), "BasePanelView::getItem"); return mItems[_index]; } //! Search item, returns the position of the first occurrence in list or ITEM_NONE if item not found size_t findItem(BasePanelViewItem* _item) { for (VectorCell::iterator iter = mItems.begin(); iter != mItems.end(); ++iter) { if ((*iter) == _item) return iter - mItems.begin(); } return MyGUI::ITEM_NONE; } //! Remove item at a specified position void removeItemAt(size_t _index) { MYGUI_ASSERT_RANGE(_index, mItems.size(), "BasePanelView::removeItemAt"); BasePanelViewCell* cell = mItems[_index]->getPanelCell(); mItems[_index]->_shutdown(); delete cell; mItems.erase(mItems.begin() + _index); setNeedUpdate(); } //! Remove item at a specified position void removeItem(BasePanelViewItem* _item) { size_t index = findItem(_item); MYGUI_ASSERT(index != MyGUI::ITEM_NONE, "item is not found"); removeItemAt(index); } //! Remove all items void removeAllItems() { for (VectorCell::iterator iter = mItems.begin(); iter != mItems.end(); ++iter) { BasePanelViewCell* cell = (*iter)->getPanelCell(); (*iter)->_shutdown(); delete cell; } mItems.clear(); setNeedUpdate(); } void updateView() { // вычисляем максимальную высоту всего добра int height = 0; for (VectorCell::iterator iter = mItems.begin(); iter != mItems.end(); ++iter) { MyGUI::Widget* widget = (*iter)->getPanelCell()->getMainWidget(); if (widget->getVisible()) { height += widget->getHeight(); } } // ставим высоту холста, и спрашиваем получившуюся ширину клиента mScrollView->setCanvasSize(0, height); // ширина клиента могла поменятся const MyGUI::IntSize& size = mScrollView->getViewCoord().size(); mScrollView->setCanvasSize(size.width, height); bool change = mFirstInitialise; if (mOldClientWidth != size.width) { mOldClientWidth = size.width; change = true; } // выравниваем все панели int pos = 0; for (VectorCell::iterator iter = mItems.begin(); iter != mItems.end(); ++iter) { MyGUI::Widget* widget = (*iter)->getPanelCell()->getMainWidget(); if (widget->getVisible() || mFirstInitialise) { height = widget->getHeight(); widget->setCoord(MyGUI::IntCoord(0, pos, size.width, height)); // оповещаем, что мы обновили ширину if (change) (*iter)->notifyChangeWidth(size.width); pos += height; } } mNeedUpdate = false; mFirstInitialise = false; MyGUI::Gui::getInstance().eventFrameStart -= MyGUI::newDelegate(this, &BasePanelView::frameEntered); } // изменились размеры // необходимо обновить все панели void setNeedUpdate() { if (!mNeedUpdate) { mNeedUpdate = true; MyGUI::Gui::getInstance().eventFrameStart += MyGUI::newDelegate(this, &BasePanelView::frameEntered); } } private: void notifyUpdatePanel(BasePanelViewCell* _panel) { setNeedUpdate(); } void frameEntered(float _time) { updateView(); } void frameEnteredCheck(float _time) { const MyGUI::IntSize& size = mMainWidget->getSize(); if (size != mOldSize) { mOldSize = size; setNeedUpdate(); } } protected: MyGUI::ScrollView* mScrollView; private: VectorCell mItems; bool mNeedUpdate; int mOldClientWidth; MyGUI::IntSize mOldSize; bool mFirstInitialise; }; } // namespace wraps #endif // BASE_PANEL_VIEW_H_ mygui-MyGUI3.4.1+dfsg/Common/PanelView/BasePanelViewItem.h0000664000175000017500000000314214017025067022246 0ustar psi29apsi29a/*! @file @author Albert Semenov @date 01/2009 @module */ #ifndef BASE_PANEL_VIEW_ITEM_H_ #define BASE_PANEL_VIEW_ITEM_H_ #include #include "BaseLayout/BaseLayout.h" #include "PanelView/BasePanelViewCell.h" namespace wraps { class BasePanelViewItem : public wraps::BaseLayout { public: BasePanelViewItem(const std::string& _layout) : BaseLayout("", nullptr), mPanelCell(nullptr), mWidgetClient(nullptr), mLayout(_layout) { } void _initialise(BasePanelViewCell* _cell) { mPanelCell = _cell; mWidgetClient = mPanelCell->getClient(); if ( ! mLayout.empty()) { BaseLayout::initialise(mLayout, mWidgetClient); mMainWidget->setCoord(0, 0, mWidgetClient->getWidth(), mMainWidget->getHeight()); mPanelCell->setClientHeight(mMainWidget->getHeight(), false); } initialise(); } void _shutdown() { shutdown(); if ( ! mLayout.empty()) { BaseLayout::shutdown(); } mPanelCell = nullptr; mWidgetClient = nullptr; } // реально изменилась ширина ячейки virtual void notifyChangeWidth(int _width) { } virtual void setVisible(bool _visible) { mPanelCell->setVisible(_visible); mPanelCell->eventUpdatePanel(mPanelCell); } bool getVisible() { return mPanelCell->getVisible(); } BasePanelViewCell* getPanelCell() { return mPanelCell; } protected: virtual void initialise() { } virtual void shutdown() { } protected: BasePanelViewCell* mPanelCell; MyGUI::Widget* mWidgetClient; std::string mLayout; }; } // namespace wraps #endif // BASE_PANEL_VIEW_ITEM_H_ mygui-MyGUI3.4.1+dfsg/Common/PanelView/BasePanelViewCell.h0000664000175000017500000000650114017025067022231 0ustar psi29apsi29a/*! @file @author Albert Semenov @date 01/2009 @module */ #ifndef BASE_PANEL_VIEW_CELL_H_ #define BASE_PANEL_VIEW_CELL_H_ #include #include "BaseLayout/BaseLayout.h" namespace wraps { class BasePanelViewCell : public BaseLayout { public: BasePanelViewCell(const std::string& _layout, MyGUI::Widget* _parent) : BaseLayout(_layout, _parent), mTextCaption(nullptr), mWidgetClient(nullptr), m_minimized(false) { mMainWidget->setPosition(0, 0); m_minHeight = mMainWidget->getHeight() - getClient()->getHeight(); m_maxHeight = mMainWidget->getHeight(); } void setCaption(const MyGUI::UString& _caption) { if (mTextCaption) mTextCaption->setCaption(_caption); } MyGUI::Widget* getClient() { return mWidgetClient ? mWidgetClient : mMainWidget; } MyGUI::Widget* getMainWidget() { return mMainWidget; } void setClientHeight(int _height, bool _smooth = true) { m_minHeight = mMainWidget->getHeight() - getClient()->getHeight(); m_maxHeight = m_minHeight + _height; if (_smooth) { if (!m_minimized) { updateMinimized(); } } else { mMainWidget->setSize(mMainWidget->getWidth(), m_maxHeight); eventUpdatePanel(this); } } bool isMinimized() const { return m_minimized; } virtual void setMinimized(bool _minimized) { m_minimized = _minimized; updateMinimized(); } void setVisible(bool _visible) { mMainWidget->setVisible(_visible); } bool getVisible() { return mMainWidget->getVisible(); } MyGUI::delegates::CDelegate1 eventUpdatePanel; private: void notifyUpdateAction(MyGUI::Widget* _widget, MyGUI::ControllerItem* _controller) { eventUpdatePanel(this); } void updateMinimized() { const float POSITION_CONTROLLER_TIME = 0.5f; if (!m_minimized) { MyGUI::IntSize size(mMainWidget->getWidth(), m_maxHeight); MyGUI::ControllerPosition* controller = createControllerPosition(size, POSITION_CONTROLLER_TIME, MyGUI::newDelegate(MyGUI::action::inertionalMoveFunction)); controller->eventUpdateAction += newDelegate(this, &BasePanelViewCell::notifyUpdateAction); MyGUI::ControllerManager::getInstance().addItem(mMainWidget, controller); } else { MyGUI::IntSize size(mMainWidget->getWidth(), m_minHeight); MyGUI::ControllerPosition* controller = createControllerPosition(size, POSITION_CONTROLLER_TIME, MyGUI::newDelegate(MyGUI::action::inertionalMoveFunction)); controller->eventUpdateAction += newDelegate(this, &BasePanelViewCell::notifyUpdateAction); MyGUI::ControllerManager::getInstance().addItem(mMainWidget, controller); } } MyGUI::ControllerPosition* createControllerPosition(const MyGUI::IntSize& _size, float _time, MyGUI::ControllerPosition::FrameAction::IDelegate* _action) { MyGUI::ControllerItem* item = MyGUI::ControllerManager::getInstance().createItem(MyGUI::ControllerPosition::getClassTypeName()); MyGUI::ControllerPosition* controller = item->castType(); controller->setSize(_size); controller->setTime(_time); controller->setAction(_action); return controller; } protected: MyGUI::TextBox* mTextCaption; MyGUI::Widget* mWidgetClient; bool m_minimized; int m_minHeight; int m_maxHeight; }; } // namespace wraps #endif // BASE_PANEL_VIEW_CELL_H_ mygui-MyGUI3.4.1+dfsg/Common/Input/0000775000175000017500000000000014017025067015776 5ustar psi29apsi29amygui-MyGUI3.4.1+dfsg/Common/Input/InputConverter.h0000664000175000017500000006677614017025067021164 0ustar psi29apsi29a/*! @file @author Albert Semenov @date 02/2010 @module */ #ifndef INPUT_CONVERTER_H_ #define INPUT_CONVERTER_H_ #include #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32 #include #ifdef max #undef max #endif #ifdef min #undef min #endif #endif //#define INPUT_KEY_NAME #ifdef INPUT_KEY_NAME #include #include #endif namespace input { // Windows virtual keys enum VirtualKey { VLK_LBUTTON = 0x01, VLK_RBUTTON = 0x02, VLK_CANCEL = 0x03, VLK_MBUTTON = 0x04, /* NOT contiguous with L & RBUTTON */ VLK_XBUTTON1 = 0x05, /* NOT contiguous with L & RBUTTON */ VLK_XBUTTON2 = 0x06, /* NOT contiguous with L & RBUTTON */ /* 0x07 : unassigned */ VLK_BACK = 0x08, VLK_TAB = 0x09, /* 0x0A - 0x0B : reserved */ VLK_CLEAR = 0x0C, VLK_RETURN = 0x0D, VLK_SHIFT = 0x10, VLK_CONTROL = 0x11, VLK_MENU = 0x12, VLK_PAUSE = 0x13, VLK_CAPITAL = 0x14, VLK_KANA = 0x15, VLK_HANGEUL = 0x15, /* old name - should be here for compatibility */ VLK_HANGUL = 0x15, VLK_JUNJA = 0x17, VLK_FINAL = 0x18, VLK_HANJA = 0x19, VLK_KANJI = 0x19, VLK_ESCAPE = 0x1B, VLK_CONVERT = 0x1C, VLK_NONCONVERT = 0x1D, VLK_ACCEPT = 0x1E, VLK_MODECHANGE = 0x1F, VLK_SPACE = 0x20, VLK_PRIOR = 0x21, VLK_NEXT = 0x22, VLK_END = 0x23, VLK_HOME = 0x24, VLK_LEFT = 0x25, VLK_UP = 0x26, VLK_RIGHT = 0x27, VLK_DOWN = 0x28, VLK_SELECT = 0x29, VLK_PRINT = 0x2A, VLK_EXECUTE = 0x2B, VLK_SNAPSHOT = 0x2C, VLK_INSERT = 0x2D, VLK_DELETE = 0x2E, VLK_HELP = 0x2F, /* VLK_0 - VLK_9 are the same as ASCII '0' - '9' (0x30 - 0x39) 0x40 : unassigned VLK_A - VLK_Z are the same as ASCII 'A' - 'Z' (0x41 - 0x5A) */ VLK_0 = 0x30, VLK_1 = 0x31, VLK_2 = 0x32, VLK_3 = 0x33, VLK_4 = 0x34, VLK_5 = 0x35, VLK_6 = 0x36, VLK_7 = 0x37, VLK_8 = 0x38, VLK_9 = 0x39, VLK_A = 0x41, VLK_B = 0x42, VLK_C = 0x43, VLK_D = 0x44, VLK_E = 0x45, VLK_F = 0x46, VLK_G = 0x47, VLK_H = 0x48, VLK_I = 0x49, VLK_J = 0x4A, VLK_K = 0x4B, VLK_L = 0x4C, VLK_M = 0x4D, VLK_N = 0x4E, VLK_O = 0x4F, VLK_P = 0x50, VLK_Q = 0x51, VLK_R = 0x52, VLK_S = 0x53, VLK_T = 0x54, VLK_U = 0x55, VLK_V = 0x56, VLK_W = 0x57, VLK_X = 0x58, VLK_Y = 0x59, VLK_Z = 0x5A, VLK_LWIN = 0x5B, VLK_RWIN = 0x5C, VLK_APPS = 0x5D, /* 0x5E : reserved */ VLK_SLEEP = 0x5F, VLK_NUMPAD0 = 0x60, VLK_NUMPAD1 = 0x61, VLK_NUMPAD2 = 0x62, VLK_NUMPAD3 = 0x63, VLK_NUMPAD4 = 0x64, VLK_NUMPAD5 = 0x65, VLK_NUMPAD6 = 0x66, VLK_NUMPAD7 = 0x67, VLK_NUMPAD8 = 0x68, VLK_NUMPAD9 = 0x69, VLK_MULTIPLY = 0x6A, VLK_ADD = 0x6B, VLK_SEPARATOR = 0x6C, VLK_SUBTRACT = 0x6D, VLK_DECIMAL = 0x6E, VLK_DIVIDE = 0x6F, VLK_F1 = 0x70, VLK_F2 = 0x71, VLK_F3 = 0x72, VLK_F4 = 0x73, VLK_F5 = 0x74, VLK_F6 = 0x75, VLK_F7 = 0x76, VLK_F8 = 0x77, VLK_F9 = 0x78, VLK_F10 = 0x79, VLK_F11 = 0x7A, VLK_F12 = 0x7B, VLK_F13 = 0x7C, VLK_F14 = 0x7D, VLK_F15 = 0x7E, VLK_F16 = 0x7F, VLK_F17 = 0x80, VLK_F18 = 0x81, VLK_F19 = 0x82, VLK_F20 = 0x83, VLK_F21 = 0x84, VLK_F22 = 0x85, VLK_F23 = 0x86, VLK_F24 = 0x87, /* 0x88 - 0x8F : unassigned */ VLK_NUMLOCK = 0x90, VLK_SCROLL = 0x91, /* NEC PC-9800 kbd definitions */ VLK_OEM_NEC_EQUAL = 0x92, // '=' key on numpad /* Fujitsu/OASYS kbd definitions */ VLK_OEM_FJ_JISHO = 0x92, // 'Dictionary' key VLK_OEM_FJ_MASSHOU = 0x93, // 'Unregister word' key VLK_OEM_FJ_TOUROKU = 0x94, // 'Register word' key VLK_OEM_FJ_LOYA = 0x95, // 'Left OYAYUBI' key VLK_OEM_FJ_ROYA = 0x96, // 'Right OYAYUBI' key /* 0x97 - 0x9F : unassigned */ /* VLK_L* & VLK_R* - left and right Alt, Ctrl and Shift virtual keys. Used only as parameters to GetAsyncKeyState() and GetKeyState(). No other API or message will distinguish left and right keys in this way. */ VLK_LSHIFT = 0xA0, VLK_RSHIFT = 0xA1, VLK_LCONTROL = 0xA2, VLK_RCONTROL = 0xA3, VLK_LMENU = 0xA4, VLK_RMENU = 0xA5, VLK_BROWSER_BACK = 0xA6, VLK_BROWSER_FORWARD = 0xA7, VLK_BROWSER_REFRESH = 0xA8, VLK_BROWSER_STOP = 0xA9, VLK_BROWSER_SEARCH = 0xAA, VLK_BROWSER_FAVORITES = 0xAB, VLK_BROWSER_HOME = 0xAC, VLK_VOLUME_MUTE = 0xAD, VLK_VOLUME_DOWN = 0xAE, VLK_VOLUME_UP = 0xAF, VLK_MEDIA_NEXT_TRACK = 0xB0, VLK_MEDIA_PREV_TRACK = 0xB1, VLK_MEDIA_STOP = 0xB2, VLK_MEDIA_PLAY_PAUSE = 0xB3, VLK_LAUNCH_MAIL = 0xB4, VLK_LAUNCH_MEDIA_SELECT = 0xB5, VLK_LAUNCH_APP1 = 0xB6, VLK_LAUNCH_APP2 = 0xB7, /* 0xB8 - 0xB9 : reserved */ VLK_OEM_1 = 0xBA, // ';:' for US VLK_OEM_PLUS = 0xBB, // '+' any country VLK_OEM_COMMA = 0xBC, // ',' any country VLK_OEM_MINUS = 0xBD, // '-' any country VLK_OEM_PERIOD = 0xBE, // '.' any country VLK_OEM_2 = 0xBF, // '/?' for US VLK_OEM_3 = 0xC0, // '`~' for US /* 0xC1 - 0xD7 : reserved */ /* 0xD8 - 0xDA : unassigned */ VLK_OEM_4 = 0xDB, // '[{' for US VLK_OEM_5 = 0xDC, // '\|' for US VLK_OEM_6 = 0xDD, // ']}' for US VLK_OEM_7 = 0xDE, // ''"' for US VLK_OEM_8 = 0xDF, /* 0xE0 : reserved */ /* Various extended or enhanced keyboards */ VLK_OEM_AX = 0xE1, // 'AX' key on Japanese AX kbd VLK_OEM_102 = 0xE2, // "<>" or "\|" on RT 102-key kbd. VLK_ICO_HELP = 0xE3, // Help key on ICO VLK_ICO_00 = 0xE4, // 00 key on ICO VLK_PROCESSKEY = 0xE5, VLK_ICO_CLEAR = 0xE6, VLK_PACKET = 0xE7, /* 0xE8 : unassigned */ /* Nokia/Ericsson definitions */ VLK_OEM_RESET = 0xE9, VLK_OEM_JUMP = 0xEA, VLK_OEM_PA1 = 0xEB, VLK_OEM_PA2 = 0xEC, VLK_OEM_PA3 = 0xED, VLK_OEM_WSCTRL = 0xEE, VLK_OEM_CUSEL = 0xEF, VLK_OEM_ATTN = 0xF0, VLK_OEM_FINISH = 0xF1, VLK_OEM_COPY = 0xF2, VLK_OEM_AUTO = 0xF3, VLK_OEM_ENLW = 0xF4, VLK_OEM_BACKTAB = 0xF5, VLK_ATTN = 0xF6, VLK_CRSEL = 0xF7, VLK_EXSEL = 0xF8, VLK_EREOF = 0xF9, VLK_PLAY = 0xFA, VLK_ZOOM = 0xFB, VLK_NONAME = 0xFC, VLK_PA1 = 0xFD, VLK_OEM_CLEAR = 0xFE, VLK_MAX }; // Keyboard scan codes - DirectInput enum ScanCode { SC_UNASSIGNED = 0x00, SC_ESCAPE = 0x01, SC_1 = 0x02, SC_2 = 0x03, SC_3 = 0x04, SC_4 = 0x05, SC_5 = 0x06, SC_6 = 0x07, SC_7 = 0x08, SC_8 = 0x09, SC_9 = 0x0A, SC_0 = 0x0B, SC_MINUS = 0x0C, // - on main keyboard SC_EQUALS = 0x0D, SC_BACK = 0x0E, // backspace SC_TAB = 0x0F, SC_Q = 0x10, SC_W = 0x11, SC_E = 0x12, SC_R = 0x13, SC_T = 0x14, SC_Y = 0x15, SC_U = 0x16, SC_I = 0x17, SC_O = 0x18, SC_P = 0x19, SC_LBRACKET = 0x1A, SC_RBRACKET = 0x1B, SC_RETURN = 0x1C, // Enter on main keyboard SC_LCONTROL = 0x1D, SC_A = 0x1E, SC_S = 0x1F, SC_D = 0x20, SC_F = 0x21, SC_G = 0x22, SC_H = 0x23, SC_J = 0x24, SC_K = 0x25, SC_L = 0x26, SC_SEMICOLON = 0x27, SC_APOSTROPHE = 0x28, SC_GRAVE = 0x29, // accent SC_LSHIFT = 0x2A, SC_BACKSLASH = 0x2B, SC_Z = 0x2C, SC_X = 0x2D, SC_C = 0x2E, SC_V = 0x2F, SC_B = 0x30, SC_N = 0x31, SC_M = 0x32, SC_COMMA = 0x33, SC_PERIOD = 0x34, // . on main keyboard SC_SLASH = 0x35, // / on main keyboard SC_RSHIFT = 0x36, SC_MULTIPLY = 0x37, // * on numeric keypad SC_LMENU = 0x38, // left Alt SC_SPACE = 0x39, SC_CAPITAL = 0x3A, SC_F1 = 0x3B, SC_F2 = 0x3C, SC_F3 = 0x3D, SC_F4 = 0x3E, SC_F5 = 0x3F, SC_F6 = 0x40, SC_F7 = 0x41, SC_F8 = 0x42, SC_F9 = 0x43, SC_F10 = 0x44, SC_NUMLOCK = 0x45, SC_SCROLL = 0x46, // Scroll Lock SC_NUMPAD7 = 0x47, SC_NUMPAD8 = 0x48, SC_NUMPAD9 = 0x49, SC_SUBTRACT = 0x4A, // - on numeric keypad SC_NUMPAD4 = 0x4B, SC_NUMPAD5 = 0x4C, SC_NUMPAD6 = 0x4D, SC_ADD = 0x4E, // + on numeric keypad SC_NUMPAD1 = 0x4F, SC_NUMPAD2 = 0x50, SC_NUMPAD3 = 0x51, SC_NUMPAD0 = 0x52, SC_DECIMAL = 0x53, // . on numeric keypad SC_OEM_102 = 0x56, // < > | on UK/Germany keyboards SC_F11 = 0x57, SC_F12 = 0x58, SC_F13 = 0x64, // (NEC PC98) SC_F14 = 0x65, // (NEC PC98) SC_F15 = 0x66, // (NEC PC98) SC_KANA = 0x70, // (Japanese keyboard) SC_ABNT_C1 = 0x73, // / ? on Portugese (Brazilian) keyboards SC_CONVERT = 0x79, // (Japanese keyboard) SC_NOCONVERT = 0x7B, // (Japanese keyboard) SC_YEN = 0x7D, // (Japanese keyboard) SC_ABNT_C2 = 0x7E, // Numpad . on Portugese (Brazilian) keyboards SC_NUMPADEQUALS = 0x8D, // = on numeric keypad (NEC PC98) SC_PREVTRACK = 0x90, // Previous Track (SC_CIRCUMFLEX on Japanese keyboard) SC_AT = 0x91, // (NEC PC98) SC_COLON = 0x92, // (NEC PC98) SC_UNDERLINE = 0x93, // (NEC PC98) SC_KANJI = 0x94, // (Japanese keyboard) SC_STOP = 0x95, // (NEC PC98) SC_AX = 0x96, // (Japan AX) SC_UNLABELED = 0x97, // (J3100) SC_NEXTTRACK = 0x99, // Next Track SC_NUMPADENTER = 0x9C, // Enter on numeric keypad SC_RCONTROL = 0x9D, SC_MUTE = 0xA0, // Mute SC_CALCULATOR = 0xA1, // Calculator SC_PLAYPAUSE = 0xA2, // Play / Pause SC_MEDIASTOP = 0xA4, // Media Stop SC_VOLUMEDOWN = 0xAE, // Volume - SC_VOLUMEUP = 0xB0, // Volume + SC_WEBHOME = 0xB2, // Web home SC_NUMPADCOMMA = 0xB3, // , on numeric keypad (NEC PC98) SC_DIVIDE = 0xB5, // / on numeric keypad SC_SYSRQ = 0xB7, SC_RMENU = 0xB8, // right Alt SC_PAUSE = 0xC5, // Pause SC_HOME = 0xC7, // Home on arrow keypad SC_UP = 0xC8, // UpArrow on arrow keypad SC_PGUP = 0xC9, // PgUp on arrow keypad SC_LEFT = 0xCB, // LeftArrow on arrow keypad SC_RIGHT = 0xCD, // RightArrow on arrow keypad SC_END = 0xCF, // End on arrow keypad SC_DOWN = 0xD0, // DownArrow on arrow keypad SC_PGDOWN = 0xD1, // PgDn on arrow keypad SC_INSERT = 0xD2, // Insert on arrow keypad SC_DELETE = 0xD3, // Delete on arrow keypad SC_LWIN = 0xDB, // Left Windows key SC_RWIN = 0xDC, // Right Windows key SC_APPS = 0xDD, // AppMenu key SC_POWER = 0xDE, // System Power SC_SLEEP = 0xDF, // System Sleep SC_WAKE = 0xE3, // System Wake SC_WEBSEARCH = 0xE5, // Web Search SC_WEBFAVORITES = 0xE6, // Web Favorites SC_WEBREFRESH = 0xE7, // Web Refresh SC_WEBSTOP = 0xE8, // Web Stop SC_WEBFORWARD = 0xE9, // Web Forward SC_WEBBACK = 0xEA, // Web Back SC_MYCOMPUTER = 0xEB, // My Computer SC_MAIL = 0xEC, // Mail SC_MEDIASELECT = 0xED, // Media Select SC_MAX }; class Table { public: Table() { #ifdef INPUT_KEY_NAME mVirtualKeyToName.resize(VLK_MAX); #define DECLARE_VIRTUAL_KEY(_key) mVirtualKeyToName[_key] = #_key; DECLARE_VIRTUAL_KEY(VLK_LBUTTON) DECLARE_VIRTUAL_KEY(VLK_RBUTTON) DECLARE_VIRTUAL_KEY(VLK_CANCEL) DECLARE_VIRTUAL_KEY(VLK_MBUTTON) DECLARE_VIRTUAL_KEY(VLK_XBUTTON1) DECLARE_VIRTUAL_KEY(VLK_XBUTTON2) DECLARE_VIRTUAL_KEY(VLK_BACK) DECLARE_VIRTUAL_KEY(VLK_TAB) DECLARE_VIRTUAL_KEY(VLK_CLEAR) DECLARE_VIRTUAL_KEY(VLK_RETURN) DECLARE_VIRTUAL_KEY(VLK_SHIFT) DECLARE_VIRTUAL_KEY(VLK_CONTROL) DECLARE_VIRTUAL_KEY(VLK_MENU) DECLARE_VIRTUAL_KEY(VLK_PAUSE) DECLARE_VIRTUAL_KEY(VLK_CAPITAL) DECLARE_VIRTUAL_KEY(VLK_KANA) DECLARE_VIRTUAL_KEY(VLK_HANGEUL) DECLARE_VIRTUAL_KEY(VLK_HANGUL) DECLARE_VIRTUAL_KEY(VLK_JUNJA) DECLARE_VIRTUAL_KEY(VLK_FINAL) DECLARE_VIRTUAL_KEY(VLK_HANJA) DECLARE_VIRTUAL_KEY(VLK_KANJI) DECLARE_VIRTUAL_KEY(VLK_ESCAPE) DECLARE_VIRTUAL_KEY(VLK_CONVERT) DECLARE_VIRTUAL_KEY(VLK_NONCONVERT) DECLARE_VIRTUAL_KEY(VLK_ACCEPT) DECLARE_VIRTUAL_KEY(VLK_MODECHANGE) DECLARE_VIRTUAL_KEY(VLK_SPACE) DECLARE_VIRTUAL_KEY(VLK_PRIOR) DECLARE_VIRTUAL_KEY(VLK_NEXT) DECLARE_VIRTUAL_KEY(VLK_END) DECLARE_VIRTUAL_KEY(VLK_HOME) DECLARE_VIRTUAL_KEY(VLK_LEFT) DECLARE_VIRTUAL_KEY(VLK_UP) DECLARE_VIRTUAL_KEY(VLK_RIGHT) DECLARE_VIRTUAL_KEY(VLK_DOWN) DECLARE_VIRTUAL_KEY(VLK_SELECT) DECLARE_VIRTUAL_KEY(VLK_PRINT) DECLARE_VIRTUAL_KEY(VLK_EXECUTE) DECLARE_VIRTUAL_KEY(VLK_SNAPSHOT) DECLARE_VIRTUAL_KEY(VLK_INSERT) DECLARE_VIRTUAL_KEY(VLK_DELETE) DECLARE_VIRTUAL_KEY(VLK_HELP) DECLARE_VIRTUAL_KEY(VLK_0) DECLARE_VIRTUAL_KEY(VLK_1) DECLARE_VIRTUAL_KEY(VLK_2) DECLARE_VIRTUAL_KEY(VLK_3) DECLARE_VIRTUAL_KEY(VLK_4) DECLARE_VIRTUAL_KEY(VLK_5) DECLARE_VIRTUAL_KEY(VLK_6) DECLARE_VIRTUAL_KEY(VLK_7) DECLARE_VIRTUAL_KEY(VLK_8) DECLARE_VIRTUAL_KEY(VLK_9) DECLARE_VIRTUAL_KEY(VLK_A) DECLARE_VIRTUAL_KEY(VLK_B) DECLARE_VIRTUAL_KEY(VLK_C) DECLARE_VIRTUAL_KEY(VLK_D) DECLARE_VIRTUAL_KEY(VLK_E) DECLARE_VIRTUAL_KEY(VLK_F) DECLARE_VIRTUAL_KEY(VLK_G) DECLARE_VIRTUAL_KEY(VLK_H) DECLARE_VIRTUAL_KEY(VLK_I) DECLARE_VIRTUAL_KEY(VLK_J) DECLARE_VIRTUAL_KEY(VLK_K) DECLARE_VIRTUAL_KEY(VLK_L) DECLARE_VIRTUAL_KEY(VLK_M) DECLARE_VIRTUAL_KEY(VLK_N) DECLARE_VIRTUAL_KEY(VLK_O) DECLARE_VIRTUAL_KEY(VLK_P) DECLARE_VIRTUAL_KEY(VLK_Q) DECLARE_VIRTUAL_KEY(VLK_R) DECLARE_VIRTUAL_KEY(VLK_S) DECLARE_VIRTUAL_KEY(VLK_T) DECLARE_VIRTUAL_KEY(VLK_U) DECLARE_VIRTUAL_KEY(VLK_V) DECLARE_VIRTUAL_KEY(VLK_W) DECLARE_VIRTUAL_KEY(VLK_X) DECLARE_VIRTUAL_KEY(VLK_Y) DECLARE_VIRTUAL_KEY(VLK_Z) DECLARE_VIRTUAL_KEY(VLK_LWIN) DECLARE_VIRTUAL_KEY(VLK_RWIN) DECLARE_VIRTUAL_KEY(VLK_APPS) DECLARE_VIRTUAL_KEY(VLK_SLEEP) DECLARE_VIRTUAL_KEY(VLK_NUMPAD0) DECLARE_VIRTUAL_KEY(VLK_NUMPAD1) DECLARE_VIRTUAL_KEY(VLK_NUMPAD2) DECLARE_VIRTUAL_KEY(VLK_NUMPAD3) DECLARE_VIRTUAL_KEY(VLK_NUMPAD4) DECLARE_VIRTUAL_KEY(VLK_NUMPAD5) DECLARE_VIRTUAL_KEY(VLK_NUMPAD6) DECLARE_VIRTUAL_KEY(VLK_NUMPAD7) DECLARE_VIRTUAL_KEY(VLK_NUMPAD8) DECLARE_VIRTUAL_KEY(VLK_NUMPAD9) DECLARE_VIRTUAL_KEY(VLK_MULTIPLY) DECLARE_VIRTUAL_KEY(VLK_ADD) DECLARE_VIRTUAL_KEY(VLK_SEPARATOR) DECLARE_VIRTUAL_KEY(VLK_SUBTRACT) DECLARE_VIRTUAL_KEY(VLK_DECIMAL) DECLARE_VIRTUAL_KEY(VLK_DIVIDE) DECLARE_VIRTUAL_KEY(VLK_F1) DECLARE_VIRTUAL_KEY(VLK_F2) DECLARE_VIRTUAL_KEY(VLK_F3) DECLARE_VIRTUAL_KEY(VLK_F4) DECLARE_VIRTUAL_KEY(VLK_F5) DECLARE_VIRTUAL_KEY(VLK_F6) DECLARE_VIRTUAL_KEY(VLK_F7) DECLARE_VIRTUAL_KEY(VLK_F8) DECLARE_VIRTUAL_KEY(VLK_F9) DECLARE_VIRTUAL_KEY(VLK_F10) DECLARE_VIRTUAL_KEY(VLK_F11) DECLARE_VIRTUAL_KEY(VLK_F12) DECLARE_VIRTUAL_KEY(VLK_F13) DECLARE_VIRTUAL_KEY(VLK_F14) DECLARE_VIRTUAL_KEY(VLK_F15) DECLARE_VIRTUAL_KEY(VLK_F16) DECLARE_VIRTUAL_KEY(VLK_F17) DECLARE_VIRTUAL_KEY(VLK_F18) DECLARE_VIRTUAL_KEY(VLK_F19) DECLARE_VIRTUAL_KEY(VLK_F20) DECLARE_VIRTUAL_KEY(VLK_F21) DECLARE_VIRTUAL_KEY(VLK_F22) DECLARE_VIRTUAL_KEY(VLK_F23) DECLARE_VIRTUAL_KEY(VLK_F24) DECLARE_VIRTUAL_KEY(VLK_NUMLOCK) DECLARE_VIRTUAL_KEY(VLK_SCROLL) DECLARE_VIRTUAL_KEY(VLK_OEM_NEC_EQUAL) DECLARE_VIRTUAL_KEY(VLK_OEM_FJ_JISHO) DECLARE_VIRTUAL_KEY(VLK_OEM_FJ_MASSHOU) DECLARE_VIRTUAL_KEY(VLK_OEM_FJ_TOUROKU) DECLARE_VIRTUAL_KEY(VLK_OEM_FJ_LOYA) DECLARE_VIRTUAL_KEY(VLK_OEM_FJ_ROYA) DECLARE_VIRTUAL_KEY(VLK_LSHIFT) DECLARE_VIRTUAL_KEY(VLK_RSHIFT) DECLARE_VIRTUAL_KEY(VLK_LCONTROL) DECLARE_VIRTUAL_KEY(VLK_RCONTROL) DECLARE_VIRTUAL_KEY(VLK_LMENU) DECLARE_VIRTUAL_KEY(VLK_RMENU) DECLARE_VIRTUAL_KEY(VLK_BROWSER_BACK) DECLARE_VIRTUAL_KEY(VLK_BROWSER_FORWARD) DECLARE_VIRTUAL_KEY(VLK_BROWSER_REFRESH) DECLARE_VIRTUAL_KEY(VLK_BROWSER_STOP) DECLARE_VIRTUAL_KEY(VLK_BROWSER_SEARCH) DECLARE_VIRTUAL_KEY(VLK_BROWSER_FAVORITES) DECLARE_VIRTUAL_KEY(VLK_BROWSER_HOME) DECLARE_VIRTUAL_KEY(VLK_VOLUME_MUTE) DECLARE_VIRTUAL_KEY(VLK_VOLUME_DOWN) DECLARE_VIRTUAL_KEY(VLK_VOLUME_UP) DECLARE_VIRTUAL_KEY(VLK_MEDIA_NEXT_TRACK) DECLARE_VIRTUAL_KEY(VLK_MEDIA_PREV_TRACK) DECLARE_VIRTUAL_KEY(VLK_MEDIA_STOP) DECLARE_VIRTUAL_KEY(VLK_MEDIA_PLAY_PAUSE) DECLARE_VIRTUAL_KEY(VLK_LAUNCH_MAIL) DECLARE_VIRTUAL_KEY(VLK_LAUNCH_MEDIA_SELECT) DECLARE_VIRTUAL_KEY(VLK_LAUNCH_APP1) DECLARE_VIRTUAL_KEY(VLK_LAUNCH_APP2) DECLARE_VIRTUAL_KEY(VLK_OEM_1) DECLARE_VIRTUAL_KEY(VLK_OEM_PLUS) DECLARE_VIRTUAL_KEY(VLK_OEM_COMMA) DECLARE_VIRTUAL_KEY(VLK_OEM_MINUS) DECLARE_VIRTUAL_KEY(VLK_OEM_PERIOD) DECLARE_VIRTUAL_KEY(VLK_OEM_2) DECLARE_VIRTUAL_KEY(VLK_OEM_3) DECLARE_VIRTUAL_KEY(VLK_OEM_4) DECLARE_VIRTUAL_KEY(VLK_OEM_5) DECLARE_VIRTUAL_KEY(VLK_OEM_6) DECLARE_VIRTUAL_KEY(VLK_OEM_7) DECLARE_VIRTUAL_KEY(VLK_OEM_8) DECLARE_VIRTUAL_KEY(VLK_OEM_AX) DECLARE_VIRTUAL_KEY(VLK_OEM_102) DECLARE_VIRTUAL_KEY(VLK_ICO_HELP) DECLARE_VIRTUAL_KEY(VLK_ICO_00) DECLARE_VIRTUAL_KEY(VLK_PROCESSKEY) DECLARE_VIRTUAL_KEY(VLK_ICO_CLEAR) DECLARE_VIRTUAL_KEY(VLK_PACKET) DECLARE_VIRTUAL_KEY(VLK_OEM_RESET) DECLARE_VIRTUAL_KEY(VLK_OEM_JUMP) DECLARE_VIRTUAL_KEY(VLK_OEM_PA1) DECLARE_VIRTUAL_KEY(VLK_OEM_PA2) DECLARE_VIRTUAL_KEY(VLK_OEM_PA3) DECLARE_VIRTUAL_KEY(VLK_OEM_WSCTRL) DECLARE_VIRTUAL_KEY(VLK_OEM_CUSEL) DECLARE_VIRTUAL_KEY(VLK_OEM_ATTN) DECLARE_VIRTUAL_KEY(VLK_OEM_FINISH) DECLARE_VIRTUAL_KEY(VLK_OEM_COPY) DECLARE_VIRTUAL_KEY(VLK_OEM_AUTO) DECLARE_VIRTUAL_KEY(VLK_OEM_ENLW) DECLARE_VIRTUAL_KEY(VLK_OEM_BACKTAB) DECLARE_VIRTUAL_KEY(VLK_ATTN) DECLARE_VIRTUAL_KEY(VLK_CRSEL) DECLARE_VIRTUAL_KEY(VLK_EXSEL) DECLARE_VIRTUAL_KEY(VLK_EREOF) DECLARE_VIRTUAL_KEY(VLK_PLAY) DECLARE_VIRTUAL_KEY(VLK_ZOOM) DECLARE_VIRTUAL_KEY(VLK_NONAME) DECLARE_VIRTUAL_KEY(VLK_PA1) DECLARE_VIRTUAL_KEY(VLK_OEM_CLEAR) #undef DECLARE_VIRTUAL_KEY mScanCodeToName.resize(SC_MAX); #define DECLARE_SCAN_CODE(_code) mScanCodeToName[_code] = #_code; DECLARE_SCAN_CODE(SC_ESCAPE) DECLARE_SCAN_CODE(SC_1) DECLARE_SCAN_CODE(SC_2) DECLARE_SCAN_CODE(SC_3) DECLARE_SCAN_CODE(SC_4) DECLARE_SCAN_CODE(SC_5) DECLARE_SCAN_CODE(SC_6) DECLARE_SCAN_CODE(SC_7) DECLARE_SCAN_CODE(SC_8) DECLARE_SCAN_CODE(SC_9) DECLARE_SCAN_CODE(SC_0) DECLARE_SCAN_CODE(SC_MINUS) DECLARE_SCAN_CODE(SC_EQUALS) DECLARE_SCAN_CODE(SC_BACK) DECLARE_SCAN_CODE(SC_TAB) DECLARE_SCAN_CODE(SC_Q) DECLARE_SCAN_CODE(SC_W) DECLARE_SCAN_CODE(SC_E) DECLARE_SCAN_CODE(SC_R) DECLARE_SCAN_CODE(SC_T) DECLARE_SCAN_CODE(SC_Y) DECLARE_SCAN_CODE(SC_U) DECLARE_SCAN_CODE(SC_I) DECLARE_SCAN_CODE(SC_O) DECLARE_SCAN_CODE(SC_P) DECLARE_SCAN_CODE(SC_LBRACKET) DECLARE_SCAN_CODE(SC_RBRACKET) DECLARE_SCAN_CODE(SC_RETURN) DECLARE_SCAN_CODE(SC_LCONTROL) DECLARE_SCAN_CODE(SC_A) DECLARE_SCAN_CODE(SC_S) DECLARE_SCAN_CODE(SC_D) DECLARE_SCAN_CODE(SC_F) DECLARE_SCAN_CODE(SC_G) DECLARE_SCAN_CODE(SC_H) DECLARE_SCAN_CODE(SC_J) DECLARE_SCAN_CODE(SC_K) DECLARE_SCAN_CODE(SC_L) DECLARE_SCAN_CODE(SC_SEMICOLON) DECLARE_SCAN_CODE(SC_APOSTROPHE) DECLARE_SCAN_CODE(SC_GRAVE) DECLARE_SCAN_CODE(SC_LSHIFT) DECLARE_SCAN_CODE(SC_BACKSLASH) DECLARE_SCAN_CODE(SC_Z) DECLARE_SCAN_CODE(SC_X) DECLARE_SCAN_CODE(SC_C) DECLARE_SCAN_CODE(SC_V) DECLARE_SCAN_CODE(SC_B) DECLARE_SCAN_CODE(SC_N) DECLARE_SCAN_CODE(SC_M) DECLARE_SCAN_CODE(SC_COMMA) DECLARE_SCAN_CODE(SC_PERIOD) DECLARE_SCAN_CODE(SC_SLASH) DECLARE_SCAN_CODE(SC_RSHIFT) DECLARE_SCAN_CODE(SC_MULTIPLY) DECLARE_SCAN_CODE(SC_LMENU) DECLARE_SCAN_CODE(SC_SPACE) DECLARE_SCAN_CODE(SC_CAPITAL) DECLARE_SCAN_CODE(SC_F1) DECLARE_SCAN_CODE(SC_F2) DECLARE_SCAN_CODE(SC_F3) DECLARE_SCAN_CODE(SC_F4) DECLARE_SCAN_CODE(SC_F5) DECLARE_SCAN_CODE(SC_F6) DECLARE_SCAN_CODE(SC_F7) DECLARE_SCAN_CODE(SC_F8) DECLARE_SCAN_CODE(SC_F9) DECLARE_SCAN_CODE(SC_F10) DECLARE_SCAN_CODE(SC_NUMLOCK) DECLARE_SCAN_CODE(SC_SCROLL) DECLARE_SCAN_CODE(SC_NUMPAD7) DECLARE_SCAN_CODE(SC_NUMPAD8) DECLARE_SCAN_CODE(SC_NUMPAD9) DECLARE_SCAN_CODE(SC_SUBTRACT) DECLARE_SCAN_CODE(SC_NUMPAD4) DECLARE_SCAN_CODE(SC_NUMPAD5) DECLARE_SCAN_CODE(SC_NUMPAD6) DECLARE_SCAN_CODE(SC_ADD) DECLARE_SCAN_CODE(SC_NUMPAD1) DECLARE_SCAN_CODE(SC_NUMPAD2) DECLARE_SCAN_CODE(SC_NUMPAD3) DECLARE_SCAN_CODE(SC_NUMPAD0) DECLARE_SCAN_CODE(SC_DECIMAL) DECLARE_SCAN_CODE(SC_OEM_102) DECLARE_SCAN_CODE(SC_F11) DECLARE_SCAN_CODE(SC_F12) DECLARE_SCAN_CODE(SC_F13) DECLARE_SCAN_CODE(SC_F14) DECLARE_SCAN_CODE(SC_F15) DECLARE_SCAN_CODE(SC_KANA) DECLARE_SCAN_CODE(SC_ABNT_C1) DECLARE_SCAN_CODE(SC_CONVERT) DECLARE_SCAN_CODE(SC_NOCONVERT) DECLARE_SCAN_CODE(SC_YEN) DECLARE_SCAN_CODE(SC_ABNT_C2) DECLARE_SCAN_CODE(SC_NUMPADEQUALS) DECLARE_SCAN_CODE(SC_PREVTRACK) DECLARE_SCAN_CODE(SC_AT) DECLARE_SCAN_CODE(SC_COLON) DECLARE_SCAN_CODE(SC_UNDERLINE) DECLARE_SCAN_CODE(SC_KANJI) DECLARE_SCAN_CODE(SC_STOP) DECLARE_SCAN_CODE(SC_AX) DECLARE_SCAN_CODE(SC_UNLABELED) DECLARE_SCAN_CODE(SC_NEXTTRACK) DECLARE_SCAN_CODE(SC_NUMPADENTER) DECLARE_SCAN_CODE(SC_RCONTROL) DECLARE_SCAN_CODE(SC_MUTE) DECLARE_SCAN_CODE(SC_CALCULATOR) DECLARE_SCAN_CODE(SC_PLAYPAUSE) DECLARE_SCAN_CODE(SC_MEDIASTOP) DECLARE_SCAN_CODE(SC_VOLUMEDOWN) DECLARE_SCAN_CODE(SC_VOLUMEUP) DECLARE_SCAN_CODE(SC_WEBHOME) DECLARE_SCAN_CODE(SC_NUMPADCOMMA) DECLARE_SCAN_CODE(SC_DIVIDE) DECLARE_SCAN_CODE(SC_SYSRQ) DECLARE_SCAN_CODE(SC_RMENU) DECLARE_SCAN_CODE(SC_PAUSE) DECLARE_SCAN_CODE(SC_HOME) DECLARE_SCAN_CODE(SC_UP) DECLARE_SCAN_CODE(SC_PGUP) DECLARE_SCAN_CODE(SC_LEFT) DECLARE_SCAN_CODE(SC_RIGHT) DECLARE_SCAN_CODE(SC_END) DECLARE_SCAN_CODE(SC_DOWN) DECLARE_SCAN_CODE(SC_PGDOWN) DECLARE_SCAN_CODE(SC_INSERT) DECLARE_SCAN_CODE(SC_DELETE) DECLARE_SCAN_CODE(SC_LWIN) DECLARE_SCAN_CODE(SC_RWIN) DECLARE_SCAN_CODE(SC_APPS) DECLARE_SCAN_CODE(SC_POWER) DECLARE_SCAN_CODE(SC_SLEEP) DECLARE_SCAN_CODE(SC_WAKE) DECLARE_SCAN_CODE(SC_WEBSEARCH) DECLARE_SCAN_CODE(SC_WEBFAVORITES) DECLARE_SCAN_CODE(SC_WEBREFRESH) DECLARE_SCAN_CODE(SC_WEBSTOP) DECLARE_SCAN_CODE(SC_WEBFORWARD) DECLARE_SCAN_CODE(SC_WEBBACK) DECLARE_SCAN_CODE(SC_MYCOMPUTER) DECLARE_SCAN_CODE(SC_MAIL) DECLARE_SCAN_CODE(SC_MEDIASELECT) #undef DECLARE_SCAN_CODE #endif memset(mVirtualKeyToScanCode, 0, VLK_MAX); memset(mScanCodeToVirtualKey, 0, SC_MAX); #define ADD_MAP(_keyName) \ mVirtualKeyToScanCode[VLK_##_keyName] = SC_##_keyName; \ mScanCodeToVirtualKey[SC_##_keyName] = VLK_##_keyName; #define ADD_MAP2(_virtualKey, _scanCode) \ mVirtualKeyToScanCode[VLK_##_virtualKey] = SC_##_scanCode; \ mScanCodeToVirtualKey[SC_##_scanCode] = VLK_##_virtualKey; ADD_MAP(0) ADD_MAP(1) ADD_MAP(2) ADD_MAP(3) ADD_MAP(4) ADD_MAP(5) ADD_MAP(6) ADD_MAP(7) ADD_MAP(8) ADD_MAP(9) ADD_MAP(A) ADD_MAP(B) ADD_MAP(C) ADD_MAP(D) ADD_MAP(E) ADD_MAP(F) ADD_MAP(G) ADD_MAP(H) ADD_MAP(I) ADD_MAP(J) ADD_MAP(K) ADD_MAP(L) ADD_MAP(M) ADD_MAP(N) ADD_MAP(O) ADD_MAP(P) ADD_MAP(Q) ADD_MAP(R) ADD_MAP(S) ADD_MAP(T) ADD_MAP(U) ADD_MAP(V) ADD_MAP(W) ADD_MAP(X) ADD_MAP(Y) ADD_MAP(Z) ADD_MAP(F1) ADD_MAP(F2) ADD_MAP(F3) ADD_MAP(F4) ADD_MAP(F5) ADD_MAP(F6) ADD_MAP(F7) ADD_MAP(F8) ADD_MAP(F9) ADD_MAP(F10) ADD_MAP(F11) ADD_MAP(F12) ADD_MAP(F13) ADD_MAP(F14) ADD_MAP(F15) ADD_MAP(NUMPAD0) ADD_MAP(NUMPAD1) ADD_MAP(NUMPAD2) ADD_MAP(NUMPAD3) ADD_MAP(NUMPAD4) ADD_MAP(NUMPAD5) ADD_MAP(NUMPAD6) ADD_MAP(NUMPAD7) ADD_MAP(NUMPAD8) ADD_MAP(NUMPAD9) ADD_MAP(ESCAPE) ADD_MAP(TAB) ADD_MAP(RETURN) ADD_MAP(SPACE) ADD_MAP(BACK) ADD_MAP2(SCROLL, SCROLL) ADD_MAP2(PAUSE, PAUSE) ADD_MAP2(OEM_3, GRAVE) ADD_MAP2(OEM_MINUS, MINUS) ADD_MAP2(OEM_PLUS, EQUALS) ADD_MAP2(OEM_5, BACKSLASH) ADD_MAP2(OEM_4, LBRACKET) ADD_MAP2(OEM_6, RBRACKET) ADD_MAP2(CAPITAL, CAPITAL) ADD_MAP2(OEM_1, SEMICOLON) ADD_MAP2(OEM_7, APOSTROPHE) ADD_MAP2(SHIFT, LSHIFT) ADD_MAP2(OEM_COMMA, COMMA) ADD_MAP2(OEM_PERIOD, PERIOD) ADD_MAP2(OEM_2, SLASH) ADD_MAP2(CONTROL, LCONTROL) ADD_MAP2(LWIN, LWIN) ADD_MAP2(RWIN, RWIN) ADD_MAP2(APPS, APPS) ADD_MAP2(MENU, LMENU) ADD_MAP2(LEFT, LEFT) ADD_MAP2(RIGHT, RIGHT) ADD_MAP2(UP, UP) ADD_MAP2(DOWN, DOWN) ADD_MAP2(INSERT, INSERT) ADD_MAP2(DELETE, DELETE) ADD_MAP2(HOME, HOME) ADD_MAP2(END, END) ADD_MAP2(PRIOR, PGUP) ADD_MAP2(NEXT, PGDOWN) ADD_MAP2(SNAPSHOT, SYSRQ) ADD_MAP2(NUMLOCK, NUMLOCK) ADD_MAP2(DIVIDE, DIVIDE) ADD_MAP2(MULTIPLY, MULTIPLY) ADD_MAP2(SUBTRACT, SUBTRACT) ADD_MAP2(ADD, ADD) ADD_MAP2(DECIMAL, DECIMAL) ADD_MAP(NUMPAD0) ADD_MAP(NUMPAD1) ADD_MAP(NUMPAD2) ADD_MAP(NUMPAD3) ADD_MAP(NUMPAD4) ADD_MAP(NUMPAD5) ADD_MAP(NUMPAD6) ADD_MAP(NUMPAD7) ADD_MAP(NUMPAD8) ADD_MAP(NUMPAD9) #undef ADD_MAP #undef ADD_MAP2 } int VirtualKeyToScanCode(WPARAM _virtualKey) const { if (_virtualKey < VLK_MAX) return (int)mVirtualKeyToScanCode[_virtualKey]; return 0; } int ScanCodeToVirtualKey(int _scanCode) const { if (_scanCode < SC_MAX) return (int)mScanCodeToVirtualKey[_scanCode]; return 0; } #ifdef INPUT_KEY_NAME const std::string VirtualKeyToName(WPARAM _virtualKey) const { if (_virtualKey < VLK_MAX) return mVirtualKeyToName[_virtualKey]; return ""; } const std::string ScanCodeToName(int _scanCode) const { if (_scanCode < SC_MAX) return mScanCodeToName[_scanCode]; return ""; } #endif private: unsigned char mVirtualKeyToScanCode[VLK_MAX]; unsigned char mScanCodeToVirtualKey[SC_MAX]; #ifdef INPUT_KEY_NAME std::vector mVirtualKeyToName; std::vector mScanCodeToName; #endif }; const Table& getTable() { static Table table; return table; } int VirtualKeyToScanCode(WPARAM _virtualKey) { const Table& table = getTable(); return table.VirtualKeyToScanCode(_virtualKey); } int ScanCodeToVirtualKey(int _scanCode) { const Table& table = getTable(); return table.ScanCodeToVirtualKey(_scanCode); } #ifdef INPUT_KEY_NAME std::string VirtualKeyToName(WPARAM _virtualKey) { const Table& table = getTable(); return table.VirtualKeyToName(_virtualKey); } std::string ScanCodeToName(int _scanCode) { const Table& table = getTable(); return table.ScanCodeToName(_scanCode); } #endif #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32 int VirtualKeyToText(WPARAM _virtualKey) { static WCHAR deadKey = 0; BYTE keyState[256]; HKL layout = GetKeyboardLayout(0); if (GetKeyboardState(keyState) == 0) return 0; WCHAR buff[3] = { 0, 0, 0 }; int ascii = ToUnicodeEx((UINT)_virtualKey, 0, keyState, buff, 3, 0, layout); if (ascii == 1 && deadKey != '\0' ) { // A dead key is stored and we have just converted a character key // Combine the two into a single character WCHAR wcBuff[3] = { buff[0], deadKey, '\0' }; WCHAR out[3]; deadKey = '\0'; if (FoldStringW(MAP_PRECOMPOSED, (LPWSTR)wcBuff, 3, (LPWSTR)out, 3)) return out[0]; } else if (ascii == 1) { // We have a single character deadKey = '\0'; return buff[0]; } else if (ascii == 2) { // Convert a non-combining diacritical mark into a combining diacritical mark // Combining versions range from 0x300 to 0x36F; only 5 (for French) have been mapped below // http://www.fileformat.info/info/unicode/block/combining_diacritical_marks/images.htm switch (buff[0]) { case 0x5E: // Circumflex accent: в deadKey = 0x302; break; case 0x60: // Grave accent: а deadKey = 0x300; break; case 0xA8: // Diaeresis: ь deadKey = 0x308; break; case 0xB4: // Acute accent: й deadKey = 0x301; break; case 0xB8: // Cedilla: з deadKey = 0x327; break; default: deadKey = buff[0]; break; } } return 0; } int ScanCodeToText(int _scanCode) { HKL layout = GetKeyboardLayout(0); unsigned int vk = MapVirtualKeyEx((UINT)_scanCode, 3 /*MAPVK_VSC_TO_VK_EX*/, layout); if (vk == 0) return 0; return VirtualKeyToText(vk); } #endif } #endif // INPUT_CONVERTER_H_ mygui-MyGUI3.4.1+dfsg/Common/Input/SDL/0000775000175000017500000000000014017025067016420 5ustar psi29apsi29amygui-MyGUI3.4.1+dfsg/Common/Input/SDL/ResourceSDLPointer.h0000664000175000017500000000113314017025067022262 0ustar psi29apsi29a/*! @file @author Albert Semenov @date 11/2009 @module */ #ifndef RESOURCE_W32_POINTER_H_ #define RESOURCE_W32_POINTER_H_ #include "MyGUI_Prerequest.h" #include "MyGUI_IResource.h" #include namespace input { class ResourceSDLPointer : public MyGUI::IResource { MYGUI_RTTI_DERIVED( ResourceSDLPointer ) public: ResourceSDLPointer(); void deserialization(MyGUI::xml::ElementPtr _node, MyGUI::Version _version) override; SDL_SystemCursor getPointerType() { return mCursorType; } private: SDL_SystemCursor mCursorType; }; } #endif // RESOURCE_W32_POINTER_H_ mygui-MyGUI3.4.1+dfsg/Common/Input/SDL/PointerManager.h0000664000175000017500000000147714017025067021515 0ustar psi29apsi29a/*! @file @author Albert Semenov @date 11/2009 */ #ifndef POINTER_MANAGER_H_ #define POINTER_MANAGER_H_ #include #include namespace input { class PointerManager { public: PointerManager(); virtual ~PointerManager(); void createPointerManager(); void destroyPointerManager(); void setPointerVisible(bool _value); void setPointerName(const std::string& _name); void loadPointerResources(); private: void notifyChangeMousePointer(const std::string& _name); void updateSDLPointer(SDL_SystemCursor _newCursor); bool isMouseInClient(); void setPointer(const std::string& _name); private: typedef std::map MapPointer; MapPointer mMapPointer; bool mManagerPointer; SDL_Cursor* mCursor; }; } // namespace input #endif // POINTER_MANAGER_H_ mygui-MyGUI3.4.1+dfsg/Common/Input/SDL/ResourceSDLPointer.cpp0000664000175000017500000000356614017025067022631 0ustar psi29apsi29a/*! @file @author Albert Semenov @date 11/2009 @module */ #include "ResourceSDLPointer.h" namespace input { ResourceSDLPointer::ResourceSDLPointer() : mCursorType(SDL_NUM_SYSTEM_CURSORS) { } void ResourceSDLPointer::deserialization(MyGUI::xml::ElementPtr _node, MyGUI::Version _version) { Base::deserialization(_node, _version); MyGUI::xml::ElementEnumerator info = _node->getElementEnumerator(); while (info.next()) { if (info->getName() == "Property") { const std::string& key = info->findAttribute("key"); if (key == "SourceFile") { //std::string path = MyGUI::DataManager::getInstance().getDataPath(info->getContent()); //mCursorType = (size_t)LoadCursorFromFileA(path.c_str()); } else if (key == "SourceSystem") { std::string value = info->getContent(); if (value == "SDL_SYSTEM_CURSOR_ARROW") mCursorType = SDL_SYSTEM_CURSOR_ARROW; else if (value == "SDL_SYSTEM_CURSOR_IBEAM") mCursorType = SDL_SYSTEM_CURSOR_IBEAM; else if (value == "SDL_SYSTEM_CURSOR_WAIT") mCursorType = SDL_SYSTEM_CURSOR_WAIT; else if (value == "SDL_SYSTEM_CURSOR_CROSSHAIR") mCursorType = SDL_SYSTEM_CURSOR_CROSSHAIR; else if (value == "SDL_SYSTEM_CURSOR_SIZENWSE") mCursorType = SDL_SYSTEM_CURSOR_SIZENWSE; else if (value == "SDL_SYSTEM_CURSOR_SIZENESW") mCursorType = SDL_SYSTEM_CURSOR_SIZENESW; else if (value == "SDL_SYSTEM_CURSOR_SIZEWE") mCursorType = SDL_SYSTEM_CURSOR_SIZEWE; else if (value == "SDL_SYSTEM_CURSOR_SIZENS") mCursorType = SDL_SYSTEM_CURSOR_SIZENS; else if (value == "SDL_SYSTEM_CURSOR_SIZEALL") mCursorType = SDL_SYSTEM_CURSOR_SIZEALL; else if (value == "SDL_SYSTEM_CURSOR_NO") mCursorType = SDL_SYSTEM_CURSOR_NO; else if (value == "SDL_SYSTEM_CURSOR_HAND") mCursorType = SDL_SYSTEM_CURSOR_HAND; } } } } } mygui-MyGUI3.4.1+dfsg/Common/Input/SDL/PointerManager.cpp0000664000175000017500000000464414017025067022047 0ustar psi29apsi29a/*! @file @author Albert Semenov @date 1/2009 */ #include "Precompiled.h" #include "PointerManager.h" #include #include "ResourceSDLPointer.cpp" namespace input { PointerManager::PointerManager() : mManagerPointer(true), mCursor(nullptr) { } PointerManager::~PointerManager() { SDL_FreeCursor(mCursor); } void PointerManager::createPointerManager() { MyGUI::PointerManager& manager = MyGUI::PointerManager::getInstance(); manager.setVisible(false); manager.eventChangeMousePointer += MyGUI::newDelegate(this, &PointerManager::notifyChangeMousePointer); std::string resourceCategory = MyGUI::ResourceManager::getInstance().getCategoryName(); MyGUI::FactoryManager::getInstance().registerFactory(resourceCategory); } void PointerManager::destroyPointerManager() { std::string resourceCategory = MyGUI::ResourceManager::getInstance().getCategoryName(); MyGUI::FactoryManager::getInstance().unregisterFactory(resourceCategory); MyGUI::PointerManager& manager = MyGUI::PointerManager::getInstance(); manager.eventChangeMousePointer -= MyGUI::newDelegate(this, &PointerManager::notifyChangeMousePointer); } void PointerManager::setPointerVisible(bool _value) { SDL_ShowCursor(static_cast(_value)); } void PointerManager::notifyChangeMousePointer(const std::string& _name) { if (mManagerPointer) { setPointer(_name); } } void PointerManager::setPointerName(const std::string& _name) { mManagerPointer = false; setPointer(_name); } void PointerManager::updateSDLPointer(SDL_SystemCursor _newCursor) { SDL_FreeCursor(mCursor); mCursor = SDL_CreateSystemCursor(_newCursor); SDL_SetCursor(mCursor); } void PointerManager::setPointer(const std::string& _name) { MapPointer::iterator iter = mMapPointer.find(_name); if (iter != mMapPointer.end()) { updateSDLPointer(iter->second); } else { MyGUI::IResource* resource_generic = MyGUI::ResourceManager::getInstance().getByName(_name, false); if (resource_generic != nullptr) { ResourceSDLPointer* resource = resource_generic->castType(false); if (resource != nullptr) { mMapPointer[_name] = resource->getPointerType(); updateSDLPointer(resource->getPointerType()); } } } } void PointerManager::loadPointerResources() { MyGUI::ResourceManager::getInstance().load("PointersSDL.xml"); } } // namespace input mygui-MyGUI3.4.1+dfsg/Common/Input/SDL/InputManager.h0000664000175000017500000000361514017025067021170 0ustar psi29apsi29a/*! @file @author Albert Semenov @date 09/2009 */ #ifndef INPUT_MANAGER_H_ #define INPUT_MANAGER_H_ #include #include namespace input { class InputManager { public: InputManager(); virtual ~InputManager() = default; void createInput(); void destroyInput(); void captureInput(); void setInputViewSize(int _width, int _height); // following five methods are to be implemented in BaseManager class virtual void injectMouseMove(int _absx, int _absy, int _absz){} virtual void injectMousePress(int _absx, int _absy, MyGUI::MouseButton _id){} virtual void injectMouseRelease(int _absx, int _absy, MyGUI::MouseButton _id){} virtual void injectKeyPress(MyGUI::KeyCode _key, MyGUI::Char _text){} virtual void injectKeyRelease(MyGUI::KeyCode _key){} virtual void onFileDrop(const std::wstring& _filename) { } virtual bool onWindowClose(size_t _handle) { return true; } void setMousePosition(int _x, int _y); void updateCursorPosition(); protected: void frameEvent(float _time); void computeMouseMove(); void onClipboardChanged(const std::string& _type, const std::string& _data); void onClipboardRequested(const std::string& _type, std::string& _data); virtual bool mouseMoved(const SDL_MouseMotionEvent &evt); virtual bool mousePressed(const SDL_MouseButtonEvent &evt); virtual bool mouseReleased(const SDL_MouseButtonEvent &evt); virtual bool keyPressed(SDL_Keycode key, const SDL_TextInputEvent* evt); virtual bool keyReleased(const SDL_KeyboardEvent &key); virtual bool mouseWheelMoved(const SDL_MouseWheelEvent &evt); void checkPosition(); void buildVKeyMap(); void buildMouseButtonMap(); private: int mMouseX; int mMouseY; int mMouseZ; bool mMouseMove; int mWidth; int mHeight; std::map mSDLVKeyMap; std::map mSDLMouseMap; }; } // namespace input #endif // INPUT_MANAGER_H_ mygui-MyGUI3.4.1+dfsg/Common/Input/SDL/InputManager.cpp0000664000175000017500000002322614017025067021523 0ustar psi29apsi29a#include "Precompiled.h" #include "InputManager.h" namespace input { InputManager::InputManager() : mMouseX(0), mMouseY(0), mMouseZ(0), mMouseMove(false), mWidth(0), mHeight(0) { // build the virtual key map and mouse button between SDL and MyGUI buildVKeyMap(); buildMouseButtonMap(); } struct KeyMapItem { int sdlKey; MyGUI::KeyCode myguiKey; }; static KeyMapItem mapItems[] = { {0, MyGUI::KeyCode::None}, {SDLK_UNKNOWN, MyGUI::KeyCode::None}, {SDLK_ESCAPE, MyGUI::KeyCode::Escape}, {SDLK_1, MyGUI::KeyCode::One}, {SDLK_2, MyGUI::KeyCode::Two}, {SDLK_3, MyGUI::KeyCode::Three}, {SDLK_4, MyGUI::KeyCode::Four}, {SDLK_5, MyGUI::KeyCode::Five}, {SDLK_6, MyGUI::KeyCode::Six}, {SDLK_7, MyGUI::KeyCode::Seven}, {SDLK_8, MyGUI::KeyCode::Eight}, {SDLK_9, MyGUI::KeyCode::Nine}, {SDLK_0, MyGUI::KeyCode::Zero}, {SDLK_MINUS, MyGUI::KeyCode::Minus}, {SDLK_EQUALS, MyGUI::KeyCode::Equals}, {SDLK_BACKSPACE, MyGUI::KeyCode::Backspace}, {SDLK_TAB, MyGUI::KeyCode::Tab}, {SDLK_q, MyGUI::KeyCode::Q}, {SDLK_w, MyGUI::KeyCode::W}, {SDLK_e, MyGUI::KeyCode::E}, {SDLK_r, MyGUI::KeyCode::R}, {SDLK_t, MyGUI::KeyCode::T}, {SDLK_y, MyGUI::KeyCode::Y}, {SDLK_u, MyGUI::KeyCode::U}, {SDLK_i, MyGUI::KeyCode::I}, {SDLK_o, MyGUI::KeyCode::O}, {SDLK_p, MyGUI::KeyCode::P}, {SDLK_LEFTBRACKET, MyGUI::KeyCode::LeftBracket}, {SDLK_RIGHTBRACKET, MyGUI::KeyCode::RightBracket}, {SDLK_RETURN, MyGUI::KeyCode::Return}, {SDLK_LCTRL, MyGUI::KeyCode::LeftControl}, {SDLK_a, MyGUI::KeyCode::A}, {SDLK_s, MyGUI::KeyCode::S}, {SDLK_d, MyGUI::KeyCode::D}, {SDLK_f, MyGUI::KeyCode::F}, {SDLK_g, MyGUI::KeyCode::G}, {SDLK_h, MyGUI::KeyCode::H}, {SDLK_j, MyGUI::KeyCode::J}, {SDLK_k, MyGUI::KeyCode::K}, {SDLK_l, MyGUI::KeyCode::L}, {SDLK_SEMICOLON, MyGUI::KeyCode::Semicolon}, {SDLK_QUOTEDBL, MyGUI::KeyCode::Apostrophe}, {SDLK_BACKQUOTE, MyGUI::KeyCode::Grave}, {SDLK_LSHIFT, MyGUI::KeyCode::LeftShift}, {SDLK_BACKSLASH, MyGUI::KeyCode::Backslash}, {SDLK_z, MyGUI::KeyCode::Z}, {SDLK_x, MyGUI::KeyCode::X}, {SDLK_c, MyGUI::KeyCode::C}, {SDLK_v, MyGUI::KeyCode::V}, {SDLK_b, MyGUI::KeyCode::B}, {SDLK_n, MyGUI::KeyCode::N}, {SDLK_m, MyGUI::KeyCode::M}, {SDLK_COMMA, MyGUI::KeyCode::Comma}, {SDLK_PERIOD, MyGUI::KeyCode::Period}, {SDLK_SLASH, MyGUI::KeyCode::Slash}, {SDLK_RSHIFT, MyGUI::KeyCode::RightShift}, {SDLK_KP_MULTIPLY, MyGUI::KeyCode::Multiply}, {SDLK_LALT, MyGUI::KeyCode::LeftAlt}, {SDLK_SPACE, MyGUI::KeyCode::Space}, {SDLK_CAPSLOCK, MyGUI::KeyCode::Capital}, {SDLK_F1, MyGUI::KeyCode::F1}, {SDLK_F2, MyGUI::KeyCode::F2}, {SDLK_F3, MyGUI::KeyCode::F3}, {SDLK_F4, MyGUI::KeyCode::F4}, {SDLK_F5, MyGUI::KeyCode::F5}, {SDLK_F6, MyGUI::KeyCode::F6}, {SDLK_F7, MyGUI::KeyCode::F7}, {SDLK_F8, MyGUI::KeyCode::F8}, {SDLK_F9, MyGUI::KeyCode::F9}, {SDLK_F10, MyGUI::KeyCode::F10}, {SDLK_NUMLOCKCLEAR, MyGUI::KeyCode::NumLock}, {SDLK_SCROLLLOCK, MyGUI::KeyCode::ScrollLock}, {SDLK_KP_7, MyGUI::KeyCode::Numpad7}, {SDLK_KP_8, MyGUI::KeyCode::Numpad8}, {SDLK_KP_9, MyGUI::KeyCode::Numpad9}, {SDLK_KP_MINUS, MyGUI::KeyCode::Subtract}, {SDLK_KP_4, MyGUI::KeyCode::Numpad4}, {SDLK_KP_5, MyGUI::KeyCode::Numpad5}, {SDLK_KP_6, MyGUI::KeyCode::Numpad6}, {SDLK_KP_PLUS, MyGUI::KeyCode::Add}, {SDLK_KP_1, MyGUI::KeyCode::Numpad1}, {SDLK_KP_2, MyGUI::KeyCode::Numpad2}, {SDLK_KP_3, MyGUI::KeyCode::Numpad3}, {SDLK_KP_0, MyGUI::KeyCode::Numpad0}, {SDLK_KP_PERIOD, MyGUI::KeyCode::Decimal}, //{, MyGUI::KeyCode::OEM_102}, {SDLK_F11, MyGUI::KeyCode::F11}, {SDLK_F12, MyGUI::KeyCode::F12}, {SDLK_F13, MyGUI::KeyCode::F13}, {SDLK_F14, MyGUI::KeyCode::F14}, {SDLK_F15, MyGUI::KeyCode::F15}, //{, MyGUI::KeyCode::Kana}, //{, MyGUI::KeyCode::ABNT_C1}, //{, MyGUI::KeyCode::Convert}, //{, MyGUI::KeyCode::NoConvert}, //{, MyGUI::KeyCode::Yen}, //{, MyGUI::KeyCode::ABNT_C2}, {SDLK_KP_EQUALS, MyGUI::KeyCode::NumpadEquals}, //{, MyGUI::KeyCode::PrevTrack}, //{, MyGUI::KeyCode::At}, //{, MyGUI::KeyCode::Colon}, //{, MyGUI::KeyCode::Underline}, //{, MyGUI::KeyCode::Kanji}, //{, MyGUI::KeyCode::Stop}, //{, MyGUI::KeyCode::AX}, //{, MyGUI::KeyCode::Unlabeled}, //{, MyGUI::KeyCode::NextTrack}, {SDLK_KP_DIVIDE, MyGUI::KeyCode::NumpadEnter}, {SDLK_RCTRL, MyGUI::KeyCode::RightControl}, //{, MyGUI::KeyCode::Mute}, //{, MyGUI::KeyCode::Calculator}, //{, MyGUI::KeyCode::PlayPause}, //{, MyGUI::KeyCode::MediaStop}, //{, MyGUI::KeyCode::VolumeDown}, //{, MyGUI::KeyCode::VolumeUp}, //{, MyGUI::KeyCode::WebHome}, //{, MyGUI::KeyCode::NumpadComma}, {SDLK_KP_DIVIDE, MyGUI::KeyCode::Divide}, {SDLK_SYSREQ, MyGUI::KeyCode::SysRq}, {SDLK_RALT, MyGUI::KeyCode::RightAlt}, {SDLK_PAUSE, MyGUI::KeyCode::Pause}, {SDLK_HOME, MyGUI::KeyCode::Home}, {SDLK_UP, MyGUI::KeyCode::ArrowUp}, {SDLK_PAGEUP, MyGUI::KeyCode::PageUp}, {SDLK_LEFT, MyGUI::KeyCode::ArrowLeft}, {SDLK_RIGHT, MyGUI::KeyCode::ArrowRight}, {SDLK_END, MyGUI::KeyCode::End}, {SDLK_DOWN, MyGUI::KeyCode::ArrowDown}, {SDLK_PAGEDOWN, MyGUI::KeyCode::PageDown}, {SDLK_INSERT, MyGUI::KeyCode::Insert}, {SDLK_DELETE, MyGUI::KeyCode::Delete}, {SDLK_LGUI, MyGUI::KeyCode::LeftWindows}, //{, MyGUI::KeyCode::RightWindow}, {SDLK_RGUI, MyGUI::KeyCode::RightWindows}, {SDLK_APPLICATION, MyGUI::KeyCode::AppMenu} }; void InputManager::buildVKeyMap() { mSDLVKeyMap.clear(); for (size_t i = 0; i < sizeof(mapItems) / sizeof(KeyMapItem); ++i) mSDLVKeyMap.insert(std::pair(mapItems[i].sdlKey, mapItems[i].myguiKey)); } void InputManager::buildMouseButtonMap() { mSDLMouseMap.clear(); mSDLMouseMap.insert(std::pair(SDL_BUTTON_LEFT, MyGUI::MouseButton::Left)); mSDLMouseMap.insert(std::pair(SDL_BUTTON_RIGHT, MyGUI::MouseButton::Right)); mSDLMouseMap.insert(std::pair(SDL_BUTTON_MIDDLE, MyGUI::MouseButton::Middle)); } void InputManager::createInput() { MyGUI::Gui::getInstance().eventFrameStart += MyGUI::newDelegate(this, &InputManager::frameEvent); // Removes default MyGUI system clipboard implementation, which is supported on Windows only MyGUI::ClipboardManager::getInstance().eventClipboardChanged.clear(); MyGUI::ClipboardManager::getInstance().eventClipboardRequested.clear(); // Set the cross-platform SDL system clipboard handler MyGUI::ClipboardManager::getInstance().eventClipboardChanged += MyGUI::newDelegate(this, &InputManager::onClipboardChanged); MyGUI::ClipboardManager::getInstance().eventClipboardRequested += MyGUI::newDelegate(this, &InputManager::onClipboardRequested); } void InputManager::destroyInput() { MyGUI::ClipboardManager::getInstance().eventClipboardChanged -= MyGUI::newDelegate(this, &InputManager::onClipboardChanged); MyGUI::ClipboardManager::getInstance().eventClipboardRequested -= MyGUI::newDelegate(this, &InputManager::onClipboardRequested); } void InputManager::updateCursorPosition() { } void InputManager::frameEvent(float _time) { computeMouseMove(); } void InputManager::computeMouseMove() { if (mMouseMove) { injectMouseMove(mMouseX, mMouseY, mMouseZ); mMouseMove = false; } } bool InputManager::mouseMoved(const SDL_MouseMotionEvent &evt) { mMouseX = evt.x; mMouseY = evt.y; mMouseMove = true; return true; } bool InputManager::mousePressed(const SDL_MouseButtonEvent &evt) { computeMouseMove(); injectMousePress(mMouseX, mMouseY, mSDLMouseMap[evt.button]); return true; } bool InputManager::mouseReleased(const SDL_MouseButtonEvent &evt ) { computeMouseMove(); injectMouseRelease(mMouseX, mMouseY, mSDLMouseMap[evt.button]); return true; } bool InputManager::keyPressed(SDL_Keycode key, const SDL_TextInputEvent* evt) { if (mSDLVKeyMap.count(key) == 0) { return false; } MyGUI::KeyCode myGuiKeyCode = mSDLVKeyMap[key]; if (evt == nullptr) { injectKeyPress(myGuiKeyCode, 0); } else { MyGUI::UString ustring(evt->text); MyGUI::UString::utf32string utf32string = ustring.asUTF32(); for (MyGUI::UString::utf32string::const_iterator it = utf32string.begin(); it != utf32string.end(); ++it) { injectKeyPress(myGuiKeyCode, *it); } } return true; } bool InputManager::keyReleased(const SDL_KeyboardEvent &key) { if (mSDLVKeyMap.count(key.keysym.sym) == 0) { return false; } injectKeyRelease(mSDLVKeyMap[key.keysym.sym]); return true; } bool InputManager::mouseWheelMoved(const SDL_MouseWheelEvent &evt) { mMouseZ += evt.y; mMouseMove = true; return true; } void InputManager::captureInput() { } void InputManager::setInputViewSize(int _width, int _height) { mWidth = _width; mHeight = _height; checkPosition(); } void InputManager::setMousePosition(int _x, int _y) { mMouseX = _x; mMouseY = _y; checkPosition(); } void InputManager::checkPosition() { if (mMouseX < 0) mMouseX = 0; else if (mMouseX >= mWidth) mMouseX = mWidth - 1; if (mMouseY < 0) mMouseY = 0; else if (mMouseY >= mHeight) mMouseY = mHeight - 1; } void InputManager::onClipboardChanged(const std::string &_type, const std::string &_data) { if (_type == "Text") SDL_SetClipboardText(MyGUI::TextIterator::getOnlyText(MyGUI::UString(_data)).asUTF8().c_str()); } void InputManager::onClipboardRequested(const std::string &_type, std::string &_data) { if (_type != "Text") return; char* text = SDL_GetClipboardText(); if (text) { // MyGUI's clipboard might still have color information, to retain that information, only set the new text // if it actually changed (clipboard inserted by an external application) if (MyGUI::TextIterator::getOnlyText(_data) != text) _data = text; } SDL_free(text); } } // namespace input mygui-MyGUI3.4.1+dfsg/Common/BaseLayout/0000775000175000017500000000000014017025067016747 5ustar psi29apsi29amygui-MyGUI3.4.1+dfsg/Common/BaseLayout/BaseLayout.h0000664000175000017500000001622314017025067021174 0ustar psi29apsi29a/*! @file @author Albert Semenov @date 07/2008 @module */ #ifndef BASE_LAYOUT_H_ #define BASE_LAYOUT_H_ #include #include "WrapsAttribute.h" namespace wraps { class BaseLayout { protected: BaseLayout() : mMainWidget(nullptr) { } BaseLayout(const std::string& _layout, MyGUI::Widget* _parent = nullptr) : mMainWidget(nullptr) { initialise(_layout, _parent); } template void assignWidget(T * & _widget, const std::string& _name, bool _throw = true, bool _createFakeWidgets = true) { _widget = nullptr; for (MyGUI::VectorWidgetPtr::iterator iter = mListWindowRoot.begin(); iter != mListWindowRoot.end(); ++iter) { MyGUI::Widget* find = (*iter)->findWidget(mPrefix + _name); if (nullptr != find) { T* cast = find->castType(false); if (nullptr != cast) { _widget = cast; } else { MYGUI_LOG(Warning, "Widget with name '" << _name << "' have wrong type ('" << find->getTypeName() << "instead of '" << T::getClassTypeName() << "'). [" << mLayoutName << "]"); MYGUI_ASSERT( ! _throw, "Can't assign widget with name '" << _name << "'. [" << mLayoutName << "]"); if (_createFakeWidgets) _widget = _createFakeWidget(mMainWidget); } return; } } MYGUI_LOG(Warning, "Widget with name '" << _name << "' not found. [" << mLayoutName << "]"); MYGUI_ASSERT( ! _throw, "Can't assign widget with name '" << _name << "'. [" << mLayoutName << "]"); if (_createFakeWidgets) _widget = _createFakeWidget(mMainWidget); } template void assignBase(T * & _widget, const std::string& _name, bool _throw = true, bool _createFakeWidgets = true) { _widget = nullptr; for (MyGUI::VectorWidgetPtr::iterator iter = mListWindowRoot.begin(); iter != mListWindowRoot.end(); ++iter) { MyGUI::Widget* find = (*iter)->findWidget(mPrefix + _name); if (nullptr != find) { _widget = new T(find); mListBase.push_back(_widget); return; } } MYGUI_LOG(Warning, "Widget with name '" << _name << "' not found. [" << mLayoutName << "]"); MYGUI_ASSERT( ! _throw, "Can't assign base widget with name '" << _name << "'. [" << mLayoutName << "]"); if (_createFakeWidgets) { _widget = new T(_createFakeWidget(mMainWidget)); mListBase.push_back(_widget); } } void initialise(const std::string& _layout, MyGUI::Widget* _parent = nullptr, bool _throw = true, bool _createFakeWidgets = true) { const std::string MAIN_WINDOW1 = "_Main"; const std::string MAIN_WINDOW2 = "Root"; mLayoutName = _layout; // оборачиваем if (mLayoutName.empty()) { mMainWidget = _parent; if (mMainWidget != nullptr) { mListWindowRoot.push_back(mMainWidget); mPrefix = FindParentPrefix(mMainWidget); } } // загружаем лейаут на виджет else { mPrefix = MyGUI::utility::toString(this, "_"); mListWindowRoot = MyGUI::LayoutManager::getInstance().loadLayout(mLayoutName, mPrefix, _parent); const std::string mainName1 = mPrefix + MAIN_WINDOW1; const std::string mainName2 = mPrefix + MAIN_WINDOW2; for (MyGUI::VectorWidgetPtr::iterator iter = mListWindowRoot.begin(); iter != mListWindowRoot.end(); ++iter) { if ((*iter)->getName() == mainName1 || (*iter)->getName() == mainName2) { mMainWidget = (*iter); snapToParent(mMainWidget); break; } } if (mMainWidget == nullptr) { MYGUI_LOG(Warning, "Root widget with name '" << MAIN_WINDOW1 << "' or '" << MAIN_WINDOW2 << "' not found. [" << mLayoutName << "]"); MYGUI_ASSERT(!_throw, "No root widget. ['" << mLayoutName << "]"); if (_createFakeWidgets) mMainWidget = _createFakeWidget(_parent); } mMainWidget->setUserString("BaseLayoutPrefix", mPrefix); } } void shutdown() { // удаляем все классы for (VectorBasePtr::reverse_iterator iter = mListBase.rbegin(); iter != mListBase.rend(); ++iter) delete (*iter); mListBase.clear(); // удаляем все рутовые виджеты if (!mLayoutName.empty()) MyGUI::LayoutManager::getInstance().unloadLayout(mListWindowRoot); mListWindowRoot.clear(); } template void initialiseByAttributes(Type* _owner, MyGUI::Widget* _parent = nullptr, bool _throw = true, bool _createFakeWidgets = true) { initialise(attribute::AttributeLayout::getData(), _parent, _throw, _createFakeWidgets); typename attribute::AttributeFieldWidgetName::VectorBindPair& data = attribute::AttributeFieldWidgetName::getData(); for (typename attribute::AttributeFieldWidgetName::VectorBindPair::iterator item = data.begin(); item != data.end(); ++item) { MyGUI::Widget* value = nullptr; assignWidget(value, item->second, _throw, false); bool result = item->first->set(_owner, value); if (!result && _createFakeWidgets) { value = _createFakeWidgetT(item->first->getFieldTypeName(), mMainWidget); item->first->set(_owner, value); } } } private: std::string FindParentPrefix(MyGUI::Widget* _parent) { std::string prefix = _parent->getUserString("BaseLayoutPrefix"); if (!prefix.empty()) return prefix; if (_parent->getParent() != nullptr) return FindParentPrefix(_parent->getParent()); return ""; } void snapToParent(MyGUI::Widget* _child) { if (_child->isUserString("SnapTo")) { MyGUI::Align align = MyGUI::Align::parse(_child->getUserString("SnapTo")); MyGUI::IntCoord coord = _child->getCoord(); MyGUI::IntSize size = _child->getParentSize(); if (align.isHStretch()) { coord.left = 0; coord.width = size.width; } else if (align.isLeft()) { coord.left = 0; } else if (align.isRight()) { coord.left = size.width - coord.width; } else { coord.left = (size.width - coord.width) / 2; } if (align.isVStretch()) { coord.top = 0; coord.height = size.height; } else if (align.isTop()) { coord.top = 0; } else if (align.isBottom()) { coord.top = size.height - coord.height; } else { coord.top = (size.height - coord.height) / 2; } _child->setCoord(coord); } } template T* _createFakeWidget(MyGUI::Widget* _parent) { return static_cast(_createFakeWidgetT(T::getClassTypeName(), _parent)); } MyGUI::Widget* _createFakeWidgetT(const std::string& _typeName, MyGUI::Widget* _parent) { if (_parent) return _parent->createWidgetT(_typeName, MyGUI::SkinManager::getInstance().getDefaultSkin(), MyGUI::IntCoord(), MyGUI::Align::Default); return MyGUI::Gui::getInstance().createWidgetT(_typeName, MyGUI::SkinManager::getInstance().getDefaultSkin(), MyGUI::IntCoord(), MyGUI::Align::Default, ""); } public: virtual ~BaseLayout() { shutdown(); } protected: MyGUI::Widget* mMainWidget; private: std::string mPrefix; std::string mLayoutName; MyGUI::VectorWidgetPtr mListWindowRoot; typedef std::vector VectorBasePtr; VectorBasePtr mListBase; }; } // namespace wraps #endif // BASE_LAYOUT_H_ mygui-MyGUI3.4.1+dfsg/Common/BaseLayout/WrapsAttribute.h0000664000175000017500000000146114017025067022102 0ustar psi29apsi29a/*! @file @author Albert Semenov @date 10/2009 @module */ #ifndef WRAPS_ATTRIBUTE_H_ #define WRAPS_ATTRIBUTE_H_ #include #include "Attribute.h" namespace attribute { struct FieldSetterWidget { typedef MyGUI::Widget BaseValueType; template static Type* convert(BaseValueType* _value) { return _value == nullptr ? nullptr : _value->castType(false); } }; DECLARE_ATTRIBUTE_FIELD(AttributeFieldWidgetName, std::string, FieldSetterWidget); #define ATTRIBUTE_FIELD_WIDGET_NAME(_class, _field, _value) \ ATTRIBUTE_FIELD(AttributeFieldWidgetName, _class, _field, _value) DECLARE_ATTRIBUTE_CLASS(AttributeLayout, std::string); #define ATTRIBUTE_CLASS_LAYOUT(_class, _value) \ ATTRIBUTE_CLASS(AttributeLayout, _class, _value) } #endif // WRAPS_ATTRIBUTE_H_ mygui-MyGUI3.4.1+dfsg/Common/BaseLayout/Attribute.h0000664000175000017500000000714514017025067021072 0ustar psi29apsi29a/*! @file @author Albert Semenov @date 10/2009 @module */ #ifndef ATTRIBUTE_H_ #define ATTRIBUTE_H_ namespace attribute { // класс обертка для удаления данных из статического вектора template struct DataHolder { ~DataHolder() { for (typename Type::iterator item = data.begin(); item != data.end(); ++item) delete (*item).first; } Type data; }; // интерфейс для обертки поля template struct Field { virtual ~Field() { } virtual bool set(OwnerType* _target, typename SetterType::BaseValueType* _value) = 0; virtual const std::string& getFieldTypeName() const = 0; }; // шаблон для обертки поля template struct FieldHolder : public Field { FieldHolder(FieldType* OwnerType::* offset) : m_offset(offset) { } FieldType* OwnerType::* const m_offset; bool set(OwnerType* _target, typename SetterType::BaseValueType* _value) override { _target->*m_offset = SetterType::template convert(_value); return _target->*m_offset != nullptr; } const std::string& getFieldTypeName() const override { return FieldType::getClassTypeName(); } }; // шаблон для атрибута поля template struct AttributeField { typedef std::pair*, ValueType> BindPair; typedef std::vector VectorBindPair; template AttributeField(FieldType* OwnerType::* _offset, const ValueType& _value) { getData().push_back(BindPair(new FieldHolder(_offset), _value)); } static VectorBindPair& getData() { static DataHolder data; return data.data; } }; // макрос для инстансирования атрибута поля #define DECLARE_ATTRIBUTE_FIELD(_name, _type, _setter) \ template \ struct _name : public attribute::AttributeField \ { \ template \ _name(FieldType* OwnerType::* _offset, const ValueType& _value) : \ AttributeField(_offset, _value) { } \ } // макрос для инстансирования экземпляра атрибута #define ATTRIBUTE_FIELD(_attribute, _class, _field, _value) \ struct _attribute##_##_field \ { \ _attribute##_##_field() \ { \ static attribute::_attribute<_class> bind(&_class::_field, _value); \ } \ } _attribute##_##_field // шаблон для атрибута класса template struct ClassAttribute { ClassAttribute(const ValueType& _value) { getData() = _value; } static ValueType& getData() { static ValueType data; return data; } }; // макрос для инстансирования атрибута класса #define DECLARE_ATTRIBUTE_CLASS(_name, _type) \ template \ struct _name : public attribute::ClassAttribute<_name, ValueType> \ { \ _name(const ValueType& _value) : \ ClassAttribute<_name, ValueType>(_value) { } \ } // макрос для инстансирования экземпляра класса #define ATTRIBUTE_CLASS(_attribute, _class, _value) \ class _class; \ static attribute::_attribute<_class> _attribute##_##_class(_value) } #endif // ATTRIBUTE_H_ mygui-MyGUI3.4.1+dfsg/Common/FileSystemInfo/0000775000175000017500000000000014017025067017577 5ustar psi29apsi29amygui-MyGUI3.4.1+dfsg/Common/FileSystemInfo/FileSystemInfo.h0000664000175000017500000001263114017025067022653 0ustar psi29apsi29a/*! @file @author Albert Semenov @date 09/2009 @module */ #ifndef FILE_SYSTEM_INFO_H_ #define FILE_SYSTEM_INFO_H_ #include #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32 #include #include #else #include #include #include #include #include #include #endif #include #include #include namespace common { struct FileInfo { FileInfo(const std::wstring& _name, bool _folder) : name(_name), folder(_folder) { } std::wstring name; bool folder; }; typedef std::vector VectorFileInfo; inline std::wstring toLower(const std::wstring& _input) { std::wstring result; result.resize(_input.size()); static std::locale sLocale(""); for (unsigned int i=0; i<_input.size(); ++i) result[i] = std::tolower(_input[i], sLocale); return result; } inline bool sortFiles(const common::FileInfo& left, const common::FileInfo& right) { if (left.folder < right.folder) return true; if (left.folder > right.folder) return false; return toLower(left.name) < toLower(right.name); } inline bool isAbsolutePath(const wchar_t* path) { #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32 if (IsCharAlphaW(path[0]) && path[1] == ':') return true; #endif return path[0] == '/' || path[0] == '\\'; } inline bool endWith(const std::wstring& _source, const std::wstring& _value) { size_t count = _value.size(); if (_source.size() < count) return false; size_t offset = _source.size() - count; for (size_t index = 0; index < count; ++ index) { if (_source[index + offset] != _value[index]) return false; } return true; } inline std::wstring concatenatePath(const std::wstring& _base, const std::wstring& _name) { if (_base.empty() || isAbsolutePath(_name.c_str())) { return _name; } else { if (endWith(_base, L"\\") || endWith(_base, L"/")) return _base + _name; #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32 return _base + L'\\' + _name; #else return _base + L'/' + _name; #endif } } inline bool isReservedDir (const wchar_t* _fn) { // if "." return (_fn [0] == '.' && _fn [1] == 0); } inline bool isParentDir (const wchar_t* _fn) { // if ".." return (_fn [0] == '.' && _fn [1] == '.' && _fn [2] == 0); } inline void getSystemFileList(VectorFileInfo& _result, const std::wstring& _folder, const std::wstring& _mask, bool _sorted = true) { #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32 //FIXME add optional parameter? bool ms_IgnoreHidden = true; intptr_t lHandle; int res; struct _wfinddata_t tagData; // pattern can contain a directory name, separate it from mask size_t pos = _mask.find_last_of(L"/\\"); std::wstring directory; if (pos != _mask.npos) directory = _mask.substr (0, pos); std::wstring full_mask = concatenatePath(_folder, _mask); lHandle = _wfindfirst(full_mask.c_str(), &tagData); res = 0; while (lHandle != -1 && res != -1) { if (( !ms_IgnoreHidden || (tagData.attrib & _A_HIDDEN) == 0 ) && !isReservedDir(tagData.name)) { _result.push_back(FileInfo(concatenatePath(directory, tagData.name), (tagData.attrib & _A_SUBDIR) != 0)); } res = _wfindnext( lHandle, &tagData ); } // Close if we found any files if (lHandle != -1) _findclose(lHandle); #else DIR* dir = opendir(MyGUI::UString(_folder).asUTF8_c_str()); struct dirent* dp; if (dir == nullptr) { /* opendir() failed */ MYGUI_LOG(Error, (std::string("Can't open ") + MyGUI::UString(_folder).asUTF8_c_str())); return; } rewinddir (dir); while ((dp = readdir (dir)) != nullptr) { if ((fnmatch(MyGUI::UString(_mask).asUTF8_c_str(), dp->d_name, 0) == 0) && !isReservedDir(MyGUI::UString(dp->d_name).asWStr_c_str())) { struct stat fInfo; std::string path = MyGUI::UString(_folder).asUTF8() + "/" + dp->d_name; if (stat(path.c_str(), &fInfo) == -1)perror("stat"); _result.push_back(FileInfo(MyGUI::UString(dp->d_name).asWStr(), (S_ISDIR(fInfo.st_mode)))); } } closedir(dir); #endif if (_sorted) { std::sort(_result.begin(), _result.end(), sortFiles); } } inline std::wstring getSystemCurrentFolder() { #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32 wchar_t buff[MAX_PATH+1]; ::GetCurrentDirectoryW(MAX_PATH, buff); return buff; #else # ifndef PATH_MAX # define PATH_MAX 256 # endif char buff[PATH_MAX+1]; return getcwd(buff, PATH_MAX) ? MyGUI::UString(buff).asWStr() : std::wstring(); #endif } typedef std::vector VectorWString; inline void scanFolder(VectorWString& _result, const std::wstring& _folder, bool _recursive, const std::wstring& _mask, bool _fullpath) { std::wstring folder = _folder; if (!folder.empty() && *folder.rbegin() != '/' && *folder.rbegin() != '\\') folder += L"/"; VectorFileInfo result; getSystemFileList(result, folder, _mask); for (VectorFileInfo::const_iterator item = result.begin(); item != result.end(); ++item) { if (item->folder) continue; if (_fullpath) _result.push_back(folder + item->name); else _result.push_back(item->name); } if (_recursive) { getSystemFileList(result, folder, L"*"); for (VectorFileInfo::const_iterator item = result.begin(); item != result.end(); ++item) { if (!item->folder || item->name == L".." || item->name == L".") continue; scanFolder(_result, folder + item->name, _recursive, _mask, _fullpath); } } } } #endif // FILE_SYSTEM_INFO_H_ mygui-MyGUI3.4.1+dfsg/Common/MessageBox/0000775000175000017500000000000014017025067016734 5ustar psi29apsi29amygui-MyGUI3.4.1+dfsg/Common/MessageBox/MessageBox.h0000664000175000017500000002557314017025067021156 0ustar psi29apsi29a/*! @file @author Albert Semenov @date 12/2010 */ #ifndef MESSAGE_BOX_H_ #define MESSAGE_BOX_H_ #include #include "MessageBoxStyle.h" #include "BaseLayout/BaseLayout.h" namespace MyGUI { class Message; typedef delegates::CMultiDelegate2 EventHandle_MessageBoxPtrMessageStyle; class Message : public wraps::BaseLayout { public: Message() : wraps::BaseLayout("MessageBox.layout"), mWidgetText(nullptr), mInfoOk(MessageBoxStyle::None), mInfoCancel(MessageBoxStyle::None), mSmoothShow(false), mIcon(nullptr), mLeftOffset1(0), mLeftOffset2(0) { initialise(); } Message(const std::string& _layoutName) : wraps::BaseLayout(_layoutName), mWidgetText(nullptr), mInfoOk(MessageBoxStyle::None), mInfoCancel(MessageBoxStyle::None), mSmoothShow(false), mIcon(nullptr), mLeftOffset1(0), mLeftOffset2(0) { initialise(); } ~Message() override { mWidgetText = nullptr; mIcon = nullptr; } /** Set caption text*/ void setCaption(const UString& _value) { mMainWidget->castType()->setCaption(_value); } /** Set message text*/ void setMessageText(const UString& _value) { if (mWidgetText != nullptr) mWidgetText->setCaption(_value); updateSize(); } /** Create button with specific name*/ MessageBoxStyle addButtonName(const UString& _name) { if (mVectorButton.size() >= MessageBoxStyle::_CountUserButtons) { MYGUI_LOG(Warning, "Too many buttons in message box, ignored"); return MessageBoxStyle::None; } // бит, номер кнопки + смещение до Button1 MessageBoxStyle info = MessageBoxStyle(MessageBoxStyle::Enum(MYGUI_FLAG(mVectorButton.size() + MessageBoxStyle::_IndexUserButton1))); // запоминаем кнопки для отмены и подтверждения if (mVectorButton.empty()) mInfoOk = info; mInfoCancel = info; Widget* widget = mMainWidget->createWidgetT(mButtonType, mButtonSkin, IntCoord(), Align::Left | Align::Bottom); Button* button = widget->castType