Commit 0549b900 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

richedit: Simplified handling of background brush while painting.

parent 2602a39b
......@@ -1284,7 +1284,8 @@ void ME_DestroyEditor(ME_TextEditor *editor)
if (editor->pFontCache[i].hFont)
DeleteObject(editor->pFontCache[i].hFont);
}
DeleteObject(editor->hbrBackground);
if (editor->rgbBackColor != -1)
DeleteObject(editor->hbrBackground);
if(editor->lpOleCallback)
IUnknown_Release(editor->lpOleCallback);
......@@ -1732,9 +1733,13 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
}
case EM_SETBKGNDCOLOR:
{
LRESULT lColor = ME_GetBackColor(editor);
if (editor->rgbBackColor != -1)
LRESULT lColor;
if (editor->rgbBackColor != -1) {
DeleteObject(editor->hbrBackground);
lColor = editor->rgbBackColor;
}
else lColor = GetSysColor(COLOR_WINDOW);
if (wParam)
{
editor->rgbBackColor = -1;
......
......@@ -239,7 +239,6 @@ void ME_RewrapRepaint(ME_TextEditor *editor);
void ME_UpdateRepaint(ME_TextEditor *editor);
void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph);
void ME_EnsureVisible(ME_TextEditor *editor, ME_DisplayItem *pRun);
COLORREF ME_GetBackColor(const ME_TextEditor *editor);
void ME_InvalidateSelection(ME_TextEditor *editor);
void ME_QueueInvalidateFromCursor(ME_TextEditor *editor, int nCursor);
BOOL ME_SetZoom(ME_TextEditor *editor, int numerator, int denominator);
......
......@@ -146,13 +146,12 @@ static void ME_DrawTextWithStyle(ME_Context *c, int x, int y, LPCWSTR szText, in
ME_Style *s, int *width, int nSelFrom, int nSelTo, int ymin, int cy) {
HDC hDC = c->hDC;
HGDIOBJ hOldFont;
COLORREF rgbOld, rgbBack;
COLORREF rgbOld;
int yOffset = 0, yTwipsOffset = 0;
SIZE sz;
COLORREF rgb;
hOldFont = ME_SelectStyleFont(c->editor, hDC, s);
rgbBack = ME_GetBackColor(c->editor);
if ((s->fmt.dwMask & CFM_LINK) && (s->fmt.dwEffects & CFE_LINK))
rgb = RGB(0,0,255);
else if ((s->fmt.dwMask & CFM_COLOR) && (s->fmt.dwEffects & CFE_AUTOCOLOR))
......@@ -309,17 +308,6 @@ static void ME_DrawRun(ME_Context *c, int x, int y, ME_DisplayItem *rundi, ME_Pa
}
}
COLORREF ME_GetBackColor(const ME_TextEditor *editor)
{
/* Looks like I was seriously confused
return GetSysColor((GetWindowLong(editor->hWnd, GWL_STYLE) & ES_READONLY) ? COLOR_3DFACE: COLOR_WINDOW);
*/
if (editor->rgbBackColor == -1)
return GetSysColor(COLOR_WINDOW);
else
return editor->rgbBackColor;
}
void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph) {
int align = SetTextAlign(c->hDC, TA_BASELINE);
ME_DisplayItem *p;
......@@ -350,22 +338,19 @@ void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph) {
rcPara.bottom = y+p->member.row.nHeight;
visible = RectVisible(c->hDC, &rcPara);
if (visible) {
HBRUSH hbr;
hbr = CreateSolidBrush(ME_GetBackColor(c->editor));
/* left margin */
rc.left = c->rcView.left;
rc.right = c->rcView.left+nMargWidth;
rc.top = y;
rc.bottom = y+p->member.row.nHeight;
FillRect(c->hDC, &rc, hbr/* c->hbrMargin */);
FillRect(c->hDC, &rc, c->editor->hbrBackground);
/* right margin */
rc.left = xe;
rc.right = c->rcView.right;
FillRect(c->hDC, &rc, hbr/* c->hbrMargin */);
FillRect(c->hDC, &rc, c->editor->hbrBackground);
rc.left = c->rcView.left+nMargWidth;
rc.right = xe;
FillRect(c->hDC, &rc, hbr);
DeleteObject(hbr);
FillRect(c->hDC, &rc, c->editor->hbrBackground);
}
if (me_debug)
{
......
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