Beispiel #1
0
//
/// Sets the XPage and YPage data members (amount by which to scroll on a page
/// scroll request) to the width and height (in XUnits and
/// YUnits) of the owner window's client area.
//
void
TScroller::SetPageSize()
{
    PRECONDITION(Window);
    PRECONDITION(Window->GetHandle());

    if (Window && Window->GetHandle()) {
        TRect  clientRect;
        Window->GetClientRect(clientRect);
        int width = clientRect.Width();
        int height = clientRect.Height();

        if (width && XUnit > 0) {
            XPage = std::max(1, (width+1) / XUnit - 1);
            if (XTotalUnits && XTotalUnits > width) {
                SetScrollPage(SB_HORZ, (width * XRange) / XTotalUnits, true);
            }
            else
                SetScrollPage(SB_HORZ, XPage, false);
        }

        if (height && YUnit > 0) {
            YPage = std::max(1, (height+1) / YUnit - 1);
            if (YTotalUnits && YTotalUnits > height) {
                SetScrollPage(SB_VERT, (height * YRange) / YTotalUnits, true);
            }
            else
                SetScrollPage(SB_VERT, YPage, false);
        }
    }
}
Beispiel #2
0
void CDocWindow::EliminateScrollbars(bool bRedraw)
{
	// Set the scroll range
	SetScrollRange(SB_HORZ, 0, 0/*xSize-1*/, false);
	SetScrollRange(SB_VERT, 0, 0/*ySize-1*/, false);

	// Set the scroll page size
	SetScrollPage(SB_HORZ, 0/*xVisible*/, false);
	SetScrollPage(SB_VERT, 0/*yVisible*/, false);

	// Set the scroll position
	SetScrollPos(SB_HORZ, 0/*xPos*/, bRedraw);
	SetScrollPos(SB_VERT, 0/*yPos*/, bRedraw);
}
Beispiel #3
0
void CTextWnd::SetText (const char *pszText)
{

	//
	// Reset the lines
	//

	m_asLines .RemoveAll ();

	//
	// Save the text
	//

	m_strText = pszText;
	pszText = m_strText;

	//
	// Create the line array
	//

	const char *pachStart = m_strText;
	const char *pachEnd = &pachStart [m_strText .GetLength ()];
	m_nMaxLength = 0;
	while (pachStart < pachEnd)
	{
		const char *pachLine = pachStart;
		while (pachStart < pachEnd)
		{
			if (*pachStart == '\r' || *pachStart == '\n')
				break;
			pachStart++;
		}
		{
			TextLine2 tl;
			tl .pachStart = pachLine;
			tl .nLength = pachStart - pachLine;
			m_asLines .Add (tl);
			if (tl .nLength > m_nMaxLength)
				m_nMaxLength = tl .nLength;
		}
		if (pachStart < pachEnd)
		{
			if (pachStart + 1 < pachEnd &&
				pachStart [0] == '\r' &&
				pachStart [1] == '\n')
				pachStart += 2;
			else
				pachStart++;
		}
	}
	m_sizeTotal .cx = m_nMaxLength;
	m_sizeTotal .cx *= g_sizeFixed .cx;
	m_sizeTotal .cy = (int) m_asLines .GetCount ();
	m_sizeTotal .cy *= g_sizeFixed .cy;
	SetScrollOffset (0, 0, TRUE);
	SetScrollSize (1, 1, TRUE);//Seems to fix a SB update problem on XP
	SetScrollSize (m_sizeTotal);
	SetScrollLine (g_sizeFixed);
	SetScrollPage (m_sizeClient);
}
Beispiel #4
0
void EPropWnd::OnSize(UINT nType, int cx, int cy) 
{
	cy -= 20;

	CWnd::OnSize(nType, cx, cy);

	SetScrollPage();
}
Beispiel #5
0
void CDocWindow::SetupScrollbars(int xPos, int yPos, int xSize, int ySize, int xVisible, int yVisible, bool bRedraw)
{
	// If no (x,y) position was passed in, set the position to be the center of the current page
	if (xPos < 0 && yPos < 0)
	{
		xPos = GetScrollPos(SB_HORZ) + GetScrollPage(SB_HORZ)/2 - xVisible/2;
		yPos = GetScrollPos(SB_VERT) + GetScrollPage(SB_VERT)/2 - yVisible/2;
	}

	// Set the scroll range
	SetScrollRange(SB_HORZ, 0, xSize-1, false);
	SetScrollRange(SB_VERT, 0, ySize-1, false);

	// Set the scroll page size
	SetScrollPage(SB_HORZ, xVisible, false);
	SetScrollPage(SB_VERT, yVisible, false);

	// Reset the scroll position and be sure it is valid
	ResetScrollPos(SB_HORZ, xPos, bRedraw);
	ResetScrollPos(SB_VERT, yPos, bRedraw);
}
void EGridCtrl::OnMouseMove( UINT nFlags, CPoint point )
{
	char* pCursor = IDC_ARROW;

	if( nFlags & MK_LBUTTON )		//left button is down
	{
		if( m_pDragColumn )			//drag column found on mouse down
		{
			pCursor = IDC_SIZEWE;

			if( m_ButtonDownPoint.x == -1 )	//first time?
			{
				m_ButtonDownPoint  = point;
				m_nButtonDownWidth = m_pDragColumn->m_nWidth;
			}

			CPoint Delta = point - m_ButtonDownPoint;
			m_pDragColumn->m_nWidth = m_nButtonDownWidth + Delta.x;

			if( m_pDragColumn->m_nWidth<3 )
			{
				m_pDragColumn->m_nWidth=3;
			}

			RefreshColumnLefts( m_ViewportOrg.x );
			SetScrollPage();
			Invalidate();
		}
	}
	else
	{
		m_ButtonDownPoint.x = -1;

		bool bOnHeader = (0<=point.y) && (point.y<GetHeaderRowHeight());
		if( bOnHeader )
		{
			bool bOverVerticalEdge = (GetColumn(point.x,true)!=NULL);
			if( bOverVerticalEdge )
			{
				pCursor = IDC_SIZEWE;
			}
		}
	}

	SetCursor( LoadCursor(NULL,pCursor) );

	//
	//
	//

//	EProperty* pProperty = GetProperty( point );
//
//	if( pProperty == NULL )
//	{
//		TRACE("NULL\n");
//	}
//	else
//	{
//		TRACE("%s 0x%08x\n",pProperty->GetName(),pProperty);
//	}

}