mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
SetScrollInfo() now repaints the scrollbars if needed
svn path=/trunk/; revision=6213
This commit is contained in:
parent
e2486f18e3
commit
9dc187ebe5
2 changed files with 90 additions and 12 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: scrollbar.c,v 1.18 2003/09/25 21:16:56 weiden Exp $
|
/* $Id: scrollbar.c,v 1.19 2003/10/02 23:21:42 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -65,6 +65,56 @@ static BOOL SCROLL_trackVertical;
|
||||||
/* INTERNAL FUNCTIONS *********************************************************/
|
/* INTERNAL FUNCTIONS *********************************************************/
|
||||||
|
|
||||||
HBRUSH DefWndControlColor (HDC hDC, UINT ctlType);
|
HBRUSH DefWndControlColor (HDC hDC, UINT ctlType);
|
||||||
|
void
|
||||||
|
SCROLL_DrawScrollBar (HWND hwnd, HDC hdc, INT nBar,
|
||||||
|
BOOL arrows, BOOL interior);
|
||||||
|
|
||||||
|
static void
|
||||||
|
SCROLL_DrawChanges(HWND hwnd, int sBar, DWORD Changes)
|
||||||
|
{
|
||||||
|
HDC dc;
|
||||||
|
SCROLLBARINFO sbi;
|
||||||
|
BOOL btns = FALSE, interior = FALSE;
|
||||||
|
|
||||||
|
sbi.cbSize = sizeof(SCROLLBARINFO);
|
||||||
|
switch(sBar)
|
||||||
|
{
|
||||||
|
case SB_VERT:
|
||||||
|
NtUserGetScrollBarInfo (hwnd, OBJID_HSCROLL, &sbi);
|
||||||
|
break;
|
||||||
|
case SB_HORZ:
|
||||||
|
NtUserGetScrollBarInfo (hwnd, OBJID_VSCROLL, &sbi);
|
||||||
|
break;
|
||||||
|
case SB_CTL:
|
||||||
|
NtUserGetScrollBarInfo (hwnd, OBJID_CLIENT, &sbi);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
dc = GetWindowDC(hwnd);
|
||||||
|
if(dc)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(Changes & SBU_TOPRIGHT)
|
||||||
|
{
|
||||||
|
btns = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Changes & SBU_BOTTOMLEFT)
|
||||||
|
{
|
||||||
|
btns = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Changes & SBU_SCROLLBOX)
|
||||||
|
{
|
||||||
|
interior = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FIXME - draw it directly */
|
||||||
|
SCROLL_DrawScrollBar(hwnd, dc, sBar, btns, interior);
|
||||||
|
|
||||||
|
ReleaseDC(hwnd, dc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Ported from WINE20020904 */
|
/* Ported from WINE20020904 */
|
||||||
/* Draw the scroll bar interior (everything except the arrows). */
|
/* Draw the scroll bar interior (everything except the arrows). */
|
||||||
|
@ -512,7 +562,7 @@ SetScrollInfo (HWND hwnd, int fnBar, LPCSCROLLINFO lpsi, WINBOOL fRedraw)
|
||||||
int Ret = (int)NtUserSetScrollInfo(hwnd, fnBar, (LPSCROLLINFO)lpsi, &Changed);
|
int Ret = (int)NtUserSetScrollInfo(hwnd, fnBar, (LPSCROLLINFO)lpsi, &Changed);
|
||||||
if(fRedraw && Changed)
|
if(fRedraw && Changed)
|
||||||
{
|
{
|
||||||
|
SCROLL_DrawChanges(hwnd, fnBar, Changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ret;
|
return Ret;
|
||||||
|
@ -545,6 +595,10 @@ SetScrollPos (HWND hWnd, int nBar, int nPos, WINBOOL bRedraw)
|
||||||
si.nPos = nPos;
|
si.nPos = nPos;
|
||||||
/* finally set the new position */
|
/* finally set the new position */
|
||||||
NtUserSetScrollInfo(hWnd, nBar, &si, &Action);
|
NtUserSetScrollInfo(hWnd, nBar, &si, &Action);
|
||||||
|
if(Action && bRedraw)
|
||||||
|
{
|
||||||
|
SCROLL_DrawChanges(hWnd, nBar, Action);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -570,6 +624,11 @@ SetScrollRange (HWND hWnd,
|
||||||
NtUserSetScrollInfo(hWnd, nBar, &si, &Action);
|
NtUserSetScrollInfo(hWnd, nBar, &si, &Action);
|
||||||
/* FIXME - check if called successfully */
|
/* FIXME - check if called successfully */
|
||||||
|
|
||||||
|
if(Action && bRedraw)
|
||||||
|
{
|
||||||
|
SCROLL_DrawChanges(hWnd, nBar, Action);
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: scrollbar.c,v 1.15 2003/09/24 13:41:40 weiden Exp $
|
/* $Id: scrollbar.c,v 1.16 2003/10/02 23:21:42 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -312,6 +312,7 @@ IntSetScrollInfo(PWINDOW_OBJECT Window, INT nBar, LPSCROLLINFO lpsi, DWORD *Acti
|
||||||
BOOL Chg = FALSE;
|
BOOL Chg = FALSE;
|
||||||
UINT Mask;
|
UINT Mask;
|
||||||
DWORD Ret;
|
DWORD Ret;
|
||||||
|
int old;
|
||||||
|
|
||||||
if(((lpsi->cbSize != sizeof(SCROLLINFO)) &&
|
if(((lpsi->cbSize != sizeof(SCROLLINFO)) &&
|
||||||
(lpsi->cbSize != sizeof(SCROLLINFO) - sizeof(lpsi->nTrackPos))))
|
(lpsi->cbSize != sizeof(SCROLLINFO) - sizeof(lpsi->nTrackPos))))
|
||||||
|
@ -391,29 +392,37 @@ IntSetScrollInfo(PWINDOW_OBJECT Window, INT nBar, LPSCROLLINFO lpsi, DWORD *Acti
|
||||||
|
|
||||||
if((Mask & SIF_PAGE) && (psi->nPage != lpsi->nPage))
|
if((Mask & SIF_PAGE) && (psi->nPage != lpsi->nPage))
|
||||||
{
|
{
|
||||||
|
old = psi->nPage;
|
||||||
psi->nPage = lpsi->nPage;
|
psi->nPage = lpsi->nPage;
|
||||||
Chg = TRUE;
|
|
||||||
if(Action)
|
|
||||||
*Action |= SBU_SCROLLBOX;
|
|
||||||
if(psi->nPage < 0) psi->nPage = 0;
|
if(psi->nPage < 0) psi->nPage = 0;
|
||||||
else if(psi->nPage > psi->nMax - psi->nMin + 1)
|
else if(psi->nPage > psi->nMax - psi->nMin + 1)
|
||||||
psi->nPage = psi->nMax - psi->nMin + 1;
|
psi->nPage = psi->nMax - psi->nMin + 1;
|
||||||
|
|
||||||
|
if(old != psi->nPage)
|
||||||
|
{
|
||||||
|
Chg = TRUE;
|
||||||
|
if(Action)
|
||||||
|
*Action |= SBU_SCROLLBOX;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((Mask & SIF_POS) && (psi->nPos != lpsi->nPos))
|
if((Mask & SIF_POS) && (psi->nPos != lpsi->nPos))
|
||||||
{
|
{
|
||||||
|
old = psi->nPos;
|
||||||
psi->nPos = lpsi->nPos;
|
psi->nPos = lpsi->nPos;
|
||||||
Chg = TRUE;
|
|
||||||
if(Action)
|
|
||||||
*Action |= SBU_SCROLLBOX;
|
|
||||||
if(psi->nPos < psi->nMin)
|
if(psi->nPos < psi->nMin)
|
||||||
psi->nPos = psi->nMin;
|
psi->nPos = psi->nMin;
|
||||||
else if(psi->nPos > psi->nMax - max(psi->nPage - 1, 0))
|
else if(psi->nPos > psi->nMax - max(psi->nPage - 1, 0))
|
||||||
psi->nPos = psi->nMax - max(psi->nPage - 1, 0);
|
psi->nPos = psi->nMax - max(psi->nPage - 1, 0);
|
||||||
|
|
||||||
|
if(old != psi->nPos)
|
||||||
|
{
|
||||||
|
Chg = TRUE;
|
||||||
|
if(Action)
|
||||||
|
*Action |= SBU_SCROLLBOX;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME check assigned values */
|
|
||||||
|
|
||||||
Ret = psi->nPos;
|
Ret = psi->nPos;
|
||||||
|
|
||||||
return Ret;
|
return Ret;
|
||||||
|
@ -648,15 +657,17 @@ NtUserGetScrollInfo(HWND hwnd, int fnBar, LPSCROLLINFO lpsi)
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PWINDOW_OBJECT Window;
|
PWINDOW_OBJECT Window;
|
||||||
SCROLLINFO psi;
|
SCROLLINFO psi;
|
||||||
|
DWORD sz;
|
||||||
BOOL Ret;
|
BOOL Ret;
|
||||||
|
|
||||||
Status = MmCopyFromCaller(&psi, lpsi, sizeof(SCROLLINFO) - sizeof(psi.nTrackPos));
|
Status = MmCopyFromCaller(&psi, lpsi, sizeof(SCROLLINFO) - sizeof(psi.nTrackPos));
|
||||||
if(!NT_SUCCESS(Status) ||
|
if(!NT_SUCCESS(Status) ||
|
||||||
(psi.cbSize != sizeof(SCROLLINFO)) || (psi.cbSize != sizeof(SCROLLINFO) - sizeof(psi.nTrackPos)))
|
!((psi.cbSize == sizeof(SCROLLINFO)) || (psi.cbSize == sizeof(SCROLLINFO) - sizeof(psi.nTrackPos))))
|
||||||
{
|
{
|
||||||
SetLastNtError(Status);
|
SetLastNtError(Status);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
sz = psi.cbSize;
|
||||||
|
|
||||||
Window = IntGetWindowObject(hwnd);
|
Window = IntGetWindowObject(hwnd);
|
||||||
|
|
||||||
|
@ -669,6 +680,14 @@ NtUserGetScrollInfo(HWND hwnd, int fnBar, LPSCROLLINFO lpsi)
|
||||||
Ret = IntGetScrollInfo(Window, fnBar, &psi);
|
Ret = IntGetScrollInfo(Window, fnBar, &psi);
|
||||||
|
|
||||||
IntReleaseWindowObject(Window);
|
IntReleaseWindowObject(Window);
|
||||||
|
|
||||||
|
Status = MmCopyToCaller(lpsi, &psi, sz);
|
||||||
|
if(!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
SetLastNtError(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
return Ret;
|
return Ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue