Commit f7e0f7ca authored by Krzysztof Foltman's avatar Krzysztof Foltman Committed by Alexandre Julliard

- Optimized repaint of the area below the text.

- ME_JoinRuns didn't mark the paragraph for rewrapping, fixed. - Removed PostQuitMessage(0) from WM_DESTROY handler (duh!). - Use of EM_GETOLEINTERFACE is reported with FIXME instead of TRACE (any app using this message is likely to encounter major problems).
parent 639a87cb
......@@ -380,6 +380,7 @@ BOOL ME_ArrowLeft(ME_TextEditor *editor, ME_Cursor *p)
if (pRun->type == diRun) {
p->pRun = pRun;
assert(p->pRun->type == diRun);
assert(pRun->member.run.strText->nLen);
p->nOffset = pRun->member.run.strText->nLen;
if (p->nOffset) {
p->nOffset = ME_StrRelPos2(pRun->member.run.strText, p->nOffset, -1);
......
......@@ -279,7 +279,6 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
RTF_Info parser;
ME_Style *style;
FIXME("%08lx %p\n", format, stream);
TRACE("%p %p\n", stream, editor->hWnd);
if (format & SFF_SELECTION) {
......@@ -340,7 +339,7 @@ ME_TextEditor *ME_MakeEditor(HWND hWnd) {
ed->pCursors[0].nOffset = 0;
ed->pCursors[1].pRun = ME_FindItemFwd(ed->pBuffer->pFirst, diRun);
ed->pCursors[1].nOffset = 0;
ed->nTotalLength = 0;
ed->nLastTotalLength = ed->nTotalLength = 0;
ed->nScrollPos = 0;
ed->nUDArrowX = -1;
ed->nSequence = 0;
......@@ -398,6 +397,7 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
PAINTSTRUCT ps;
SCROLLINFO si;
ME_TextEditor *editor = (ME_TextEditor *)GetWindowLongW(hWnd, 0);
TRACE("msg %d %08x %08lx\n", msg, wParam, lParam);
switch(msg) {
UNSUPPORTED_MSG(EM_AUTOURLDETECT)
......@@ -703,15 +703,13 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
}
case WM_CREATE:
ME_CommitUndo(editor);
/* ME_InsertTextFromCursor(editor, 0, (WCHAR *)L"x", 1, editor->pBuffer->pDefaultStyle); */
ME_WrapMarkedParagraphs(editor);
ME_MoveCaret(editor);
return 0;
case WM_DESTROY:
ME_DestroyEditor(editor);
SetWindowLongW(hWnd, 0, 0);
PostQuitMessage(0);
break;
return 0;
case WM_LBUTTONDOWN:
SetFocus(hWnd);
ME_LButtonDown(editor, (short)LOWORD(lParam), (short)HIWORD(lParam));
......@@ -727,7 +725,7 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
break;
case WM_PAINT:
hDC = BeginPaint(hWnd, &ps);
ME_PaintContent(editor, hDC, FALSE);
ME_PaintContent(editor, hDC, FALSE, &ps.rcPaint);
EndPaint(hWnd, &ps);
break;
case WM_SETFOCUS:
......@@ -822,7 +820,7 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
case EM_GETOLEINTERFACE:
{
LPVOID *ppvObj = (LPVOID*) lParam;
TRACE("EM_GETOLEINTERFACE %p\n", ppvObj);
FIXME("EM_GETOLEINTERFACE %p: stub\n", ppvObj);
return CreateIRichEditOle(ppvObj);
}
default:
......
......@@ -181,7 +181,7 @@ void ME_MarkForWrapping(ME_TextEditor *editor, ME_DisplayItem *first, ME_Display
void ME_MarkAllForWrapping(ME_TextEditor *editor);
/* paint.c */
void ME_PaintContent(ME_TextEditor *editor, HDC hDC, BOOL bOnlyNew);
void ME_PaintContent(ME_TextEditor *editor, HDC hDC, BOOL bOnlyNew, RECT *rcUpdate);
void ME_Repaint(ME_TextEditor *editor);
void ME_UpdateRepaint(ME_TextEditor *editor);
void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph);
......
......@@ -211,7 +211,7 @@ typedef struct tagME_TextEditor
int nCursors;
SIZE sizeWindow;
int nScrollPos;
int nTotalLength;
int nTotalLength, nLastTotalLength;
int nUDArrowX;
int nSequence;
int nOldSelFrom, nOldSelTo;
......
......@@ -22,41 +22,76 @@
WINE_DEFAULT_DEBUG_CHANNEL(richedit);
void ME_PaintContent(ME_TextEditor *editor, HDC hDC, BOOL bOnlyNew) {
void ME_PaintContent(ME_TextEditor *editor, HDC hDC, BOOL bOnlyNew, RECT *rcUpdate) {
ME_DisplayItem *item;
ME_Context c;
int yoffset;
editor->nSequence++;
yoffset = GetScrollPos(editor->hWnd, SB_VERT);
ME_InitContext(&c, editor, hDC);
SetBkMode(hDC, TRANSPARENT);
ME_MoveCaret(editor);
item = editor->pBuffer->pFirst->next;
c.pt.y=-GetScrollPos(editor->hWnd, SB_VERT);
c.pt.y -= yoffset;
while(item != editor->pBuffer->pLast) {
assert(item->type == diParagraph);
if (!bOnlyNew || (item->member.para.nFlags & MEPF_REPAINT))
{
ME_DrawParagraph(&c, item);
item->member.para.nFlags &= ~MEPF_REPAINT;
BOOL bPaint = (rcUpdate == NULL);
if (rcUpdate)
bPaint = c.pt.y<rcUpdate->bottom &&
c.pt.y+item->member.para.nHeight>rcUpdate->top;
if (bPaint)
{
ME_DrawParagraph(&c, item);
item->member.para.nFlags &= ~MEPF_REPAINT;
}
}
c.pt.y += item->member.para.nHeight;
item = item->member.para.next_para;
}
/* FIXME this code just sucks, it should try to redraw incrementally */
if (c.pt.y<c.rcView.bottom) {
RECT rc;
rc.left = c.rcView.left;
int xs = c.rcView.left, xe = c.rcView.right;
int ys = c.pt.y, ye = c.rcView.bottom;
if (bOnlyNew)
{
int y1 = editor->nTotalLength-yoffset, y2 = editor->nLastTotalLength-yoffset;
if (y1<y2)
ys = y1, ye = y2+1;
else
ys = ye;
}
if (rcUpdate && ys!=ye)
{
xs = rcUpdate->left, xe = rcUpdate->right;
if (rcUpdate->top > ys)
ys = rcUpdate->top;
if (rcUpdate->bottom < ye)
ye = rcUpdate->bottom;
}
rc.left = xs; /* FIXME remove if it's not necessary anymore */
rc.top = c.pt.y;
rc.right = c.rcView.right;
rc.right = xe;
rc.bottom = c.pt.y+1;
FillRect(hDC, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH));
rc.left = c.rcView.left;
rc.top = c.pt.y+1;
rc.right = c.rcView.right;
rc.bottom = c.rcView.bottom;
FillRect(hDC, &rc, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
if (ys == c.pt.y) /* don't overwrite the top bar */
ys++;
if (ye>ys) {
rc.left = xs;
rc.top = ys;
rc.right = xe;
rc.bottom = ye;
/* this is not supposed to be gray, I know, but lets keep it gray for now for debugging purposes */
FillRect(hDC, &rc, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
}
}
editor->nLastTotalLength = editor->nTotalLength;
ME_DestroyContext(&c);
}
......@@ -120,7 +155,7 @@ void ME_Repaint(ME_TextEditor *editor)
ME_WrapMarkedParagraphs(editor);
hDC = GetDC(editor->hWnd);
ME_HideCaret(editor);
ME_PaintContent(editor, hDC, TRUE);
ME_PaintContent(editor, hDC, TRUE, NULL);
ReleaseDC(editor->hWnd, hDC);
ME_ShowCaret(editor);
}
......
......@@ -172,6 +172,7 @@ void ME_JoinRuns(ME_TextEditor *editor, ME_DisplayItem *p)
int i;
assert(p->type == diRun && pNext->type == diRun);
assert(p->member.run.nCharOfs != -1);
ME_GetParagraph(p)->member.para.nFlags |= MEPF_REWRAP;
for (i=0; i<editor->nCursors; i++) {
if (editor->pCursors[i].pRun == pNext) {
......
......@@ -442,7 +442,7 @@ void ME_WrapMarkedParagraphs(ME_TextEditor *editor) {
}
editor->sizeWindow.cx = c.rcView.right-c.rcView.left;
editor->sizeWindow.cy = c.rcView.bottom-c.rcView.top;
editor->nTotalLength = c.pt.y-c.rcView.top;
editor->nTotalLength = c.pt.y;
ME_DestroyContext(&c);
ReleaseDC(hWnd, hDC);
......
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