richedit: Removed redundant editor height variables and calculations.
During wrapping there were three different heights that were being stored, with only one of them being done correctly. The other ones failed to incorporate the height of the paragraph or row, so ended up being incorrect.
This commit is contained in:
parent
40fdc88efc
commit
dc03b6b2f2
|
@ -2605,7 +2605,6 @@ ME_TextEditor *ME_MakeEditor(HWND hWnd) {
|
|||
ed->pCursors[2] = ed->pCursors[0];
|
||||
ed->pCursors[3] = ed->pCursors[1];
|
||||
ed->nLastTotalLength = ed->nTotalLength = 0;
|
||||
ed->nHeight = 0;
|
||||
ed->nUDArrowX = -1;
|
||||
ed->nSequence = 0;
|
||||
ed->rgbBackColor = -1;
|
||||
|
|
|
@ -333,7 +333,6 @@ typedef struct tagME_TextEditor
|
|||
int nCursors;
|
||||
SIZE sizeWindow;
|
||||
int nTotalLength, nLastTotalLength;
|
||||
int nHeight;
|
||||
int nUDArrowX;
|
||||
int nSequence;
|
||||
COLORREF rgbBackColor;
|
||||
|
|
|
@ -1101,7 +1101,7 @@ void ME_Scroll(ME_TextEditor *editor, int value, int type)
|
|||
hWnd = editor->hWnd;
|
||||
winStyle = GetWindowLongW(hWnd, GWL_STYLE);
|
||||
bScrollBarIsVisible = (winStyle & WS_VSCROLL) != 0;
|
||||
bScrollBarWillBeVisible = (editor->nHeight > editor->sizeWindow.cy)
|
||||
bScrollBarWillBeVisible = (editor->nTotalLength > editor->sizeWindow.cy)
|
||||
|| (winStyle & ES_DISABLENOSCROLL);
|
||||
if (bScrollBarIsVisible != bScrollBarWillBeVisible)
|
||||
{
|
||||
|
@ -1127,7 +1127,7 @@ void ME_UpdateScrollBar(ME_TextEditor *editor)
|
|||
hWnd = editor->hWnd;
|
||||
si.cbSize = sizeof(si);
|
||||
bScrollBarWasVisible = ME_GetYScrollVisible(editor);
|
||||
bScrollBarWillBeVisible = editor->nHeight > editor->sizeWindow.cy;
|
||||
bScrollBarWillBeVisible = editor->nTotalLength > editor->sizeWindow.cy;
|
||||
|
||||
si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS;
|
||||
if (GetWindowLongW(hWnd, GWL_STYLE) & ES_DISABLENOSCROLL)
|
||||
|
|
|
@ -578,17 +578,14 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor)
|
|||
ME_Context c;
|
||||
BOOL bModified = FALSE;
|
||||
int yStart = -1;
|
||||
int yLastPos = 0;
|
||||
|
||||
ME_InitContext(&c, editor, GetDC(editor->hWnd));
|
||||
c.pt.x = 0;
|
||||
editor->nHeight = 0;
|
||||
item = editor->pBuffer->pFirst->next;
|
||||
while(item != editor->pBuffer->pLast) {
|
||||
BOOL bRedraw = FALSE;
|
||||
|
||||
assert(item->type == diParagraph);
|
||||
editor->nHeight = max(editor->nHeight, item->member.para.pt.y);
|
||||
if ((item->member.para.nFlags & MEPF_REWRAP)
|
||||
|| (item->member.para.pt.y != c.pt.y))
|
||||
bRedraw = TRUE;
|
||||
|
@ -605,8 +602,6 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor)
|
|||
|
||||
bModified = bModified | bRedraw;
|
||||
|
||||
yLastPos = max(yLastPos, c.pt.y);
|
||||
|
||||
if (item->member.para.nFlags & MEPF_ROWSTART)
|
||||
{
|
||||
ME_DisplayItem *cell = ME_FindItemFwd(item, diCell);
|
||||
|
@ -718,18 +713,10 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor)
|
|||
|
||||
editor->nTotalLength = c.pt.y;
|
||||
editor->pBuffer->pLast->member.para.pt.x = 0;
|
||||
editor->pBuffer->pLast->member.para.pt.y = yLastPos;
|
||||
editor->pBuffer->pLast->member.para.pt.y = c.pt.y;
|
||||
|
||||
ME_DestroyContext(&c, editor->hWnd);
|
||||
|
||||
/* Each paragraph may contain multiple rows, which should be scrollable, even
|
||||
if the containing paragraph has pt.y == 0 */
|
||||
item = editor->pBuffer->pFirst;
|
||||
while ((item = ME_FindItemFwd(item, diStartRow)) != NULL) {
|
||||
assert(item->type == diStartRow);
|
||||
editor->nHeight = max(editor->nHeight, item->member.row.pt.y);
|
||||
}
|
||||
|
||||
if (bModified || editor->nTotalLength < editor->nLastTotalLength)
|
||||
ME_InvalidateMarkedParagraphs(editor);
|
||||
return bModified;
|
||||
|
|
Loading…
Reference in New Issue