riched20: Keep track of the current scrollbar state.
Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
39f5c438c5
commit
9685d5d62c
|
@ -3012,12 +3012,14 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
|
||||||
ed->vert_si.nMax = 0;
|
ed->vert_si.nMax = 0;
|
||||||
ed->vert_si.nPage = 0;
|
ed->vert_si.nPage = 0;
|
||||||
ed->vert_si.nPos = 0;
|
ed->vert_si.nPos = 0;
|
||||||
|
ed->vert_sb_enabled = 0;
|
||||||
|
|
||||||
ed->horz_si.cbSize = sizeof(SCROLLINFO);
|
ed->horz_si.cbSize = sizeof(SCROLLINFO);
|
||||||
ed->horz_si.nMin = 0;
|
ed->horz_si.nMin = 0;
|
||||||
ed->horz_si.nMax = 0;
|
ed->horz_si.nMax = 0;
|
||||||
ed->horz_si.nPage = 0;
|
ed->horz_si.nPage = 0;
|
||||||
ed->horz_si.nPos = 0;
|
ed->horz_si.nPos = 0;
|
||||||
|
ed->horz_sb_enabled = 0;
|
||||||
|
|
||||||
if (ed->scrollbars & ES_DISABLENOSCROLL)
|
if (ed->scrollbars & ES_DISABLENOSCROLL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -428,6 +428,8 @@ typedef struct tagME_TextEditor
|
||||||
|
|
||||||
/* Cache previously set scrollbar info */
|
/* Cache previously set scrollbar info */
|
||||||
SCROLLINFO vert_si, horz_si;
|
SCROLLINFO vert_si, horz_si;
|
||||||
|
unsigned int vert_sb_enabled : 1;
|
||||||
|
unsigned int horz_sb_enabled : 1;
|
||||||
|
|
||||||
int caret_height;
|
int caret_height;
|
||||||
BOOL caret_hidden;
|
BOOL caret_hidden;
|
||||||
|
|
|
@ -1073,15 +1073,14 @@ void ME_ScrollAbs(ME_TextEditor *editor, int x, int y)
|
||||||
if (editor->scrollbars & WS_HSCROLL)
|
if (editor->scrollbars & WS_HSCROLL)
|
||||||
{
|
{
|
||||||
old_vis = winStyle & WS_HSCROLL;
|
old_vis = winStyle & WS_HSCROLL;
|
||||||
new_vis = editor->nTotalWidth > editor->sizeWindow.cx || editor->scrollbars & ES_DISABLENOSCROLL;
|
new_vis = editor->horz_sb_enabled || editor->scrollbars & ES_DISABLENOSCROLL;
|
||||||
if (!old_vis ^ !new_vis) ITextHost_TxShowScrollBar( editor->texthost, SB_HORZ, new_vis );
|
if (!old_vis ^ !new_vis) ITextHost_TxShowScrollBar( editor->texthost, SB_HORZ, new_vis );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (editor->scrollbars & WS_VSCROLL)
|
if (editor->scrollbars & WS_VSCROLL)
|
||||||
{
|
{
|
||||||
old_vis = winStyle & WS_VSCROLL;
|
old_vis = winStyle & WS_VSCROLL;
|
||||||
new_vis = (editor->nTotalLength > editor->sizeWindow.cy && editor->props & TXTBIT_MULTILINE) ||
|
new_vis = editor->vert_sb_enabled || editor->scrollbars & ES_DISABLENOSCROLL;
|
||||||
editor->scrollbars & ES_DISABLENOSCROLL;
|
|
||||||
if (!old_vis ^ !new_vis) ITextHost_TxShowScrollBar( editor->texthost, SB_VERT, new_vis );
|
if (!old_vis ^ !new_vis) ITextHost_TxShowScrollBar( editor->texthost, SB_VERT, new_vis );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1118,25 +1117,13 @@ void ME_ScrollRight(ME_TextEditor *editor, int cx)
|
||||||
ME_HScrollAbs(editor, editor->horz_si.nPos + cx);
|
ME_HScrollAbs(editor, editor->horz_si.nPos + cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculates the visibility after a call to SetScrollRange or
|
|
||||||
* SetScrollInfo with SIF_RANGE. */
|
|
||||||
static BOOL ME_PostSetScrollRangeVisibility(SCROLLINFO *si)
|
|
||||||
{
|
|
||||||
if (si->fMask & SIF_DISABLENOSCROLL)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
/* This must match the check in SetScrollInfo to determine whether
|
|
||||||
* to show or hide the scrollbars. */
|
|
||||||
return si->nMin < si->nMax - max(si->nPage - 1, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ME_UpdateScrollBar(ME_TextEditor *editor)
|
void ME_UpdateScrollBar(ME_TextEditor *editor)
|
||||||
{
|
{
|
||||||
/* Note that this is the only function that should ever call
|
/* Note that this is the only function that should ever call
|
||||||
* SetScrollInfo with SIF_PAGE or SIF_RANGE. */
|
* SetScrollInfo with SIF_PAGE or SIF_RANGE. */
|
||||||
|
|
||||||
SCROLLINFO si;
|
SCROLLINFO si;
|
||||||
BOOL bScrollBarWasVisible, bScrollBarWillBeVisible;
|
BOOL enable;
|
||||||
|
|
||||||
if (ME_WrapMarkedParagraphs(editor))
|
if (ME_WrapMarkedParagraphs(editor))
|
||||||
FIXME("ME_UpdateScrollBar had to call ME_WrapMarkedParagraphs\n");
|
FIXME("ME_UpdateScrollBar had to call ME_WrapMarkedParagraphs\n");
|
||||||
|
@ -1148,13 +1135,11 @@ void ME_UpdateScrollBar(ME_TextEditor *editor)
|
||||||
si.fMask |= SIF_DISABLENOSCROLL;
|
si.fMask |= SIF_DISABLENOSCROLL;
|
||||||
|
|
||||||
/* Update horizontal scrollbar */
|
/* Update horizontal scrollbar */
|
||||||
bScrollBarWasVisible = editor->horz_si.nMax > editor->horz_si.nPage;
|
enable = editor->nTotalWidth > editor->sizeWindow.cx;
|
||||||
bScrollBarWillBeVisible = editor->nTotalWidth > editor->sizeWindow.cx;
|
if (editor->horz_si.nPos && !enable)
|
||||||
if (editor->horz_si.nPos && !bScrollBarWillBeVisible)
|
|
||||||
{
|
{
|
||||||
ME_HScrollAbs(editor, 0);
|
ME_HScrollAbs(editor, 0);
|
||||||
/* ME_HScrollAbs will call this function,
|
/* ME_HScrollAbs will call this function, so nothing else needs to be done here. */
|
||||||
* so nothing else needs to be done here. */
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1168,8 +1153,7 @@ void ME_UpdateScrollBar(ME_TextEditor *editor)
|
||||||
TRACE("min=%d max=%d page=%d\n", si.nMin, si.nMax, si.nPage);
|
TRACE("min=%d max=%d page=%d\n", si.nMin, si.nMax, si.nPage);
|
||||||
editor->horz_si.nMax = si.nMax;
|
editor->horz_si.nMax = si.nMax;
|
||||||
editor->horz_si.nPage = si.nPage;
|
editor->horz_si.nPage = si.nPage;
|
||||||
if ((bScrollBarWillBeVisible || bScrollBarWasVisible) &&
|
if ((enable || editor->horz_sb_enabled) && editor->scrollbars & WS_HSCROLL)
|
||||||
editor->scrollbars & WS_HSCROLL)
|
|
||||||
{
|
{
|
||||||
if (si.nMax > 0xFFFF)
|
if (si.nMax > 0xFFFF)
|
||||||
{
|
{
|
||||||
|
@ -1183,29 +1167,25 @@ void ME_UpdateScrollBar(ME_TextEditor *editor)
|
||||||
ITextHost_TxSetScrollRange(editor->texthost, SB_HORZ, si.nMin, si.nMax, FALSE);
|
ITextHost_TxSetScrollRange(editor->texthost, SB_HORZ, si.nMin, si.nMax, FALSE);
|
||||||
ITextHost_TxSetScrollPos(editor->texthost, SB_HORZ, si.nPos, TRUE);
|
ITextHost_TxSetScrollPos(editor->texthost, SB_HORZ, si.nPos, TRUE);
|
||||||
}
|
}
|
||||||
/* SetScrollInfo or SetScrollRange change scrollbar visibility. */
|
|
||||||
bScrollBarWasVisible = ME_PostSetScrollRangeVisibility(&si);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (editor->scrollbars & WS_HSCROLL)
|
if (editor->scrollbars & WS_HSCROLL && !enable ^ !editor->horz_sb_enabled)
|
||||||
{
|
{
|
||||||
if (si.fMask & SIF_DISABLENOSCROLL) bScrollBarWillBeVisible = TRUE;
|
if (enable || editor->scrollbars & ES_DISABLENOSCROLL)
|
||||||
|
ITextHost_TxEnableScrollBar( editor->texthost, SB_HORZ, enable ? 0 : ESB_DISABLE_BOTH );
|
||||||
if (bScrollBarWasVisible != bScrollBarWillBeVisible)
|
if (!(editor->scrollbars & ES_DISABLENOSCROLL))
|
||||||
ITextHost_TxShowScrollBar(editor->texthost, SB_HORZ, bScrollBarWillBeVisible);
|
ITextHost_TxShowScrollBar( editor->texthost, SB_HORZ, enable );
|
||||||
|
editor->horz_sb_enabled = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update vertical scrollbar */
|
/* Update vertical scrollbar */
|
||||||
bScrollBarWasVisible = editor->vert_si.nMax > editor->vert_si.nPage;
|
enable = editor->nTotalLength > editor->sizeWindow.cy && (editor->props & TXTBIT_MULTILINE);
|
||||||
bScrollBarWillBeVisible = editor->nTotalLength > editor->sizeWindow.cy &&
|
|
||||||
(editor->props & TXTBIT_MULTILINE);
|
|
||||||
|
|
||||||
if (editor->vert_si.nPos && !bScrollBarWillBeVisible)
|
if (editor->vert_si.nPos && !enable)
|
||||||
{
|
{
|
||||||
ME_VScrollAbs(editor, 0);
|
ME_VScrollAbs(editor, 0);
|
||||||
/* ME_VScrollAbs will call this function,
|
/* ME_VScrollAbs will call this function, so nothing else needs to be done here. */
|
||||||
* so nothing else needs to be done here. */
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1219,8 +1199,7 @@ void ME_UpdateScrollBar(ME_TextEditor *editor)
|
||||||
TRACE("min=%d max=%d page=%d\n", si.nMin, si.nMax, si.nPage);
|
TRACE("min=%d max=%d page=%d\n", si.nMin, si.nMax, si.nPage);
|
||||||
editor->vert_si.nMax = si.nMax;
|
editor->vert_si.nMax = si.nMax;
|
||||||
editor->vert_si.nPage = si.nPage;
|
editor->vert_si.nPage = si.nPage;
|
||||||
if ((bScrollBarWillBeVisible || bScrollBarWasVisible) &&
|
if ((enable || editor->vert_sb_enabled) && editor->scrollbars & WS_VSCROLL)
|
||||||
editor->scrollbars & WS_VSCROLL)
|
|
||||||
{
|
{
|
||||||
if (si.nMax > 0xFFFF)
|
if (si.nMax > 0xFFFF)
|
||||||
{
|
{
|
||||||
|
@ -1234,18 +1213,16 @@ void ME_UpdateScrollBar(ME_TextEditor *editor)
|
||||||
ITextHost_TxSetScrollRange(editor->texthost, SB_VERT, si.nMin, si.nMax, FALSE);
|
ITextHost_TxSetScrollRange(editor->texthost, SB_VERT, si.nMin, si.nMax, FALSE);
|
||||||
ITextHost_TxSetScrollPos(editor->texthost, SB_VERT, si.nPos, TRUE);
|
ITextHost_TxSetScrollPos(editor->texthost, SB_VERT, si.nPos, TRUE);
|
||||||
}
|
}
|
||||||
/* SetScrollInfo or SetScrollRange change scrollbar visibility. */
|
|
||||||
bScrollBarWasVisible = ME_PostSetScrollRangeVisibility(&si);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (editor->scrollbars & WS_VSCROLL)
|
if (editor->scrollbars & WS_VSCROLL && !enable ^ !editor->vert_sb_enabled)
|
||||||
{
|
{
|
||||||
if (si.fMask & SIF_DISABLENOSCROLL) bScrollBarWillBeVisible = TRUE;
|
if (enable || editor->scrollbars & ES_DISABLENOSCROLL)
|
||||||
|
ITextHost_TxEnableScrollBar( editor->texthost, SB_VERT, enable ? 0 : ESB_DISABLE_BOTH );
|
||||||
if (bScrollBarWasVisible != bScrollBarWillBeVisible)
|
if (!(editor->scrollbars & ES_DISABLENOSCROLL))
|
||||||
ITextHost_TxShowScrollBar(editor->texthost, SB_VERT,
|
ITextHost_TxShowScrollBar( editor->texthost, SB_VERT, enable );
|
||||||
bScrollBarWillBeVisible);
|
editor->vert_sb_enabled = enable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue