riched20: Implement several scrollbar-related messages and styles
Matt Finnicum
mattfinn at gmail.com
Tue Aug 8 15:08:43 CDT 2006
Hi,
This patch adds several scrollbar-related messages and styles to
riched20, and also changes wordpad to properly request the WS_VSCROLL
style.
ChangeLog:
riched20: Implement EM_SHOWSCROLLBAR, EM_SETSCROLLPOS,
ES_DISABLENOSCROLL, and WS_VSCROLL.
wordpad: Request WS_VSCROLL now that riched20 supports it.
--Matt Finnicum
-------------- next part --------------
From d3111f698b61e28893272b40bc752d1ca6e6ee32 Mon Sep 17 00:00:00 2001
From: Matthew Finnicum <MattFinn at gmail.com>
Date: Tue, 8 Aug 2006 13:24:05 -0400
Subject: [PATCH] riched20: Implement some scrollbar-related messages and styles
Implements EM_SHOWSCROLLBAR, EM_SETSCROLLPOS, ES_DISABLENOSCROLL,
and WS_VSCROLL. Adds support for richedit controls that don't want
vertical scrollbars (when long enough to need one). Makes wordpad
request WS_VSCROLL, now that riched20 supports it.
---
dlls/riched20/editor.c | 44 +++++++++++++++++++++++++++++++++++++-------
dlls/riched20/paint.c | 38 +++++++++++++++++++++++---------------
programs/wordpad/wordpad.c | 2 +-
3 files changed, 61 insertions(+), 23 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 1268782..abb97e7 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -87,7 +87,7 @@
+ EM_REDO 2.0
+ EM_REQUESTRESIZE
+ EM_REPLACESEL (proper style?) ANSI&Unicode
- - EM_SCROLL
+ + EM_SCROLL
+ EM_SCROLLCARET
- EM_SELECTIONTYPE
- EM_SETBIDIOPTIONS 3.0
@@ -111,7 +111,7 @@
+ EM_SETRECT
+ EM_SETRECTNP (EM_SETRECT without repainting)
+ EM_SETSEL
- - EM_SETSCROLLPOS 3.0
+ + EM_SETSCROLLPOS 3.0
- EM_SETTABSTOPS 3.0
- EM_SETTARGETDEVICE
+ EM_SETTEXTEX 3.0 (unicode only, no rich text insertion handling, proper style?)
@@ -122,7 +122,7 @@
- EM_SETWORDBREAKPROCEX
- EM_SETWORDWRAPMODE 1.0asian
+ EM_SETZOOM 3.0
- - EM_SHOWSCROLLBAR 2.0
+ + EM_SHOWSCROLLBAR 2.0
- EM_STOPGROUPTYPING 2.0
+ EM_STREAMIN
+ EM_STREAMOUT
@@ -168,7 +168,7 @@
- ES_AUTOHSCROLL
- ES_AUTOVSCROLL
- ES_CENTER
- - ES_DISABLENOSCROLL (scrollbar is always visible)
+ + ES_DISABLENOSCROLL (scrollbar is always visible)
- ES_EX_NOCALLOLEINIT
- ES_LEFT
- ES_MULTILINE (currently single line controls aren't supported)
@@ -182,7 +182,7 @@
- ES_WANTRETURN (don't know how to do WM_GETDLGCODE part)
- WS_SETFONT
- WS_HSCROLL
- - WS_VSCROLL
+ + WS_VSCROLL
*/
/*
@@ -1145,6 +1145,12 @@ ME_TextEditor *ME_MakeEditor(HWND hWnd)
ed->pFontCache[i].nAge = 0;
ed->pFontCache[i].hFont = NULL;
}
+
+ if (GetWindowLongW(hWnd, GWL_STYLE) & WS_HSCROLL)
+ FIXME("WS_HSCROLL requested, but horizontal scrolling isn't implemented yet.\n");
+ ed->bScrollX = 0;
+ ed->bScrollY = GetWindowLongW(hWnd, GWL_STYLE) & WS_VSCROLL;
+
ME_CheckCharOffsets(ed);
if (GetWindowLongW(hWnd, GWL_STYLE) & ES_PASSWORD)
@@ -1437,12 +1443,10 @@ LRESULT WINAPI RichEditANSIWndProc(HWND
UNSUPPORTED_MSG(EM_SETFONTSIZE)
UNSUPPORTED_MSG(EM_SETLANGOPTIONS)
UNSUPPORTED_MSG(EM_SETPALETTE)
- UNSUPPORTED_MSG(EM_SETSCROLLPOS)
UNSUPPORTED_MSG(EM_SETTABSTOPS)
UNSUPPORTED_MSG(EM_SETTARGETDEVICE)
UNSUPPORTED_MSG(EM_SETTYPOGRAPHYOPTIONS)
UNSUPPORTED_MSG(EM_SETWORDBREAKPROCEX)
- UNSUPPORTED_MSG(EM_SHOWSCROLLBAR)
UNSUPPORTED_MSG(WM_STYLECHANGING)
UNSUPPORTED_MSG(WM_STYLECHANGED)
/* UNSUPPORTED_MSG(WM_UNICHAR) FIXME missing in Wine headers */
@@ -1573,6 +1577,14 @@ LRESULT WINAPI RichEditANSIWndProc(HWND
ME_SendSelChange(editor);
return 0;
}
+ case EM_SETSCROLLPOS:
+ {
+ POINT *point = (POINT *)lParam;
+ /* Native behavior when point->y is too large is very odd / dosn't follow MSDN.
+ This seems to be a pretty close approximation of what it does. */
+ ME_Scroll(editor, 0, -(min(point->y, (editor->nTotalLength - 1)) - editor->nScrollPosY));
+ return 0;
+ }
case EM_AUTOURLDETECT:
{
if (wParam==1 || wParam ==0)
@@ -1596,6 +1608,15 @@ LRESULT WINAPI RichEditANSIWndProc(HWND
ME_SendSelChange(editor);
return 0;
}
+ case EM_SHOWSCROLLBAR:
+ {
+ if (wParam == SB_VERT)
+ editor->bScrollY = lParam;
+ else if (wParam == SB_HORZ)
+ editor->bScrollX = lParam;
+ ME_UpdateScrollBar(editor);
+ return 0;
+ }
case EM_SETTEXTEX:
{
LPWSTR wszText = (LPWSTR)lParam;
@@ -2240,6 +2261,15 @@ LRESULT WINAPI RichEditANSIWndProc(HWND
return MAKELONG( pt.x, pt.y );
}
case WM_CREATE:
+ if (GetWindowLongW(hWnd, GWL_STYLE) & WS_HSCROLL)
+ { /* Squelch the default horizontal scrollbar it would make */
+ si.cbSize = sizeof(SCROLLINFO);
+ si.fMask = SIF_POS | SIF_RANGE;
+ si.nMax = 0;
+ si.nMin = 0;
+ si.nPos = 0;
+ SetScrollInfo(hWnd, SB_HORZ, &si, FALSE);
+ }
ME_CommitUndo(editor);
ME_WrapMarkedParagraphs(editor);
ME_MoveCaret(editor);
diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c
index 899f2d0..bc5000c 100644
--- a/dlls/riched20/paint.c
+++ b/dlls/riched20/paint.c
@@ -396,42 +396,50 @@ void ME_UpdateScrollBar(ME_TextEditor *e
{
HWND hWnd = editor->hWnd;
SCROLLINFO si;
- int nOldLen = editor->nTotalLength;
- BOOL bScrollY = (editor->nTotalLength > editor->sizeWindow.cy);
BOOL bUpdateScrollBars;
si.cbSize = sizeof(si);
- si.fMask = SIF_POS | SIF_RANGE;
+ si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
GetScrollInfo(hWnd, SB_VERT, &si);
- bUpdateScrollBars = (bScrollY || editor->bScrollY)&& ((si.nMax != nOldLen) || (si.nPage != editor->sizeWindow.cy));
-
- if (bScrollY != editor->bScrollY)
- {
+ bUpdateScrollBars = (editor->bScrollY)&& ((si.nMax != editor->nTotalLength) || (si.nPage != editor->sizeWindow.cy));
+
+ if (editor->bScrollY != (si.nMax > 0))
+ { /* The scroll bar needs to be shown or hidden */
si.fMask = SIF_RANGE | SIF_PAGE;
+ if (GetWindowLongW(hWnd, GWL_STYLE) & ES_DISABLENOSCROLL)
+ si.fMask |= SIF_DISABLENOSCROLL;
+
si.nMin = 0;
si.nPage = editor->sizeWindow.cy;
- if (bScrollY) {
+
+ if (editor->bScrollY)
si.nMax = editor->nTotalLength;
- } else {
+ else
si.nMax = 0;
- }
+
SetScrollInfo(hWnd, SB_VERT, &si, FALSE);
ME_MarkAllForWrapping(editor);
- editor->bScrollY = bScrollY;
ME_WrapMarkedParagraphs(editor);
+
bUpdateScrollBars = TRUE;
}
- if (bUpdateScrollBars) {
+ if (bUpdateScrollBars)
+ {
int nScroll = 0;
si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS;
- if (editor->nTotalLength > editor->sizeWindow.cy) {
+ if (GetWindowLongW(hWnd, GWL_STYLE) & ES_DISABLENOSCROLL)
+ si.fMask |= SIF_DISABLENOSCROLL;
+ if (editor->bScrollY)
+ {
si.nMax = editor->nTotalLength;
si.nPage = editor->sizeWindow.cy;
- if (si.nPos > si.nMax-si.nPage) {
+ if (si.nPos > si.nMax-si.nPage)
+ {
nScroll = (si.nMax-si.nPage)-si.nPos;
si.nPos = si.nMax-si.nPage;
}
}
- else {
+ else
+ {
si.nMax = 0;
si.nPage = 0;
si.nPos = 0;
diff --git a/programs/wordpad/wordpad.c b/programs/wordpad/wordpad.c
index 0abe457..7ca54e6 100644
--- a/programs/wordpad/wordpad.c
+++ b/programs/wordpad/wordpad.c
@@ -133,7 +133,7 @@ static LRESULT OnCreate( HWND hWnd, WPAR
assert(hDLL);
hEditorWnd = CreateWindowExW(WS_EX_CLIENTEDGE, wszRichEditClass, NULL,
- WS_CHILD|WS_VISIBLE|ES_MULTILINE|ES_AUTOVSCROLL|ES_WANTRETURN,
+ WS_CHILD|WS_VISIBLE|ES_MULTILINE|ES_AUTOVSCROLL|ES_WANTRETURN|WS_VSCROLL,
0, 0, 1000, 100, hWnd, (HMENU)IDC_EDITOR, hInstance, NULL);
if (!hEditorWnd)
{
--
1.4.1.1
More information about the wine-patches
mailing list