void ItemBox::removeItemAt(size_t _index) { MYGUI_ASSERT_RANGE(_index, mItemsInfo.size(), "ItemBox::removeItemAt"); _resetContainer(false); resetCurrentActiveItem(); mItemsInfo.erase(mItemsInfo.begin() + _index); // расчитываем новый индекс выделения if (mIndexSelect != ITEM_NONE) { if (mItemsInfo.empty()) { mIndexSelect = ITEM_NONE; } else if ((mIndexSelect > _index) || (mIndexSelect == mItemsInfo.size())) { mIndexSelect --; } } updateScrollSize(); updateScrollPosition(); findCurrentActiveItem(); _updateAllVisible(true); }
void ItemBox::insertItemAt(size_t _index, Any _data) { MYGUI_ASSERT_RANGE_INSERT(_index, mItemsInfo.size(), "ItemBox::insertItemAt"); if (_index == ITEM_NONE) _index = mItemsInfo.size(); _resetContainer(false); resetCurrentActiveItem(); mItemsInfo.insert(mItemsInfo.begin() + _index, ItemDataInfo(_data)); // расчитываем новый индекс выделения if (mIndexSelect != ITEM_NONE) { if (mIndexSelect >= _index) { mIndexSelect ++; } } updateScrollSize(); updateScrollPosition(); findCurrentActiveItem(); _updateAllVisible(true); }
void ItemBox::updateFromResize() { requestItemSize(); updateScrollSize(); updateScrollPosition(); _updateAllVisible(true); _resetContainer(true); }
void ListCtrl::updateFromResize() { updateMetrics(); updateScrollSize(); updateScrollPosition(); _updateAllVisible(ITEM_NONE, true, true); _resetContainer(true); }
void ListCtrl::removeAllItems() { if (0 == mItemsInfo.size()) return; _resetContainer(false); mItemsInfo.clear(); mIndexSelect = ITEM_NONE; mIndexActive = ITEM_NONE; updateScrollSize(); updateScrollPosition(); _updateAllVisible(ITEM_NONE, true, true); }
void ItemBox::removeAllItems() { if (mItemsInfo.empty()) return; _resetContainer(false); mItemsInfo.clear(); mIndexSelect = ITEM_NONE; mIndexActive = ITEM_NONE; updateScrollSize(); updateScrollPosition(); _updateAllVisible(true); }
void ItemBox::initialiseOverride() { Base::initialiseOverride(); // FIXME нам нужен фокус клавы setNeedKeyFocus(true); mDragLayer = "DragAndDrop"; if (isUserString("DragLayer")) mDragLayer = getUserString("DragLayer"); ///@wskin_child{ItemBox, Widget, Client} Клиентская зона. assignWidget(mClient, "Client"); if (mClient != nullptr) { mClient->eventMouseWheel += newDelegate(this, &ItemBox::notifyMouseWheel); mClient->eventMouseButtonPressed += newDelegate(this, &ItemBox::notifyMouseButtonPressed); mClient->eventMouseButtonReleased += newDelegate(this, &ItemBox::notifyMouseButtonReleased); setWidgetClient(mClient); } ///@wskin_child{ItemBox, ScrollBar, VScroll} Вертикальная полоса прокрутки. assignWidget(mVScroll, "VScroll"); if (mVScroll != nullptr) { mVScroll->eventScrollChangePosition += newDelegate(this, &ItemBox::notifyScrollChangePosition); } ///@wskin_child{ItemBox, ScrollBar, HScroll} Горизонтальная полоса прокрутки. assignWidget(mHScroll, "HScroll"); if (mHScroll != nullptr) { mHScroll->eventScrollChangePosition += newDelegate(this, &ItemBox::notifyScrollChangePosition); } // подписываем клиент для драгэндропа if (mClient != nullptr) mClient->_setContainer(this); requestItemSize(); updateScrollSize(); updateScrollPosition(); }
void ScrollView::updateView() { updateScrollSize(); updateScrollPosition(); }
void ListCtrl::_updateAllVisible(size_t _index, bool _needUpdateContetntSize, bool _update) { bool change = false; int top = 0; size_t widget_index = 0; for (size_t index = 0; index < mItemsInfo.size(); ++index) { ItemDataInfo& info = mItemsInfo[index]; // айтем сверху не виден if ((top + info.size.height) < (mContentPosition.top)) { } // айтем снизу и не виден else if (top > ((mContentPosition.top) + _getClientWidget()->getHeight())) { } // айтем встрял в видимость else { Widget* item = getItemWidget(widget_index); widget_index++; if (index == _index || ITEM_NONE == _index) { item->_setInternalData((size_t)index); item->setPosition(-mContentPosition.left, top - (mContentPosition.top)); item->setVisible(true); IBDrawItemInfo data(index, mIndexSelect, mIndexActive, mIndexAccept, mIndexRefuse, _update, false); IntCoord coord(IntPoint(), info.size); requestDrawItem(this, item, data, coord); if (info.size != coord.size()) change = true; info.size = coord.size(); item->setSize(mClient->getWidth()/*mContentSize.width*/, info.size.height); } } top += info.size.height; } // если виджеты еще есть, то их надо скрыть while (widget_index < mVectorItems.size()) { Widget* item = mVectorItems[widget_index]; widget_index ++; item->setVisible(false); item->_setInternalData((size_t)ITEM_NONE); } if (change && _needUpdateContetntSize) { updateMetrics(); updateScrollSize(); updateScrollPosition(); } }