Signed-off-by: Huw Davies huw@codeweavers.com --- dlls/riched20/editor.c | 18 +++++++++++------- dlls/riched20/paint.c | 27 ++++++++++++--------------- 2 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index b10f719bb0..c4a6902733 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -4983,42 +4983,46 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, { case WM_PAINT: { - HDC hDC; + HDC hdc; RECT rc; PAINTSTRUCT ps; + HBRUSH old_brush;
update_caret(editor); - hDC = BeginPaint(editor->hWnd, &ps); + hdc = BeginPaint(editor->hWnd, &ps); if (!editor->bEmulateVersion10 || (editor->nEventMask & ENM_UPDATE)) ME_SendOldNotify(editor, EN_UPDATE); + old_brush = SelectObject(hdc, editor->hbrBackground); + /* Erase area outside of the formatting rectangle */ if (ps.rcPaint.top < editor->rcFormat.top) { rc = ps.rcPaint; rc.bottom = editor->rcFormat.top; - FillRect(hDC, &rc, editor->hbrBackground); + PatBlt(hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); ps.rcPaint.top = editor->rcFormat.top; } if (ps.rcPaint.bottom > editor->rcFormat.bottom) { rc = ps.rcPaint; rc.top = editor->rcFormat.bottom; - FillRect(hDC, &rc, editor->hbrBackground); + PatBlt(hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); ps.rcPaint.bottom = editor->rcFormat.bottom; } if (ps.rcPaint.left < editor->rcFormat.left) { rc = ps.rcPaint; rc.right = editor->rcFormat.left; - FillRect(hDC, &rc, editor->hbrBackground); + PatBlt(hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); ps.rcPaint.left = editor->rcFormat.left; } if (ps.rcPaint.right > editor->rcFormat.right) { rc = ps.rcPaint; rc.left = editor->rcFormat.right; - FillRect(hDC, &rc, editor->hbrBackground); + PatBlt(hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); ps.rcPaint.right = editor->rcFormat.right; }
- ME_PaintContent(editor, hDC, &ps.rcPaint); + ME_PaintContent(editor, hdc, &ps.rcPaint); + SelectObject(hdc, old_brush); EndPaint(editor->hWnd, &ps); return 0; } diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c index 94fe0516bd..fe27932719 100644 --- a/dlls/riched20/paint.c +++ b/dlls/riched20/paint.c @@ -43,6 +43,7 @@ void ME_PaintContent(ME_TextEditor *editor, HDC hDC, const RECT *rcUpdate)
ME_InitContext(&c, editor, hDC); SetBkMode(hDC, TRANSPARENT); + item = editor->pBuffer->pFirst->next; /* This context point is an offset for the paragraph positions stored * during wrapping. It shouldn't be modified during painting. */ @@ -86,7 +87,7 @@ void ME_PaintContent(ME_TextEditor *editor, HDC hDC, const RECT *rcUpdate) IntersectRect(&rc, &rc, rcUpdate);
if (!IsRectEmpty(&rc)) - FillRect(hDC, &rc, c.editor->hbrBackground); + PatBlt(hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); } if (editor->nTotalLength != editor->nLastTotalLength || editor->nTotalWidth != editor->nLastTotalWidth) @@ -597,7 +598,7 @@ static void ME_DrawParaDecoration(ME_Context* c, ME_Paragraph* para, int y, RECT rc.top = y; bounds->top = ME_twips2pointsY(c, para->fmt.dySpaceBefore); rc.bottom = y + bounds->top + top_border; - FillRect(c->hDC, &rc, c->editor->hbrBackground); + PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); }
if (para->fmt.dwMask & PFM_SPACEAFTER) @@ -607,7 +608,7 @@ static void ME_DrawParaDecoration(ME_Context* c, ME_Paragraph* para, int y, RECT rc.bottom = y + para->nHeight; bounds->bottom = ME_twips2pointsY(c, para->fmt.dySpaceAfter); rc.top = rc.bottom - bounds->bottom - bottom_border; - FillRect(c->hDC, &rc, c->editor->hbrBackground); + PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); }
/* Native richedit doesn't support paragraph borders in v1.0 - 4.1, @@ -646,7 +647,7 @@ static void ME_DrawParaDecoration(ME_Context* c, ME_Paragraph* para, int y, RECT rc.right = rc.left + border_width; rc.top = y + bounds->top; rc.bottom = y + para->nHeight - bounds->bottom; - FillRect(c->hDC, &rc, c->editor->hbrBackground); + PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); MoveToEx(c->hDC, c->pt.x + pen_width + 1, y + bounds->top + DD(4), NULL); LineTo(c->hDC, c->pt.x + pen_width + 1, y + para->nHeight - bounds->bottom - DD(8)); } @@ -661,7 +662,7 @@ static void ME_DrawParaDecoration(ME_Context* c, ME_Paragraph* para, int y, RECT rc.right = rc.left + pen_width; rc.top = y + bounds->top; rc.bottom = y + para->nHeight - bounds->bottom; - FillRect(c->hDC, &rc, c->editor->hbrBackground); + PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); MoveToEx(c->hDC, rightEdge - 1 - pen_width - 1, y + bounds->top + DD(4), NULL); LineTo(c->hDC, rightEdge - 1 - pen_width - 1, y + para->nHeight - bounds->bottom - DD(8)); } @@ -725,9 +726,8 @@ static void ME_DrawTableBorders(ME_Context *c, ME_DisplayItem *paragraph) rc.top = top + width; width = cell->yTextOffset - width; rc.bottom = rc.top + width; - if (width) { - FillRect(c->hDC, &rc, c->editor->hbrBackground); - } + if (width) + PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); } /* Draw cell borders. * The order borders are draw in is left, top, bottom, right in order @@ -966,9 +966,8 @@ static void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph) rc.bottom = y + p->member.row.nHeight; } visible = RectVisible(c->hDC, &rc); - if (visible) { - FillRect(c->hDC, &rc, c->editor->hbrBackground); - } + if (visible) + PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); if (bounds.right) { /* If scrolled to the right past the end of the text, then @@ -977,7 +976,7 @@ static void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph) rcAfterBrdr.left = rc.right + bounds.right; rcAfterBrdr.right = c->rcView.right; if (RectVisible(c->hDC, &rcAfterBrdr)) - FillRect(c->hDC, &rcAfterBrdr, c->editor->hbrBackground); + PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); } if (me_debug) { @@ -1026,9 +1025,7 @@ static void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph) rc.top = c->pt.y + para->pt.y + para->nHeight; rc.bottom = c->pt.y + p->member.cell.pt.y + p->member.cell.nHeight; if (RectVisible(c->hDC, &rc)) - { - FillRect(c->hDC, &rc, c->editor->hbrBackground); - } + PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); break; default: break;
On Mon, Aug 19, 2019 at 09:44:52AM +0100, Huw Davies wrote:
Signed-off-by: Huw Davies huw@codeweavers.com
dlls/riched20/editor.c | 18 +++++++++++------- dlls/riched20/paint.c | 27 ++++++++++++--------------- 2 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c index 94fe0516bd..fe27932719 100644 --- a/dlls/riched20/paint.c +++ b/dlls/riched20/paint.c @@ -977,7 +976,7 @@ static void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph) rcAfterBrdr.left = rc.right + bounds.right; rcAfterBrdr.right = c->rcView.right; if (RectVisible(c->hDC, &rcAfterBrdr))
FillRect(c->hDC, &rcAfterBrdr, c->editor->hbrBackground);
PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); } if (me_debug) {
I've just realised this is using the wrong rect. I'll send in a new version.
Huw.