Commit c70f6a39 authored by Dylan Smith's avatar Dylan Smith Committed by Alexandre Julliard

richedit: Use the DefWindowProc to implement WM_SETREDRAW.

parent ae339427
......@@ -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);
......
......@@ -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;
......
......@@ -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);
}
......
......@@ -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),
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment