- Timestamp:
- Nov 12, 1999, 6:16:37 PM (26 years ago)
- Location:
- trunk/src/user32
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/edit.cpp
r1705 r1717 1 /* $Id: edit.cpp,v 1.1 2 1999-11-11 17:13:45cbratschi Exp $ */1 /* $Id: edit.cpp,v 1.13 1999-11-12 17:16:36 cbratschi Exp $ */ 2 2 /* 3 3 * Edit control … … 7 7 * Copyright Frans van Dorsselaer, 1996, 1997 8 8 * 9 * Copyright 1999 Christoph Bratschi (ported from WINE)9 * Copyright 1999 Christoph Bratschi 10 10 * 11 11 * WINE version: 990923 … … 15 15 * please read EDIT.TODO (and update it when you change things) 16 16 */ 17 18 /* CB: todo 19 - EN_UPDATE: send before update 20 - EN_CHANGE: send after update -> WM_PAINT isn't the right place 21 - EN_HSCROLL/EN_VSCROLL: send before update 22 - still problems with caret 23 - WS_BORDER -> bug in Win32BaseWindow::SetWindowLong 24 */ 17 25 18 26 #include <os2win.h> … … 143 151 static void EDIT_MovePageUp_ML(HWND hwnd, EDITSTATE *es, BOOL extend); 144 152 static void EDIT_MoveUp_ML(HWND hwnd, EDITSTATE *es, BOOL extend); 153 static VOID EDIT_UpdateScrollBars(HWND hwnd,EDITSTATE *es,BOOL updateHorz,BOOL updateVert); 145 154 /* 146 155 * Helper functions valid for both single line _and_ multi line controls … … 166 175 static void EDIT_UnlockBuffer(HWND hwnd, EDITSTATE *es, BOOL force); 167 176 static INT EDIT_WordBreakProc(LPSTR s, INT index, INT count, INT action); 177 static VOID EDIT_Draw(HWND hwnd,EDITSTATE *es,HDC hdc); 178 static VOID EDIT_Refresh(HWND hwnd,EDITSTATE *es); 179 168 180 /* 169 181 * EM_XXX message handlers … … 331 343 if ((es->style & ES_MULTILINE) && lParam) { 332 344 EDIT_SetRectNP(hwnd, es, (LPRECT)lParam); 333 InvalidateRect(hwnd, NULL, TRUE);345 EDIT_Refresh(hwnd,es); 334 346 } 335 347 break; … … 597 609 //DPRINTF_EDIT_MSG32("WM_ENABLE"); 598 610 es->bEnableState = (BOOL)wParam; 599 InvalidateRect(hwnd, NULL, TRUE);611 EDIT_Refresh(hwnd,es); 600 612 break; 601 613 … … 830 842 SelectObject(dc, old_font); 831 843 ReleaseDC(hwnd, dc); 844 EDIT_UpdateScrollBars(hwnd,es,TRUE,TRUE); 832 845 } 833 846 … … 1634 1647 if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL)) 1635 1648 EDIT_BuildLineDefs_ML(hwnd, es); 1649 EDIT_UpdateScrollBars(hwnd,es,TRUE,TRUE); 1636 1650 } 1637 1651 … … 1996 2010 } 1997 2011 2012 static VOID EDIT_UpdateScrollBars(HWND hwnd,EDITSTATE *es,BOOL updateHorz,BOOL updateVert) 2013 { 2014 if (updateHorz && (es->style & WS_HSCROLL) && !(es->flags & EF_HSCROLL_TRACK)) 2015 { 2016 SCROLLINFO si; 2017 INT fw = es->format_rect.right - es->format_rect.left; 2018 2019 si.cbSize = sizeof(SCROLLINFO); 2020 si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE | SIF_DISABLENOSCROLL; 2021 si.nMin = 0; 2022 si.nMax = es->text_width + fw - 1; 2023 si.nPage = fw; 2024 si.nPos = es->x_offset; 2025 SetScrollInfo(hwnd, SB_HORZ, &si, TRUE); 2026 } 2027 2028 if (updateVert && (es->style & WS_VSCROLL) && !(es->flags & EF_VSCROLL_TRACK)) 2029 { 2030 INT vlc = (es->format_rect.bottom-es->format_rect.top)/es->line_height; 2031 SCROLLINFO si; 2032 2033 si.cbSize = sizeof(SCROLLINFO); 2034 si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE | SIF_DISABLENOSCROLL; 2035 si.nMin = 0; 2036 si.nMax = es->line_count + vlc - 2; 2037 si.nPage = vlc; 2038 si.nPos = es->y_offset; 2039 SetScrollInfo(hwnd, SB_VERT, &si, TRUE); 2040 } 2041 } 2042 1998 2043 1999 2044 /********************************************************************* … … 2031 2076 es->y_offset = nyoff; 2032 2077 es->x_offset += dx; 2078 EDIT_UpdateScrollBars(hwnd,es,dx,dy); 2033 2079 } 2034 2080 if (dx && !(es->flags & EF_HSCROLL_TRACK)) … … 2204 2250 2205 2251 /* FIXME: really inefficient */ 2206 InvalidateRect(hwnd, NULL, TRUE);2252 EDIT_Refresh(hwnd,es); 2207 2253 } 2208 2254 … … 2292 2338 x = SLOWORD(EDIT_EM_PosFromChar(hwnd, es, es->selection_end, FALSE)); 2293 2339 format_width = es->format_rect.right - es->format_rect.left; 2294 if (x < es->format_rect.left) { 2340 if (x < es->format_rect.left) 2341 { 2295 2342 goal = es->format_rect.left + format_width / HSCROLL_FRACTION; 2296 2343 do { … … 2299 2346 } while ((x < goal) && es->x_offset); 2300 2347 /* FIXME: use ScrollWindow() somehow to improve performance */ 2301 InvalidateRect(hwnd, NULL, TRUE); 2302 } else if (x > es->format_rect.right) { 2348 EDIT_Refresh(hwnd,es); 2349 EDIT_UpdateScrollBars(hwnd,es,TRUE,FALSE); 2350 } else if (x > es->format_rect.right) 2351 { 2303 2352 INT x_last; 2304 2353 INT len = lstrlenA(es->text); … … 2310 2359 } while ((x > goal) && (x_last > es->format_rect.right)); 2311 2360 /* FIXME: use ScrollWindow() somehow to improve performance */ 2312 InvalidateRect(hwnd, NULL, TRUE); 2361 EDIT_Refresh(hwnd,es); 2362 EDIT_UpdateScrollBars(hwnd,es,TRUE,FALSE); 2313 2363 } 2314 2364 } … … 2353 2403 es->flags &= ~EF_UPDATE; 2354 2404 EDIT_BuildLineDefs_ML(hwnd, es); 2355 InvalidateRect(hwnd, NULL, TRUE);2405 EDIT_Refresh(hwnd,es); 2356 2406 EDIT_EM_ScrollCaret(hwnd, es); 2407 EDIT_UpdateScrollBars(hwnd,es,TRUE,TRUE); 2357 2408 } 2358 2409 … … 2431 2482 es->style &= ~ES_PASSWORD; 2432 2483 } 2433 InvalidateRect(hwnd, NULL, TRUE);2484 EDIT_Refresh(hwnd,es); 2434 2485 } 2435 2486 … … 2470 2521 ORDER_UINT(start, old_start); 2471 2522 ORDER_UINT(old_start, old_end); 2472 if (es->flags & EF_FOCUSED) HideCaret(hwnd);2473 2523 if (end != old_start) 2474 2524 { … … 2492 2542 } 2493 2543 else EDIT_InvalidateText(hwnd, es, start, old_end); 2494 if (es->flags & EF_FOCUSED) ShowCaret(hwnd);2495 2544 } 2496 2545 … … 2531 2580 if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL)) { 2532 2581 EDIT_BuildLineDefs_ML(hwnd, es); 2533 InvalidateRect(hwnd, NULL, TRUE);2582 EDIT_Refresh(hwnd,es); 2534 2583 } 2535 2584 } … … 3326 3375 } 3327 3376 3377 static VOID EDIT_Draw(HWND hwnd,EDITSTATE *es,HDC hdc,BOOL eraseBkGnd) 3378 { 3379 INT i; 3380 HFONT old_font = 0; 3381 RECT rc; 3382 RECT rcLine; 3383 RECT rcRgn; 3384 BOOL rev = es->bEnableState && ((es->flags & EF_FOCUSED) || (es->style & ES_NOHIDESEL)); 3385 3386 if (es->flags & EF_UPDATE) EDIT_NOTIFY_PARENT(hwnd, EN_UPDATE); 3387 3388 if (es->flags & EF_FOCUSED) HideCaret(hwnd); 3389 3390 if (eraseBkGnd) 3391 { 3392 HBRUSH brush; 3393 3394 if (!es->bEnableState || (es->style & ES_READONLY)) 3395 brush = (HBRUSH)EDIT_SEND_CTLCOLORSTATIC(hwnd, hdc); 3396 else 3397 brush = (HBRUSH)EDIT_SEND_CTLCOLOR(hwnd, hdc); 3398 3399 if (!brush) 3400 brush = (HBRUSH)GetStockObject(WHITE_BRUSH); 3401 3402 GetClientRect(hwnd, &rc); 3403 /* 3404 * FIXME: specs say that we should UnrealizeObject() the brush, 3405 * but the specs of UnrealizeObject() say that we shouldn't 3406 * unrealize a stock object. The default brush that 3407 * DefWndProc() returns is ... a stock object. 3408 */ 3409 FillRect(hdc, &rc, brush); 3410 } 3411 3412 if(es->style & WS_BORDER) 3413 { 3414 GetClientRect(hwnd, &rc); 3415 if(es->style & ES_MULTILINE) 3416 { 3417 if(es->style & WS_HSCROLL) rc.bottom++; 3418 if(es->style & WS_VSCROLL) rc.right++; 3419 } 3420 Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom); 3421 } 3422 3423 IntersectClipRect(hdc, es->format_rect.left, 3424 es->format_rect.top, 3425 es->format_rect.right, 3426 es->format_rect.bottom); 3427 if (es->style & ES_MULTILINE) 3428 { 3429 GetClientRect(hwnd, &rc); 3430 IntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom); 3431 } 3432 if (es->font) old_font = SelectObject(hdc, es->font); 3433 if (!es->bEnableState || (es->style & ES_READONLY)) 3434 EDIT_SEND_CTLCOLORSTATIC(hwnd, hdc); 3435 else 3436 EDIT_SEND_CTLCOLOR(hwnd, hdc); 3437 if (!es->bEnableState) 3438 SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT)); 3439 GetClipBox(hdc, &rcRgn); 3440 if (es->style & ES_MULTILINE) 3441 { 3442 INT vlc = (es->format_rect.bottom - es->format_rect.top) / es->line_height; 3443 3444 for (i = es->y_offset ; i <= MIN(es->y_offset + vlc, es->y_offset + es->line_count - 1) ; i++) 3445 { 3446 EDIT_GetLineRect(hwnd, es, i, 0, -1, &rcLine); 3447 if (IntersectRect(&rc, &rcRgn, &rcLine)) 3448 EDIT_PaintLine(hwnd, es, hdc, i, rev); 3449 } 3450 } else 3451 { 3452 EDIT_GetLineRect(hwnd, es, 0, 0, -1, &rcLine); 3453 if (IntersectRect(&rc, &rcRgn, &rcLine)) 3454 EDIT_PaintLine(hwnd, es, hdc, 0, rev); 3455 } 3456 if (es->font) SelectObject(hdc, old_font); 3457 if (es->flags & EF_FOCUSED) 3458 EDIT_SetCaretPos(hwnd, es, es->selection_end,es->flags & EF_AFTER_WRAP); 3459 3460 if (es->flags & EF_FOCUSED) ShowCaret(hwnd); 3461 3462 //CB: replace 3463 if (es->flags & EF_UPDATE) 3464 { 3465 es->flags &= ~EF_UPDATE; 3466 EDIT_NOTIFY_PARENT(hwnd, EN_CHANGE); 3467 } 3468 } 3469 3470 static VOID EDIT_Refresh(HWND hwnd,EDITSTATE *es) 3471 { 3472 HDC hdc,hdcCompatible; 3473 HBITMAP bitmap,oldbmp; 3474 RECT rect; 3475 3476 //CB: original controls redraws many times, cache drawing 3477 if (es->flags & EF_FOCUSED) HideCaret(hwnd); 3478 GetClientRect(hwnd,&rect); 3479 hdc = GetDC(hwnd); 3480 hdcCompatible = CreateCompatibleDC(hdc); 3481 bitmap = CreateCompatibleBitmap(hdc,rect.right,rect.bottom); 3482 oldbmp = SelectObject(hdcCompatible,bitmap); 3483 EDIT_Draw(hwnd,es,hdcCompatible,TRUE); 3484 SelectClipRgn(hdcCompatible,0); 3485 BitBlt(hdc,0,0,rect.right,rect.bottom,hdcCompatible,0,0,SRCCOPY); 3486 SelectObject(hdcCompatible,oldbmp); 3487 DeleteObject(bitmap); 3488 DeleteDC(hdcCompatible); 3489 ReleaseDC(hwnd,hdc); 3490 if (es->flags & EF_FOCUSED) ShowCaret(hwnd); 3491 } 3492 3328 3493 /********************************************************************* 3329 3494 * … … 3333 3498 static void EDIT_WM_Paint(HWND hwnd, EDITSTATE *es,WPARAM wParam) 3334 3499 { 3335 PAINTSTRUCT ps; 3336 INT i; 3337 HDC dc; 3338 HFONT old_font = 0; 3339 RECT rc; 3340 RECT rcLine; 3341 RECT rcRgn; 3342 BOOL rev = es->bEnableState && 3343 ((es->flags & EF_FOCUSED) || 3344 (es->style & ES_NOHIDESEL)); 3345 3346 if (es->flags & EF_UPDATE) 3347 EDIT_NOTIFY_PARENT(hwnd, EN_UPDATE); 3348 3349 if (!wParam) 3350 dc = BeginPaint(hwnd, &ps); 3351 else 3352 dc = (HDC) wParam; 3353 3354 if(es->style & WS_BORDER) { 3355 GetClientRect(hwnd, &rc); 3356 if(es->style & ES_MULTILINE) { 3357 if(es->style & WS_HSCROLL) rc.bottom++; 3358 if(es->style & WS_VSCROLL) rc.right++; 3359 } 3360 Rectangle(dc, rc.left, rc.top, rc.right, rc.bottom); 3361 } 3362 IntersectClipRect(dc, es->format_rect.left, 3363 es->format_rect.top, 3364 es->format_rect.right, 3365 es->format_rect.bottom); 3366 if (es->style & ES_MULTILINE) { 3367 GetClientRect(hwnd, &rc); 3368 IntersectClipRect(dc, rc.left, rc.top, rc.right, rc.bottom); 3369 } 3370 if (es->font) 3371 old_font = SelectObject(dc, es->font); 3372 if (!es->bEnableState || (es->style & ES_READONLY)) 3373 EDIT_SEND_CTLCOLORSTATIC(hwnd, dc); 3374 else 3375 EDIT_SEND_CTLCOLOR(hwnd, dc); 3376 if (!es->bEnableState) 3377 SetTextColor(dc, GetSysColor(COLOR_GRAYTEXT)); 3378 GetClipBox(dc, &rcRgn); 3379 if (es->style & ES_MULTILINE) { 3380 INT vlc = (es->format_rect.bottom - es->format_rect.top) / es->line_height; 3381 for (i = es->y_offset ; i <= MIN(es->y_offset + vlc, es->y_offset + es->line_count - 1) ; i++) { 3382 EDIT_GetLineRect(hwnd, es, i, 0, -1, &rcLine); 3383 if (IntersectRect(&rc, &rcRgn, &rcLine)) 3384 EDIT_PaintLine(hwnd, es, dc, i, rev); 3385 } 3386 } else { 3387 EDIT_GetLineRect(hwnd, es, 0, 0, -1, &rcLine); 3388 if (IntersectRect(&rc, &rcRgn, &rcLine)) 3389 EDIT_PaintLine(hwnd, es, dc, 0, rev); 3390 } 3391 if (es->font) 3392 SelectObject(dc, old_font); 3393 if (es->flags & EF_FOCUSED) 3394 EDIT_SetCaretPos(hwnd, es, es->selection_end, 3395 es->flags & EF_AFTER_WRAP); 3396 if (!wParam) EndPaint(hwnd, &ps); 3397 if ((es->style & WS_VSCROLL) && !(es->flags & EF_VSCROLL_TRACK)) { 3398 INT vlc = (es->format_rect.bottom - es->format_rect.top) / es->line_height; 3399 SCROLLINFO si; 3400 si.cbSize = sizeof(SCROLLINFO); 3401 si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE | SIF_DISABLENOSCROLL; 3402 si.nMin = 0; 3403 si.nMax = es->line_count + vlc - 2; 3404 si.nPage = vlc; 3405 si.nPos = es->y_offset; 3406 SetScrollInfo(hwnd, SB_VERT, &si, TRUE); 3407 } 3408 if ((es->style & WS_HSCROLL) && !(es->flags & EF_HSCROLL_TRACK)) { 3409 SCROLLINFO si; 3410 INT fw = es->format_rect.right - es->format_rect.left; 3411 si.cbSize = sizeof(SCROLLINFO); 3412 si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE | SIF_DISABLENOSCROLL; 3413 si.nMin = 0; 3414 si.nMax = es->text_width + fw - 1; 3415 si.nPage = fw; 3416 si.nPos = es->x_offset; 3417 SetScrollInfo(hwnd, SB_HORZ, &si, TRUE); 3418 } 3419 3420 if (es->flags & EF_UPDATE) { 3421 es->flags &= ~EF_UPDATE; 3422 EDIT_NOTIFY_PARENT(hwnd, EN_CHANGE); 3423 } 3500 PAINTSTRUCT ps; 3501 HDC hdc; 3502 3503 if (!wParam) hdc = BeginPaint(hwnd, &ps); 3504 else hdc = (HDC) wParam; 3505 3506 EDIT_Draw(hwnd,es,hdc,FALSE); 3507 3508 if (!wParam) EndPaint(hwnd, &ps); 3424 3509 } 3425 3510 … … 3462 3547 EDIT_NOTIFY_PARENT(hwnd, EN_SETFOCUS); 3463 3548 } 3464 3465 3549 3466 3550 /********************************************************************* … … 3505 3589 3506 3590 if (redraw) 3507 InvalidateRect(hwnd, NULL, TRUE);3591 EDIT_Refresh(hwnd,es); 3508 3592 if (es->flags & EF_FOCUSED) { 3509 3593 DestroyCaret(); … … 3547 3631 EDIT_EM_SetSel(hwnd, es, 0, 0, FALSE); 3548 3632 EDIT_EM_ScrollCaret(hwnd, es); 3633 EDIT_UpdateScrollBars(hwnd,es,TRUE,TRUE); 3549 3634 } 3550 3635 … … 3561 3646 SetRect(&rc, 0, 0, width, height); 3562 3647 EDIT_SetRectNP(hwnd, es, &rc); 3563 InvalidateRect(hwnd, NULL, TRUE);3648 EDIT_Refresh(hwnd,es); 3564 3649 } 3565 3650 } -
trunk/src/user32/scroll.cpp
r1693 r1717 1 /* $Id: scroll.cpp,v 1.2 0 1999-11-10 17:11:30cbratschi Exp $ */1 /* $Id: scroll.cpp,v 1.21 1999-11-12 17:16:37 cbratschi Exp $ */ 2 2 /* 3 3 * Scrollbar control … … 701 701 static POINT prevPt; /* Previous mouse position for timer events */ 702 702 static UINT trackThumbPos; /* Thumb position when tracking started. */ 703 static BOOL thumbTrackSent; 703 704 static INT lastClickPos; /* Position in the scroll-bar of the last button-down event. */ 704 705 static INT lastMousePos; /* Position in the scroll-bar of the last mouse event. */ … … 942 943 SCROLL_TrackingVal = infoPtr->CurVal; 943 944 SCROLL_MovingThumb = TRUE; 945 thumbTrackSent = FALSE; 944 946 SCROLL_DrawMovingThumb(hdc, &rect, vertical, arrowSize, thumbSize); 945 947 } else if (msg == WM_LBUTTONUP || msg == WM_CAPTURECHANGED) … … 954 956 trackThumbPos + lastMousePos - lastClickPos ); 955 957 956 if (val != infoPtr->CurVal )958 if (val != infoPtr->CurVal || thumbTrackSent) 957 959 SendMessageA( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, 958 960 MAKEWPARAM( SB_THUMBPOSITION, val ), hwndCtl ); … … 991 993 MAKEWPARAM( SB_THUMBTRACK, SCROLL_TrackingVal), 992 994 hwndCtl ); 995 thumbTrackSent = TRUE; 993 996 } 994 997 }
Note:
See TracChangeset
for help on using the changeset viewer.