Huw Davies : riched20: Move the split point calculation to wrap.c.
Alexandre Julliard
julliard at winehq.org
Fri Feb 8 14:13:46 CST 2013
Module: wine
Branch: master
Commit: 9e8a9f4f657e30de42d422bda3b23810e56976bd
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9e8a9f4f657e30de42d422bda3b23810e56976bd
Author: Huw Davies <huw at codeweavers.com>
Date: Fri Feb 8 11:45:03 2013 +0000
riched20: Move the split point calculation to wrap.c.
---
dlls/riched20/editor.h | 1 -
dlls/riched20/run.c | 50 ------------------------------------------------
dlls/riched20/wrap.c | 47 ++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 46 insertions(+), 52 deletions(-)
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index 9722f36..4401498 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -140,7 +140,6 @@ ME_DisplayItem *ME_InsertRunAtCursor(ME_TextEditor *editor, ME_Cursor *cursor,
ME_Style *style, const WCHAR *str, int len, int flags) DECLSPEC_HIDDEN;
void ME_CheckCharOffsets(ME_TextEditor *editor) DECLSPEC_HIDDEN;
void ME_PropagateCharOffset(ME_DisplayItem *p, int shift) DECLSPEC_HIDDEN;
-int ME_CharFromPoint(ME_Context *c, int cx, ME_Run *run) DECLSPEC_HIDDEN;
/* this one accounts for 1/2 char tolerance */
int ME_CharFromPointCursor(ME_TextEditor *editor, int cx, ME_Run *run) DECLSPEC_HIDDEN;
int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset) DECLSPEC_HIDDEN;
diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c
index aaa6300..6f9d5b5 100644
--- a/dlls/riched20/run.c
+++ b/dlls/riched20/run.c
@@ -404,56 +404,6 @@ void ME_UpdateRunFlags(ME_TextEditor *editor, ME_Run *run)
}
/******************************************************************************
- * ME_CharFromPoint
- *
- * Returns a character position inside the run given a run-relative
- * 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_Context *c, int cx, ME_Run *run)
-{
- int fit = 0;
- HGDIOBJ hOldFont;
- SIZE sz;
- if (!run->len || cx <= 0)
- return 0;
-
- if (run->nFlags & MERF_TAB ||
- (run->nFlags & (MERF_ENDCELL|MERF_ENDPARA)) == MERF_ENDCELL)
- {
- if (cx < run->nWidth/2)
- return 0;
- return 1;
- }
- if (run->nFlags & MERF_GRAPHICS)
- {
- SIZE sz;
- ME_GetOLEObjectSize(c, run, &sz);
- if (cx < sz.cx)
- return 0;
- return 1;
- }
- hOldFont = ME_SelectStyleFont(c, run->style);
-
- if (c->editor->cPasswordMask)
- {
- ME_String *strMasked = ME_MakeStringR(c->editor->cPasswordMask, run->len);
- GetTextExtentExPointW(c->hDC, strMasked->szData, run->len,
- cx, &fit, NULL, &sz);
- ME_DestroyString(strMasked);
- }
- else
- {
- GetTextExtentExPointW(c->hDC, get_text( run, 0 ), run->len,
- cx, &fit, NULL, &sz);
- }
-
- ME_UnselectStyleFont(c, run->style, hOldFont);
-
- return fit;
-}
-
-/******************************************************************************
* ME_CharFromPointCursor
*
* Returns a character position inside the run given a run-relative
diff --git a/dlls/riched20/wrap.c b/dlls/riched20/wrap.c
index 97598e7..0531c97 100644
--- a/dlls/riched20/wrap.c
+++ b/dlls/riched20/wrap.c
@@ -80,6 +80,51 @@ static ME_DisplayItem *split_run_extents(ME_WrapContext *wc, ME_DisplayItem *ite
return cursor.pRun;
}
+/******************************************************************************
+ * find_split_point
+ *
+ * Returns a character position to split inside the run given a run-relative
+ * 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).
+ */
+static int find_split_point( ME_Context *c, int cx, ME_Run *run )
+{
+ int fit = 0;
+ HGDIOBJ hOldFont;
+ SIZE sz;
+
+ if (!run->len || cx <= 0) return 0;
+
+ if (run->nFlags & MERF_TAB ||
+ (run->nFlags & (MERF_ENDCELL|MERF_ENDPARA)) == MERF_ENDCELL)
+ {
+ if (cx < run->nWidth / 2) return 0;
+ return 1;
+ }
+ if (run->nFlags & MERF_GRAPHICS)
+ {
+ SIZE sz;
+ ME_GetOLEObjectSize( c, run, &sz );
+ if (cx < sz.cx) return 0;
+ return 1;
+ }
+ hOldFont = ME_SelectStyleFont( c, run->style );
+
+ if (c->editor->cPasswordMask)
+ {
+ ME_String *strMasked = ME_MakeStringR( c->editor->cPasswordMask, run->len );
+ GetTextExtentExPointW( c->hDC, strMasked->szData, run->len, cx, &fit, NULL, &sz );
+ ME_DestroyString( strMasked );
+ }
+ else
+ {
+ GetTextExtentExPointW( c->hDC, get_text( run, 0 ), run->len, cx, &fit, NULL, &sz );
+ }
+
+ ME_UnselectStyleFont( c, run->style, hOldFont );
+
+ return fit;
+}
static ME_DisplayItem *ME_MakeRow(int height, int baseline, int width)
{
@@ -337,7 +382,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, loc, run);
+ idesp = i = find_split_point( wc->context, loc, run );
len = run->len;
assert(len>0);
assert(i<len);
More information about the wine-cvs
mailing list