richedit: Simplified handling of background brush while painting.

This commit is contained in:
Eric Pouech 2008-01-01 22:04:10 +01:00 committed by Alexandre Julliard
parent 2602a39bd9
commit 0549b9009a
3 changed files with 12 additions and 23 deletions

View File

@ -1284,7 +1284,8 @@ void ME_DestroyEditor(ME_TextEditor *editor)
if (editor->pFontCache[i].hFont) if (editor->pFontCache[i].hFont)
DeleteObject(editor->pFontCache[i].hFont); DeleteObject(editor->pFontCache[i].hFont);
} }
DeleteObject(editor->hbrBackground); if (editor->rgbBackColor != -1)
DeleteObject(editor->hbrBackground);
if(editor->lpOleCallback) if(editor->lpOleCallback)
IUnknown_Release(editor->lpOleCallback); IUnknown_Release(editor->lpOleCallback);
@ -1732,9 +1733,13 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
} }
case EM_SETBKGNDCOLOR: case EM_SETBKGNDCOLOR:
{ {
LRESULT lColor = ME_GetBackColor(editor); LRESULT lColor;
if (editor->rgbBackColor != -1) if (editor->rgbBackColor != -1) {
DeleteObject(editor->hbrBackground); DeleteObject(editor->hbrBackground);
lColor = editor->rgbBackColor;
}
else lColor = GetSysColor(COLOR_WINDOW);
if (wParam) if (wParam)
{ {
editor->rgbBackColor = -1; editor->rgbBackColor = -1;

View File

@ -239,7 +239,6 @@ void ME_RewrapRepaint(ME_TextEditor *editor);
void ME_UpdateRepaint(ME_TextEditor *editor); void ME_UpdateRepaint(ME_TextEditor *editor);
void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph); void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph);
void ME_EnsureVisible(ME_TextEditor *editor, ME_DisplayItem *pRun); void ME_EnsureVisible(ME_TextEditor *editor, ME_DisplayItem *pRun);
COLORREF ME_GetBackColor(const ME_TextEditor *editor);
void ME_InvalidateSelection(ME_TextEditor *editor); void ME_InvalidateSelection(ME_TextEditor *editor);
void ME_QueueInvalidateFromCursor(ME_TextEditor *editor, int nCursor); void ME_QueueInvalidateFromCursor(ME_TextEditor *editor, int nCursor);
BOOL ME_SetZoom(ME_TextEditor *editor, int numerator, int denominator); BOOL ME_SetZoom(ME_TextEditor *editor, int numerator, int denominator);

View File

@ -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) { ME_Style *s, int *width, int nSelFrom, int nSelTo, int ymin, int cy) {
HDC hDC = c->hDC; HDC hDC = c->hDC;
HGDIOBJ hOldFont; HGDIOBJ hOldFont;
COLORREF rgbOld, rgbBack; COLORREF rgbOld;
int yOffset = 0, yTwipsOffset = 0; int yOffset = 0, yTwipsOffset = 0;
SIZE sz; SIZE sz;
COLORREF rgb; COLORREF rgb;
hOldFont = ME_SelectStyleFont(c->editor, hDC, s); hOldFont = ME_SelectStyleFont(c->editor, hDC, s);
rgbBack = ME_GetBackColor(c->editor);
if ((s->fmt.dwMask & CFM_LINK) && (s->fmt.dwEffects & CFE_LINK)) if ((s->fmt.dwMask & CFM_LINK) && (s->fmt.dwEffects & CFE_LINK))
rgb = RGB(0,0,255); rgb = RGB(0,0,255);
else if ((s->fmt.dwMask & CFM_COLOR) && (s->fmt.dwEffects & CFE_AUTOCOLOR)) 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) { void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph) {
int align = SetTextAlign(c->hDC, TA_BASELINE); int align = SetTextAlign(c->hDC, TA_BASELINE);
ME_DisplayItem *p; ME_DisplayItem *p;
@ -350,22 +338,19 @@ void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph) {
rcPara.bottom = y+p->member.row.nHeight; rcPara.bottom = y+p->member.row.nHeight;
visible = RectVisible(c->hDC, &rcPara); visible = RectVisible(c->hDC, &rcPara);
if (visible) { if (visible) {
HBRUSH hbr;
hbr = CreateSolidBrush(ME_GetBackColor(c->editor));
/* left margin */ /* left margin */
rc.left = c->rcView.left; rc.left = c->rcView.left;
rc.right = c->rcView.left+nMargWidth; rc.right = c->rcView.left+nMargWidth;
rc.top = y; rc.top = y;
rc.bottom = y+p->member.row.nHeight; rc.bottom = y+p->member.row.nHeight;
FillRect(c->hDC, &rc, hbr/* c->hbrMargin */); FillRect(c->hDC, &rc, c->editor->hbrBackground);
/* right margin */ /* right margin */
rc.left = xe; rc.left = xe;
rc.right = c->rcView.right; 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.left = c->rcView.left+nMargWidth;
rc.right = xe; rc.right = xe;
FillRect(c->hDC, &rc, hbr); FillRect(c->hDC, &rc, c->editor->hbrBackground);
DeleteObject(hbr);
} }
if (me_debug) if (me_debug)
{ {