コード例 #1
0
	void ListCtrl::notifyRootMouseChangeFocus(Widget* _sender, bool _focus)
	{
		size_t index = calcIndexByWidget(_sender);
		if (_focus)
		{
			MYGUI_ASSERT_RANGE(index, mItemsInfo.size(), "ListCtrl::notifyRootMouseChangeFocus");

			// сбрасываем старый
			if (mIndexActive != ITEM_NONE)
			{
				size_t old_index = mIndexActive;
				mIndexActive = ITEM_NONE;

				//FIXME потом только один попробовать обновить
				_updateAllVisible(old_index, true, false);

				/*IBDrawItemInfo data(old_index, mIndexSelect, mIndexActive, mIndexAccept, mIndexRefuse, false, false);
				IntCoord coord(IntPoint(), mItemsInfo[old_index].size);
				requestDrawItem(this, mVectorItems[old_index - mFirstVisibleIndex], data, coord);
				mItemsInfo[old_index].size = coord.size();*/

			}

			mIndexActive = index;

			//FIXME потом только один попробовать обновить
			_updateAllVisible(index, true, false);

			/*IBDrawItemInfo data(index, mIndexSelect, mIndexActive, mIndexAccept, mIndexRefuse, false, false);
			IntCoord coord(IntPoint(), mItemsInfo[index].size);
			requestDrawItem(this, mVectorItems[*_sender->_getInternalData<size_t>()], data, coord);
			mItemsInfo[index].size = coord.size();*/

		}
		else
		{
			// при сбросе виджет может быть уже скрыт, и соответсвенно отсутсвовать индекс
			// сбрасываем индекс, только если мы и есть актив
			if (index < mItemsInfo.size() && mIndexActive == index)
			{
				mIndexActive = ITEM_NONE;

				//FIXME потом только один попробовать обновить
				_updateAllVisible(index, true, false);

				/*IBDrawItemInfo data(index, mIndexSelect, mIndexActive, mIndexAccept, mIndexRefuse, false, false);
				IntCoord coord(IntPoint(), mItemsInfo[index].size);
				requestDrawItem(this, mVectorItems[*_sender->_getInternalData<size_t>()], data, coord);
				mItemsInfo[index].size = coord.size();*/

			}
		}
	}
コード例 #2
0
ファイル: MyGUI_ItemBox.cpp プロジェクト: DotWolff/mygui
	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);
	}
コード例 #3
0
ファイル: MyGUI_ItemBox.cpp プロジェクト: DotWolff/mygui
	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);
	}
コード例 #4
0
	void ListCtrl::setContentPosition(const IntPoint& _point)
	{
		mContentPosition = _point;

		_updateAllVisible(ITEM_NONE, true, true);
		_resetContainer(true);
	}
コード例 #5
0
	void ListCtrl::_setContainerItemInfo(size_t _index, bool _set, bool _accept)
	{
		if (_index == ITEM_NONE) return;
		MYGUI_ASSERT_RANGE(_index, mItemsInfo.size(), "ListCtrl::_setContainerItemInfo");

		mIndexAccept = (_set && _accept ) ? _index : ITEM_NONE;
		mIndexRefuse = (_set && !_accept) ? _index : ITEM_NONE;

		//FIXME потом только один попробовать обновить
		_updateAllVisible(_index, true, false);

		/*size_t start = (size_t)mFirstVisibleIndex;
		if ((_index >= start) && (_index < (start + mVectorItems.size())))
		{

			IBDrawItemInfo data(_index, mIndexSelect, mIndexActive, mIndexAccept, mIndexRefuse, false, false);

			IntCoord coord(IntPoint(), mItemsInfo[_index].size);

			requestDrawItem(this, mVectorItems[_index - start], data, coord);

			mItemsInfo[_index].size = coord.size();

		}*/
	}
コード例 #6
0
	void ListCtrl::resetCurrentActiveItem()
	{
		// сбрасываем старую подсветку
		if (mIndexActive != ITEM_NONE)
		{
			//size_t start = (size_t)mFirstVisibleIndex;
			size_t index = mIndexActive;
			mIndexActive = ITEM_NONE;

			//FIXME потом только один попробовать обновить
			_updateAllVisible(index, true, false);

			// если видим, то обновляем
			/*if ((mIndexActive >= start) && (mIndexActive < (start + mVectorItems.size())))
			{
				IBDrawItemInfo data(index, mIndexSelect, mIndexActive, mIndexAccept, mIndexRefuse, false, false);

				IntCoord coord(IntPoint(), mItemsInfo[index].size);

				requestDrawItem(this, mVectorItems[mIndexActive - start], data, coord);

				mItemsInfo[index].size = coord.size();

			}*/
		}
	}
コード例 #7
0
ファイル: MyGUI_ItemBox.cpp プロジェクト: DotWolff/mygui
	void ItemBox::updateFromResize()
	{
		requestItemSize();

		updateScrollSize();
		updateScrollPosition();

		_updateAllVisible(true);
		_resetContainer(true);
	}
コード例 #8
0
	void ListCtrl::setIndexSelected(size_t _index)
	{
		MYGUI_ASSERT_RANGE_AND_NONE(_index, mItemsInfo.size(), "ListCtrl::setIndexSelected");
		if (_index == mIndexSelect) return;

		//size_t start = (size_t)mFirstVisibleIndex;

		// сбрасываем старое выделение
		if (mIndexSelect != ITEM_NONE)
		{

			size_t index = mIndexSelect;
			mIndexSelect = ITEM_NONE;

			//FIXME потом только один попробовать обновить
			_updateAllVisible(index, true, false);

			/*if ((index >= start) && (index < (start + mVectorItems.size())))
			{
				IBDrawItemInfo data(index, mIndexSelect, mIndexActive, mIndexAccept, mIndexRefuse, false, false);
				IntCoord coord(IntPoint(), mItemsInfo[index].size);
				requestDrawItem(this, mVectorItems[index - start], data, coord);
				mItemsInfo[index].size = coord.size();
			}*/
		}

		mIndexSelect = _index;
		if (mIndexSelect != ITEM_NONE)
		{

			//FIXME потом только один попробовать обновить
			_updateAllVisible(_index, true, false);

			/*if ((_index >= start) && (_index < (start + mVectorItems.size())))
			{
				IBDrawItemInfo data(_index, mIndexSelect, mIndexActive, mIndexAccept, mIndexRefuse, false, false);
				IntCoord coord(IntPoint(), mItemsInfo[_index].size);
				requestDrawItem(this, mVectorItems[_index - start], data, coord);
				mItemsInfo[_index].size = coord.size();
			}*/
		}

	}
コード例 #9
0
	void ListCtrl::updateFromResize()
	{
		updateMetrics();

		updateScrollSize();
		updateScrollPosition();

		_updateAllVisible(ITEM_NONE, true, true);
		_resetContainer(true);
	}
コード例 #10
0
	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);
	}
コード例 #11
0
ファイル: MyGUI_ItemBox.cpp プロジェクト: DotWolff/mygui
	void ItemBox::removeAllItems()
	{
		if (mItemsInfo.empty())
			return;
		_resetContainer(false);

		mItemsInfo.clear();

		mIndexSelect = ITEM_NONE;
		mIndexActive = ITEM_NONE;

		updateScrollSize();
		updateScrollPosition();

		_updateAllVisible(true);
	}
コード例 #12
0
	void ListCtrl::redrawItemAt(size_t _index)
	{
		MYGUI_ASSERT_RANGE(_index, mItemsInfo.size(), "ListCtrl::redrawItemAt");

		//FIXME потом только один попробовать обновить
		_updateAllVisible(_index, true, true);

		/*size_t start = (size_t)mFirstVisibleIndex;
		if ((_index >= start) && (_index < (start + mVectorItems.size())))
		{
			IBDrawItemInfo data(_index, mIndexSelect, mIndexActive, mIndexAccept, mIndexRefuse, true, false);
			IntCoord coord(IntPoint(), mItemsInfo[_index].size);
			requestDrawItem(this, mVectorItems[_index - start], data, coord);
			mItemsInfo[_index].size = coord.size();
		}*/
	}
コード例 #13
0
ファイル: MyGUI_ItemBox.cpp プロジェクト: DotWolff/mygui
	void ItemBox::setContentPosition(const IntPoint& _point)
	{
		mContentPosition = _point;

		int old = mFirstVisibleIndex;

		if (mAlignVert)
		{
			mFirstVisibleIndex = mContentPosition.top / mSizeItem.height;
			mFirstOffsetIndex = mContentPosition.top % mSizeItem.height;
		}
		else
		{
			mFirstVisibleIndex = mContentPosition.left / mSizeItem.width;
			mFirstOffsetIndex = mContentPosition.left % mSizeItem.width;
		}

		_updateAllVisible(old != mFirstVisibleIndex);
		_resetContainer(true);
	}
コード例 #14
0
	void ListCtrl::findCurrentActiveItem()
	{
		MYGUI_DEBUG_ASSERT(mIndexActive == ITEM_NONE, "use : resetCurrentActiveItem() before findCurrentActiveItem()");

		const IntPoint& point = InputManager::getInstance().getMousePositionByLayer();

		// сначала проверяем клиентскую зону
		const IntRect& rect = _getClientWidget()->getAbsoluteRect();
		if ((point.left < rect.left) || (point.left > rect.right) || (point.top < rect.top) || (point.top > rect.bottom))
		{
			return;
		}

		for (size_t pos = 0; pos < mVectorItems.size(); ++pos)
		{
			Widget* item = mVectorItems[pos];
			const IntRect& abs_rect = item->getAbsoluteRect();
			if ((point.left >= abs_rect.left) && (point.left <= abs_rect.right) && (point.top >= abs_rect.top) && (point.top <= abs_rect.bottom))
			{

				size_t index = calcIndexByWidget(item);
				// при переборе индекс может быть больше, так как может создасться сколько угодно
				if (index < mItemsInfo.size())
				{

					mIndexActive = index;
					//FIXME потом только один попробовать обновить
					_updateAllVisible(index, true, false);

					/*IBDrawItemInfo data(index, mIndexSelect, mIndexActive, mIndexAccept, mIndexRefuse, false, false);
					IntCoord coord(IntPoint(), mItemsInfo[index].size);
					requestDrawItem(this, item, data, coord);
					mItemsInfo[index].size = coord.size();*/

				}

				break;
			}
		}
	}
コード例 #15
0
ファイル: MyGUI_ItemBox.cpp プロジェクト: DotWolff/mygui
	void ItemBox::redrawAllItems()
	{
		_updateAllVisible(true);
	}
コード例 #16
0
	void ListCtrl::eraseContent()
	{
		_updateAllVisible(ITEM_NONE, false, true);
		updateMetrics();
	}