Exemple #1
0
void CScrollBufL1::DoubleSelection(long nLine, long *nStartChar, long *nEndChar)
{
    char *pText;
    CScrollBufL3 *pL3;

    pL3 = m_pL2->GetScreen(&nLine);
    if (nLine < (long)pL3->GetNumLines())
    {
        pText = pL3->m_vecLine[nLine].szLine;
        if ((*nStartChar) == (*nEndChar))
        {
            if (isspace(pText[*nStartChar]))
            {
                MoveSelectionDown(pText, nStartChar, isspace);
                MoveSelectionUp(pText, nEndChar, isspace);
            }
            else
            {
                MoveSelectionDown(pText, nStartChar, isnotspace);
                MoveSelectionUp(pText, nEndChar, isnotspace);
            }
            m_nDoubleSelectionStart = (*nStartChar);
            m_nDoubleSelectionEnd = (*nEndChar);
            m_nDoubleSelectionLine = nLine;
        }
        else
        {
            if ((m_bDoubleClickDown) && 
                (m_nDoubleSelectionStart != m_nDoubleSelectionEnd) && 
                (nLine == m_nDoubleSelectionLine))
            {
                if (IsSelectionBackwards())
                {
                    (*nEndChar) = m_nDoubleSelectionEnd;
                }
                else
                {
                    (*nStartChar) = m_nDoubleSelectionStart;
                }
            }

            if (IsSelectionBackwards())
            {
                if (isspace(pText[*nStartChar]))
                {
                    MoveSelectionDown(pText, nStartChar, isspace);
                }
                else
                {
                    MoveSelectionDown(pText, nStartChar, isnotspace);
                }
            }
            else
            {
                if (isspace(pText[*nEndChar]))
                {
                    MoveSelectionUp(pText, nEndChar, isspace);
                }
                else
                {
                    MoveSelectionUp(pText, nEndChar, isnotspace);
                }
            }
        }
    }
}
LRESULT GraphicsWindow::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg)
    {
    case WM_CREATE:
		// Should be created before the first WM_PAINT message
        if (FAILED(D2D1CreateFactory(
                D2D1_FACTORY_TYPE_SINGLE_THREADED, &pFactory)))
        {
            return -1;  // Fail CreateWindowEx.
        }
		DPIScale::Initialize(pFactory);
		SetTimer(m_hwnd, m_nTimerID, 1000, NULL);
        return 0;

    case WM_DESTROY:
		KillTimer(m_hwnd, m_nTimerID);
        DiscardGraphicsResources();
        SafeRelease(&pFactory);
        break;
	case WM_TIMER:
		InvalidateRect(m_hwnd, NULL, FALSE); // allow the clock faces to cycle the second hand
		break;
    case WM_PAINT:
        OnPaint();
        return 0;

	case WM_LBUTTONDOWN: 
        OnLButtonDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), (DWORD)wParam);
        return 0;

    case WM_LBUTTONUP: 
        OnLButtonUp();
        return 0;
		
    case WM_MOUSEMOVE: 
        OnMouseMove(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), (DWORD)wParam);
        return 0;

    case WM_SIZE:
        Resize();
        return 0;

	case WM_COMMAND: // We've received an accelerator command
        switch (LOWORD(wParam))
        {
			case ID_DRAW_MODE:
				SetMode(DrawMode);
				break;

			case ID_SELECT_MODE:
				SetMode(SelectMode);
				break;

			case ID_TOGGLE_MODE:
				if (mode == DrawMode)
				{
					SetMode(SelectMode);
				}
				else
				{
					SetMode(DrawMode);
				}
				break;
			case ID_MOVE_UP:
				MoveSelectionUp();
				break;
			case ID_MOVE_DOWN:
				MoveSelectionDown();
				break;
			case ID_DELETE:
				DeleteSelection();
				break;
        }
        return 0;
	case WM_SETCURSOR:
		// The mouse is back on our window, maintain the cursor display we had before
        if (LOWORD(lParam) == HTCLIENT)
        {
            SetCursor(hCursor);
            return TRUE;
        }
        break;
    }
    return DefWindowProc(m_hwnd, uMsg, wParam, lParam);
}