Eric Pouech : richedit: Added support for spaces above & below paragraphs.
Alexandre Julliard
julliard at winehq.org
Wed Jan 2 07:34:55 CST 2008
Module: wine
Branch: master
Commit: f1b029ef6a096eeef4b5234124314fb238cd295c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f1b029ef6a096eeef4b5234124314fb238cd295c
Author: Eric Pouech <eric.pouech at orange.fr>
Date: Tue Jan 1 22:04:52 2008 +0100
richedit: Added support for spaces above & below paragraphs.
---
dlls/riched20/paint.c | 136 ++++++++++++++++++++++++++++++-------------------
dlls/riched20/wrap.c | 4 ++
2 files changed, 88 insertions(+), 52 deletions(-)
diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c
index b5211e2..72c03f1 100644
--- a/dlls/riched20/paint.c
+++ b/dlls/riched20/paint.c
@@ -365,70 +365,102 @@ int ME_GetParaBorderWidth(ME_TextEditor* editor, int flags)
return width;
}
-static int ME_DrawParaDecoration(ME_Context* c, ME_Paragraph* para, int y)
+static int ME_DrawParaDecoration(ME_Context* c, ME_Paragraph* para, int y, int dpi)
{
- HPEN pen, oldpen;
- POINT pt;
- int idx, pen_width, border_width;
- COLORREF pencr;
+ int idx, border_width;
+ int ybefore, yafter;
+ RECT rc;
- if (!(para->pFmt->dwMask & PFM_BORDER)) return 0;
+ if (!(para->pFmt->dwMask & (PFM_BORDER | PFM_SPACEBEFORE | PFM_SPACEAFTER))) return 0;
- if (para->pFmt->wBorders & 0x00B0)
- FIXME("Unsupported border flags %x\n", para->pFmt->wBorders);
- border_width = ME_GetParaBorderWidth(c->editor, para->pFmt->wBorders);
- if (border_width == 0 || !(para->pFmt->wBorders & 0xF)) return 0;
+ if (para->pFmt->dwMask & PFM_SPACEBEFORE)
+ {
+ rc.left = c->rcView.left;
+ rc.right = c->rcView.right;
+ rc.top = y;
+ ybefore = ME_twips2points(c, para->pFmt->dySpaceBefore, dpi);
+ rc.bottom = y + ybefore;
+ FillRect(c->hDC, &rc, c->editor->hbrBackground);
+ }
+ else ybefore = 0;
+ if (para->pFmt->dwMask & PFM_SPACEAFTER)
+ {
+ rc.left = c->rcView.left;
+ rc.right = c->rcView.right;
+ rc.bottom = y + para->nHeight;
+ yafter = ME_twips2points(c, para->pFmt->dySpaceAfter, dpi);
+ rc.top = rc.bottom - yafter;
+ FillRect(c->hDC, &rc, c->editor->hbrBackground);
+ }
+ else yafter = 0;
+
+ border_width = 0;
idx = (para->pFmt->wBorders >> 8) & 0xF;
+ if ((para->pFmt->dwMask & PFM_BORDER) && idx != 0 && (para->pFmt->wBorders & 0xF)) {
+ int pen_width;
+ COLORREF pencr;
+ HPEN pen = NULL, oldpen = NULL;
+ POINT pt;
+
+ if (para->pFmt->wBorders & 0x00B0)
+ FIXME("Unsupported border flags %x\n", para->pFmt->wBorders);
+ border_width = ME_GetParaBorderWidth(c->editor, para->pFmt->wBorders);
- if (para->pFmt->wBorders & 64) /* autocolor */
+ if (para->pFmt->wBorders & 64) /* autocolor */
pencr = GetSysColor(COLOR_WINDOWTEXT);
- else
+ else
pencr = pen_colors[(para->pFmt->wBorders >> 12) & 0xF];
- pen_width = ME_GetBorderPenWidth(c->editor, idx);
- pen = CreatePen(border_details[idx].pen_style, pen_width, pencr);
- oldpen = SelectObject(c->hDC, pen);
- MoveToEx(c->hDC, 0, 0, &pt);
- if (para->pFmt->wBorders & 1)
- {
- MoveToEx(c->hDC, c->rcView.left, y, NULL);
- LineTo(c->hDC, c->rcView.left, y + para->nHeight);
- if (border_details[idx].dble) {
- MoveToEx(c->hDC, c->rcView.left + pen_width + 1, y + pen_width + 1, NULL);
- LineTo(c->hDC, c->rcView.left + pen_width + 1, y + para->nHeight - pen_width - 1);
+ pen_width = ME_GetBorderPenWidth(c->editor, idx);
+ pen = CreatePen(border_details[idx].pen_style, pen_width, pencr);
+ oldpen = SelectObject(c->hDC, pen);
+ MoveToEx(c->hDC, 0, 0, &pt);
+
+ /* before & after spaces are not included in border */
+ if (para->pFmt->wBorders & 1)
+ {
+ MoveToEx(c->hDC, c->rcView.left, y + ybefore, NULL);
+ LineTo(c->hDC, c->rcView.left, y + para->nHeight - yafter);
+ if (border_details[idx].dble) {
+ MoveToEx(c->hDC, c->rcView.left + pen_width + 1, y + ybefore + pen_width + 1, NULL);
+ LineTo(c->hDC, c->rcView.left + pen_width + 1, y + para->nHeight - yafter - pen_width - 1);
+ }
}
- }
- if (para->pFmt->wBorders & 2)
- {
- MoveToEx(c->hDC, c->rcView.right, y, NULL);
- LineTo(c->hDC, c->rcView.right, y + para->nHeight);
- if (border_details[idx].dble) {
- MoveToEx(c->hDC, c->rcView.right - pen_width - 1, y + pen_width + 1, NULL);
- LineTo(c->hDC, c->rcView.right - pen_width - 1, y + para->nHeight - pen_width - 1);
+ if (para->pFmt->wBorders & 2)
+ {
+ MoveToEx(c->hDC, c->rcView.right, y + ybefore, NULL);
+ LineTo(c->hDC, c->rcView.right, y + para->nHeight - yafter);
+ if (border_details[idx].dble) {
+ MoveToEx(c->hDC, c->rcView.right - pen_width - 1, y + ybefore + pen_width + 1, NULL);
+ LineTo(c->hDC, c->rcView.right - pen_width - 1, y + para->nHeight - yafter - pen_width - 1);
+ }
}
- }
- if (para->pFmt->wBorders & 4)
- {
- MoveToEx(c->hDC, c->rcView.left, y, NULL);
- LineTo(c->hDC, c->rcView.right, y);
- if (border_details[idx].dble) {
- MoveToEx(c->hDC, c->rcView.left + pen_width + 1, y + pen_width + 1, NULL);
- LineTo(c->hDC, c->rcView.right - pen_width - 1, y + pen_width + 1);
+ if (para->pFmt->wBorders & 4)
+ {
+ MoveToEx(c->hDC, c->rcView.left, y + ybefore, NULL);
+ LineTo(c->hDC, c->rcView.right, y + ybefore);
+ if (border_details[idx].dble) {
+ MoveToEx(c->hDC, c->rcView.left + pen_width + 1, y + ybefore + pen_width + 1, NULL);
+ LineTo(c->hDC, c->rcView.right - pen_width - 1, y + ybefore + pen_width + 1);
+ }
}
- }
- if (para->pFmt->wBorders & 8)
- {
- MoveToEx(c->hDC, c->rcView.left, y + para->nHeight - 1, NULL);
- LineTo(c->hDC, c->rcView.right, y + para->nHeight - 1);
- if (border_details[idx].dble) {
- MoveToEx(c->hDC, c->rcView.left + pen_width + 1, y + para->nHeight - 1 - pen_width - 1, NULL);
- LineTo(c->hDC, c->rcView.right - pen_width - 1, y + para->nHeight - 1 - pen_width - 1);
+ if (para->pFmt->wBorders & 8)
+ {
+ MoveToEx(c->hDC, c->rcView.left, y + para->nHeight - yafter - 1, NULL);
+ LineTo(c->hDC, c->rcView.right, y + para->nHeight - yafter - 1);
+ if (border_details[idx].dble) {
+ MoveToEx(c->hDC, c->rcView.left + pen_width + 1, y + para->nHeight - yafter - 1 - pen_width - 1, NULL);
+ LineTo(c->hDC, c->rcView.right - pen_width - 1, y + para->nHeight - yafter - 1 - pen_width - 1);
+ }
}
+
+ MoveToEx(c->hDC, pt.x, pt.y, NULL);
+ SelectObject(c->hDC, oldpen);
+ DeleteObject(pen);
}
- MoveToEx(c->hDC, pt.x, pt.y, NULL);
- SelectObject(c->hDC, oldpen);
- DeleteObject(pen);
- return (para->pFmt->wBorders & 4) ? border_width : 0;
+ return ybefore +
+ ((para->pFmt->dwMask & PFM_BORDER) && (para->pFmt->wBorders & 4) ?
+ border_width : 0);
}
void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph) {
@@ -457,7 +489,7 @@ void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph) {
nMargWidth += ME_twips2points(c, para->pFmt->dxOffset, dpi);
xs = c->rcView.left+nMargWidth;
xe = c->rcView.right - ME_twips2points(c, para->pFmt->dxRightIndent, dpi);
- y += ME_DrawParaDecoration(c, para, y);
+ y += ME_DrawParaDecoration(c, para, y, dpi);
break;
case diStartRow:
y += height;
diff --git a/dlls/riched20/wrap.c b/dlls/riched20/wrap.c
index 2069261..d1f6203 100644
--- a/dlls/riched20/wrap.c
+++ b/dlls/riched20/wrap.c
@@ -359,6 +359,8 @@ static void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp, DWORD begino
wc.nRow = 0;
wc.pt.x = 0;
wc.pt.y = 0;
+ if (tp->member.para.pFmt->dwMask & PFM_SPACEBEFORE)
+ wc.pt.y += ME_twips2points(c, tp->member.para.pFmt->dySpaceBefore, dpi);
if (tp->member.para.pFmt->dwMask & PFM_BORDER)
{
border = ME_GetParaBorderWidth(c->editor, tp->member.para.pFmt->wBorders);
@@ -388,6 +390,8 @@ static void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp, DWORD begino
ME_WrapEndParagraph(&wc, p);
if ((tp->member.para.pFmt->dwMask & PFM_BORDER) && (tp->member.para.pFmt->wBorders & 8))
wc.pt.y += border;
+ if (tp->member.para.pFmt->dwMask & PFM_SPACEAFTER)
+ wc.pt.y += ME_twips2points(c, tp->member.para.pFmt->dySpaceAfter, dpi);
tp->member.para.nFlags &= ~MEPF_REWRAP;
tp->member.para.nHeight = wc.pt.y;
More information about the wine-cvs
mailing list