void CWin32CursorControl::setCursor(E_CURSOR_TYPE type)
{
	SWin32Cursor is;

	is.FileName = CursorTypeName[type];
    is.FileName.make_lower();

    s32 index = m_Cursors.binary_search(is);
    if (index != -1)
	{
		m_CurCursorIdx = index;
	}
	else
	{
		is.Cursor = LoadCursor(NULL, Win32Cursor[type]);
		if (is.Cursor)
		{
			m_Cursors.push_back(is);
			m_CurCursorIdx = m_Cursors.size()-1;
		}
		else
		{
			LOGGER.logErr("Cant load cursor %s", is.FileName.c_str());
			m_CurCursorIdx = -1;
		}
	}
	refreshCursor();
}
Example #2
0
void FlatLabel::updateHover(const Text::StateResult &state) {
	bool lnkChanged = ClickHandler::setActive(state.link, this);

	if (!_selectable) {
		refreshCursor(state.uponSymbol);
		return;
	}

	Qt::CursorShape cur = style::cur_default;
	if (_dragAction == NoDrag) {
		if (state.link) {
			cur = style::cur_pointer;
		} else if (state.uponSymbol) {
			cur = style::cur_text;
		}
	} else {
		if (_dragAction == Selecting) {
			uint16 second = state.symbol;
			if (state.afterSymbol && _selectionType == TextSelectType::Letters) {
				++second;
			}
			auto selection = _text.adjustSelection({ qMin(second, _dragSymbol), qMax(second, _dragSymbol) }, _selectionType);
			if (_selection != selection) {
				_selection = selection;
				_savedSelection = { 0, 0 };
				setFocus();
				update();
			}
		} else if (_dragAction == Dragging) {
		}

		if (ClickHandler::getPressed()) {
			cur = style::cur_pointer;
		} else if (_dragAction == Selecting) {
			cur = style::cur_text;
		}
	}
	if (_dragAction == Selecting) {
//		checkSelectingScroll();
	} else {
//		noSelectingScroll();
	}

	if (_dragAction == NoDrag && (lnkChanged || cur != _cursor)) {
		setCursor(_cursor = cur);
	}
}
void CWin32CursorControl::setCursor(const c8* filename)
{
	SWin32Cursor is;
    if (!filename)
        filename = "";

    is.FileName = filename;
    is.FileName.make_lower();

    s32 index = m_Cursors.binary_search(is);
    if (index != -1)
	{
		m_CurCursorIdx = index;
	}
	else
	{
		is.Cursor = (HCURSOR)LoadImage(
			0, 	                 // handle of the instance that contains the image
			is.FileName.c_str(), // name or identifier of image
			IMAGE_CURSOR,	     // type of image
			0,	                 // desired width
			0,	                 // desired height
			LR_LOADFROMFILE	     // load flags
			);

		if (is.Cursor)
		{
			m_Cursors.push_back(is);
			m_CurCursorIdx = m_Cursors.size()-1;
		}
		else
		{
			LOGGER.logErr("Cant load cursor %s", is.FileName.c_str());
			m_CurCursorIdx = -1;
		}
	}
	refreshCursor();
}