コード例 #1
0
ファイル: ltguieditctrl.cpp プロジェクト: Arc0re/lithtech
// Handles a key press
bool CLTGUIEditCtrl::HandleKeyDown(int key, int rep)
{
	if (CLTGUICtrl::HandleKeyDown(key, rep))
        return true;

	switch (key)
	{
	case VK_BACK:
		if (m_nCaretPos > 0)
		{
			m_nCaretPos--;
			RemoveCharacter();
		}
		break;
	case VK_DELETE:
		RemoveCharacter();
		break;
	case VK_HOME:
		m_nCaretPos = 0;
		break;
	case VK_END:
		m_nCaretPos = LTStrLen(m_Text.GetText());
		break;
	case VK_LEFT:
		if (m_nCaretPos > 0) m_nCaretPos--;
		break;
	case VK_RIGHT:
		if (m_nCaretPos < LTStrLen(m_Text.GetText())) m_nCaretPos++;
		break;
	default:
		return false;
	}

    return true;
}
コード例 #2
0
ファイル: ltguieditctrl.cpp プロジェクト: emoose/lithtech
void CLTGUIEditCtrl::SetFixedWidth(uint16 nWidth, LTBOOL bUseFrame)
{
	uint16 nMinWidth = m_nBaseFontSize + 1;
	ASSERT(nWidth >= nMinWidth);
	if (nWidth < nMinWidth)
		nWidth = nMinWidth;
	m_nFixedWidth = nWidth;
	CalculateSize();

	if (m_nFixedWidth)
	{
		m_bUseFrame = bUseFrame;
		if (m_pText)
		{
			float testWidth = m_fScale * m_nFixedWidth;
			int nOldCaret = m_nCaretPos;
			m_nCaretPos = m_pText->GetLength();
			while (m_pText->GetLength() && m_pText->GetWidth() > testWidth )
			{
				m_nCaretPos--;
				RemoveCharacter();				
			}
			if (nOldCaret > m_pText->GetLength())
				m_nCaretPos = m_pText->GetLength();
			else
				m_nCaretPos = nOldCaret;
		}
	}
	else
		m_bUseFrame = LTFALSE;
}
コード例 #3
0
ファイル: Input.cpp プロジェクト: Manuzor/ezEngine
bool ezConsole::ProcessInputCharacter(ezUInt32 uiChar)
{
  switch (uiChar)
  {
  case 27: // Escape
    ClearInputLine();
    return false;

  case '\b': // backspace
    {
      if (!m_sInputLine.IsEmpty() && m_iCaretPosition > 0)
      {
        RemoveCharacter(m_iCaretPosition - 1);
        MoveCaret(-1);
      }
    }
    return false;

  case '\t':
    AutoCompleteInputLine();
    return false;

  case 13: // Enter
    AddToInputHistory(m_sInputLine.GetData());
    ProcessCommand(m_sInputLine.GetData());
    ClearInputLine();
    return false;
  }

  return true;
}
コード例 #4
0
ファイル: PARSER.C プロジェクト: dougc333/stanford
void RemoveCharacterRange(int a, int b, CharSetT *cs) {
  int i;

  if (a < 0 || b < 0 || a > 255 || b > 255 || a > b) {
#if ERR_MESG
    fprintf(stderr, "RemoveCharacterRange: invalid arguments");
#endif
    return; 
  }
  for (i = a; i <= b; i++)
    RemoveCharacter(i, cs);
}
コード例 #5
0
ファイル: ltguieditctrl.cpp プロジェクト: emoose/lithtech
// Handles a key press
LTBOOL CLTGUIEditCtrl::HandleKeyDown(int key, int rep)
{
	if (CLTGUICtrl::HandleKeyDown(key, rep))
        return LTTRUE;

	switch (key)
	{
	case VK_BACK:
		if (m_nCaretPos > 0)
		{
			m_nCaretPos--;
			RemoveCharacter();
		}
		break;
	case VK_DELETE:
		RemoveCharacter();
		break;
	case VK_HOME:
		m_nCaretPos = 0;
		break;
	case VK_END:
		if (m_pText)
			m_nCaretPos = m_pText->GetLength();
		break;
	case VK_LEFT:
		if (m_nCaretPos > 0) m_nCaretPos--;
		break;
	case VK_RIGHT:
		if (m_nCaretPos < m_pText->GetLength()) m_nCaretPos++;
		break;
	default:
		return LTFALSE;
	}

    return LTTRUE;
}
コード例 #6
0
ファイル: ltguieditctrl.cpp プロジェクト: Arc0re/lithtech
// Add a character to the end
void CLTGUIEditCtrl::AddCharacter(wchar_t c)
{
	//add 1 for trailing 0
	uint32 len = LTStrLen(m_Text.GetText()) + 1;

	// Check to see are at our buffer limit
	if (len >= m_nMaxLength)
		return;

	// strip out leading whitespace which confuses things
	if (LTStrEmpty(m_Text.GetText( )) && c == ' ')
		return;

	
	LTStrCpy(szString, m_Text.GetText(), LTARRAYSIZE(szString));
	uint32 nIndex = LTStrLen(szString);

	while (nIndex > m_nCaretPos)
	{
		szString[nIndex] = szString[nIndex-1];
		nIndex--;
	}

	szString[nIndex]	= c;
	m_nCaretPos++;
	m_Text.SetText(szString);

	LTRect2n rExt;
	LTRESULT res = m_Text.GetExtents(rExt);
	if (res == LT_OK)
	{
		if (rExt.GetWidth() > int32(GetWidth()) )
		{
			m_nCaretPos--;
			RemoveCharacter();
		}
	}
}
コード例 #7
0
ファイル: ltguieditctrl.cpp プロジェクト: emoose/lithtech
// Add a character to the end
void CLTGUIEditCtrl::AddCharacter(char c)
{
	if (!m_pText)
		return;

	// Check to see are at our buffer limit
	if (m_pText->GetLength() >= m_nMaxLength)
		return;

	
	SAFE_STRCPY(szString,m_pText->GetText());
	int nIndex = (int)strlen(szString);

	while (nIndex > m_nCaretPos)
	{
		szString[nIndex] = szString[nIndex-1];
		nIndex--;
	}

	szString[nIndex]	= c;
	m_nCaretPos++;
	m_pText->SetText(szString);

	if (m_nFixedWidth)
	{
		float testWidth = m_fScale * m_nFixedWidth;
		if (m_pText->GetWidth() > testWidth )
		{
			m_nCaretPos--;
			RemoveCharacter();
		}
	}

	CalculateSize();

}
コード例 #8
0
bool MythUITextEdit::keyPressEvent(QKeyEvent *e)
{
    m_lastKeyPress.restart();

    QStringList actions;
    bool handled = false;

    handled = GetMythMainWindow()->TranslateKeyPress("Global", e, actions, false);

    if (!handled && InsertCharacter(e->text()))
        handled = true;

    for (int i = 0; i < actions.size() && !handled; i++)
    {

        QString action = actions[i];
        handled = true;

        if (action == "LEFT")
        {
            if (!MoveCursor(MoveLeft))
                handled = false;
        }
        else if (action == "RIGHT")
        {
            if (!MoveCursor(MoveRight))
                handled = false;
        }
        else if (action == "DELETE")
        {
            RemoveCharacter(m_Position+1);
        }
        else if (action == "BACKSPACE")
        {
            RemoveCharacter(m_Position);
        }
        else if (action == "SELECT" && e->key() != Qt::Key_Space
                 && GetMythDB()->GetNumSetting("UseVirtualKeyboard", 1) == 1)
        {
            MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
            MythUIVirtualKeyboard *kb =  new MythUIVirtualKeyboard(popupStack, this);

            if (kb->Create())
            {
                //connect(kb, SIGNAL(keyPress(QString)), SLOT(keyPress(QString)));
                popupStack->AddScreen(kb);
            }
            else
                delete kb;
        }
        else if (action == "CUT")
        {
            CutTextToClipboard();
        }
        else if (action == "COPY")
        {
            CopyTextToClipboard();
        }
        else if (action == "PASTE")
        {
            PasteTextFromClipboard();
        }
        else
            handled = false;
    }

    return handled;
}
コード例 #9
0
bool MythUITextEdit::keyPressEvent(QKeyEvent *event)
{
    m_lastKeyPress.restart();

    QStringList actions;
    bool handled = false;

    handled = GetMythMainWindow()->TranslateKeyPress("Global", event, actions,
                                                     false);

    Qt::KeyboardModifiers modifiers = event->modifiers();
    int keynum = event->key();

    if (keynum >= Qt::Key_Shift && keynum <= Qt::Key_CapsLock)
        return false;

    QString character;
    // Compose key handling
    // Enter composition mode
    if ((modifiers & Qt::GroupSwitchModifier) &&
        (keynum >= Qt::Key_Dead_Grave) && (keynum <= Qt::Key_Dead_Horn))
    {
        m_composeKey = keynum;
        handled = true;
    }
    else if (m_composeKey > 0) // 'Compose' the key
    {
        if (gDeadKeyMap.isEmpty())
            LoadDeadKeys(gDeadKeyMap);

        LOG(VB_GUI, LOG_DEBUG, QString("Compose key: %1 Key: %2").arg(QString::number(m_composeKey, 16)).arg(QString::number(keynum, 16)));

        if (gDeadKeyMap.contains(keyCombo(m_composeKey, keynum)))
        {
            int keycode = gDeadKeyMap.value(keyCombo(m_composeKey, keynum));

            //QKeyEvent key(QEvent::KeyPress, keycode, modifiers);
            character = QChar(keycode);

            if (modifiers & Qt::ShiftModifier)
                character = character.toUpper();
            else
                character = character.toLower();
            LOG(VB_GUI, LOG_DEBUG, QString("Found match for dead-key combo - %1").arg(character));
        }
        m_composeKey = 0;
    }

    if (character.isEmpty())
        character = event->text();

    if (!handled && InsertCharacter(character))
        handled = true;

    for (int i = 0; i < actions.size() && !handled; i++)
    {

        QString action = actions[i];
        handled = true;

        if (action == "LEFT")
        {
            MoveCursor(MoveLeft);
        }
        else if (action == "RIGHT")
        {
            MoveCursor(MoveRight);
        }
        else if (action == "UP")
        {
            handled = MoveCursor(MoveUp);
        }
        else if (action == "DOWN")
        {
            handled = MoveCursor(MoveDown);
        }
        else if (action == "PAGEUP")
        {
            handled = MoveCursor(MovePageUp);
        }
        else if (action == "PAGEDOWN")
        {
            handled = MoveCursor(MovePageDown);
        }
        else if (action == "DELETE")
        {
            RemoveCharacter(m_Position + 1);
        }
        else if (action == "BACKSPACE")
        {
            RemoveCharacter(m_Position);
        }
        else if (action == "NEWLINE")
        {
            QString newmessage = m_Message;
            newmessage.insert(m_Position + 1, '\n');
            SetText(newmessage, false);
            MoveCursor(MoveRight);
        }
        else if (action == "SELECT" && keynum != Qt::Key_Space
                 && GetMythDB()->GetNumSetting("UseVirtualKeyboard", 1) == 1)
        {
            MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
            MythUIVirtualKeyboard *kb =  new MythUIVirtualKeyboard(popupStack, this);

            if (kb->Create())
            {
                //connect(kb, SIGNAL(keyPress(QString)), SLOT(keyPress(QString)));
                popupStack->AddScreen(kb);
            }
            else
                delete kb;
        }
        else if (action == "CUT")
        {
            CutTextToClipboard();
        }
        else if (action == "COPY")
        {
            CopyTextToClipboard();
        }
        else if (action == "PASTE")
        {
            PasteTextFromClipboard();
        }
        else
            handled = false;
    }

    return handled;
}
コード例 #10
0
ファイル: Input.cpp プロジェクト: Manuzor/ezEngine
void ezConsole::DeleteNextCharacter()
{
  RemoveCharacter(m_iCaretPosition);
}