Commit 28cc0f9e authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

richedit: Fix the para computation when zoom is used.

parent f4fd0631
...@@ -214,6 +214,7 @@ BOOL ME_UpdateSelection(ME_TextEditor *editor, const ME_Cursor *pTempCursor); ...@@ -214,6 +214,7 @@ BOOL ME_UpdateSelection(ME_TextEditor *editor, const ME_Cursor *pTempCursor);
BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor); BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor);
void ME_InvalidateMarkedParagraphs(ME_TextEditor *editor); void ME_InvalidateMarkedParagraphs(ME_TextEditor *editor);
void ME_SendRequestResize(ME_TextEditor *editor, BOOL force); void ME_SendRequestResize(ME_TextEditor *editor, BOOL force);
int ME_twips2points(ME_Context *c, int x, int dpi);
/* para.c */ /* para.c */
ME_DisplayItem *ME_GetParagraph(ME_DisplayItem *run); ME_DisplayItem *ME_GetParagraph(ME_DisplayItem *run);
......
...@@ -141,6 +141,13 @@ ME_RewrapRepaint(ME_TextEditor *editor) ...@@ -141,6 +141,13 @@ ME_RewrapRepaint(ME_TextEditor *editor)
ME_Repaint(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, 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) { 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 ...@@ -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 (s->fmt.dwEffects & CFE_SUBSCRIPT) yTwipsOffset = -s->fmt.yHeight/12;
} }
if (yTwipsOffset) if (yTwipsOffset)
{ yOffset = ME_twips2points(c, yTwipsOffset, GetDeviceCaps(hDC, LOGPIXELSY));
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;
}
ExtTextOutW(hDC, x, y-yOffset, 0, NULL, szText, nChars, NULL); ExtTextOutW(hDC, x, y-yOffset, 0, NULL, szText, nChars, NULL);
GetTextExtentPoint32W(hDC, szText, nChars, &sz); GetTextExtentPoint32W(hDC, szText, nChars, &sz);
if (width) *width = sz.cx; if (width) *width = sz.cx;
...@@ -329,11 +327,11 @@ void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph) { ...@@ -329,11 +327,11 @@ void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph) {
case diParagraph: case diParagraph:
para = &p->member.para; para = &p->member.para;
assert(para); assert(para);
nMargWidth = para->pFmt->dxStartIndent*dpi/1440; nMargWidth = ME_twips2points(c, para->pFmt->dxStartIndent, dpi);
if (pno != 0) if (pno != 0)
nMargWidth += para->pFmt->dxOffset*dpi/1440; nMargWidth += ME_twips2points(c, para->pFmt->dxOffset, dpi);
xs = c->rcView.left+nMargWidth; 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; break;
case diStartRow: case diStartRow:
y += height; y += height;
......
...@@ -352,9 +352,9 @@ static void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp, DWORD begino ...@@ -352,9 +352,9 @@ static void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp, DWORD begino
wc.context = c; wc.context = c;
/* wc.para_style = tp->member.para.style; */ /* wc.para_style = tp->member.para.style; */
wc.style = NULL; wc.style = NULL;
wc.nFirstMargin = tp->member.para.pFmt->dxStartIndent*dpi/1440 + beginofs; wc.nFirstMargin = ME_twips2points(c, tp->member.para.pFmt->dxStartIndent, dpi) + beginofs
wc.nLeftMargin = wc.nFirstMargin + tp->member.para.pFmt->dxOffset*dpi/1440 + beginofs; wc.nLeftMargin = wc.nFirstMargin + ME_twips2points(c, tp->member.para.pFmt->dxOffset, dpi) + beginofs
wc.nRightMargin = tp->member.para.pFmt->dxRightIndent*dpi/1440; wc.nRightMargin = ME_twips2points(c, tp->member.para.pFmt->dxRightIndent, dpi);
wc.nRow = 0; wc.nRow = 0;
wc.pt.x = 0; wc.pt.x = 0;
wc.pt.y = 0; wc.pt.y = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment