[1/2] richedit: Clip painting to formatting rectangle (try 2)
Dylan Smith
dylan.ah.smith at gmail.com
Tue Jan 13 12:32:54 CST 2009
I realized after my patch wasn't accepted that I probably didn't handle
the case were no clip region was retrived by GetClipRgn properly, so I
corrected my patch to handle this case.
I also checked other places GetClipRgn was used in wine code, and used
similar code in winefile as a reference for setting the clip region
properly.
---
dlls/riched20/paint.c | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
-------------- next part --------------
diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c
index b6430e4..d58ea41 100644
--- a/dlls/riched20/paint.c
+++ b/dlls/riched20/paint.c
@@ -29,6 +29,17 @@ void ME_PaintContent(ME_TextEditor *editor, HDC hDC, BOOL bOnlyNew, const RECT *
ME_Context c;
int yoffset;
int ys, ye;
+ HRGN oldRgn, clipRgn;
+
+ oldRgn = CreateRectRgn(0, 0, 0, 0);
+ if (!GetClipRgn(hDC, oldRgn))
+ {
+ DeleteObject(oldRgn);
+ oldRgn = NULL;
+ }
+ clipRgn = CreateRectRgnIndirect(rcUpdate);
+ ExtSelectClipRgn(hDC, clipRgn, RGN_AND);
+ DeleteObject(clipRgn);
editor->nSequence++;
yoffset = ME_GetYScrollPos(editor);
@@ -105,6 +116,10 @@ void ME_PaintContent(ME_TextEditor *editor, HDC hDC, BOOL bOnlyNew, const RECT *
ME_SendRequestResize(editor, FALSE);
editor->nLastTotalLength = editor->nTotalLength;
ME_DestroyContext(&c, NULL);
+
+ SelectClipRgn(hDC, oldRgn);
+ if (oldRgn)
+ DeleteObject(oldRgn);
}
void ME_Repaint(ME_TextEditor *editor)
@@ -1050,7 +1065,8 @@ void ME_Scroll(ME_TextEditor *editor, int value, int type)
if (abs(nActualScroll) > editor->sizeWindow.cy)
InvalidateRect(editor->hWnd, NULL, TRUE);
else
- ScrollWindowEx(editor->hWnd, 0, nActualScroll, NULL, NULL, NULL, NULL, SW_INVALIDATE);
+ ScrollWindowEx(editor->hWnd, 0, nActualScroll, &editor->rcFormat,
+ &editor->rcFormat, NULL, NULL, SW_INVALIDATE);
ME_Repaint(editor);
hWnd = editor->hWnd;
More information about the wine-patches
mailing list