void Gui::destroyWidgets(EnumeratorWidgetPtr& _widgets) { VectorWidgetPtr widgets; while (_widgets.next()) widgets.push_back(_widgets.current()); destroyWidgets(widgets); }
VectorWidgetPtr ResourceLayout::createLayout(const std::string& _prefix, Widget* _parent) { VectorWidgetPtr widgets; for (VectorWidgetInfo::iterator iter = mLayoutData.begin(); iter != mLayoutData.end(); ++iter) { Widget* widget = createWidget(*iter, _prefix, _parent); widgets.push_back(widget); } return widgets; }
void WidgetManager::destroyWidget(WidgetPtr _widget) { // иначе возможен бесконечный цикл MYGUI_ASSERT(_widget != null, "widget is deleted"); // отписываем от всех VectorWidgetPtr childs = _widget->getChilds(); for (VectorWidgetPtr::iterator iter = childs.begin(); iter != childs.end(); ++iter) unlinkFromUnlinkers(*iter); unlinkFromUnlinkers(_widget); // делегирует удаление отцу виджета WidgetPtr parent = _widget->getParent(); if (parent == null) Gui::getInstance()._destroyChildWidget(_widget); else parent->_destroyChildWidget(_widget); }
void Window::initialiseOverride() { Base::initialiseOverride(); // FIXME нам нужен фокус клавы setNeedKeyFocus(true); // дефолтные размеры mMinmax.set( (std::numeric_limits<int>::min)(), (std::numeric_limits<int>::min)(), (std::numeric_limits<int>::max)(), (std::numeric_limits<int>::max)()); bool main_move = false; if (isUserString("MainMove")) { setUserString("Scale", "1 1 0 0"); main_move = true; } ///@wskin_child{Window, Widget, Client} Клиентская зона. assignWidget(mClient, "Client"); if (mClient != nullptr) { if (main_move) { mClient->setUserString("Scale", "1 1 0 0"); mClient->eventMouseButtonPressed += newDelegate(this, &Window::notifyMousePressed); mClient->eventMouseButtonReleased += newDelegate(this, &Window::notifyMouseReleased); mClient->eventMouseDrag += newDelegate(this, &Window::notifyMouseDrag); } setWidgetClient(mClient); } ///@wskin_child{Window, TextBox, Caption} Caption for window. assignWidget(mWidgetCaption, "Caption"); if (mWidgetCaption != nullptr) { mWidgetCaption->setUserString("Scale", "1 1 0 0"); mWidgetCaption->eventMouseButtonPressed += newDelegate(this, &Window::notifyMousePressed); mWidgetCaption->eventMouseButtonReleased += newDelegate(this, &Window::notifyMouseReleased); mWidgetCaption->eventMouseDrag += newDelegate(this, &Window::notifyMouseDrag); } VectorWidgetPtr buttons = getSkinWidgetsByName("Button"); for (VectorWidgetPtr::iterator iter = buttons.begin(); iter != buttons.end(); ++iter) { (*iter)->eventMouseButtonClick += newDelegate(this, &Window::notifyPressedButtonEvent); } VectorWidgetPtr actions = getSkinWidgetsByName("Action"); for (VectorWidgetPtr::iterator iter = actions.begin(); iter != actions.end(); ++iter) { (*iter)->eventMouseButtonPressed += newDelegate(this, &Window::notifyMousePressed); (*iter)->eventMouseButtonReleased += newDelegate(this, &Window::notifyMouseReleased); (*iter)->eventMouseDrag += newDelegate(this, &Window::notifyMouseDrag); (*iter)->eventMouseWheel += newDelegate(this, &Window::notifyMouseWheel); } const size_t countNames = 8; const char* resizers[2][countNames] = { {"ResizeLeftTop", "ResizeTop", "ResizeRightTop", "ResizeRight", "ResizeRightBottom", "ResizeBottom", "ResizeLeftBottom", "ResizeLeft"}, {"Left Top", "Top", "Right Top", "Right", "Right Bottom", "Bottom", "Left Bottom", "Left"} }; for (size_t index = 0; index < countNames; ++ index) { Widget* widget = nullptr; assignWidget(widget, resizers[0][index]); if (widget != nullptr) { widget->eventMouseButtonPressed += newDelegate(this, &Window::notifyMousePressed); widget->eventMouseButtonReleased += newDelegate(this, &Window::notifyMouseReleased); widget->eventMouseDrag += newDelegate(this, &Window::notifyMouseDrag); widget->eventMouseWheel += newDelegate(this, &Window::notifyMouseWheel); widget->setUserString("Action", resizers[1][index]); } } }
void Gui::destroyWidgets(const VectorWidgetPtr& _widgets) { for (VectorWidgetPtr::const_iterator iter = _widgets.begin(); iter != _widgets.end(); ++iter) destroyWidget(*iter); }