Eric Pouech : richedit: Simplified handling of background brush while painting.

Alexandre Julliard julliard at winehq.org
Wed Jan 2 07:34:51 CST 2008


Module: wine
Branch: master
Commit: 0549b9009a5d307835af1ea15ed833fc440064f5
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0549b9009a5d307835af1ea15ed833fc440064f5

Author: Eric Pouech <eric.pouech at orange.fr>
Date:   Tue Jan  1 22:04:10 2008 +0100

richedit: Simplified handling of background brush while painting.

---

 dlls/riched20/editor.c |   11 ++++++++---
 dlls/riched20/editor.h |    1 -
 dlls/riched20/paint.c  |   23 ++++-------------------
 3 files changed, 12 insertions(+), 23 deletions(-)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 1589173..518f86b 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -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;
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index 8757e45..5cb9b7e 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -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);
diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c
index 84ab695..b21e5bc 100644
--- a/dlls/riched20/paint.c
+++ b/dlls/riched20/paint.c
@@ -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)
         {




More information about the wine-cvs mailing list