2006-01-31 Thomas Kho * dlls/riched20/editor.c, dlls/riched20/tests/editor.c: riched20: implemented EM_SCROLLCARET and EM_GETSCROLLPOS messages Signed-off-by: Thomas Kho diff -Naur sc_conftest/dlls/riched20/editor.c sc_featureimpl/dlls/riched20/editor.c --- sc_conftest/dlls/riched20/editor.c 2006-01-31 16:49:41.161154000 -0800 +++ sc_featureimpl/dlls/riched20/editor.c 2006-01-31 16:50:40.013248000 -0800 @@ -64,7 +64,7 @@ - EM_GETREDONAME 2.0 + EM_GETSEL + EM_GETSELTEXT (ANSI&Unicode) - - EM_GETSCROLLPOS 3.0 + + EM_GETSCROLLPOS 3.0 (only Y value valid) ! - EM_GETTHUMB - EM_GETTEXTEX 2.0 + EM_GETTEXTLENGTHEX (GTL_PRECISE unimplemented) @@ -88,7 +88,7 @@ + EM_REQUESTRESIZE + EM_REPLACESEL (proper style?) ANSI&Unicode - EM_SCROLL - - EM_SCROLLCARET + + EM_SCROLLCARET - EM_SELECTIONTYPE - EM_SETBIDIOPTIONS 3.0 + EM_SETBKGNDCOLOR @@ -1190,7 +1190,6 @@ UNSUPPORTED_MSG(EM_GETOPTIONS) UNSUPPORTED_MSG(EM_GETPASSWORDCHAR) UNSUPPORTED_MSG(EM_GETREDONAME) - UNSUPPORTED_MSG(EM_GETSCROLLPOS) UNSUPPORTED_MSG(EM_GETTEXTMODE) UNSUPPORTED_MSG(EM_GETTYPOGRAPHYOPTIONS) UNSUPPORTED_MSG(EM_GETUNDONAME) @@ -1199,7 +1198,6 @@ UNSUPPORTED_MSG(EM_LIMITTEXT) /* also known as EM_SETLIMITTEXT */ UNSUPPORTED_MSG(EM_PASTESPECIAL) UNSUPPORTED_MSG(EM_SCROLL) - UNSUPPORTED_MSG(EM_SCROLLCARET) UNSUPPORTED_MSG(EM_SELECTIONTYPE) UNSUPPORTED_MSG(EM_SETBIDIOPTIONS) UNSUPPORTED_MSG(EM_SETEDITSTYLE) @@ -1501,6 +1499,41 @@ ME_UpdateRepaint(editor); return 0; } + case EM_SCROLLCARET: + { + int top, bottom; /* row's Y values relative to document top */ + ME_DisplayItem *para, *row; /* paragraph & row that contain with run */ + + row = ME_FindItemBack(editor->pCursors[0].pRun, diStartRow); + para = ME_FindItemBack(row, diParagraph); + top = para->member.para.nYPos + row->member.row.nYPos; + bottom = top + row->member.row.nHeight; + + if ((top < editor->nScrollPosY) + || (editor->nScrollPosY + editor->sizeWindow.cy < bottom)) + { + int dy; + int prevScrollPosY = editor->nScrollPosY; + + if (top < editor->nScrollPosY) /* caret above window */ + editor->nScrollPosY = top; + else /* caret below window */ + editor->nScrollPosY = bottom - editor->sizeWindow.cy; + + if (editor->nScrollPosY < 0) + editor->nScrollPosY = 0; + + dy = prevScrollPosY - editor->nScrollPosY; + SetScrollPos(hWnd, SB_VERT, editor->nScrollPosY, TRUE); + if (editor->bRedraw) + { + ScrollWindow(hWnd, 0, dy, NULL, NULL); + UpdateWindow(hWnd); + } + } + + return 0; + } case WM_SETTEXT: { ME_InternalDeleteText(editor, 0, ME_GetTextLength(editor)); @@ -1661,6 +1694,13 @@ tr.lpstrText = (WCHAR *)lParam; return RichEditANSIWndProc(hWnd, EM_GETTEXTRANGE, 0, (LPARAM)&tr); } + case EM_GETSCROLLPOS: + { + POINT *point = (POINT *)lParam; + point->x = 0; /* FIXME get this */ + point->y = editor->nScrollPosY; + return 1; + } case EM_GETTEXTRANGE: { TEXTRANGEW *rng = (TEXTRANGEW *)lParam; diff -Naur sc_conftest/dlls/riched20/tests/editor.c sc_featureimpl/dlls/riched20/tests/editor.c --- sc_conftest/dlls/riched20/tests/editor.c 2006-01-31 16:50:16.106175000 -0800 +++ sc_featureimpl/dlls/riched20/tests/editor.c 2006-01-31 16:51:48.321867000 -0800 @@ -169,9 +169,7 @@ p.x = -1; p.y = -1; SendMessage(hwnd, EM_GETSCROLLPOS, 0, (LPARAM) &p); - todo_wine { - ok(p.x != -1 && p.y != -1, "p.x:%d p.y:%d\n", p.x, p.y); - } + ok(p.x != -1 && p.y != -1, "p.x:%d p.y:%d\n", p.x, p.y); return p.y; } @@ -212,9 +210,7 @@ prevY = get_scroll_pos_y(hwndRichEdit); SendMessage(hwndRichEdit, EM_SCROLLCARET, 0, 0); curY = get_scroll_pos_y(hwndRichEdit); - todo_wine { - ok(prevY != curY, "%d == %d\n", prevY, curY); - } + ok(prevY != curY, "%d == %d\n", prevY, curY); /* caret below visible window */ move_cursor(hwndRichEdit, sizeof(text) - 1); @@ -222,9 +218,7 @@ prevY = get_scroll_pos_y(hwndRichEdit); SendMessage(hwndRichEdit, EM_SCROLLCARET, 0, 0); curY = get_scroll_pos_y(hwndRichEdit); - todo_wine { - ok(prevY != curY, "%d == %d\n", prevY, curY); - } + ok(prevY != curY, "%d == %d\n", prevY, curY); /* caret in visible window */ move_cursor(hwndRichEdit, sizeof(text) - 2);