Module: wine Branch: master Commit: 42b0c6ea3376443e67ea1598764fe2f4200f0173 URL: http://source.winehq.org/git/wine.git/?a=commit;h=42b0c6ea3376443e67ea159876...
Author: Huw Davies huw@codeweavers.com Date: Thu Feb 14 14:16:20 2013 +0000
riched20: Make it possible to perform point -> char conversion while holding a context.
---
dlls/riched20/editor.h | 1 + dlls/riched20/run.c | 33 +++++++++++++++++++++++---------- 2 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h index 5383f82..de95448 100644 --- a/dlls/riched20/editor.h +++ b/dlls/riched20/editor.h @@ -142,6 +142,7 @@ void ME_CheckCharOffsets(ME_TextEditor *editor) DECLSPEC_HIDDEN; void ME_PropagateCharOffset(ME_DisplayItem *p, int shift) 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_PointFromCharContext(ME_Context *c, ME_Run *pRun, int nOffset) DECLSPEC_HIDDEN; int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset) DECLSPEC_HIDDEN; int ME_CanJoinRuns(const ME_Run *run1, const ME_Run *run2) DECLSPEC_HIDDEN; void ME_JoinRuns(ME_TextEditor *editor, ME_DisplayItem *p) DECLSPEC_HIDDEN; diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c index 37445a1..2808045 100644 --- a/dlls/riched20/run.c +++ b/dlls/riched20/run.c @@ -487,44 +487,57 @@ static void ME_GetTextExtent(ME_Context *c, LPCWSTR szText, int nChars, ME_Style }
/****************************************************************************** - * ME_PointFromChar + * ME_PointFromCharContext * * Returns a run-relative pixel position given a run-relative character * position (character offset) */ -int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset) +int ME_PointFromCharContext(ME_Context *c, ME_Run *pRun, int nOffset) { SIZE size; - ME_Context c; ME_String *mask_text = NULL; WCHAR *str;
- ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost)); if (pRun->nFlags & MERF_GRAPHICS) { if (nOffset) - ME_GetOLEObjectSize(&c, pRun, &size); - ME_DestroyContext(&c); + ME_GetOLEObjectSize(c, pRun, &size); return nOffset != 0; } else if (pRun->nFlags & MERF_ENDPARA) { nOffset = 0; }
- if (editor->cPasswordMask) + if (c->editor->cPasswordMask) { - mask_text = ME_MakeStringR(editor->cPasswordMask, pRun->len); + mask_text = ME_MakeStringR(c->editor->cPasswordMask, pRun->len); str = mask_text->szData; } else str = get_text( pRun, 0 );
- ME_GetTextExtent(&c, str, nOffset, pRun->style, &size); - ME_DestroyContext(&c); + ME_GetTextExtent(c, str, nOffset, pRun->style, &size); ME_DestroyString( mask_text ); return size.cx; }
/****************************************************************************** + * ME_PointFromChar + * + * Calls ME_PointFromCharContext after first creating a context. + */ +int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset) +{ + ME_Context c; + int ret; + + ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost)); + ret = ME_PointFromCharContext( &c, pRun, nOffset ); + ME_DestroyContext(&c); + + return ret; +} + +/****************************************************************************** * ME_GetRunSizeCommon * * Finds width, height, ascent and descent of a run, up to given character