Exemplo n.º 1
0
 bool ReverseArrayIterator::setInputPosition(size_t i) 
 { 
     Dimensions const& dims = array.dims;
     if (i == dims.size()) {
         return inputIterator->setPosition(inPos);
     }
     if (setInputPosition(i+1)) { 
         return true;
     }
     size_t interval = dims[i].getChunkInterval() - 1;
     inPos[i] -= interval;
     bool rc = setInputPosition(i+1);
     inPos[i] += interval;
     return rc;
 }
Exemplo n.º 2
0
	bool ReverseArrayIterator::setPosition(Coordinates const& pos)
	{
        outPos = pos;
        chunkInitialized = false;
        array.revert(outPos, inPos);
        array.getArrayDesc().getChunkPositionFor(inPos);
        return hasCurrent = setInputPosition(0);
    }
Exemplo n.º 3
0
 bool ReverseArrayIterator::nextAvailable()
 {
     Dimensions const& dims = array.dims;
     chunkInitialized = false;
     while (true) { 
         size_t i = outPos.size()-1;
         while ((outPos[i] += dims[i].getChunkInterval()) > dims[i].getEndMax()) { 
             outPos[i] = dims[i].getStartMin();
             if (i-- == 0) { 
                 return false;
             }
         }
         array.revert(outPos, inPos);
         array.getArrayDesc().getChunkPositionFor(inPos);
         if (setInputPosition(0)) { 
             return true;
         }
     }
     return false;
 } 
Exemplo n.º 4
0
//! [0]
void CustomInputHandler::mouseMoveEvent(QMouseEvent *event, const QPoint &mousePos)
{
    Q_UNUSED(event)
    setInputPosition(mousePos);
}
Exemplo n.º 5
0
	void TextInput::onEvent(KeyboardEvent *e)
	{
		if (!e)
		{
			return;
		}
		int key = e->getKey();
		if (e->isSystemKey() || key == 8)
		{
			bool ctrlDown = KeyboardManager::getManager()->isKeyDown(17);
			// Backspace
			if (key == 8)
			{
				std::string str = getText();
				if (str.size() == 0 || mInputPosition == 0)
				{
					return;
				}

				if (ctrlDown)
				{
					int count = util::Utils::countWordLetters(getText(), mInputPosition, false);
					if (count != 0)
					{
						str.erase(mInputPosition + count, -count);
						mText->setText(str);
						fireChangeEvent();
						updateInputCursor(count);
					}
				}
				else
				{
					str.erase(mInputPosition - 1, 1);
					mText->setText(str);
					fireChangeEvent();
					updateInputCursor(-1);
				}
				return;
			}
			// Delete
			if (key == 46)
			{
				std::string str = getText();
				if (str.size() == 0 || mInputPosition == 0)
				{
					return;
				}

				if (ctrlDown)
				{
					int count = util::Utils::countWordLetters(getText(), mInputPosition, true);
					if (count != 0)
					{
						str.erase(mInputPosition, count);
						mText->setText(str);
						fireChangeEvent();
						//updateInputCursor(count);
					}
				}
				else
				{
					str.erase(mInputPosition, 1);
					mText->setText(str);
					fireChangeEvent();
					//updateInputCursor(0);
				}
				return;
			}
			// Home key
			if (key == 36)
			{
				// Go to very start
				if (ctrlDown)
				{
					setInputPosition(0);
				}
				else
				{
					int position = mText->getStartOfLine(mInputPosition);
					setInputPosition(position);
				}
			}
			// End key
			else if (key == 35)
			{
				// Go to very end
				if (ctrlDown)
				{
					setInputPosition(mText->length());
				}
				else
				{
					int position = mText->getEndOfLine(mInputPosition);
					setInputPosition(position);
				}
			}
			// Left key
			else if (key == 37)
			{
				if (ctrlDown)
				{
					int count = util::Utils::countWordLetters(getText(), mInputPosition, false);
					if (count != 0)
					{
						updateInputCursor(count);
						return;
					}
				}
				updateInputCursor(-1);
			}
			// Right key
			else if(key == 39)
			{
				if (ctrlDown)
				{
					int count = util::Utils::countWordLetters(getText(), mInputPosition, true);
					if (count != 0)
					{
						updateInputCursor(count);
						return;
					}
				}
				updateInputCursor(1);
			}
			// Up key
			else if (key == 38)
			{
				int position = mText->getLineAbove(mInputPosition);
				if (position >= 0)
				{
					setInputPosition(position);
				}
			}
			// Down key
			else if (key == 40)
			{
				int position = mText->getLineBelow(mInputPosition);
				if (position >= 0)
				{
					setInputPosition(position);
				}
			}
		}
		else
		{
			appendText(e->getKey());
			fireChangeEvent();
		}
	}
Exemplo n.º 6
0
	void TextInput::moveInputPosition(int move)
	{
		setInputPosition(mInputPosition + move);
	}