ImgEdit_UI/ImgEdit_UI/ScrollWnd.cpp
// 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