https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2aea4ab94529a0a6b1620…
commit 2aea4ab94529a0a6b1620217b272e5b6f06733b8
Author: Joachim Henze <Joachim.Henze(a)reactos.org>
AuthorDate: Sun Mar 12 10:33:21 2023 +0100
Commit: Joachim Henze <Joachim.Henze(a)reactos.org>
CommitDate: Sun Mar 12 10:34:50 2023 +0100
[NTUSER] Scrollbar.c pure whitespace fixes
The scrollbar code is now finally in a good shape.
Therefore I will port the current state back today,
and for that I want to have the formatting in good shape.
No functional changes!
---
win32ss/user/ntuser/scrollbar.c | 412 +++++++++++++++-------------------------
1 file changed, 152 insertions(+), 260 deletions(-)
diff --git a/win32ss/user/ntuser/scrollbar.c b/win32ss/user/ntuser/scrollbar.c
index e52b70a21da..63bb168ca34 100644
--- a/win32ss/user/ntuser/scrollbar.c
+++ b/win32ss/user/ntuser/scrollbar.c
@@ -1,48 +1,43 @@
/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Scrollbars
- * FILE: win32ss/user/ntuser/scrollbar.c
- * PROGRAMER: Thomas Weidenmueller (w3seek(a)users.sourceforge.net)
- * Jason Filby (jasonfilby(a)yahoo.com)
+ * PROJECT: ReactOS kernel
+ * LICENSE: See COPYING in the top level directory
+ * PURPOSE: Scrollbars
+ * COPYRIGHT: Thomas Weidenmueller (w3seek(a)users.sourceforge.net)
+ * Jason Filby (jasonfilby(a)yahoo.com)
*/
#include <win32k.h>
DBG_DEFAULT_CHANNEL(UserScrollbar);
/* Definitions for scrollbar hit testing [See SCROLLBARINFO in MSDN] */
-#define SCROLL_NOWHERE 0x00 /* Outside the scroll bar */
+#define SCROLL_NOWHERE 0x00 /* Outside the scrollbar */
#define SCROLL_TOP_ARROW 0x01 /* Top or left arrow */
#define SCROLL_TOP_RECT 0x02 /* Rectangle between the top arrow and the thumb */
#define SCROLL_THUMB 0x03 /* Thumb rectangle */
#define SCROLL_BOTTOM_RECT 0x04 /* Rectangle between the thumb and the bottom arrow
*/
#define SCROLL_BOTTOM_ARROW 0x05 /* Bottom or right arrow */
-#define SCROLL_FIRST_DELAY 200 /* Delay (in ms) before first repetition when
- holding the button down */
-#define SCROLL_REPEAT_DELAY 50 /* Delay (in ms) between scroll repetitions */
+#define SCROLL_FIRST_DELAY 200 /* Delay (in ms) before first repetition when holding
the button down */
+#define SCROLL_REPEAT_DELAY 50 /* Delay (in ms) between scroll repetitions */
-#define SCROLL_TIMER 0 /* Scroll timer id */
+#define SCROLL_TIMER 0 /* Scroll timer id */
- /* Minimum size of the rectangle between the arrows */
+/* Minimum size of the rectangle between the arrows */
#define SCROLL_MIN_RECT 4
- /* Minimum size of the thumb in pixels */
+/* Minimum size of the thumb in pixels */
#define SCROLL_MIN_THUMB 6
- /* Overlap between arrows and thumb */
+/* Overlap between arrows and thumb */
#define SCROLL_ARROW_THUMB_OVERLAP 0
-//
-//
-//
-#define MINTRACKTHUMB 8 /* Minimum size of the rectangle between the
arrows */
+#define MINTRACKTHUMB 8 /* Minimum size of the rectangle between the arrows
*/
- /* What to do after SetScrollInfo() */
- #define SA_SSI_HIDE 0x0001
- #define SA_SSI_SHOW 0x0002
- #define SA_SSI_REFRESH 0x0004
- #define SA_SSI_REPAINT_ARROWS 0x0008
+/* What to do after SetScrollInfo() */
+#define SA_SSI_HIDE 0x0001
+#define SA_SSI_SHOW 0x0002
+#define SA_SSI_REFRESH 0x0004
+#define SA_SSI_REPAINT_ARROWS 0x0008
#define SBRG_SCROLLBAR 0 /* The scrollbar itself */
#define SBRG_TOPRIGHTBTN 1 /* The top or right button */
@@ -64,14 +59,13 @@ IntEnableScrollBar(BOOL Horz, PSCROLLBARINFO Info, UINT wArrows);
static void
IntRefeshScrollInterior(PWND pWnd, INT nBar, PSCROLLBARINFO psbi);
-
/* Ported from WINE20020904 */
-/* Compute the scroll bar rectangle, in drawing coordinates (i.e. client coords for
SB_CTL, window coords for SB_VERT and
+/* Compute the scrollbar rectangle, in drawing coordinates (i.e. client coords for
SB_CTL, window coords for SB_VERT and
* SB_HORZ). 'arrowSize' returns the width or height of an arrow (depending on *
the orientation of the scrollbar),
* 'thumbSize' returns the size of the thumb, and 'thumbPos' returns the
position of the thumb relative to the left or to
* the top. Return TRUE if the scrollbar is vertical, FALSE if horizontal.
*/
-static inline void mirror_rect( const RECT *window_rect, RECT *rect )
+static inline void mirror_rect(const RECT *window_rect, RECT *rect)
{
int width = window_rect->right - window_rect->left;
int tmp = rect->left;
@@ -88,39 +82,39 @@ IntGetSBData(PWND pwnd, INT Bar)
pSBInfo = pwnd->pSBInfo;
switch (Bar)
{
- case SB_HORZ:
+ case SB_HORZ:
return &pSBInfo->Horz;
- case SB_VERT:
+ case SB_VERT:
return &pSBInfo->Vert;
- case SB_CTL:
- if ( pwnd->cbwndExtra < (sizeof(SBWND)-sizeof(WND)) )
+ case SB_CTL:
+ if (pwnd->cbwndExtra < (sizeof(SBWND)-sizeof(WND)))
{
- ERR("IntGetSBData Wrong Extra bytes for CTL Scrollbar!\n");
+ ERR("IntGetSBData Wrong Extra bytes for CTL Scrollbar\n");
return 0;
}
pSBWnd = (PSBWND)pwnd;
return (PSBDATA)&pSBWnd->SBCalc;
- default:
- ERR("IntGetSBData Bad Bar!\n");
+ default:
+ ERR("IntGetSBData Bad Bar\n");
}
return NULL;
}
BOOL FASTCALL
-IntGetScrollBarRect (PWND Wnd, INT nBar, RECTL *lprect)
+IntGetScrollBarRect(PWND Wnd, INT nBar, RECTL *lprect)
{
BOOL vertical;
*lprect = Wnd->rcClient;
- RECTL_vOffsetRect( lprect, -Wnd->rcWindow.left, -Wnd->rcWindow.top );
+ RECTL_vOffsetRect(lprect, -Wnd->rcWindow.left, -Wnd->rcWindow.top);
if (Wnd->ExStyle & WS_EX_LAYOUTRTL)
- mirror_rect( &Wnd->rcWindow, lprect );
+ mirror_rect(&Wnd->rcWindow, lprect);
switch (nBar)
{
case SB_HORZ:
lprect->top = lprect->bottom;
- lprect->bottom += UserGetSystemMetrics (SM_CYHSCROLL);
+ lprect->bottom += UserGetSystemMetrics(SM_CYHSCROLL);
if (Wnd->style & WS_BORDER)
{
lprect->left--;
@@ -157,7 +151,7 @@ IntGetScrollBarRect (PWND Wnd, INT nBar, RECTL *lprect)
break;
case SB_CTL:
- IntGetClientRect (Wnd, lprect);
+ IntGetClientRect(Wnd, lprect);
vertical = !!(Wnd->style & SBS_VERT);
break;
@@ -202,7 +196,7 @@ IntCalculateThumb(PWND Wnd, LONG idObject, PSCROLLBARINFO psbi,
PSBDATA pSBData)
}
ThumbPos = Thumb;
- /* Calculate Thumb */
+ // Calculate Thumb
if(cxy <= (2 * Thumb))
{
Thumb = cxy / 2;
@@ -214,7 +208,7 @@ IntCalculateThumb(PWND Wnd, LONG idObject, PSCROLLBARINFO psbi,
PSBDATA pSBData)
psbi->rgstate[SBRG_BOTTOMLEFTBTN] == STATE_SYSTEM_UNAVAILABLE &&
pSBData->posMin >= (int)(pSBData->posMax - max(pSBData->page - 1,
0)))
{
- /* Nothing to scroll */
+ // Nothing to scroll
psbi->xyThumbTop = 0;
psbi->xyThumbBottom = 0;
}
@@ -225,9 +219,7 @@ IntCalculateThumb(PWND Wnd, LONG idObject, PSCROLLBARINFO psbi,
PSBDATA pSBData)
if(cxy >= ThumbBox)
{
if(pSBData->page)
- {
ThumbBox = max(EngMulDiv(cxy, pSBData->page, pSBData->posMax -
pSBData->posMin + 1), ThumbBox);
- }
if(cxy > ThumbBox)
{
@@ -276,7 +268,7 @@ co_IntGetScrollInfo(PWND Window, INT nBar, PSBDATA pSBData,
LPSCROLLINFO lpsi)
ASSERT_REFS_CO(Window);
- lpsi->fMask &= ~SIF_THEMED; // Remove Theme bit
+ lpsi->fMask &= ~SIF_THEMED; // Remove Theme bit
if(!SBID_IS_VALID(nBar))
{
EngSetLastError(ERROR_INVALID_PARAMETER);
@@ -286,30 +278,22 @@ co_IntGetScrollInfo(PWND Window, INT nBar, PSBDATA pSBData,
LPSCROLLINFO lpsi)
if (!Window->pSBInfo)
{
- ERR("IntGetScrollInfo No window scrollbar info!\n");
+ 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))
{
@@ -318,9 +302,7 @@ co_IntGetScrollInfo(PWND Window, INT nBar, PSBDATA pSBData,
LPSCROLLINFO lpsi)
}
if (0 != (Mask & SIF_TRACKPOS))
- {
lpsi->nTrackPos = psi->nTrackPos;
- }
return TRUE;
}
@@ -335,12 +317,12 @@ NEWco_IntGetScrollInfo(
UINT Mask;
PSBTRACK pSBTrack = pWnd->head.pti->pSBTrack;
- lpsi->fMask &= ~SIF_THEMED; // Remove Theme bit
+ lpsi->fMask &= ~SIF_THEMED; // Remove Theme bit
if (!SBID_IS_VALID(nBar))
{
- EngSetLastError(ERROR_INVALID_PARAMETER);
- ERR("Trying to get scrollinfo for unknown scrollbar type %d\n", nBar);
- return FALSE;
+ EngSetLastError(ERROR_INVALID_PARAMETER);
+ ERR("Trying to get scrollinfo for unknown scrollbar type %d\n", nBar);
+ return FALSE;
}
if (!pWnd->pSBInfo || !pSBTrack) return FALSE;
@@ -348,35 +330,29 @@ NEWco_IntGetScrollInfo(
Mask = lpsi->fMask;
if (0 != (Mask & SIF_PAGE))
- {
- lpsi->nPage = pSBData->page;
- }
+ lpsi->nPage = pSBData->page;
if (0 != (Mask & SIF_POS))
- {
- lpsi->nPos = pSBData->pos;
- }
+ lpsi->nPos = pSBData->pos;
if (0 != (Mask & SIF_RANGE))
{
- lpsi->nMin = pSBData->posMin;
- lpsi->nMax = pSBData->posMax;
+ 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;
+ if (pSBTrack && pSBTrack->nBar == nBar && pSBTrack->spwndTrack
== pWnd)
+ lpsi->nTrackPos = pSBTrack->posNew;
+ else
+ lpsi->nTrackPos = pSBData->pos;
}
return (Mask & SIF_ALL) !=0;
}
/*************************************************************************
- * SCROLL_GetScrollBarInfo
+ * SCROLL_GetScrollBarInfo
*
* Internal helper for the API function
*
@@ -406,13 +382,13 @@ static BOOL SCROLL_GetScrollBarInfo(HWND hwnd, LONG idObject,
LPSCROLLBARINFO in
default: return FALSE;
}
- /* handle invalid data structure */
+ // handle invalid data structure
if (info->cbSize != sizeof(*info))
return FALSE;
SCROLL_GetScrollBarRect(hwnd, nBar, &info->rcScrollBar, &nDummy,
&info->dxyLineButton, &info->xyThumbTop);
- /* rcScrollBar needs to be in screen coordinates */
+ // rcScrollBar needs to be in screen coordinates
GetWindowRect(hwnd, &rect);
OffsetRect(&info->rcScrollBar, rect.left, rect.top);
@@ -422,7 +398,7 @@ static BOOL SCROLL_GetScrollBarInfo(HWND hwnd, LONG idObject,
LPSCROLLBARINFO in
if (!infoPtr)
return FALSE;
- /* Scroll bar state */
+ // Scrollbar state
info->rgstate[0] = 0;
if ((nBar == SB_HORZ && !(style & WS_HSCROLL))
|| (nBar == SB_VERT && !(style & WS_VSCROLL)))
@@ -436,52 +412,50 @@ static BOOL SCROLL_GetScrollBarInfo(HWND hwnd, LONG idObject,
LPSCROLLBARINFO in
}
if (nBar == SB_CTL && !IsWindowEnabled(hwnd))
info->rgstate[0] |= STATE_SYSTEM_UNAVAILABLE;
-
+
pressed = ((nBar == SB_VERT) == SCROLL_trackVertical && GetCapture() ==
hwnd);
-
- /* Top/left arrow button state. MSDN says top/right, but I don't believe it */
+
+ // Top/left arrow button state. MSDN says top/right, but I don't believe it
info->rgstate[1] = 0;
if (pressed && SCROLL_trackHitTest == SCROLL_TOP_ARROW)
info->rgstate[1] |= STATE_SYSTEM_PRESSED;
if (infoPtr->flags & ESB_DISABLE_LTUP)
info->rgstate[1] |= STATE_SYSTEM_UNAVAILABLE;
- /* Page up/left region state. MSDN says up/right, but I don't believe it */
+ // Page up/left region state. MSDN says up/right, but I don't believe it
info->rgstate[2] = 0;
if (infoPtr->curVal == infoPtr->minVal)
info->rgstate[2] |= STATE_SYSTEM_INVISIBLE;
if (pressed && SCROLL_trackHitTest == SCROLL_TOP_RECT)
info->rgstate[2] |= STATE_SYSTEM_PRESSED;
- /* Thumb state */
+ // Thumb state
info->rgstate[3] = 0;
if (pressed && SCROLL_trackHitTest == SCROLL_THUMB)
info->rgstate[3] |= STATE_SYSTEM_PRESSED;
- /* Page down/right region state. MSDN says down/left, but I don't believe it */
+ // Page down/right region state. MSDN says down/left, but I don't believe it
info->rgstate[4] = 0;
if (infoPtr->curVal >= infoPtr->maxVal - 1)
info->rgstate[4] |= STATE_SYSTEM_INVISIBLE;
if (pressed && SCROLL_trackHitTest == SCROLL_BOTTOM_RECT)
info->rgstate[4] |= STATE_SYSTEM_PRESSED;
-
- /* Bottom/right arrow button state. MSDN says bottom/left, but I don't believe it
*/
+
+ // Bottom/right arrow button state. MSDN says bottom/left, but I don't believe
it
info->rgstate[5] = 0;
if (pressed && SCROLL_trackHitTest == SCROLL_BOTTOM_ARROW)
info->rgstate[5] |= STATE_SYSTEM_PRESSED;
if (infoPtr->flags & ESB_DISABLE_RTDN)
info->rgstate[5] |= STATE_SYSTEM_UNAVAILABLE;
-
+
return TRUE;
}
#endif
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.
- */
+ // Update the scrollbar state and set action flags according to
+ // what has to be done graphics wise.
LPSCROLLINFO Info;
PSCROLLBARINFO psbi;
@@ -489,7 +463,7 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL
bRedraw)
INT action = 0;
PSBDATA pSBData;
DWORD OldPos = 0;
- BOOL bChangeParams = FALSE; /* Don't show/hide scrollbar if params don't
change */
+ BOOL bChangeParams = FALSE; // Don't show/hide scrollbar if params don't
change
UINT MaxPage;
int MaxPos;
BOOL bVisible;
@@ -504,9 +478,7 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL
bRedraw)
}
if(!co_IntCreateScrollBars(Window))
- {
return FALSE;
- }
if (lpsi->cbSize != sizeof(SCROLLINFO) &&
lpsi->cbSize != (sizeof(SCROLLINFO) - sizeof(lpsi->nTrackPos)))
@@ -525,11 +497,9 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL
bRedraw)
pSBData = IntGetSBData(Window, nBar);
if (lpsi->fMask & SIF_THEMED && !(Info->fMask & SIF_THEMED))
- {
- Info->fMask |= SIF_THEMED;
- }
+ Info->fMask |= SIF_THEMED;
- /* Set the page size */
+ // Set the page size
if (lpsi->fMask & SIF_PAGE)
{
if (Info->nPage != lpsi->nPage)
@@ -540,7 +510,7 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL
bRedraw)
}
}
- /* Set the scroll pos */
+ // Set the scroll pos
if (lpsi->fMask & SIF_POS)
{
OldPos = Info->nPos;
@@ -551,7 +521,7 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL
bRedraw)
}
}
- /* Set the scroll range */
+ // Set the scroll range
if (lpsi->fMask & SIF_RANGE)
{
if (lpsi->nMin > lpsi->nMax)
@@ -572,42 +542,30 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL
bRedraw)
}
}
- /* Make sure the page size is valid */
+ // 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 */
+ // 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
- */
+ // 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 */
+ // 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)max(Info->nPage, 1) > Info->nMax)
{
- /* Hide or disable scroll-bar */
+ // Hide or disable scrollbar
if (lpsi->fMask & SIF_DISABLENOSCROLL)
{
new_flags = ESB_DISABLE_BOTH;
@@ -618,9 +576,8 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL
bRedraw)
action = SA_SSI_HIDE;
}
}
- else /* Show and enable scroll-bar only if no page only changed. */
- if ((lpsi->fMask & ~SIF_THEMED) != SIF_PAGE)
- {
+ else if ((lpsi->fMask & ~SIF_THEMED) != SIF_PAGE)
+ { // Show and enable scrollbar only if no page only changed
if ((nBar != SB_CTL) && bChangeParams)
{
new_flags = ESB_ENABLE_BOTH;
@@ -632,23 +589,22 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL
bRedraw)
}
}
- if (Window->pSBInfo->WSBflags != new_flags) /* Check arrow flags */
+ 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 )
+ 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 (action & SA_SSI_SHOW)
+ if (co_UserShowScrollBar(Window, nBar, TRUE, TRUE))
+ return lpsi->fMask & SIF_PREVIOUSPOS ? OldPos : pSBData->pos; //
SetWindowPos() already did the painting
switch (nBar)
{
@@ -668,11 +624,11 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL
bRedraw)
if (bRedraw && bVisible)
{
- if (!(Info->fMask & SIF_THEMED)) /* Not Using Themes */
+ if (!(Info->fMask & SIF_THEMED)) // Not Using Themes
{
if (action & SA_SSI_REPAINT_ARROWS)
{
- // Redraw the entire bar.
+ // Redraw the entire bar
RECTL UpdateRect = psbi->rcScrollBar;
UpdateRect.left -= Window->rcClient.left - Window->rcWindow.left;
UpdateRect.right -= Window->rcClient.left - Window->rcWindow.left;
@@ -682,11 +638,11 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL
bRedraw)
}
else
{
- // Redraw only the interior part of the bar.
+ // Redraw only the interior part of the bar
IntRefeshScrollInterior(Window, nBar, psbi);
}
}
- else /* Using Themes */
+ else // Using Themes
{
RECTL UpdateRect = psbi->rcScrollBar;
UpdateRect.left -= Window->rcClient.left - Window->rcWindow.left;
@@ -694,17 +650,15 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL
bRedraw)
UpdateRect.top -= Window->rcClient.top - Window->rcWindow.top;
UpdateRect.bottom -= Window->rcClient.top - Window->rcWindow.top;
if (bChangeParams || (OldPos != pSBData->pos))
- co_UserRedrawWindow(Window, &UpdateRect, 0, RDW_INVALIDATE |
RDW_FRAME);
+ co_UserRedrawWindow(Window, &UpdateRect, 0, RDW_INVALIDATE |
RDW_FRAME);
}
}
}
if (bChangeParams && (nBar == SB_HORZ || nBar == SB_VERT) &&
(lpsi->fMask & SIF_DISABLENOSCROLL))
- {
- IntEnableScrollBar(nBar == SB_HORZ, psbi, Window->pSBInfo->WSBflags);
- }
+ IntEnableScrollBar(nBar == SB_HORZ, psbi, Window->pSBInfo->WSBflags);
- /* Return current position */
+ // Return current position
return lpsi->fMask & SIF_PREVIOUSPOS ? OldPos : pSBData->pos;
}
@@ -727,7 +681,7 @@ co_IntGetScrollBarInfo(PWND Window, LONG idObject, PSCROLLBARINFO
psbi)
if(!co_IntCreateScrollBars(Window))
{
- ERR("Failed to create scrollbars for window.\n");
+ ERR("Failed to create scrollbars for window\n");
return FALSE;
}
@@ -737,7 +691,7 @@ co_IntGetScrollBarInfo(PWND Window, LONG idObject, PSCROLLBARINFO
psbi)
IntGetScrollBarRect(Window, Bar, &(sbi->rcScrollBar));
IntCalculateThumb(Window, Bar, sbi, pSBData);
- /* Scroll bar state */
+ // Scrollbar state
psbi->rgstate[0] = 0;
if ((Bar == SB_HORZ && !(Window->style & WS_HSCROLL))
|| (Bar == SB_VERT && !(Window->style & WS_VSCROLL)))
@@ -776,7 +730,7 @@ co_IntSetScrollBarInfo(PWND Window, LONG idObject, PSETSCROLLBARINFO
psbi)
if(!co_IntCreateScrollBars(Window))
{
- ERR("Failed to create scrollbars for window.\n");
+ ERR("Failed to create scrollbars for window\n");
return FALSE;
}
@@ -801,12 +755,9 @@ co_IntCreateScrollBars(PWND Window)
ASSERT_REFS_CO(Window);
if (Window->pSBInfo && Window->pSBInfoex)
- {
- /* No need to create it anymore */
- return TRUE;
- }
+ return TRUE; // No need to create it anymore
- /* Allocate memory for all scrollbars (HORZ, VERT, CONTROL) */
+ // Allocate memory for all scrollbars (HORZ, VERT, CONTROL)
Size = 3 * (sizeof(SBINFOEX));
if(!(Window->pSBInfoex = ExAllocatePoolWithTag(PagedPool, Size, TAG_SBARINFO)))
{
@@ -816,7 +767,7 @@ co_IntCreateScrollBars(PWND Window)
RtlZeroMemory(Window->pSBInfoex, Size);
- if(!(Window->pSBInfo = DesktopHeapAlloc( Window->head.rpdesk, sizeof(SBINFO))))
+ if(!(Window->pSBInfo = DesktopHeapAlloc(Window->head.rpdesk, sizeof(SBINFO))))
{
ERR("Unable to allocate memory for scrollbar information for window
%p\n", Window->head.h);
return FALSE;
@@ -826,9 +777,7 @@ co_IntCreateScrollBars(PWND Window)
Window->pSBInfo->Vert.posMax = 100;
Window->pSBInfo->Horz.posMax = 100;
- co_WinPosGetNonClientSize(Window,
- &Window->rcWindow,
- &Window->rcClient);
+ co_WinPosGetNonClientSize(Window, &Window->rcWindow,
&Window->rcClient);
for(s = SB_HORZ; s <= SB_VERT; s++)
{
@@ -911,7 +860,6 @@ co_UserShowScrollBar(PWND Wnd, int nBar, BOOL fShowH, BOOL fShowV)
case SB_CTL:
{
//IntUpdateSBInfo(Wnd, SB_CTL); // Is this needed? Was tested w/o!
-
co_WinPosShowWindow(Wnd, fShowH ? SW_SHOW : SW_HIDE);
return TRUE;
}
@@ -920,29 +868,29 @@ co_UserShowScrollBar(PWND Wnd, int nBar, BOOL fShowH, BOOL fShowV)
if (fShowH) set_bits |= WS_HSCROLL;
else clear_bits |= WS_HSCROLL;
if( nBar == SB_HORZ ) break;
- /* Fall through */
+ // Fall through
case SB_VERT:
if (fShowV) set_bits |= WS_VSCROLL;
else clear_bits |= WS_VSCROLL;
break;
default:
EngSetLastError(ERROR_INVALID_PARAMETER);
- return FALSE; /* Nothing to do! */
+ return FALSE; // Nothing to do
}
- old_style = IntSetStyle( Wnd, set_bits, clear_bits );
+ old_style = IntSetStyle(Wnd, set_bits, clear_bits);
if ((old_style & clear_bits) != 0 || (old_style & set_bits) != set_bits)
{
- ///// Is this needed? Was tested w/o!
+ //// Is this needed? Was tested w/o!
//if (Wnd->style & WS_HSCROLL) IntUpdateSBInfo(Wnd, SB_HORZ);
//if (Wnd->style & WS_VSCROLL) IntUpdateSBInfo(Wnd, SB_VERT);
- /////
- /* Frame has been changed, let the window redraw itself */
- co_WinPosSetWindowPos( Wnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE
- | SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
+
+ // Frame has been changed, let the window redraw itself
+ co_WinPosSetWindowPos(Wnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE
+ | SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED);
return TRUE;
}
- return FALSE; /* no frame changes */
+ return FALSE; // no frame changes
}
static void
@@ -959,14 +907,12 @@ IntDrawScrollInterior(PWND pWnd, HDC hDC, INT nBar, BOOL Vertical,
PSCROLLBARINF
if (ScrollBarInfo->rgstate[SCROLL_BOTTOM_RECT] & STATE_SYSTEM_PRESSED)
BottomSelected = TRUE;
- /*
- * Only scrollbar controls send WM_CTLCOLORSCROLLBAR.
- * The window-owned scrollbars need to call DefWndControlColor
- * to correctly setup default scrollbar colors
- */
+ // Only scrollbar controls send WM_CTLCOLORSCROLLBAR.
+ // The window-owned scrollbars need to call DefWndControlColor
+ // to correctly setup default scrollbar colors
if (nBar == SB_CTL)
{
- hBrush = GetControlBrush( pWnd, hDC, WM_CTLCOLORSCROLLBAR);
+ hBrush = GetControlBrush(pWnd, hDC, WM_CTLCOLORSCROLLBAR);
if (!hBrush)
hBrush = IntGetSysColorBrush(COLOR_SCROLLBAR);
}
@@ -977,7 +923,7 @@ IntDrawScrollInterior(PWND pWnd, HDC hDC, INT nBar, BOOL Vertical,
PSCROLLBARINF
hSaveBrush = NtGdiSelectBrush(hDC, hBrush);
- /* Calculate the scroll rectangle */
+ // Calculate the scroll rectangle
if (Vertical)
{
Rect.top = ScrollBarInfo->rcScrollBar.top + ScrollBarInfo->dxyLineButton;
@@ -993,13 +939,13 @@ IntDrawScrollInterior(PWND pWnd, HDC hDC, INT nBar, BOOL Vertical,
PSCROLLBARINF
Rect.right = ScrollBarInfo->rcScrollBar.right -
ScrollBarInfo->dxyLineButton;
}
- /* Draw the scroll rectangles and thumb */
+ // Draw scroll rectangles and thumb
if (!ScrollBarInfo->xyThumbBottom)
{
NtGdiPatBlt(hDC, Rect.left, Rect.top, Rect.right - Rect.left,
Rect.bottom - Rect.top, PATCOPY);
- /* Cleanup and return */
+ // Cleanup and return
NtGdiSelectBrush(hDC, hSaveBrush);
return;
}
@@ -1013,7 +959,7 @@ IntDrawScrollInterior(PWND pWnd, HDC hDC, INT nBar, BOOL Vertical,
PSCROLLBARINF
if (ThumbSize)
{
NtGdiPatBlt(hDC, Rect.left, Rect.top, Rect.right - Rect.left,
- ThumbTop, TopSelected ? BLACKNESS : PATCOPY);
+ ThumbTop, TopSelected ? BLACKNESS : PATCOPY);
Rect.top += ThumbTop;
NtGdiPatBlt(hDC, Rect.left, Rect.top + ThumbSize, Rect.right - Rect.left,
Rect.bottom - Rect.top - ThumbSize, BottomSelected ? BLACKNESS :
PATCOPY);
@@ -1051,15 +997,14 @@ IntDrawScrollInterior(PWND pWnd, HDC hDC, INT nBar, BOOL Vertical,
PSCROLLBARINF
}
}
- /* Draw the thumb */
+ // Draw thumb
if (ThumbSize)
DrawEdge(hDC, &Rect, EDGE_RAISED, BF_RECT | BF_MIDDLE);
- /* Cleanup */
+ // Cleanup
NtGdiSelectBrush(hDC, hSaveBrush);
}
-
static VOID FASTCALL
IntDrawScrollArrows(HDC hDC, PSCROLLBARINFO ScrollBarInfo, BOOL Vertical)
{
@@ -1083,21 +1028,16 @@ IntDrawScrollArrows(HDC hDC, PSCROLLBARINFO ScrollBarInfo, BOOL
Vertical)
}
if (ScrollBarInfo->rgstate[SCROLL_TOP_ARROW] & STATE_SYSTEM_PRESSED)
- {
ScrollDirFlagLT |= DFCS_PUSHED | DFCS_FLAT;
- }
+
if (ScrollBarInfo->rgstate[SCROLL_TOP_ARROW] & STATE_SYSTEM_UNAVAILABLE)
- {
ScrollDirFlagLT |= DFCS_INACTIVE;
- }
+
if (ScrollBarInfo->rgstate[SCROLL_BOTTOM_ARROW] & STATE_SYSTEM_PRESSED)
- {
ScrollDirFlagRB |= DFCS_PUSHED | DFCS_FLAT;
- }
+
if (ScrollBarInfo->rgstate[SCROLL_BOTTOM_ARROW] & STATE_SYSTEM_UNAVAILABLE)
- {
ScrollDirFlagRB |= DFCS_INACTIVE;
- }
DrawFrameControl(hDC, &RectLT, DFC_SCROLL, ScrollDirFlagLT);
DrawFrameControl(hDC, &RectRB, DFC_SCROLL, ScrollDirFlagRB);
@@ -1107,9 +1047,9 @@ static LONG FASTCALL
IntScrollGetObjectId(INT SBType)
{
if (SBType == SB_VERT)
- return OBJID_VSCROLL;
+ return OBJID_VSCROLL;
if (SBType == SB_HORZ)
- return OBJID_HSCROLL;
+ return OBJID_HSCROLL;
return OBJID_CLIENT;
}
@@ -1121,7 +1061,7 @@ IntRefeshScrollInterior(PWND pWnd, INT nBar, PSCROLLBARINFO psbi)
hdc = UserGetDCEx(pWnd, NULL, DCX_CACHE | ((nBar == SB_CTL) ? 0 : DCX_WINDOW));
if (hdc)
- { /* Get updated info. */
+ {
co_IntGetScrollBarInfo(pWnd, IntScrollGetObjectId(nBar), psbi);
IntDrawScrollInterior(pWnd, hdc, nBar, Vertical, psbi);
UserReleaseDC(pWnd, hdc, FALSE);
@@ -1131,17 +1071,13 @@ IntRefeshScrollInterior(PWND pWnd, INT nBar, PSCROLLBARINFO psbi)
void
IntDrawScrollBar(PWND Wnd, HDC DC, INT Bar)
{
- //PSBWND pSBWnd;
- //INT ThumbSize;
PTHREADINFO pti;
SCROLLBARINFO Info;
BOOL Vertical;
pti = PsGetCurrentThreadWin32Thread();
- /*
- * Get scroll bar info.
- */
+ // Get scrollbar info
switch (Bar)
{
case SB_HORZ:
@@ -1161,47 +1097,28 @@ IntDrawScrollBar(PWND Wnd, HDC DC, INT Bar)
}
if (!co_IntGetScrollBarInfo(Wnd, IntScrollGetObjectId(Bar), &Info))
- {
return;
- }
if (RECTL_bIsEmptyRect(&Info.rcScrollBar))
- {
return;
- }
-
- //ThumbSize = pSBWnd->pSBCalc->pxThumbBottom -
pSBWnd->pSBCalc->pxThumbTop;
- /*
- * Draw the arrows.
- */
+ // Draw arrows
if (Info.dxyLineButton)
- {
IntDrawScrollArrows(DC, &Info, Vertical);
- }
- /*
- * Draw the interior.
- */
+ // Draw interior
IntDrawScrollInterior(Wnd, DC, Bar, Vertical, &Info);
- /*
- * If scroll bar has focus, reposition the caret.
- */
- if ( Wnd == pti->MessageQueue->spwndFocus && Bar == SB_CTL )
+ // If scrollbar has focus, reposition the caret
+ if (Wnd == pti->MessageQueue->spwndFocus && Bar == SB_CTL)
{
if (Vertical)
- {
- co_IntSetCaretPos(Info.rcScrollBar.top + 1, Info.dxyLineButton + 1);
- }
+ co_IntSetCaretPos(Info.rcScrollBar.top + 1, Info.dxyLineButton + 1);
else
- {
- co_IntSetCaretPos(Info.dxyLineButton + 1, Info.rcScrollBar.top + 1);
- }
+ co_IntSetCaretPos(Info.dxyLineButton + 1, Info.rcScrollBar.top + 1);
}
}
-
LRESULT APIENTRY
ScrollBarWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
@@ -1212,20 +1129,14 @@ ScrollBarWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM
lParam)
switch(Msg)
{
- case WM_ENABLE:
- {
- if (pWnd->pSBInfo)
- {
- pWnd->pSBInfo->WSBflags = wParam ? ESB_ENABLE_BOTH :
ESB_DISABLE_BOTH;
- }
- }
- break;
+ case WM_ENABLE:
+ if (pWnd->pSBInfo)
+ pWnd->pSBInfo->WSBflags = wParam ? ESB_ENABLE_BOTH : ESB_DISABLE_BOTH;
+ break;
}
return lResult;
}
-////
-
BOOL
APIENTRY
NtUserGetScrollBarInfo(HWND hWnd, LONG idObject, PSCROLLBARINFO psbi)
@@ -1248,9 +1159,7 @@ NtUserGetScrollBarInfo(HWND hWnd, LONG idObject, PSCROLLBARINFO
psbi)
}
if(!(Window = UserGetWindowObject(hWnd)))
- {
RETURN(FALSE);
- }
UserRefObjectCo(Window, &Ref);
Ret = co_IntGetScrollBarInfo(Window, idObject, &sbi);
@@ -1263,13 +1172,12 @@ NtUserGetScrollBarInfo(HWND hWnd, LONG idObject, PSCROLLBARINFO
psbi)
Ret = FALSE;
}
- RETURN( Ret);
+ RETURN(Ret);
CLEANUP:
TRACE("Leave NtUserGetScrollBarInfo, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
-
}
BOOL
@@ -1294,13 +1202,11 @@ NtUserSBGetParms(
{
RtlCopyMemory(&psi, lpsi, sizeof(SCROLLINFO));
if (pSBData)
- {
RtlCopyMemory(&SBDataSafe, pSBData, sizeof(SBDATA));
- }
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
- ERR("NtUserGetScrollInfo Failed size.\n");
+ ERR("NtUserGetScrollInfo Failed size\n");
SetLastNtError(_SEH2_GetExceptionCode());
_SEH2_YIELD(RETURN(FALSE));
}
@@ -1308,7 +1214,7 @@ NtUserSBGetParms(
if(!(Window = UserGetWindowObject(hWnd)))
{
- ERR("NtUserGetScrollInfo Bad window.\n");
+ ERR("NtUserGetScrollInfo Bad window\n");
RETURN(FALSE);
}
@@ -1322,13 +1228,13 @@ NtUserSBGetParms(
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
- ERR("NtUserGetScrollInfo Failed copy to user.\n");
+ ERR("NtUserGetScrollInfo Failed copy to user\n");
SetLastNtError(_SEH2_GetExceptionCode());
_SEH2_YIELD(RETURN(FALSE));
}
_SEH2_END
- RETURN( Ret);
+ RETURN(Ret);
CLEANUP:
TRACE("Leave NtUserGetScrollInfo, ret=%i\n",_ret_);
@@ -1353,17 +1259,13 @@ NtUserEnableScrollBar(
TRACE("Enter NtUserEnableScrollBar\n");
UserEnterExclusive();
- if (!(Window = UserGetWindowObject(hWnd)) ||
- UserIsDesktopWindow(Window) || UserIsMessageWindow(Window))
- {
+ if (!(Window = UserGetWindowObject(hWnd)) || UserIsDesktopWindow(Window) ||
UserIsMessageWindow(Window))
RETURN(FALSE);
- }
+
UserRefObjectCo(Window, &Ref);
if (!co_IntCreateScrollBars(Window))
- {
- RETURN( FALSE);
- }
+ RETURN(FALSE);
OrigArrows = Window->pSBInfo->WSBflags;
Window->pSBInfo->WSBflags = wArrows;
@@ -1387,7 +1289,7 @@ NtUserEnableScrollBar(
{
case SB_BOTH:
InfoV = IntGetScrollbarInfoFromWindow(Window, SB_VERT);
- /* Fall through */
+ // Fall through
case SB_HORZ:
InfoH = IntGetScrollbarInfoFromWindow(Window, SB_HORZ);
break;
@@ -1406,11 +1308,11 @@ NtUserEnableScrollBar(
ERR("FIXME: EnableScrollBar wSBflags %u wArrows %u Chg %d\n", wSBflags,
wArrows, Chg);
// Done in user32:
-// SCROLL_RefreshScrollBar( hwnd, nBar, TRUE, TRUE );
+// SCROLL_RefreshScrollBar(hwnd, nBar, TRUE, TRUE);
- RETURN( Chg);
- if (OrigArrows == wArrows) RETURN( FALSE);
- RETURN( TRUE);
+ RETURN(Chg);
+ if (OrigArrows == wArrows) RETURN(FALSE);
+ RETURN(TRUE);
CLEANUP:
if (Window)
@@ -1438,18 +1340,16 @@ NtUserSetScrollInfo(
TRACE("Enter NtUserSetScrollInfo\n");
UserEnterExclusive();
- if(!(Window = UserGetWindowObject(hWnd)) ||
- UserIsDesktopWindow(Window) || UserIsMessageWindow(Window))
- {
- RETURN( 0);
- }
+ if(!(Window = UserGetWindowObject(hWnd)) || UserIsDesktopWindow(Window) ||
UserIsMessageWindow(Window))
+ RETURN(0);
+
UserRefObjectCo(Window, &Ref);
Status = MmCopyFromCaller(&ScrollInfo, lpsi, sizeof(SCROLLINFO) -
sizeof(ScrollInfo.nTrackPos));
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
- RETURN( 0);
+ RETURN(0);
}
RETURN(co_IntSetScrollInfo(Window, fnBar, &ScrollInfo, bRedraw));
@@ -1461,7 +1361,6 @@ CLEANUP:
TRACE("Leave NtUserSetScrollInfo, ret=%lu\n", _ret_);
UserLeave();
END_CLEANUP;
-
}
DWORD APIENTRY
@@ -1476,9 +1375,7 @@ NtUserShowScrollBar(HWND hWnd, int nBar, DWORD bShow)
UserEnterExclusive();
if (!(Window = UserGetWindowObject(hWnd)))
- {
RETURN(0);
- }
UserRefObjectCo(Window, &Ref);
ret = co_UserShowScrollBar(Window, nBar, (nBar == SB_VERT) ? 0 : bShow,
@@ -1488,14 +1385,12 @@ NtUserShowScrollBar(HWND hWnd, int nBar, DWORD bShow)
RETURN(ret);
CLEANUP:
- TRACE("Leave NtUserShowScrollBar, ret%lu\n", _ret_);
+ TRACE("Leave NtUserShowScrollBar, ret%lu\n", _ret_);
UserLeave();
END_CLEANUP;
-
}
-
-//// Ugly NtUser API ////
+// Ugly NtUser API
BOOL
APIENTRY
@@ -1517,9 +1412,8 @@ NtUserSetScrollBarInfo(
UserEnterExclusive();
if(!(Window = UserGetWindowObject(hWnd)))
- {
- RETURN( FALSE);
- }
+ RETURN(FALSE);
+
UserRefObjectCo(Window, &Ref);
Obj = SBOBJ_TO_SBID(idObject);
@@ -1527,13 +1421,11 @@ NtUserSetScrollBarInfo(
{
EngSetLastError(ERROR_INVALID_PARAMETER);
ERR("Trying to set scrollinfo for unknown scrollbar type %d\n", Obj);
- RETURN( FALSE);
+ RETURN(FALSE);
}
if(!co_IntCreateScrollBars(Window))
- {
RETURN(FALSE);
- }
Status = MmCopyFromCaller(&Safeinfo, info, sizeof(SETSCROLLBARINFO));
if(!NT_SUCCESS(Status))