[PATCH 21/24] [RichEdit]: don't recreate the DC all the time, but use uniformely a ME_Context structure where needed

Eric Pouech eric.pouech at orange.fr
Tue Jan 1 15:05:28 CST 2008




A+
---

 dlls/riched20/editor.h |    2 +-
 dlls/riched20/run.c    |   20 +++++++++-----------
 dlls/riched20/wrap.c   |    2 +-
 3 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index c9baf98..4e16155 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -150,7 +150,7 @@ ME_DisplayItem *ME_InsertRunAtCursor(ME_TextEditor *editor, ME_Cursor *cursor,
 void ME_CheckCharOffsets(ME_TextEditor *editor);
 void ME_PropagateCharOffset(ME_DisplayItem *p, int shift);
 void ME_GetGraphicsSize(ME_TextEditor *editor, ME_Run *run, SIZE *pSize);
-int ME_CharFromPoint(ME_TextEditor *editor, int cx, ME_Run *run);
+int ME_CharFromPoint(ME_Context *c, int cx, ME_Run *run);
 /* this one accounts for 1/2 char tolerance */
 int ME_CharFromPointCursor(ME_TextEditor *editor, int cx, ME_Run *run);
 int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset);
diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c
index 759ea29..a56f8a8 100644
--- a/dlls/riched20/run.c
+++ b/dlls/riched20/run.c
@@ -487,11 +487,10 @@ void ME_GetGraphicsSize(ME_TextEditor *editor, ME_Run *run, SIZE *pSize)
  * pixel horizontal position. This version rounds left (ie. if the second
  * character is at pixel position 8, then for cx=0..7 it returns 0).  
  */     
-int ME_CharFromPoint(ME_TextEditor *editor, int cx, ME_Run *run)
+int ME_CharFromPoint(ME_Context *c, int cx, ME_Run *run)
 {
   int fit = 0;
   HGDIOBJ hOldFont;
-  HDC hDC;
   SIZE sz;
   if (!run->strText->nLen)
     return 0;
@@ -505,29 +504,28 @@ int ME_CharFromPoint(ME_TextEditor *editor, int cx, ME_Run *run)
   if (run->nFlags & MERF_GRAPHICS)
   {
     SIZE sz;
-    ME_GetGraphicsSize(editor, run, &sz);
+    ME_GetGraphicsSize(c->editor, run, &sz);
     if (cx < sz.cx)
       return 0;
     return 1;
   }
-  hDC = GetDC(editor->hWnd);
-  hOldFont = ME_SelectStyleFont(editor, hDC, run->style);
+  hOldFont = ME_SelectStyleFont(c->editor, c->hDC, run->style);
   
-  if (editor->cPasswordMask)
+  if (c->editor->cPasswordMask)
   {
-    ME_String *strMasked = ME_MakeStringR(editor->cPasswordMask,ME_StrVLen(run->strText));
-    GetTextExtentExPointW(hDC, strMasked->szData, run->strText->nLen,
+    ME_String *strMasked = ME_MakeStringR(c->editor->cPasswordMask,ME_StrVLen(run->strText));
+    GetTextExtentExPointW(c->hDC, strMasked->szData, run->strText->nLen,
       cx, &fit, NULL, &sz);
     ME_DestroyString(strMasked);
   }
   else
   {
-    GetTextExtentExPointW(hDC, run->strText->szData, run->strText->nLen,
+    GetTextExtentExPointW(c->hDC, run->strText->szData, run->strText->nLen,
       cx, &fit, NULL, &sz);
   }
   
-  ME_UnselectStyleFont(editor, hDC, run->style, hOldFont);
-  ReleaseDC(editor->hWnd, hDC);
+  ME_UnselectStyleFont(c->editor, c->hDC, run->style, hOldFont);
+
   return fit;
 }
 
diff --git a/dlls/riched20/wrap.c b/dlls/riched20/wrap.c
index f49c7ab..b5f10f7 100644
--- a/dlls/riched20/wrap.c
+++ b/dlls/riched20/wrap.c
@@ -168,7 +168,7 @@ static ME_DisplayItem *ME_SplitByBacktracking(ME_WrapContext *wc, ME_DisplayItem
   int i, idesp, len;
   ME_Run *run = &p->member.run;
 
-  idesp = i = ME_CharFromPoint(wc->context->editor, loc, run);
+  idesp = i = ME_CharFromPoint(wc->context, loc, run);
   len = ME_StrVLen(run->strText);
   assert(len>0);
   assert(i<len);





More information about the wine-patches mailing list