void QFormulatorEditWidget::keyPressEvent( QKeyEvent *e )
{
	switch( e->key() )
	{
    case Qt::Key_Up:
		if( e->modifiers() == Qt::NoModifier || e->modifiers() == Qt::KeypadModifier  )
			OnMoveUp();
		else if( (e->modifiers() & Qt::ControlModifier) && (e->modifiers() & Qt::ShiftModifier) )
			OnMoveCtrlShiftUp();
		else if( e->modifiers() & Qt::ShiftModifier )
			OnMoveShiftUp();
		else if( e->modifiers() & Qt::ControlModifier )
			OnMoveCtrlUp();
        return;
    case Qt::Key_Down:
		if( e->modifiers() == Qt::NoModifier || e->modifiers() == Qt::KeypadModifier  )
			OnMoveDown();
		else if( (e->modifiers() & Qt::ControlModifier) && (e->modifiers() & Qt::ShiftModifier) )
			OnMoveCtrlShiftDown();
		else if( e->modifiers() & Qt::ShiftModifier )
			OnMoveShiftDown();
		else if( e->modifiers() & Qt::ControlModifier )
			OnMoveCtrlDown();
        return;
    case Qt::Key_Left:
		if( e->modifiers() == Qt::NoModifier || e->modifiers() == Qt::KeypadModifier  )
			OnMoveLeft();
		else if( (e->modifiers() & Qt::ControlModifier) && (e->modifiers() & Qt::ShiftModifier) )
			OnMoveCtrlShiftLeft();
		else if( e->modifiers() & Qt::ShiftModifier )
			OnMoveShiftLeft();
		else if( e->modifiers() & Qt::ControlModifier )
			OnMoveCtrlLeft();
        return;
    case Qt::Key_Right:
		if( e->modifiers() == Qt::NoModifier || e->modifiers() == Qt::KeypadModifier  )
			OnMoveRight();
		else if( (e->modifiers() & Qt::ControlModifier) && (e->modifiers() & Qt::ShiftModifier) )
			OnMoveCtrlShiftRight();
		else if( e->modifiers() & Qt::ShiftModifier )
			OnMoveShiftRight();
		else if( e->modifiers() & Qt::ControlModifier )
			OnMoveCtrlRight();
        return;
	case Qt::Key_Home:
		if( e->modifiers() == Qt::NoModifier || e->modifiers() == Qt::KeypadModifier  )
			OnMoveHome();
		else if( (e->modifiers() & Qt::ControlModifier) && (e->modifiers() & Qt::ShiftModifier) )
			OnMoveCtrlShiftHome();
		else if( e->modifiers() & Qt::ShiftModifier )
			OnMoveShiftHome();
		else if( e->modifiers() & Qt::ControlModifier )
			OnMoveCtrlHome();
        return;
	case Qt::Key_End:
		if( e->modifiers() == Qt::NoModifier || e->modifiers() == Qt::KeypadModifier  )
			OnMoveEnd();
		else if( (e->modifiers() & Qt::ControlModifier) && (e->modifiers() & Qt::ShiftModifier) )
			OnMoveCtrlShiftEnd();
		else if( e->modifiers() & Qt::ShiftModifier )
			OnMoveShiftEnd();
		else if( e->modifiers() & Qt::ControlModifier )
			OnMoveCtrlEnd();
		break;
	case Qt::Key_PageUp:
		if( e->modifiers() == Qt::NoModifier || e->modifiers() == Qt::KeypadModifier  )
			OnMovePageUp();
		else if( (e->modifiers() & Qt::ControlModifier) && (e->modifiers() & Qt::ShiftModifier) )
			OnMoveCtrlShiftPageUp();
		else if( e->modifiers() & Qt::ShiftModifier )
			OnMoveShiftPageUp();
		else if( e->modifiers() & Qt::ControlModifier )
			OnMoveCtrlPageUp();
        return;
	case Qt::Key_PageDown:
		if( e->modifiers() == Qt::NoModifier || e->modifiers() == Qt::KeypadModifier  )
			OnMovePageDown();
		else if( (e->modifiers() & Qt::ControlModifier) && (e->modifiers() & Qt::ShiftModifier) )
			OnMoveCtrlShiftPageDown();
		else if( e->modifiers() & Qt::ShiftModifier )
			OnMoveShiftPageDown();
		else if( e->modifiers() & Qt::ControlModifier )
			OnMoveCtrlPageDown();
        return;
	case Qt::Key_Backspace:
		if( e->modifiers() == Qt::NoModifier )
			BackSpace();
        return;
	case Qt::Key_Delete:
		if( e->modifiers() == Qt::NoModifier || e->modifiers() == Qt::KeypadModifier )
			Delete();
        return;
    case Qt::Key_Return:
		if( e->modifiers() == Qt::NoModifier || e->modifiers() == Qt::KeypadModifier  )
		{
			rootNode()->MoveReturn();
			updateViewDocument();
			//cbFireEvent( FORMULIB_CALLBACK_ENTER, NULL, NULL );
		}
        return;
    case Qt::Key_Escape:
		if( e->modifiers() == Qt::NoModifier )
		{
			rootNode()->Escape();
			updateFormulatorWidget();
		}
        return;
	default:
		break;
	}

	if( e->matches( QKeySequence::Copy ) )
	{
		editCopy();
		return;
	}
	else if( e->matches( QKeySequence::Cut ) )
	{
		editCut();
		return;
	}
	else if( e->matches( QKeySequence::Paste ) )
	{
		editPaste();
		return;
	}
	if( e->matches( QKeySequence::Delete ) )
	{
		Delete();
		return;
	}
	else if( e->matches( QKeySequence::Undo ) )
	{
		editUndo();
		return;
	}
	else if( e->matches( QKeySequence::Redo ) )
	{
		editRedo();
		return;
	}
	else if( e->matches( QKeySequence::SelectAll ) )
	{
		editSelectAll();
	}
	else if( e->matches( QKeySequence::ZoomIn ) )
	{
		double value = qMin( scale() + DEFAULT_VIEWSCALE_STEP, DEFAULT_VIEWSCALE_MAX );
		setScale( value );
	}
	else if( e->matches( QKeySequence::ZoomOut ) )
	{
		double value = qMax( scale() - DEFAULT_VIEWSCALE_STEP, DEFAULT_VIEWSCALE_MIN );
		setScale( value );
	}
	else if( e->text().length() > 0 )
	{
		for( long i = 0; i < e->text().length(); i++ )
			rootNode()->Char( e->text().at( i ).unicode(), undoRedo() );
		updateViewDocument();
		//cbFireEvent( FORMULIB_CALLBACK_CHAR, nChar, NULL );
	}

	QFormulatorWidget::keyPressEvent( e );
}
void HexEditViewBase::MoveLeft()
{
    if ( !m_IsActive ) return;
    OnMoveLeft();
}