Beispiel #1
0
/*
 * GoodbyeCursor - we are losing focus, so get rid of our cursor
 */
void GoodbyeCursor( HWND hwnd )
{
    if( haveOldBlinkTime ) {
        SetCaretBlinkTime( oldBlinkTime );
    }
    MyHideCaret( hwnd );
    DestroyCaret();

} /* GoodbyeCursor */
Beispiel #2
0
/*
 * GoodbyeCursor - we are losing focus, so get rid of our cursor
 */
void GoodbyeCursor( window_id wid )
{
    if( haveOldBlinkTime ) {
        SetCaretBlinkTime( oldBlinkTime );
    }
    MyHideCaret( wid );
    DestroyCaret();

} /* GoodbyeCursor */
Beispiel #3
0
void CTEKWindow::OnTimer(UINT nIDEvent)
{
	UINT T;

	if (nIDEvent==IdCaretTimer) {
		if (ts.NonblinkingCursor!=0) {
			T = GetCaretBlinkTime();
			SetCaretBlinkTime(T);
		}
		else {
			::KillTimer(HTEKWin,IdCaretTimer);
		}
		return;
	}
	else {
		::KillTimer(HTEKWin,nIDEvent);
	}
}
Beispiel #4
0
/*
 * SetCursorBlinkRate - set the rate of blinking for the caret
 */
void SetCursorBlinkRate( int cbr )
{
    SetCaretBlinkTime( cbr );
    EditVars.CursorBlinkRate = cbr;

} /* SetCursorBlinkRate */
/* a simple edit window */
static int MyeditWindowProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    int w = 0;
    SIZE Size;
    static char *pBuffer = NULL;
    static int pos = 0, len = 0;
    HDC hdc;

    switch (message) {
        case MSG_CREATE:
            SetWindowFont(hWnd, GetSystemFont(SYSLOGFONT_DEFAULT));
            if (!CreateCaret (hWnd, NULL, 1, GetSysCharHeight())) {
                return -1;
            }
            pBuffer = (char *) calloc(1, 11);
            *pBuffer = 0;
            break;

        case MSG_SETFOCUS:
            hdc = GetClientDC(hWnd);
            w = GetTextExtent (hdc, pBuffer, pos, &Size);
            SetCaretPos(hWnd, w, 0);
            //SetCaretPos(hWnd, pos*GetSysCharWidth(), 0);
            ShowCaret(hWnd);
            ReleaseDC(hdc);
            break;

        case MSG_KILLFOCUS:
            HideCaret(hWnd);
            break;

        case MSG_CHAR:
            switch (wParam) {
                case '\t':
                case '\b':
                case '\n':
                    SetCaretBlinkTime(hWnd, GetCaretBlinkTime(hWnd)-100);
                    break;

                default:
                    {
                        char ch, buf[11];
                        char *tmp;
                        ch = wParam;
                        if (!isalpha(ch) && !isdigit(ch))
                            break;
                        if (len == 10)
                            break;
                        tmp = pBuffer+pos;
                        if (*tmp != 0) {
                            strcpy(buf, tmp);
                            strcpy(tmp+1, buf);
                        }
                        *tmp = ch;
                        pos++;
                        len++;

                        hdc = GetClientDC(hWnd);
                        InvalidateRect(hWnd, NULL, TRUE);
                        w = GetTextExtent (hdc, pBuffer, pos, &Size);
                        SetCaretPos(hWnd, w, 0);
                        //SetCaretPos(hWnd, pos*GetSysCharWidth(), 0);
                        ShowCaret(hWnd);
                        ReleaseDC(hdc);
                    }
                    break;
            }
            break;

        case MSG_KEYDOWN:
            switch (wParam) {
                case SCANCODE_CURSORBLOCKLEFT:
                    pos = MAX(pos-1, 0);
                    break;
                case SCANCODE_CURSORBLOCKRIGHT:
                    pos = MIN(pos+1, len);
                    break;
                case SCANCODE_BACKSPACE:
                    {
                        char buf[11];
                        char *tmp;
                        if (len == 0 || pos == 0)
                            break;
                        tmp = pBuffer+pos;
                        strcpy(buf, tmp);
                        strcpy(tmp-1, buf);
                        pos--;
                        len--;
                        break;
                    }
            }
            if (wParam == SCANCODE_CURSORBLOCKLEFT || wParam == SCANCODE_CURSORBLOCKRIGHT ||
                    wParam == SCANCODE_BACKSPACE) {
                hdc = GetClientDC(hWnd);
                InvalidateRect(hWnd, NULL, TRUE);
                w = GetTextExtent (hdc, pBuffer, pos, &Size);
                //SetCaretPos(hWnd, pos*GetSysCharWidth(), 0);
                SetCaretPos(hWnd, w, 0);
                ReleaseDC(hdc);
            }
            break;

        case MSG_PAINT:
            hdc = BeginPaint(hWnd);
            TextOut(hdc, 0, 0, pBuffer);
            EndPaint(hWnd, hdc);
            return 0;

        case MSG_DESTROY:
            DestroyCaret (hWnd);
            if (pBuffer)
                free(pBuffer);
            return 0;
    }

    return DefaultControlProc(hWnd, message, wParam, lParam);
}
Beispiel #6
0
void Editor::OnSetFocus( CWnd *wnd ){
	if( prefs.edit_blkcursor ) SetCaretBlinkTime( 200 );
	editCtrl.SetFocus();
	caret();
}
Beispiel #7
0
/* Property page dialog callback */
INT_PTR CALLBACK
DisplayPageProc(HWND hwndDlg,
                UINT uMsg,
                WPARAM wParam,
                LPARAM lParam)
{
    PGLOBAL_DATA pGlobalData;
    LPPSHNOTIFY lppsn;
    INT i;

    pGlobalData = (PGLOBAL_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);

    switch (uMsg)
    {
    case WM_INITDIALOG:
        pGlobalData = (PGLOBAL_DATA)((LPPROPSHEETPAGE)lParam)->lParam;
        if (pGlobalData == NULL)
            return FALSE;

        SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);

        pGlobalData->fShowCaret = TRUE;
        GetWindowRect(GetDlgItem(hwndDlg, IDC_CURSOR_WIDTH_TEXT), &pGlobalData->rcCaret);
        ScreenToClient(hwndDlg, (LPPOINT)&pGlobalData->rcCaret.left);
        ScreenToClient(hwndDlg, (LPPOINT)&pGlobalData->rcCaret.right);
        CopyRect(&pGlobalData->rcOldCaret, &pGlobalData->rcCaret);

        pGlobalData->rcCaret.right = pGlobalData->rcCaret.left + pGlobalData->uCaretWidth;

        /* Set the checkbox */
        CheckDlgButton(hwndDlg,
                       IDC_CONTRAST_BOX,
                       pGlobalData->highContrast.dwFlags & HCF_HIGHCONTRASTON ? BST_CHECKED : BST_UNCHECKED);

        SendDlgItemMessage(hwndDlg, IDC_CURSOR_BLINK_TRACK, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(0, 10));
        SendDlgItemMessage(hwndDlg, IDC_CURSOR_BLINK_TRACK, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(12 - (pGlobalData->uCaretBlinkTime / 100)));

        SendDlgItemMessage(hwndDlg, IDC_CURSOR_WIDTH_TRACK, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(0, 19));
        SendDlgItemMessage(hwndDlg, IDC_CURSOR_WIDTH_TRACK, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(pGlobalData->uCaretWidth - 1));

        /* Start the blink timer */
        SetTimer(hwndDlg, ID_BLINK_TIMER, pGlobalData->uCaretBlinkTime, NULL);
        return TRUE;

    case WM_COMMAND:
        switch (LOWORD(wParam))
        {
        case IDC_CONTRAST_BOX:
            pGlobalData->highContrast.dwFlags ^= HCF_HIGHCONTRASTON;
            PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
            break;

        case IDC_CONTRAST_BUTTON:
            if (DialogBoxParam(hApplet,
                               MAKEINTRESOURCE(IDD_CONTRASTOPTIONS),
                               hwndDlg,
                               (DLGPROC)HighContrastDlgProc,
                               (LPARAM)pGlobalData))
                PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
            break;

        default:
            break;
        }
        break;

    case WM_HSCROLL:
        switch (GetWindowLongPtr((HWND) lParam, GWL_ID))
        {
        case IDC_CURSOR_BLINK_TRACK:
            i = SendDlgItemMessage(hwndDlg, IDC_CURSOR_BLINK_TRACK, TBM_GETPOS, 0, 0);
            pGlobalData->uCaretBlinkTime = (12 - (UINT)i) * 100;
            KillTimer(hwndDlg, ID_BLINK_TIMER);
            SetTimer(hwndDlg, ID_BLINK_TIMER, pGlobalData->uCaretBlinkTime, NULL);
            PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
            break;

        case IDC_CURSOR_WIDTH_TRACK:
            i = SendDlgItemMessage(hwndDlg, IDC_CURSOR_WIDTH_TRACK, TBM_GETPOS, 0, 0);
            pGlobalData->uCaretWidth = (UINT)i + 1;
            pGlobalData->rcCaret.right = pGlobalData->rcCaret.left + pGlobalData->uCaretWidth;
            if (pGlobalData->fShowCaret)
            {
                HDC hDC = GetDC(hwndDlg);
                HBRUSH hBrush = GetSysColorBrush(COLOR_BTNTEXT);
                FillRect(hDC, &pGlobalData->rcCaret, hBrush);
                DeleteObject(hBrush);
                ReleaseDC(hwndDlg, hDC);
            }
            else
            {
                InvalidateRect(hwndDlg, &pGlobalData->rcOldCaret, TRUE);
            }
            PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
            break;
        }
        break;

    case WM_TIMER:
        if (wParam == ID_BLINK_TIMER)
        {
            if (pGlobalData->fShowCaret)
            {
                HDC hDC = GetDC(hwndDlg);
                HBRUSH hBrush = GetSysColorBrush(COLOR_BTNTEXT);
                FillRect(hDC, &pGlobalData->rcCaret, hBrush);
                DeleteObject(hBrush);
                ReleaseDC(hwndDlg, hDC);
            }
            else
            {
                InvalidateRect(hwndDlg, &pGlobalData->rcOldCaret, TRUE);
            }

            pGlobalData->fShowCaret = !pGlobalData->fShowCaret;
        }
        break;

    case WM_NOTIFY:
        lppsn = (LPPSHNOTIFY)lParam;
        if (lppsn->hdr.code == PSN_APPLY)
        {
            SetCaretBlinkTime(pGlobalData->uCaretBlinkTime);
            SystemParametersInfo(SPI_SETCARETWIDTH,
                                 0,
                                 IntToPtr(pGlobalData->uCaretWidth),
                                 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE /*0*/);
            SystemParametersInfo(SPI_SETHIGHCONTRAST,
                                 sizeof(HIGHCONTRAST),
                                 &pGlobalData->highContrast,
                                 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE /*0*/);
            return TRUE;
        }
        break;

    case WM_DESTROY:
        KillTimer(hwndDlg, ID_BLINK_TIMER);
        break;
    }

    return FALSE;
}