Cache background color brush instead of recreating it at each screen
update.
This commit is contained in:
parent
2d62ba5557
commit
fe2951daaa
|
@ -821,6 +821,7 @@ ME_TextEditor *ME_MakeEditor(HWND hWnd) {
|
||||||
ed->nUDArrowX = -1;
|
ed->nUDArrowX = -1;
|
||||||
ed->nSequence = 0;
|
ed->nSequence = 0;
|
||||||
ed->rgbBackColor = -1;
|
ed->rgbBackColor = -1;
|
||||||
|
ed->hbrBackground = GetSysColorBrush(COLOR_WINDOW);
|
||||||
ed->bCaretAtEnd = FALSE;
|
ed->bCaretAtEnd = FALSE;
|
||||||
ed->nEventMask = 0;
|
ed->nEventMask = 0;
|
||||||
ed->nModifyStep = 0;
|
ed->nModifyStep = 0;
|
||||||
|
@ -926,6 +927,7 @@ 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);
|
||||||
|
|
||||||
FREE_OBJ(editor);
|
FREE_OBJ(editor);
|
||||||
}
|
}
|
||||||
|
@ -1265,10 +1267,18 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
|
||||||
case EM_SETBKGNDCOLOR:
|
case EM_SETBKGNDCOLOR:
|
||||||
{
|
{
|
||||||
LRESULT lColor = ME_GetBackColor(editor);
|
LRESULT lColor = ME_GetBackColor(editor);
|
||||||
|
if (editor->rgbBackColor != -1)
|
||||||
|
DeleteObject(editor->hbrBackground);
|
||||||
if (wParam)
|
if (wParam)
|
||||||
|
{
|
||||||
editor->rgbBackColor = -1;
|
editor->rgbBackColor = -1;
|
||||||
|
editor->hbrBackground = GetSysColorBrush(COLOR_WINDOW);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
editor->rgbBackColor = lParam;
|
editor->rgbBackColor = lParam;
|
||||||
|
editor->hbrBackground = CreateSolidBrush(editor->rgbBackColor);
|
||||||
|
}
|
||||||
if (editor->bRedraw)
|
if (editor->bRedraw)
|
||||||
{
|
{
|
||||||
InvalidateRect(hWnd, NULL, TRUE);
|
InvalidateRect(hWnd, NULL, TRUE);
|
||||||
|
@ -1792,12 +1802,9 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
|
||||||
{
|
{
|
||||||
HDC hDC = (HDC)wParam;
|
HDC hDC = (HDC)wParam;
|
||||||
RECT rc;
|
RECT rc;
|
||||||
COLORREF rgbBG = ME_GetBackColor(editor);
|
|
||||||
if (GetUpdateRect(hWnd,&rc,TRUE))
|
if (GetUpdateRect(hWnd,&rc,TRUE))
|
||||||
{
|
{
|
||||||
HBRUSH hbr = CreateSolidBrush(rgbBG);
|
FillRect(hDC, &rc, editor->hbrBackground);
|
||||||
FillRect(hDC, &rc, hbr);
|
|
||||||
DeleteObject(hbr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -270,6 +270,7 @@ typedef struct tagME_TextEditor
|
||||||
int nSequence;
|
int nSequence;
|
||||||
int nOldSelFrom, nOldSelTo;
|
int nOldSelFrom, nOldSelTo;
|
||||||
COLORREF rgbBackColor;
|
COLORREF rgbBackColor;
|
||||||
|
HBRUSH hbrBackground;
|
||||||
BOOL bCaretAtEnd;
|
BOOL bCaretAtEnd;
|
||||||
int nEventMask;
|
int nEventMask;
|
||||||
int nModifyStep;
|
int nModifyStep;
|
||||||
|
|
|
@ -78,14 +78,11 @@ void ME_PaintContent(ME_TextEditor *editor, HDC hDC, BOOL bOnlyNew, RECT *rcUpda
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ye>ys) {
|
if (ye>ys) {
|
||||||
HBRUSH hbr;
|
|
||||||
hbr = CreateSolidBrush(ME_GetBackColor(c.editor));
|
|
||||||
rc.left = xs;
|
rc.left = xs;
|
||||||
rc.top = ys;
|
rc.top = ys;
|
||||||
rc.right = xe;
|
rc.right = xe;
|
||||||
rc.bottom = ye;
|
rc.bottom = ye;
|
||||||
FillRect(hDC, &rc, hbr);
|
FillRect(hDC, &rc, c.editor->hbrBackground);
|
||||||
DeleteObject(hbr);
|
|
||||||
}
|
}
|
||||||
if (ys == c.pt.y) /* don't overwrite the top bar */
|
if (ys == c.pt.y) /* don't overwrite the top bar */
|
||||||
ys++;
|
ys++;
|
||||||
|
|
Loading…
Reference in New Issue