richedit: Added support for intra-paragraph line space.

This commit is contained in:
Eric Pouech 2008-01-01 22:04:58 +01:00 committed by Alexandre Julliard
parent f1b029ef6a
commit d319033a97
3 changed files with 30 additions and 2 deletions

View File

@ -256,6 +256,7 @@ BOOL ME_GetYScrollVisible(ME_TextEditor *editor);
/* other functions in paint.c */
int ME_GetParaBorderWidth(ME_TextEditor *editor, int);
int ME_GetParaLineSpace(ME_TextEditor *editor, ME_Paragraph*, int);
/* richole.c */
extern LRESULT CreateIRichEditOle(ME_TextEditor *editor, LPVOID *);

View File

@ -365,6 +365,29 @@ int ME_GetParaBorderWidth(ME_TextEditor* editor, int flags)
return width;
}
int ME_GetParaLineSpace(ME_TextEditor* editor, ME_Paragraph* para, int dpi)
{
int sp = 0, ls = 0;
if (!(para->pFmt->dwMask & PFM_LINESPACING)) return 0;
/* FIXME: how to compute simply the line space in ls ??? */
/* FIXME: does line spacing include the line itself ??? */
switch (para->pFmt->bLineSpacingRule)
{
case 0: sp = ls; break;
case 1: sp = (3 * ls) / 2; break;
case 2: sp = 2 * ls; break;
case 3: sp = para->pFmt->dyLineSpacing * dpi / 1440; if (sp < ls) sp = ls; break;
case 4: sp = para->pFmt->dyLineSpacing * dpi / 1440; break;
case 5: sp = para->pFmt->dyLineSpacing / 20; break;
default: FIXME("Unsupported spacing rule value %d\n", para->pFmt->bLineSpacingRule);
}
if (editor->nZoomNumerator == 0)
return sp;
else
return sp * editor->nZoomNumerator / editor->nZoomDenominator;
}
static int ME_DrawParaDecoration(ME_Context* c, ME_Paragraph* para, int y, int dpi)
{
int idx, border_width;

View File

@ -343,6 +343,7 @@ static void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp, DWORD begino
ME_WrapContext wc;
int dpi = GetDeviceCaps(c->hDC, LOGPIXELSX);
int border = 0;
int linespace = 0;
assert(tp->type == diParagraph);
if (!(tp->member.para.nFlags & MEPF_REWRAP)) {
@ -378,14 +379,17 @@ static void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp, DWORD begino
wc.nAvailWidth = wc.nTotalWidth - wc.nFirstMargin - wc.nRightMargin;
wc.pRowStart = NULL;
linespace = ME_GetParaLineSpace(c->editor, &tp->member.para, dpi);
ME_BeginRow(&wc);
for (p = tp->next; p!=tp->member.para.next_para; ) {
assert(p->type != diStartRow);
if (p->type == diRun) {
p = ME_WrapHandleRun(&wc, p);
continue;
}
p = p->next;
else p = p->next;
if (wc.nRow && p == wc.pRowStart)
wc.pt.y += linespace;
}
ME_WrapEndParagraph(&wc, p);
if ((tp->member.para.pFmt->dwMask & PFM_BORDER) && (tp->member.para.pFmt->wBorders & 8))