From eb1c6657f7090d541a440714f99d7e0bd886002b Mon Sep 17 00:00:00 2001 From: Phil Krylov Date: Thu, 30 Jun 2005 18:10:22 +0000 Subject: [PATCH] Implemented EM_GETLINECOUNT RichEdit message. --- dlls/riched20/editor.c | 16 ++++++++++++++-- dlls/riched20/editstr.h | 1 + dlls/riched20/wrap.c | 3 +++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 611d568c6bb..99ac957c5ef 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -51,7 +51,7 @@ - EM_GETLANGOPTIONS 2.0 - EM_GETLIMITTEXT - EM_GETLINE - - EM_GETLINECOUNT returns number of rows, not of paragraphs + + EM_GETLINECOUNT returns number of rows, not of paragraphs + EM_GETMODIFY - EM_GETOLEINTERFACE - EM_GETOPTIONS @@ -838,7 +838,6 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP UNSUPPORTED_MSG(EM_GETLANGOPTIONS) UNSUPPORTED_MSG(EM_GETLIMITTEXT) UNSUPPORTED_MSG(EM_GETLINE) - UNSUPPORTED_MSG(EM_GETLINECOUNT) /* UNSUPPORTED_MSG(EM_GETOLEINTERFACE) separate stub */ UNSUPPORTED_MSG(EM_GETOPTIONS) UNSUPPORTED_MSG(EM_GETPASSWORDCHAR) @@ -1235,6 +1234,19 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP } return ME_GetTextW(editor, rng->lpstrText, rng->chrg.cpMin, rng->chrg.cpMax-rng->chrg.cpMin, FALSE); } + case EM_GETLINECOUNT: + { + ME_DisplayItem *item = editor->pBuffer->pFirst->next; + int nRows = 0; + + while (item != editor->pBuffer->pLast) + { + assert(item->type == diParagraph); + nRows += item->member.para.nRows; + item = item->member.para.next_para; + } + return max(1, nRows); + } case WM_CREATE: ME_CommitUndo(editor); ME_WrapMarkedParagraphs(editor); diff --git a/dlls/riched20/editstr.h b/dlls/riched20/editstr.h index 00329fb9628..ae7a0cd995e 100644 --- a/dlls/riched20/editstr.h +++ b/dlls/riched20/editstr.h @@ -147,6 +147,7 @@ typedef struct tagME_Paragraph int nFlags; int nYPos, nHeight; int nLastPaintYPos, nLastPaintHeight; + int nRows; struct tagME_DisplayItem *prev_para, *next_para, *document; } ME_Paragraph; diff --git a/dlls/riched20/wrap.c b/dlls/riched20/wrap.c index d48da585942..3f4c9825466 100644 --- a/dlls/riched20/wrap.c +++ b/dlls/riched20/wrap.c @@ -375,12 +375,15 @@ void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp) { ME_WrapEndParagraph(&wc, p); tp->member.para.nFlags &= ~MEPF_REWRAP; tp->member.para.nHeight = wc.pt.y; + tp->member.para.nRows = wc.nRow + 1; } void ME_PrepareParagraphForWrapping(ME_Context *c, ME_DisplayItem *tp) { ME_DisplayItem *p; + /* remove all items that will be reinserted by paragraph wrapper anyway */ + tp->member.para.nRows = 0; for (p = tp->next; p!=tp->member.para.next_para; p = p->next) { switch(p->type) { case diStartRow: