Ejemplo n.º 1
0
bool UILineEdit::onKeyPress(uchar keyCode, std::string keyText, int keyboardModifiers)
{
    if(keyCode == Fw::KeyDelete) // erase right character
        removeCharacter(true);
    else if(keyCode == Fw::KeyBackspace) // erase left character {
        removeCharacter(false);
    else if(keyCode == Fw::KeyRight) // move cursor right
        moveCursor(true);
    else if(keyCode == Fw::KeyLeft) // move cursor left
        moveCursor(false);
    else if(keyCode == Fw::KeyHome) // move cursor to first character
        setCursorPos(0);
    else if(keyCode == Fw::KeyEnd) // move cursor to last character
        setCursorPos(m_text.length());
    else if(keyCode == Fw::KeyV && keyboardModifiers == Fw::KeyboardCtrlModifier)
        appendText(g_window.getClipboardText());
    else if(keyCode == Fw::KeyTab) {
        if(!m_alwaysActive) {
            if(UIWidgetPtr parent = getParent())
                parent->focusNextChild(Fw::TabFocusReason);
        }
    } else if(!keyText.empty() && (keyboardModifiers == Fw::KeyboardNoModifier || keyboardModifiers == Fw::KeyboardShiftModifier))
        appendText(keyText);
    else
        return false;

    return true;
}
Ejemplo n.º 2
0
// Pressed left button
long TextLabel::onLeftBtnPress(FXObject*,FXSelector,void* ptr)
{
    FXEvent* ev=(FXEvent*)ptr;
    handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr);
    if (isEnabled())
    {
        grab();
        if (target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONPRESS,message),ptr))
        	return 1;
        flags&=~FLAG_UPDATE;
        if (ev->click_count==1)
        {
            setCursorPos(index(ev->win_x));
            if (ev->state&SHIFTMASK)
                extendSelection(cursor);
            else
            {
                killSelection();
                setAnchorPos(cursor);
            }
            makePositionVisible(cursor);
            flags|=FLAG_PRESSED;
        }
        else
        {
            setAnchorPos(0);
            setCursorPos(contents.length());
            extendSelection(contents.length());
            makePositionVisible(cursor);
        }
        return 1;
    }
    return 0;
}
Ejemplo n.º 3
0
void consoleEnd() {
	setCursorPos(0);
	if (completionEnd>cmdEnd)
		setCursorPos(completionEnd);
	else
		setCursorPos(cmdEnd);
	drawerInvokeRedisplay();
}
Ejemplo n.º 4
0
bool TextInputWidget::handleKey(int key) {
	bool handled(true);
	
	if (!_hasFocus) return false;
	std::wstring old_input(_input);
	
	int size = static_cast<int>(_input.size());
	
	switch (key) {
	
		case osgGA::GUIEventAdapter::KEY_Left: 
			setCursorPos(_cursorPos - 1);
			break;
		case osgGA::GUIEventAdapter::KEY_Right:
			setCursorPos(_cursorPos + 1);
			break;
		
		case osgGA::GUIEventAdapter::KEY_BackSpace:
			if ((_cursorPos >= size) && (size >=1)) 
			{
				// letztes Zeichen löschen
				_input = _input.substr(0, size - 2);
				setCursorPos(getCursorPosition()-1);
			}
			else if ((_cursorPos >= 0) &&  (_cursorPos < size)) 
			{
				//Zeichen links vom Cursor löschen
				_input = _input.substr(0,_cursorPos)+_input.substr(_cursorPos+1, size);
				setCursorPos(getCursorPosition()-1);
			}
			break;
		case osgGA::GUIEventAdapter::KEY_Delete:
		case osgGA::GUIEventAdapter::KEY_KP_Delete:
			if ((_cursorPos > 0) &&  (_cursorPos < size-1))
				_input = _input.substr(0,_cursorPos+1)+_input.substr(_cursorPos+2, size);
			break;
			
		default:
			if (key >= 0xff00) {
				handled = false;
			} else {
				// std::cout <<"key " << key << std::endl;
				// TODO hande utf?
				if (_cursorPos < size)
					_input.insert(_cursorPos+1, 1, static_cast<char>(key)); 
				else 
					_input += static_cast<char>(key);
				
				_cursorPos++;
			}
	}
	
	if (_input != old_input)
		informAttachedResponder(Actions::valueChanged());
	if (handled)
		update();
	return handled;
}
Ejemplo n.º 5
0
void consoleRight() {
	if ((cursorPos+cursorLen<cmdEnd) || (cursorPos+cursorLen<completionEnd)) {
		if (cursorPos+cursorLen==cmdEnd)
			setCursorPos(cursorPos+2);
		else
			setCursorPos(cursorPos+1);
	}
	drawerInvokeRedisplay();
}
Ejemplo n.º 6
0
void consoleLeft() {
	if (cursorPos>cmdBegin) {
		if (cursorPos==cmdEnd+1)
			setCursorPos(cursorPos-2);
		else
			setCursorPos(cursorPos-1);
	}
	drawerInvokeRedisplay();
}
Ejemplo n.º 7
0
bool UITextEdit::onKeyPress(uchar keyCode, int keyboardModifiers, int autoRepeatTicks)
{
    if(UIWidget::onKeyPress(keyCode, keyboardModifiers, autoRepeatTicks))
        return true;

    if(keyboardModifiers == Fw::KeyboardNoModifier) {
        if(keyCode == Fw::KeyDelete) { // erase right character
            removeCharacter(true);
            return true;
        } else if(keyCode == Fw::KeyBackspace) { // erase left character {
            removeCharacter(false);
            return true;
        } else if(keyCode == Fw::KeyRight && !m_shiftNavigation) { // move cursor right
            moveCursor(true);
            return true;
        } else if(keyCode == Fw::KeyLeft && !m_shiftNavigation) { // move cursor left
            moveCursor(false);
            return true;
        } else if(keyCode == Fw::KeyHome) { // move cursor to first character
            setCursorPos(0);
            return true;
        } else if(keyCode == Fw::KeyEnd) { // move cursor to last character
            setCursorPos(m_text.length());
            return true;
        } else if(keyCode == Fw::KeyTab && !m_shiftNavigation) {
            if(UIWidgetPtr parent = getParent())
                parent->focusNextChild(Fw::KeyboardFocusReason);
            return true;
        } else if(keyCode == Fw::KeyEnter && m_multiline) {
            appendCharacter('\n');
            return true;
        } else if(keyCode == Fw::KeyUp && !m_shiftNavigation && m_multiline) {
            
        } else if(keyCode == Fw::KeyDown && !m_shiftNavigation && m_multiline) {

        }
    } else if(keyboardModifiers == Fw::KeyboardCtrlModifier) {
        if(keyCode == Fw::KeyV) {
            appendText(g_window.getClipboardText());
            return true;
        }
    } else if(keyboardModifiers == Fw::KeyboardShiftModifier) {
        if(keyCode == Fw::KeyRight && m_shiftNavigation) { // move cursor right
            moveCursor(true);
            return true;
        } else if(keyCode == Fw::KeyLeft && m_shiftNavigation) { // move cursor left
            moveCursor(false);
            return true;
        }
    }

    return false;
}
Ejemplo n.º 8
0
void applyCompletion() {
	if (cursorPos>cmdEnd) {
		int pos=cursorPos;
		setCursorPos(0);
		consoleLines->str[pos]='\0';
		utilStrRmChars(consoleLines->str+cmdEnd, 1);
		cmdEnd=pos-1;
		setCursorPos(cmdEnd);
	} else {
		consoleLines->str[cmdEnd]='\0';
	}
	completionEnd=0;
}
Ejemplo n.º 9
0
// Clears the entire screen
bool Console::clearScreen(void)
{
	cout.flush();
	setCursorPos(0, 0);
	DWORD numCharactersWritten;
	COORD consoleCoords = {0, 0};
    GetConsoleScreenBufferInfo(consoleHandle, &consoleInfo);
    FillConsoleOutputCharacter(consoleHandle, ' ', consoleInfo.dwSize.X * consoleInfo.dwSize.Y, consoleCoords, &numCharactersWritten);
	FillConsoleOutputAttribute(consoleHandle, consoleInfo.wAttributes, consoleInfo.dwSize.X * consoleInfo.dwSize.Y, consoleCoords, &numCharactersWritten);
	setCursorPos(0, 0);
	cout.flush();

	return true;
}
Ejemplo n.º 10
0
void TextEdit::onMouseDragged(const SimGui::Event &event)
{
    int pos = setCursorPos(event.ptMouse);
    
    //if the position is to the left
    if (pos == -1)
    {
       scrollDir = -1;
    }
    //else if the position is to the right
    else if (pos == -2)
    {
      scrollDir = 1;
    }
    //else set the new cursor position
    else
    {
        scrollDir = 0;
        cursorPos = pos;
    }
    
    //update the block
    blockStart = min(cursorPos, mouseDragStart);
    blockEnd = max(cursorPos, mouseDragStart);
    if (blockStart < 0) blockStart = 0;
    
    if (blockStart == blockEnd)
    {
        blockStart = blockEnd = 0;
    }
    
   //let the parent get the event
   Parent::onMouseDragged(event);
}
Ejemplo n.º 11
0
QHexEditPrivate::QHexEditPrivate(QScrollArea *parent) : QWidget(parent)
{
    _undoStack = new QUndoStack(this);

    _scrollArea = parent;
    _asciiArea = true;

    setOverwriteMode(true);
    setCursorPos(0);
    setAddressArea(true);

    setAddressWidth(4);
    setAddressOffset(0);
    setAsciiArea(true);
    setHighlighting(true);
    setReadOnly(false);
    setAddressAreaColor(QColor(0xd4, 0xd4, 0xd4, 0xff));
    setHighlightingColor(QColor(0xff, 0xff, 0x99, 0xff));
    setSelectionColor(QColor(0x6d, 0x9e, 0xff, 0xff));
    setFont(QFont("Courier", 10));

    _size = 0;
    resetSelection(0);

    setFocusPolicy(Qt::StrongFocus);

    connect(&_cursorTimer, SIGNAL(timeout()), this, SLOT(updateCursor()));
    _cursorTimer.setInterval(500);
    _cursorTimer.start();
}
Ejemplo n.º 12
0
void consoleKeyPress(char c) {
	if (!cursorPos)
		openConsole("");
	applyCompletion();

	int pos=cursorPos;
	setCursorPos(0);
	cmdLineRealloc(1);
	utilStrInsertChar(consoleLines->str+pos, c);
	cmdEnd++;

	updateCompletions();

	setCursorPos(pos+1);
	drawerInvokeRedisplay();
}
Ejemplo n.º 13
0
void drawReminder()
{	
	fb_setClipping(3,41,252, 150);
	
	fb_drawRect(0,37,255,148,textAreaFillColor);
	setFont(font_arial_9);
	setColor(textAreaTextColor);	
	setWrapToBorder();
	
	if(blinkOn())
	{
		if(isInsert())
			setCursorProperties(cursorNormalColor, 1, -1, 0);
		else
			setCursorProperties(cursorOverwriteColor, 1, -1, 0);
			
		showCursor();
		setCursorPos(getKBCursor());		
	}
	
	setFakeHighlight();
	
	fb_dispString(0,-3,reminder);
	
	setWrapNormal();
	hideCursor();
	clearHighlight();
	drawCurDay();
}
Ejemplo n.º 14
0
void SciDoc::removeLine() {
//	LOGGER;

	JuffScintilla* edit = int_->curEdit_;
	if ( edit == NULL ) return;

	int line1(-1), line2(-1), col1(-1), col2(-1);
	if ( edit->hasSelectedText() ) {
		edit->getSelection(&line1, &col1, &line2, &col2);
		if ( col2 == 0 )
			--line2;

		if (line1 <= line2 && line1 >= 0) {
			setCursorPos(line1, 0);
			edit->beginUndoAction();
			for (int l = line1; l <= line2; ++l) {
				edit->SendScintilla(QsciScintilla::SCI_LINEDELETE);
			}
			edit->endUndoAction();
		}
	}
	else {
		edit->getCursorPosition(&line1, &col1);
		if ( line1 >= 0 ) {
			edit->SendScintilla(QsciScintilla::SCI_LINEDELETE);
		}
	}
}
Ejemplo n.º 15
0
bool BaseApp::onMouseMove(const int x, const int y, const int deltaX, const int deltaY){
	if (mouseCaptured){
#if defined(__APPLE__)
		wx -= (invertMouse? 1 : -1) * mouseSensibility * deltaY;
		wy -= mouseSensibility * deltaX;
#else
		static bool changed = false;
		if (changed = !changed){
			wx += (invertMouse? 1 : -1) * mouseSensibility * (height / 2 - y);
			wy += mouseSensibility * (width / 2 - x);
			setCursorPos(width / 2, height / 2);
		}
#endif

		return true;
	} else {

		if (widgets.goToFirst()){
			do {
				Widget *widget = widgets.getCurrent();
				if (widget->isEnabled() && widget->isVisible() && (widget->isInWidget(x, y) || widget->isCapturing())){
					//widgets.moveCurrentToTop();
					return widget->onMouseMove(x, y);
				}
			} while (widgets.goToNext());
		}
	}
	return false;
}
Ejemplo n.º 16
0
void TextEdit::onMouseDown(const Event &event)
{
   dragHit = false;

   //undo any block function
   blockStart = 0;
   blockEnd = 0;

   //find out where the cursor should be
   int pos = setCursorPos(event.ptMouse);

   //if the position is to the left
   if (pos == -1) cursorPos = 0;
   //else if the position is to the right
   else if (pos == -2) cursorPos = strlen(text);
   //else set the cursorPos
   else cursorPos = pos;

   //save the mouseDragPos
   mouseDragStart = cursorPos;

   //lock the mouse
   mouseLock();

   //set the drag var
   dragHit = TRUE;
   
   //let the parent get the event
   Parent::onMouseDown(event);
}
Ejemplo n.º 17
0
// Erases the entire line that the cursor is on
bool Console::eraseEntireLine(void)
{
	cout.flush();
	findCursorPos();
	unsigned char tempX = xPos;
	
	setCursorPos(0, yPos);

	for(int i = 0; i < 80; i++)
		cout << " ";

	cout.flush();
	setCursorPos(tempX, yPos);
	
	return true;
}
Ejemplo n.º 18
0
// Erases everything from the start of the current line to the cursor position
bool Console::eraseFromStartOfLineToCursor(void)
{
	cout.flush();
	findCursorPos();
		
	unsigned char tempX = xPos;
	
	setCursorPos(0, yPos);

	for(int i = 0; i < xPos; i++)
		cout << " ";
	cout.flush();
	setCursorPos(tempX, yPos);

	return true;
}
Ejemplo n.º 19
0
void QHexEditPrivate::scrollToEnd()
{
    setCursorPos(_xData.size() * 2);
    resetSelection(_cursorPosition);
    _scrollArea->ensureVisible(_cursorX, _cursorY + _charHeight/2, 3, _charHeight/2 + 2);
    update();
}
Ejemplo n.º 20
0
long fx_numeric_field::change_on_digit(int sign)
{
    FXString txt = getText();
    int pos = getCursorPos();

    int pow_exp, dot_pos;
    int norm = get_normalized_int (txt.text(), pow_exp, dot_pos);

    if (dot_pos < 0) return 0;

    int pos_exp = dot_pos - pos;
    if (pos_exp < 0)
        pos_exp ++;
    int inc_abs = ipow10 (pos_exp + pow_exp);

    norm += sign * inc_abs;

    FXString new_txt = denormalize (norm, pow_exp, dot_pos);
    int new_pos = dot_pos - pos_exp;
    if (pos_exp < 0)
        new_pos ++;

    setText(new_txt);
    setCursorPos(new_pos);

    if (target)
        target->tryHandle(this, FXSEL(SEL_CHANGED,message), (void*)new_txt.text());

    return 1;
}
Ejemplo n.º 21
0
void QHexEditPrivate::undo()
{
    _undoStack->undo();
    emit dataChanged();
    setCursorPos(_cursorPosition);
    update();
}
Ejemplo n.º 22
0
void QHexEditPrivate::setData(const QByteArray &data)
{
    _xData.setData(data);
    _undoStack->clear();
    adjust();
    setCursorPos(0);
}
Ejemplo n.º 23
0
void QHexEditPrivate::setAddressArea(bool addressArea)
{
    _addressArea = addressArea;
    adjust();

    setCursorPos(_cursorPosition);
}
Ejemplo n.º 24
0
void consoleBackspace() {
	if (cursorPos>cmdBegin) {
		if (cursorPos<=cmdEnd) {
			int pos=cursorPos;
			setCursorPos(0);
			utilStrRmChars(consoleLines->str + --pos, 1);
			cmdEnd--;
			updateCompletions();
			setCursorPos(pos);
		} else {
			setCursorPos(cmdEnd);
		}
	} else if (cursorPos+cursorLen==cmdEnd) {
		consoleClear();
	}
	drawerInvokeRedisplay();
}
Ejemplo n.º 25
0
void QHexEditPrivate::mousePressEvent(QMouseEvent * event)
{
    _blink = false;
    update();
    int cPos = cursorPos(event->pos());
    resetSelection(cPos);
    setCursorPos(cPos);
}
Ejemplo n.º 26
0
void QHexEditPrivate::mouseMoveEvent(QMouseEvent * event)
{
    _blink = false;
    update();
    int actPos = cursorPos(event->pos());
    setCursorPos(actPos);
    setSelection(actPos);
}
Ejemplo n.º 27
0
void QHexEditPrivate::setData(const QByteArray &data)
{
    _data = data;
    _changedData = QByteArray(data.length(), char(1));
    adjust();
    setCursorPos(0);
    setFocus();
}
Ejemplo n.º 28
0
void QHexEditPrivate::setData(const QByteArray &data)
{
    _data = data;
    _originalData = data;
    adjust();
    setCursorPos(0);
    setFocus();
}
Ejemplo n.º 29
0
void QHexEditPrivate::setAddressWidth(int addressWidth)
{
    if ((addressWidth >= 0) and (addressWidth<=6))
    {
        _addressNumbers = addressWidth;
        adjust();
        setCursorPos(_cursorPosition);
    }
}
Ejemplo n.º 30
0
bool UILineEdit::onMousePress(const Point& mousePos, Fw::MouseButton button)
{
    if(button == Fw::MouseLeftButton) {
        int pos = getTextPos(mousePos);
        if(pos >= 0)
            setCursorPos(pos);
    }
    return true;
}