BOOL FASTCALL co_IntGetScrollBarInfo(PWND Window, LONG idObject, PSCROLLBARINFO psbi) { INT Bar; PSCROLLBARINFO sbi; PSBDATA pSBData; ASSERT_REFS_CO(Window); Bar = SBOBJ_TO_SBID(idObject); if(!SBID_IS_VALID(Bar)) { EngSetLastError(ERROR_INVALID_PARAMETER); ERR("Trying to get scrollinfo for unknown scrollbar type %d\n", Bar); return FALSE; } if(!co_IntCreateScrollBars(Window)) { ERR("Failed to create scrollbars for window.\n"); return FALSE; } sbi = IntGetScrollbarInfoFromWindow(Window, Bar); pSBData = IntGetSBData(Window, Bar); IntGetScrollBarRect(Window, Bar, &(sbi->rcScrollBar)); IntCalculateThumb(Window, Bar, sbi, pSBData); RtlCopyMemory(psbi, sbi, sizeof(SCROLLBARINFO)); return TRUE; }
BOOL FASTCALL co_IntSetScrollBarInfo(PWND Window, LONG idObject, PSETSCROLLBARINFO psbi) { INT Bar; PSCROLLBARINFO sbi; LPSCROLLINFO psi; ASSERT_REFS_CO(Window); Bar = SBOBJ_TO_SBID(idObject); if(!SBID_IS_VALID(Bar)) { EngSetLastError(ERROR_INVALID_PARAMETER); ERR("Trying to get scrollinfo for unknown scrollbar type %d\n", Bar); return FALSE; } if(!co_IntCreateScrollBars(Window)) { ERR("Failed to create scrollbars for window.\n"); return FALSE; } sbi = IntGetScrollbarInfoFromWindow(Window, Bar); psi = IntGetScrollInfoFromWindow(Window, Bar); psi->nTrackPos = psbi->nTrackPos; sbi->reserved = psbi->reserved; RtlCopyMemory(&sbi->rgstate, &psbi->rgstate, sizeof(psbi->rgstate)); return TRUE; }
/* static VOID FASTCALL IntUpdateSBInfo(PWND Window, int wBar) { PSCROLLBARINFO sbi; PSBDATA pSBData; ASSERT(Window); ASSERT(Window->pSBInfo); ASSERT(Window->pSBInfoex); sbi = IntGetScrollbarInfoFromWindow(Window, wBar); pSBData = IntGetSBData(Window, wBar); IntGetScrollBarRect(Window, wBar, &(sbi->rcScrollBar)); IntCalculateThumb(Window, wBar, sbi, pSBData); } */ static BOOL FASTCALL co_IntGetScrollInfo(PWND Window, INT nBar, PSBDATA pSBData, LPSCROLLINFO lpsi) { UINT Mask; LPSCROLLINFO psi; ASSERT_REFS_CO(Window); if(!SBID_IS_VALID(nBar)) { EngSetLastError(ERROR_INVALID_PARAMETER); ERR("Trying to get scrollinfo for unknown scrollbar type %d\n", nBar); return FALSE; } if (!Window->pSBInfo) { ERR("IntGetScrollInfo No window scrollbar info!\n"); return FALSE; } psi = IntGetScrollInfoFromWindow(Window, nBar); if (lpsi->fMask == SIF_ALL) { Mask = SIF_PAGE | SIF_POS | SIF_RANGE | SIF_TRACKPOS; } else { Mask = lpsi->fMask; } if (0 != (Mask & SIF_PAGE)) { lpsi->nPage = psi->nPage; } if (0 != (Mask & SIF_POS)) { lpsi->nPos = psi->nPos; } if (0 != (Mask & SIF_RANGE)) { lpsi->nMin = psi->nMin; lpsi->nMax = psi->nMax; } if (0 != (Mask & SIF_TRACKPOS)) { lpsi->nTrackPos = psi->nTrackPos; } return TRUE; }
BOOL FASTCALL NEWco_IntGetScrollInfo( PWND pWnd, INT nBar, PSBDATA pSBData, LPSCROLLINFO lpsi) { UINT Mask; PSBTRACK pSBTrack = pWnd->head.pti->pSBTrack; if (!SBID_IS_VALID(nBar)) { EngSetLastError(ERROR_INVALID_PARAMETER); ERR("Trying to get scrollinfo for unknown scrollbar type %d\n", nBar); return FALSE; } if (!pWnd->pSBInfo || !pSBTrack) return FALSE; Mask = lpsi->fMask; if (0 != (Mask & SIF_PAGE)) { lpsi->nPage = pSBData->page; } if (0 != (Mask & SIF_POS)) { lpsi->nPos = pSBData->pos; } if (0 != (Mask & SIF_RANGE)) { lpsi->nMin = pSBData->posMin; lpsi->nMax = pSBData->posMax; } if (0 != (Mask & SIF_TRACKPOS)) { if ( pSBTrack && pSBTrack->nBar == nBar && pSBTrack->spwndTrack == pWnd ) lpsi->nTrackPos = pSBTrack->posNew; else lpsi->nTrackPos = pSBData->pos; } return (Mask & SIF_ALL) !=0; }
static DWORD FASTCALL co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw) { /* * Update the scrollbar state and set action flags according to * what has to be done graphics wise. */ LPSCROLLINFO Info; PSCROLLBARINFO psbi; UINT new_flags; INT action = 0; PSBDATA pSBData; DWORD OldPos = 0; BOOL bChangeParams = FALSE; /* Don't show/hide scrollbar if params don't change */ UINT MaxPage; int MaxPos; ASSERT_REFS_CO(Window); if(!SBID_IS_VALID(nBar)) { EngSetLastError(ERROR_INVALID_PARAMETER); ERR("Trying to set scrollinfo for unknown scrollbar type %d", nBar); return FALSE; } if(!co_IntCreateScrollBars(Window)) { return FALSE; } if (lpsi->cbSize != sizeof(SCROLLINFO) && lpsi->cbSize != (sizeof(SCROLLINFO) - sizeof(lpsi->nTrackPos))) { EngSetLastError(ERROR_INVALID_PARAMETER); return 0; } if (lpsi->fMask & ~(SIF_ALL | SIF_DISABLENOSCROLL | SIF_PREVIOUSPOS)) { EngSetLastError(ERROR_INVALID_PARAMETER); return 0; } psbi = IntGetScrollbarInfoFromWindow(Window, nBar); Info = IntGetScrollInfoFromWindow(Window, nBar); pSBData = IntGetSBData(Window, nBar); /* Set the page size */ if (lpsi->fMask & SIF_PAGE) { if (Info->nPage != lpsi->nPage) { Info->nPage = lpsi->nPage; pSBData->page = lpsi->nPage; bChangeParams = TRUE; } } /* Set the scroll pos */ if (lpsi->fMask & SIF_POS) { if (Info->nPos != lpsi->nPos) { OldPos = Info->nPos; Info->nPos = lpsi->nPos; pSBData->pos = lpsi->nPos; bChangeParams = TRUE; } } /* Set the scroll range */ if (lpsi->fMask & SIF_RANGE) { if (lpsi->nMin > lpsi->nMax) { Info->nMin = lpsi->nMin; Info->nMax = lpsi->nMin; pSBData->posMin = lpsi->nMin; pSBData->posMax = lpsi->nMin; bChangeParams = TRUE; } else if (Info->nMin != lpsi->nMin || Info->nMax != lpsi->nMax) { Info->nMin = lpsi->nMin; Info->nMax = lpsi->nMax; pSBData->posMin = lpsi->nMin; pSBData->posMax = lpsi->nMax; bChangeParams = TRUE; } } /* Make sure the page size is valid */ MaxPage = abs(Info->nMax - Info->nMin) + 1; if (Info->nPage > MaxPage) { pSBData->page = Info->nPage = MaxPage; } /* Make sure the pos is inside the range */ MaxPos = Info->nMax + 1 - (int)max(Info->nPage, 1); ASSERT(MaxPos >= Info->nMin); if (Info->nPos < Info->nMin) { pSBData->pos = Info->nPos = Info->nMin; } else if (Info->nPos > MaxPos) { pSBData->pos = Info->nPos = MaxPos; } /* * Don't change the scrollbar state if SetScrollInfo is just called * with SIF_DISABLENOSCROLL */ if (!(lpsi->fMask & SIF_ALL)) { //goto done; return lpsi->fMask & SIF_PREVIOUSPOS ? OldPos : pSBData->pos; } /* Check if the scrollbar should be hidden or disabled */ if (lpsi->fMask & (SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL)) { new_flags = Window->pSBInfo->WSBflags; if (Info->nMin >= (int)(Info->nMax - max(Info->nPage - 1, 0))) { /* Hide or disable scroll-bar */ if (lpsi->fMask & SIF_DISABLENOSCROLL) { new_flags = ESB_DISABLE_BOTH; bChangeParams = TRUE; } else if ((nBar != SB_CTL) && bChangeParams) { action = SA_SSI_HIDE; } } else /* Show and enable scroll-bar only if no page only changed. */ if (lpsi->fMask != SIF_PAGE) { new_flags = ESB_ENABLE_BOTH; if ((nBar != SB_CTL) && bChangeParams) { action |= SA_SSI_SHOW; } } if (Window->pSBInfo->WSBflags != new_flags) /* Check arrow flags */ { Window->pSBInfo->WSBflags = new_flags; action |= SA_SSI_REPAINT_ARROWS; } } //done: if ( action & SA_SSI_HIDE ) { co_UserShowScrollBar(Window, nBar, FALSE, FALSE); } else { if ( action & SA_SSI_SHOW ) if ( co_UserShowScrollBar(Window, nBar, TRUE, TRUE) ) return lpsi->fMask & SIF_PREVIOUSPOS ? OldPos : pSBData->pos; /* SetWindowPos() already did the painting */ if (bRedraw) { // FIXME: Arrows and interior. RECTL UpdateRect = psbi->rcScrollBar; UpdateRect.left -= Window->rcClient.left - Window->rcWindow.left; UpdateRect.right -= Window->rcClient.left - Window->rcWindow.left; UpdateRect.top -= Window->rcClient.top - Window->rcWindow.top; UpdateRect.bottom -= Window->rcClient.top - Window->rcWindow.top; co_UserRedrawWindow(Window, &UpdateRect, 0, RDW_INVALIDATE | RDW_FRAME); } // FIXME: Arrows /* else if( action & SA_SSI_REPAINT_ARROWS ) { RECTL UpdateRect = psbi->rcScrollBar; UpdateRect.left -= Window->rcClient.left - Window->rcWindow.left; UpdateRect.right -= Window->rcClient.left - Window->rcWindow.left; UpdateRect.top -= Window->rcClient.top - Window->rcWindow.top; UpdateRect.bottom -= Window->rcClient.top - Window->rcWindow.top; co_UserRedrawWindow(Window, &UpdateRect, 0, RDW_INVALIDATE | RDW_FRAME); } */ } /* Return current position */ return lpsi->fMask & SIF_PREVIOUSPOS ? OldPos : pSBData->pos; }
BOOL APIENTRY NtUserSetScrollBarInfo( HWND hWnd, LONG idObject, SETSCROLLBARINFO *info) { PWND Window = NULL; SETSCROLLBARINFO Safeinfo; PSCROLLBARINFO sbi; LPSCROLLINFO psi; NTSTATUS Status; LONG Obj; DECLARE_RETURN(BOOL); USER_REFERENCE_ENTRY Ref; TRACE("Enter NtUserSetScrollBarInfo\n"); UserEnterExclusive(); if(!(Window = UserGetWindowObject(hWnd))) { RETURN( FALSE); } UserRefObjectCo(Window, &Ref); Obj = SBOBJ_TO_SBID(idObject); if(!SBID_IS_VALID(Obj)) { EngSetLastError(ERROR_INVALID_PARAMETER); ERR("Trying to set scrollinfo for unknown scrollbar type %d\n", Obj); RETURN( FALSE); } if(!co_IntCreateScrollBars(Window)) { RETURN(FALSE); } Status = MmCopyFromCaller(&Safeinfo, info, sizeof(SETSCROLLBARINFO)); if(!NT_SUCCESS(Status)) { SetLastNtError(Status); RETURN(FALSE); } sbi = IntGetScrollbarInfoFromWindow(Window, Obj); psi = IntGetScrollInfoFromWindow(Window, Obj); psi->nTrackPos = Safeinfo.nTrackPos; sbi->reserved = Safeinfo.reserved; RtlCopyMemory(&sbi->rgstate, &Safeinfo.rgstate, sizeof(Safeinfo.rgstate)); RETURN(TRUE); CLEANUP: if (Window) UserDerefObjectCo(Window); TRACE("Leave NtUserSetScrollBarInfo, ret=%i\n",_ret_); UserLeave(); END_CLEANUP; }
BOOL APIENTRY NtUserEnableScrollBar( HWND hWnd, UINT wSBflags, UINT wArrows) { UINT OrigArrows; PWND Window = NULL; PSCROLLBARINFO InfoV = NULL, InfoH = NULL; BOOL Chg = FALSE; DECLARE_RETURN(BOOL); USER_REFERENCE_ENTRY Ref; TRACE("Enter NtUserEnableScrollBar\n"); UserEnterExclusive(); if (!(Window = UserGetWindowObject(hWnd)) || // FIXME: Window == UserGetDesktopWindow() || // pWnd->fnid == FNID_DESKTOP Window == UserGetMessageWindow() ) // pWnd->fnid == FNID_MESSAGEWND { RETURN(FALSE); } UserRefObjectCo(Window, &Ref); if (!co_IntCreateScrollBars(Window)) { RETURN( FALSE); } OrigArrows = Window->pSBInfo->WSBflags; Window->pSBInfo->WSBflags = wArrows; if (wSBflags == SB_CTL) { if ((wArrows == ESB_DISABLE_BOTH || wArrows == ESB_ENABLE_BOTH)) IntEnableWindow(hWnd, (wArrows == ESB_ENABLE_BOTH)); RETURN(TRUE); } if(wSBflags != SB_BOTH && !SBID_IS_VALID(wSBflags)) { EngSetLastError(ERROR_INVALID_PARAMETER); ERR("Trying to set scrollinfo for unknown scrollbar type %u", wSBflags); RETURN(FALSE); } switch(wSBflags) { case SB_BOTH: InfoV = IntGetScrollbarInfoFromWindow(Window, SB_VERT); /* Fall through */ case SB_HORZ: InfoH = IntGetScrollbarInfoFromWindow(Window, SB_HORZ); break; case SB_VERT: InfoV = IntGetScrollbarInfoFromWindow(Window, SB_VERT); break; default: RETURN(FALSE); } if(InfoV) Chg = IntEnableScrollBar(FALSE, InfoV, wArrows); if(InfoH) Chg = (IntEnableScrollBar(TRUE, InfoH, wArrows) || Chg); ERR("FIXME: EnableScrollBar wSBflags %u wArrows %u Chg %d\n", wSBflags, wArrows, Chg); // Done in user32: // SCROLL_RefreshScrollBar( hwnd, nBar, TRUE, TRUE ); RETURN( Chg); if (OrigArrows == wArrows) RETURN( FALSE); RETURN( TRUE); CLEANUP: if (Window) UserDerefObjectCo(Window); TRACE("Leave NtUserEnableScrollBar, ret=%i\n",_ret_); UserLeave(); END_CLEANUP; }
BOOL APIENTRY NtUserEnableScrollBar( HWND hWnd, UINT wSBflags, UINT wArrows) { PWND Window = NULL; PSCROLLBARINFO InfoV = NULL, InfoH = NULL; BOOL Chg = FALSE; DECLARE_RETURN(BOOL); USER_REFERENCE_ENTRY Ref; TRACE("Enter NtUserEnableScrollBar\n"); UserEnterExclusive(); if(!(Window = UserGetWindowObject(hWnd))) { RETURN(FALSE); } UserRefObjectCo(Window, &Ref); if(wSBflags == SB_CTL) { /* FIXME Enable or Disable SB Ctrl*/ ERR("Enable Scrollbar SB_CTL\n"); InfoV = IntGetScrollbarInfoFromWindow(Window, SB_CTL); Chg = IntEnableScrollBar(FALSE, InfoV ,wArrows); /* Chg? Scrollbar is Refresh in user32/controls/scrollbar.c. */ RETURN(TRUE); } if(wSBflags != SB_BOTH && !SBID_IS_VALID(wSBflags)) { EngSetLastError(ERROR_INVALID_PARAMETER); ERR("Trying to set scrollinfo for unknown scrollbar type %d", wSBflags); RETURN(FALSE); } if(!co_IntCreateScrollBars(Window)) { RETURN( FALSE); } switch(wSBflags) { case SB_BOTH: InfoV = IntGetScrollbarInfoFromWindow(Window, SB_VERT); /* fall through */ case SB_HORZ: InfoH = IntGetScrollbarInfoFromWindow(Window, SB_HORZ); break; case SB_VERT: InfoV = IntGetScrollbarInfoFromWindow(Window, SB_VERT); break; default: RETURN(FALSE); } if(InfoV) Chg = IntEnableScrollBar(FALSE, InfoV, wArrows); if(InfoH) Chg = (IntEnableScrollBar(TRUE, InfoH, wArrows) || Chg); //if(Chg && (Window->style & WS_VISIBLE)) /* FIXME - repaint scrollbars */ RETURN( TRUE); CLEANUP: if (Window) UserDerefObjectCo(Window); TRACE("Leave NtUserEnableScrollBar, ret=%i\n",_ret_); UserLeave(); END_CLEANUP; }
static DWORD FASTCALL co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw) { /* * Update the scrollbar state and set action flags according to * what has to be done graphics wise. */ LPSCROLLINFO Info; PSCROLLBARINFO psbi; /* UINT new_flags;*/ BOOL bChangeParams = FALSE; /* don't show/hide scrollbar if params don't change */ ASSERT_REFS_CO(Window); if(!SBID_IS_VALID(nBar)) { EngSetLastError(ERROR_INVALID_PARAMETER); ERR("Trying to set scrollinfo for unknown scrollbar type %d", nBar); return FALSE; } if(!co_IntCreateScrollBars(Window)) { return FALSE; } if (lpsi->cbSize != sizeof(SCROLLINFO) && lpsi->cbSize != (sizeof(SCROLLINFO) - sizeof(lpsi->nTrackPos))) { EngSetLastError(ERROR_INVALID_PARAMETER); return 0; } if (lpsi->fMask & ~(SIF_ALL | SIF_DISABLENOSCROLL)) { EngSetLastError(ERROR_INVALID_PARAMETER); return 0; } psbi = IntGetScrollbarInfoFromWindow(Window, nBar); Info = IntGetScrollInfoFromWindow(Window, nBar); /* Set the page size */ if (0 != (lpsi->fMask & SIF_PAGE)) { if (Info->nPage != lpsi->nPage) { Info->nPage = lpsi->nPage; bChangeParams = TRUE; } } /* Set the scroll pos */ if (0 != (lpsi->fMask & SIF_POS)) { if (Info->nPos != lpsi->nPos) { Info->nPos = lpsi->nPos; } } /* Set the scroll range */ if (0 != (lpsi->fMask & SIF_RANGE)) { /* Invalid range -> range is set to (0,0) */ if (lpsi->nMin > lpsi->nMax || 0x80000000 <= (UINT)(lpsi->nMax - lpsi->nMin)) { Info->nMin = 0; Info->nMax = 0; bChangeParams = TRUE; } else if (Info->nMin != lpsi->nMin || Info->nMax != lpsi->nMax) { Info->nMin = lpsi->nMin; Info->nMax = lpsi->nMax; bChangeParams = TRUE; } } /* Make sure the page size is valid */ if (Info->nMax - Info->nMin + 1 < Info->nPage) { Info->nPage = Info->nMax - Info->nMin + 1; } /* Make sure the pos is inside the range */ if (Info->nPos < Info->nMin) { Info->nPos = Info->nMin; } else if (Info->nPos > Info->nMax - max(Info->nPage - 1, 0)) { Info->nPos = Info->nMax - max(Info->nPage - 1, 0); } /* * Don't change the scrollbar state if SetScrollInfo is just called * with SIF_DISABLENOSCROLL */ if (0 == (lpsi->fMask & SIF_ALL)) { return Info->nPos; } /* Check if the scrollbar should be hidden or disabled */ if (0 != (lpsi->fMask & (SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL))) { if (Info->nMin >= (int)(Info->nMax - max(Info->nPage - 1, 0))) { /* Hide or disable scroll-bar */ if (0 != (lpsi->fMask & SIF_DISABLENOSCROLL)) { /* new_flags = ESB_DISABLE_BOTH;*/ } else if ((nBar != SB_CTL) && bChangeParams) { co_UserShowScrollBar(Window, nBar, FALSE); return Info->nPos; } } else /* Show and enable scroll-bar */ { /* new_flags = 0;*/ if ((nBar != SB_CTL) && bChangeParams) { co_UserShowScrollBar(Window, nBar, TRUE); } } #if 0 if (infoPtr->flags != new_flags) /* check arrow flags */ { infoPtr->flags = new_flags; *Action |= SA_SSI_REPAINT_ARROWS; } #endif } if (bRedraw) { RECTL UpdateRect = psbi->rcScrollBar; UpdateRect.left -= Window->rcClient.left - Window->rcWindow.left; UpdateRect.right -= Window->rcClient.left - Window->rcWindow.left; UpdateRect.top -= Window->rcClient.top - Window->rcWindow.top; UpdateRect.bottom -= Window->rcClient.top - Window->rcWindow.top; co_UserRedrawWindow(Window, &UpdateRect, 0, RDW_INVALIDATE | RDW_FRAME); } /* Return current position */ return Info->nPos; }