ImgEdit_UI/ImgEdit_UI/ScrollWnd.cpp
void CScrollWnd::GetScrollBarState(CSize sizeClient, CSize& needSb,
									CSize& sizeRange, CPoint& ptMove, BOOL bInsideClient)
{
	// get scroll bar sizes (the part that is in the client area)
	CSize sizeSb;
	GetScrollBarSizes(sizeSb);
	
	// enough room to add scrollbars
	sizeRange = m_totalDev - sizeClient;
	// > 0 => need to scroll
	ptMove = GetDeviceScrollPosition();
	// point to move to (start at current scroll pos)
	
	BOOL bNeedH = sizeRange.cx > 0;
	if (!bNeedH)
		ptMove.x = 0;                       // jump back to origin
	else if (bInsideClient)
		sizeRange.cy += sizeSb.cy;          // need room for a scroll bar
	
	BOOL bNeedV = sizeRange.cy > 0;
	if (!bNeedV)
		ptMove.y = 0;                       // jump back to origin
	else if (bInsideClient)
		sizeRange.cx += sizeSb.cx;          // need room for a scroll bar
	
	if (bNeedV && !bNeedH && sizeRange.cx > 0)
	{
		ASSERT(bInsideClient);
		// need a horizontal scrollbar after all
		bNeedH = TRUE;
		sizeRange.cy += sizeSb.cy;
	}
	
	// if current scroll position will be past the limit, scroll to limit
	if (sizeRange.cx > 0 && ptMove.x >= sizeRange.cx)
		ptMove.x = sizeRange.cx;
	if (sizeRange.cy > 0 && ptMove.y >= sizeRange.cy)
		ptMove.y = sizeRange.cy;
	
	// now update the bars as appropriate
	needSb.cx = bNeedH;
	needSb.cy = bNeedV;
	
	// needSb, sizeRange, and ptMove area now all updated
}
// helper to return the state of the scrollbars without actually changing
//  the state of the scrollbars
helper to return the state of the scrollbars without actually changing
the state of the scrollbars
helper to return the state of the scrollbars without actually changing the state of the scrollbars
void CScrollWnd::GetScrollBarState(CSize sizeClient, CSize& needSb,
									CSize& sizeRange, CPoint& ptMove, BOOL bInsideClient)
{
	CSize sizeSb;
	GetScrollBarSizes(sizeSb);
	sizeRange = m_totalDev - sizeClient;
	ptMove = GetDeviceScrollPosition();
	BOOL bNeedH = sizeRange.cx > 0;
	if (!bNeedH)
		ptMove.x = 0;                       
	else if (bInsideClient)
		sizeRange.cy += sizeSb.cy;          
	BOOL bNeedV = sizeRange.cy > 0;
	if (!bNeedV)
		ptMove.y = 0;                       
	else if (bInsideClient)
		sizeRange.cx += sizeSb.cx;          
	if (bNeedV && !bNeedH && sizeRange.cx > 0)
	{
		ASSERT(bInsideClient);
		bNeedH = TRUE;
		sizeRange.cy += sizeSb.cy;
	}
	if (sizeRange.cx > 0 && ptMove.x >= sizeRange.cx)
		ptMove.x = sizeRange.cx;
	if (sizeRange.cy > 0 && ptMove.y >= sizeRange.cy)
		ptMove.y = sizeRange.cy;
	needSb.cx = bNeedH;
	needSb.cy = bNeedV;
}
void CScrollWnd :: GetScrollBarState ( CSize sizeClient , CSize & needSb , CSize & sizeRange , CPoint & ptMove , BOOL bInsideClient ) { CSize sizeSb ; GetScrollBarSizes ( sizeSb ) ; sizeRange = m_totalDev - sizeClient ; ptMove = GetDeviceScrollPosition ( ) ; BOOL bNeedH = sizeRange . cx > 0 ; if ( ! bNeedH ) ptMove . x = 0 ; else if ( bInsideClient ) sizeRange . cy += sizeSb . cy ; BOOL bNeedV = sizeRange . cy > 0 ; if ( ! bNeedV ) ptMove . y = 0 ; else if ( bInsideClient ) sizeRange . cx += sizeSb . cx ; if ( bNeedV && ! bNeedH && sizeRange . cx > 0 ) { ASSERT ( bInsideClient ) ; bNeedH = TRUE ; sizeRange . cy += sizeSb . cy ; } if ( sizeRange . cx > 0 && ptMove . x >= sizeRange . cx ) ptMove . x = sizeRange . cx ; if ( sizeRange . cy > 0 && ptMove . y >= sizeRange . cy ) ptMove . y = sizeRange . cy ; needSb . cx = bNeedH ; needSb . cy = bNeedV ; }
helper to return the state of the scrollbars without actually changing
the state of the scrollbars
helper to return the state of the scrollbars without actually changing the state of the scrollbars
// get scroll bar sizes (the part that is in the client area) // enough room to add scrollbars // > 0 => need to scroll // point to move to (start at current scroll pos) // jump back to origin // need room for a scroll bar // jump back to origin // need room for a scroll bar // need a horizontal scrollbar after all // if current scroll position will be past the limit, scroll to limit // now update the bars as appropriate // needSb, sizeRange, and ptMove area now all updated