From 28cc0f9e690a675aa00b0ccc02b442fcf8a819ea Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Tue, 1 Jan 2008 22:04:40 +0100 Subject: [PATCH] richedit: Fix the para computation when zoom is used. --- dlls/riched20/editor.h | 1 + dlls/riched20/paint.c | 26 ++++++++++++-------------- dlls/riched20/wrap.c | 6 +++--- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h index 5cb9b7e7f40..93789d64a10 100644 --- a/dlls/riched20/editor.h +++ b/dlls/riched20/editor.h @@ -214,6 +214,7 @@ BOOL ME_UpdateSelection(ME_TextEditor *editor, const ME_Cursor *pTempCursor); BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor); void ME_InvalidateMarkedParagraphs(ME_TextEditor *editor); void ME_SendRequestResize(ME_TextEditor *editor, BOOL force); +int ME_twips2points(ME_Context *c, int x, int dpi); /* para.c */ ME_DisplayItem *ME_GetParagraph(ME_DisplayItem *run); diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c index 11071056abb..8f71fa531a0 100644 --- a/dlls/riched20/paint.c +++ b/dlls/riched20/paint.c @@ -141,6 +141,13 @@ ME_RewrapRepaint(ME_TextEditor *editor) ME_Repaint(editor); } +int ME_twips2points(ME_Context *c, int x, int dpi) +{ + if (c->editor->nZoomNumerator == 0) + return x * dpi / 1440; + else + return x * dpi * c->editor->nZoomNumerator / 1440 / c->editor->nZoomDenominator; +} static void ME_DrawTextWithStyle(ME_Context *c, int x, int y, LPCWSTR szText, int nChars, ME_Style *s, int *width, int nSelFrom, int nSelTo, int ymin, int cy) { @@ -167,17 +174,8 @@ static void ME_DrawTextWithStyle(ME_Context *c, int x, int y, LPCWSTR szText, in if (s->fmt.dwEffects & CFE_SUBSCRIPT) yTwipsOffset = -s->fmt.yHeight/12; } if (yTwipsOffset) - { - int numerator = 1; - int denominator = 1; - - if (c->editor->nZoomNumerator) - { - numerator = c->editor->nZoomNumerator; - denominator = c->editor->nZoomDenominator; - } - yOffset = yTwipsOffset * GetDeviceCaps(hDC, LOGPIXELSY) * numerator / denominator / 1440; - } + yOffset = ME_twips2points(c, yTwipsOffset, GetDeviceCaps(hDC, LOGPIXELSY)); + ExtTextOutW(hDC, x, y-yOffset, 0, NULL, szText, nChars, NULL); GetTextExtentPoint32W(hDC, szText, nChars, &sz); if (width) *width = sz.cx; @@ -329,11 +327,11 @@ void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph) { case diParagraph: para = &p->member.para; assert(para); - nMargWidth = para->pFmt->dxStartIndent*dpi/1440; + nMargWidth = ME_twips2points(c, para->pFmt->dxStartIndent, dpi); if (pno != 0) - nMargWidth += para->pFmt->dxOffset*dpi/1440; + nMargWidth += ME_twips2points(c, para->pFmt->dxOffset, dpi); xs = c->rcView.left+nMargWidth; - xe = c->rcView.right-(para->pFmt->dxRightIndent*dpi/1440); + xe = c->rcView.right - ME_twips2points(c, para->pFmt->dxRightIndent, dpi); break; case diStartRow: y += height; diff --git a/dlls/riched20/wrap.c b/dlls/riched20/wrap.c index ae399fba6df..310aad77738 100644 --- a/dlls/riched20/wrap.c +++ b/dlls/riched20/wrap.c @@ -352,9 +352,9 @@ static void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp, DWORD begino wc.context = c; /* wc.para_style = tp->member.para.style; */ wc.style = NULL; - wc.nFirstMargin = tp->member.para.pFmt->dxStartIndent*dpi/1440 + beginofs; - wc.nLeftMargin = wc.nFirstMargin + tp->member.para.pFmt->dxOffset*dpi/1440 + beginofs; - wc.nRightMargin = tp->member.para.pFmt->dxRightIndent*dpi/1440; + wc.nFirstMargin = ME_twips2points(c, tp->member.para.pFmt->dxStartIndent, dpi) + beginofs + wc.nLeftMargin = wc.nFirstMargin + ME_twips2points(c, tp->member.para.pFmt->dxOffset, dpi) + beginofs + wc.nRightMargin = ME_twips2points(c, tp->member.para.pFmt->dxRightIndent, dpi); wc.nRow = 0; wc.pt.x = 0; wc.pt.y = 0;