Dylan Smith : richedit: Use the DefWindowProc to implement WM_SETREDRAW.
Alexandre Julliard
julliard at winehq.org
Mon Oct 20 08:00:21 CDT 2008
Module: wine
Branch: master
Commit: c70f6a3933bc19b009f42f04164f4bbe0f6531b3
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c70f6a3933bc19b009f42f04164f4bbe0f6531b3
Author: Dylan Smith <dylan.ah.smith at gmail.com>
Date: Sun Oct 19 04:43:17 2008 -0400
richedit: Use the DefWindowProc to implement WM_SETREDRAW.
---
dlls/riched20/editor.c | 24 +++++++-----------------
dlls/riched20/editstr.h | 1 -
dlls/riched20/paint.c | 30 ++++++++++--------------------
dlls/riched20/tests/editor.c | 2 +-
dlls/riched20/wrap.c | 39 ++++++++++++++++++++-------------------
5 files changed, 38 insertions(+), 58 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 8caa1f8..792f05f 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -2229,7 +2229,6 @@ ME_TextEditor *ME_MakeEditor(HWND hWnd) {
ed->nParagraphs = 1;
ed->nLastSelStart = ed->nLastSelEnd = 0;
ed->pLastSelStartPara = ed->pLastSelEndPara = ME_FindItemFwd(ed->pBuffer->pFirst, diParagraph);
- ed->bRedraw = TRUE;
ed->bWordWrap = (GetWindowLongW(hWnd, GWL_STYLE) & (WS_HSCROLL|ES_AUTOHSCROLL)) ? FALSE : TRUE;
ed->bHideSelection = FALSE;
ed->nInvalidOfs = -1;
@@ -2808,11 +2807,8 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
editor->rgbBackColor = lParam;
editor->hbrBackground = CreateSolidBrush(editor->rgbBackColor);
}
- if (editor->bRedraw)
- {
- InvalidateRect(hWnd, NULL, TRUE);
- UpdateWindow(hWnd);
- }
+ InvalidateRect(hWnd, NULL, TRUE);
+ UpdateWindow(hWnd);
return lColor;
}
case EM_GETMODIFY:
@@ -3604,7 +3600,6 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
goto do_default;
break;
case WM_PAINT:
- if (editor->bRedraw)
{
HDC hDC;
PAINTSTRUCT ps;
@@ -3627,14 +3622,11 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
return 0;
case WM_ERASEBKGND:
{
- if (editor->bRedraw)
+ HDC hDC = (HDC)wParam;
+ RECT rc;
+ if (GetUpdateRect(hWnd,&rc,TRUE))
{
- HDC hDC = (HDC)wParam;
- RECT rc;
- if (GetUpdateRect(hWnd,&rc,TRUE))
- {
- FillRect(hDC, &rc, editor->hbrBackground);
- }
+ FillRect(hDC, &rc, editor->hbrBackground);
}
return 1;
}
@@ -3953,9 +3945,7 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
ME_SendRequestResize(editor, TRUE);
return 0;
case WM_SETREDRAW:
- if ((editor->bRedraw = wParam))
- ME_RewrapRepaint(editor);
- return 0;
+ return DefWindowProcW(hWnd, msg, wParam, lParam);
case WM_SIZE:
{
GetClientRect(hWnd, &editor->rcFormat);
diff --git a/dlls/riched20/editstr.h b/dlls/riched20/editstr.h
index 7299ab3..248cc02 100644
--- a/dlls/riched20/editstr.h
+++ b/dlls/riched20/editstr.h
@@ -351,7 +351,6 @@ typedef struct tagME_TextEditor
ME_FontCacheItem pFontCache[HFONT_CACHE_SIZE];
int nZoomNumerator, nZoomDenominator;
RECT rcFormat;
- BOOL bRedraw;
BOOL bWordWrap;
int nInvalidOfs;
int nTextLimit;
diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c
index 9786af8..40761db 100644
--- a/dlls/riched20/paint.c
+++ b/dlls/riched20/paint.c
@@ -175,8 +175,7 @@ void ME_UpdateRepaint(ME_TextEditor *editor)
ME_SendOldNotify(editor, EN_CHANGE);
editor->nEventMask |= ENM_CHANGE;
}
- if (editor->bRedraw)
- ME_Repaint(editor);
+ ME_Repaint(editor);
ME_SendSelChange(editor);
}
@@ -189,10 +188,7 @@ ME_RewrapRepaint(ME_TextEditor *editor)
ME_MarkAllForWrapping(editor);
ME_WrapMarkedParagraphs(editor);
ME_UpdateScrollBar(editor);
- if (editor->bRedraw)
- {
- ME_Repaint(editor);
- }
+ ME_Repaint(editor);
}
int ME_twips2pointsX(ME_Context *c, int x)
@@ -1076,17 +1072,14 @@ void ME_Scroll(ME_TextEditor *editor, int value, int type)
si.nPos = 0;
}
- nNewPos = SetScrollInfo(editor->hWnd, SB_VERT, &si, editor->bRedraw);
+ nNewPos = SetScrollInfo(editor->hWnd, SB_VERT, &si, TRUE);
editor->vert_si.nPos = nNewPos;
nActualScroll = nOrigPos - nNewPos;
- if (editor->bRedraw)
- {
- if (abs(nActualScroll) > editor->sizeWindow.cy)
- InvalidateRect(editor->hWnd, NULL, TRUE);
- else
- ScrollWindowEx(editor->hWnd, 0, nActualScroll, NULL, NULL, NULL, NULL, SW_INVALIDATE);
- ME_Repaint(editor);
- }
+ if (abs(nActualScroll) > editor->sizeWindow.cy)
+ InvalidateRect(editor->hWnd, NULL, TRUE);
+ else
+ ScrollWindowEx(editor->hWnd, 0, nActualScroll, NULL, NULL, NULL, NULL, SW_INVALIDATE);
+ ME_Repaint(editor);
hWnd = editor->hWnd;
winStyle = GetWindowLongW(hWnd, GWL_STYLE);
@@ -1095,7 +1088,6 @@ void ME_Scroll(ME_TextEditor *editor, int value, int type)
|| (winStyle & ES_DISABLENOSCROLL);
if (bScrollBarIsVisible != bScrollBarWillBeVisible)
{
- /* FIXME: ShowScrollBar will redraw the scrollbar when editor->bRedraw is FALSE */
ShowScrollBar(hWnd, SB_VERT, bScrollBarWillBeVisible);
}
ME_UpdateScrollBar(editor);
@@ -1129,7 +1121,6 @@ void ME_UpdateScrollBar(ME_TextEditor *editor)
if (bScrollBarWasVisible != bScrollBarWillBeVisible)
{
- /* FIXME: ShowScrollBar will redraw the scrollbar when editor->bRedraw is FALSE */
ShowScrollBar(hWnd, SB_VERT, bScrollBarWillBeVisible);
ME_MarkAllForWrapping(editor);
ME_WrapMarkedParagraphs(editor);
@@ -1148,14 +1139,13 @@ void ME_UpdateScrollBar(ME_TextEditor *editor)
editor->vert_si.nPage = si.nPage;
if (bScrollBarWillBeVisible)
{
- SetScrollInfo(hWnd, SB_VERT, &si, editor->bRedraw);
+ SetScrollInfo(hWnd, SB_VERT, &si, TRUE);
}
else
{
if (bScrollBarWasVisible && !(si.fMask & SIF_DISABLENOSCROLL))
{
- SetScrollInfo(hWnd, SB_VERT, &si, editor->bRedraw);
- /* FIXME: ShowScrollBar will redraw the scrollbar when editor->bRedraw is FALSE */
+ SetScrollInfo(hWnd, SB_VERT, &si, TRUE);
ShowScrollBar(hWnd, SB_VERT, FALSE);
ME_ScrollAbs(editor, 0);
}
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index c977257..e3482ec 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -5189,7 +5189,7 @@ static void test_eventMask(void)
ok(IsWindowVisible(eventMaskEditHwnd), "Window should be visible.\n");
SendMessage(eventMaskEditHwnd, WM_SETREDRAW, FALSE, 0);
/* redraw is disabled by making the window invisible. */
- todo_wine ok(!IsWindowVisible(eventMaskEditHwnd), "Window shouldn't be visible.\n");
+ ok(!IsWindowVisible(eventMaskEditHwnd), "Window shouldn't be visible.\n");
queriedEventMask = 0; /* initialize to something other than we expect */
SendMessage(eventMaskEditHwnd, EM_REPLACESEL, 0, (LPARAM) text);
ok(queriedEventMask == (eventMask & ~ENM_CHANGE),
diff --git a/dlls/riched20/wrap.c b/dlls/riched20/wrap.c
index 53f0bfb..3ffe09a 100644
--- a/dlls/riched20/wrap.c
+++ b/dlls/riched20/wrap.c
@@ -735,30 +735,31 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) {
return bModified;
}
-void ME_InvalidateMarkedParagraphs(ME_TextEditor *editor) {
+void ME_InvalidateMarkedParagraphs(ME_TextEditor *editor)
+{
ME_Context c;
+ RECT rc;
+ int ofs;
+ ME_DisplayItem *item;
ME_InitContext(&c, editor, GetDC(editor->hWnd));
- if (editor->bRedraw)
- {
- RECT rc = c.rcView;
- int ofs = ME_GetYScrollPos(editor);
-
- ME_DisplayItem *item = editor->pBuffer->pFirst;
- while(item != editor->pBuffer->pLast) {
- if (item->member.para.nFlags & MEPF_REPAINT) {
- rc.top = item->member.para.pt.y - ofs;
- rc.bottom = item->member.para.pt.y + item->member.para.nHeight - ofs;
- InvalidateRect(editor->hWnd, &rc, TRUE);
- }
- item = item->member.para.next_para;
- }
- if (editor->nTotalLength < editor->nLastTotalLength)
- {
- rc.top = editor->nTotalLength - ofs;
- rc.bottom = editor->nLastTotalLength - ofs;
+ rc = c.rcView;
+ ofs = ME_GetYScrollPos(editor);
+
+ item = editor->pBuffer->pFirst;
+ while(item != editor->pBuffer->pLast) {
+ if (item->member.para.nFlags & MEPF_REPAINT) {
+ rc.top = item->member.para.pt.y - ofs;
+ rc.bottom = item->member.para.pt.y + item->member.para.nHeight - ofs;
InvalidateRect(editor->hWnd, &rc, TRUE);
}
+ item = item->member.para.next_para;
+ }
+ if (editor->nTotalLength < editor->nLastTotalLength)
+ {
+ rc.top = editor->nTotalLength - ofs;
+ rc.bottom = editor->nLastTotalLength - ofs;
+ InvalidateRect(editor->hWnd, &rc, TRUE);
}
ME_DestroyContext(&c, editor->hWnd);
}
More information about the wine-cvs
mailing list