Ejemplo n.º 1
0
void EPropWnd::SetScrollPage()
{
	TR( _T("EPropWnd::SetScrollPage()"), _T(""));

	CSize PageSize = GetScrollPageSize();

	if( PageSize.cx==0 && PageSize.cy==0 )
	{
		SetScrollPos ( SB_HORZ , 0     );
		SetScrollPos ( SB_VERT , 0     );
		ShowScrollBar( SB_BOTH , FALSE );
	}
	else
	{
		CRect wr;
		GetWindowRect(&wr);
		CSize ClientSize = wr.Size();

		bool bEnableH = false;
		bool bEnableV = false;

		if( PageSize.cx > ClientSize.cx )
		{
			ClientSize.cy -= GetSystemMetrics(SM_CYHSCROLL);
			bEnableH = true;
		}

		if( PageSize.cy > ClientSize.cy )
		{
			ClientSize.cx -= GetSystemMetrics(SM_CXVSCROLL);
			bEnableV = true;

			if( bEnableH == false )
			{
				if( PageSize.cx > ClientSize.cx )
				{
					ClientSize.cy -= GetSystemMetrics(SM_CYHSCROLL);
					bEnableH = true;
				}
			}
		}

		//
		//
		//

		SCROLLINFO si;
		si.cbSize = sizeof(si);
		si.fMask  = SIF_PAGE | SIF_POS | SIF_RANGE;

		//
		// horizontal scroller
		//

		si.nPage  = bEnableH ? ClientSize.cx         : 0;
		si.nMin   = bEnableH ? 0                     : 0;
		si.nMax   = bEnableH ? PageSize.cx-1         : 0;
		si.nPos   = bEnableH ? GetScrollPos(SB_HORZ) : 0;
		SetScrollInfo( SB_HORZ , &si );
		ShowScrollBar( SB_HORZ , bEnableH );

		//
		// vertical scroller
		//

		si.nPage  = bEnableV ? ClientSize.cy         : 0;
		si.nMin   = bEnableV ? 0                     : 0;
		si.nMax   = bEnableV ? PageSize.cy-1         : 0;
		si.nPos   = bEnableV ? GetScrollPos(SB_VERT) : 0;
		SetScrollInfo( SB_VERT , &si );
		ShowScrollBar( SB_VERT , bEnableV );
	}
}
Ejemplo n.º 2
0
int wxScrolledWindow::CalcScrollInc(wxScrollWinEvent& event)
{
    int pos = event.GetPosition();
    int orient = event.GetOrientation();

    int nScrollInc = 0;
    if (event.GetEventType() == wxEVT_SCROLLWIN_TOP)
    {
            if (orient == wxHORIZONTAL)
                nScrollInc = - m_xScrollPosition;
            else
                nScrollInc = - m_yScrollPosition;
    } else
    if (event.GetEventType() == wxEVT_SCROLLWIN_BOTTOM)
    {
            if (orient == wxHORIZONTAL)
                nScrollInc = GetVirtualSize().GetWidth() / m_xScrollPixelsPerLine - m_xScrollPosition;
            else
                nScrollInc = GetVirtualSize().GetHeight() / m_yScrollPixelsPerLine - m_yScrollPosition;
    } else
    if (event.GetEventType() == wxEVT_SCROLLWIN_LINEUP)
    {
            nScrollInc = -1;
    } else
    if (event.GetEventType() == wxEVT_SCROLLWIN_LINEDOWN)
    {
            nScrollInc = 1;
    } else
    if (event.GetEventType() == wxEVT_SCROLLWIN_PAGEUP)
    {
            if (orient == wxHORIZONTAL)
                nScrollInc = -GetScrollPageSize(wxHORIZONTAL);
            else
                nScrollInc = -GetScrollPageSize(wxVERTICAL);
    } else
    if (event.GetEventType() == wxEVT_SCROLLWIN_PAGEDOWN)
    {
            if (orient == wxHORIZONTAL)
                nScrollInc = GetScrollPageSize(wxHORIZONTAL);
            else
                nScrollInc = GetScrollPageSize(wxVERTICAL);
    } else
    if ((event.GetEventType() == wxEVT_SCROLLWIN_THUMBTRACK) ||
        (event.GetEventType() == wxEVT_SCROLLWIN_THUMBRELEASE))
    {
            if (orient == wxHORIZONTAL)
                nScrollInc = pos - m_xScrollPosition;
            else
                nScrollInc = pos - m_yScrollPosition;
    }

    if (orient == wxHORIZONTAL)
    {
        if (m_xScrollPixelsPerLine > 0)
        {
            int max = (int)(m_hAdjust->upper - m_hAdjust->page_size + 0.5);
            if (max < 0) max = 0;

            if ( (m_xScrollPosition + nScrollInc) < 0 )
                nScrollInc = -m_xScrollPosition; // As -ve as we can go
            else if ( (m_xScrollPosition + nScrollInc) > max )
                nScrollInc = max - m_xScrollPosition; // As +ve as we can go
        }
        else
            m_targetWindow->Refresh();
    }
    else
    {
        if (m_yScrollPixelsPerLine > 0)
        {
            int max = (int)(m_vAdjust->upper - m_vAdjust->page_size + 0.5);
            if (max < 0) max = 0;

            if ( (m_yScrollPosition + nScrollInc) < 0 )
                nScrollInc = -m_yScrollPosition; // As -ve as we can go
            else if ( (m_yScrollPosition + nScrollInc) > max )
                nScrollInc = max - m_yScrollPosition; // As +ve as we can go
        }
        else
            m_targetWindow->Refresh();
    }

    return nScrollInc;
}
Ejemplo n.º 3
0
void EPropWnd::SetScrollPage()
{
	CSize PageSize = GetScrollPageSize();

	if( PageSize.cx==0 && PageSize.cy==0 )
	{
		SetScrollPos ( SB_HORZ , 0     );
		SetScrollPos ( SB_VERT , 0     );
		ShowScrollBar( SB_BOTH , FALSE );
	}
	else
	{
		CRect wr;
		GetWindowRect(&wr);
		CSize ClientSize = wr.Size();

		bool bEnableH = false;
		bool bEnableV = false;

		if( PageSize.cx > ClientSize.cx )
		{
			ClientSize.cy -= GetSystemMetrics(SM_CYHSCROLL);
			bEnableH = true;
		}

		if( PageSize.cy > ClientSize.cy )
		{
			ClientSize.cx -= GetSystemMetrics(SM_CXVSCROLL);
			bEnableV = true;

			if( bEnableH == false )
			{
				if( PageSize.cx > ClientSize.cx )
				{
					ClientSize.cy -= GetSystemMetrics(SM_CYHSCROLL);
					bEnableH = true;
				}
			}
		}

		SCROLLINFO si;
		si.cbSize = sizeof(si);
		si.fMask  = SIF_PAGE | SIF_POS | SIF_RANGE;

		if( bEnableH )
		{
			si.nPage  = ClientSize.cx;			//size of scrolltab
			si.nMin   = 0;
			si.nMax   = PageSize.cx-1;
			si.nPos   = GetScrollPos(SB_HORZ);
			ShowScrollBar( SB_HORZ , TRUE );
			SetScrollInfo( SB_HORZ , &si );
		}
		else
		{
			ShowScrollBar( SB_HORZ , FALSE );
			SetScrollPos( SB_HORZ , 0 );
		}

		if( bEnableV )
		{
			si.nPage  = ClientSize.cy;			//size of scrolltab
			si.nMin   = 0;
			si.nMax   = PageSize.cy-1;
			si.nPos   = GetScrollPos(SB_VERT);
			ShowScrollBar( SB_VERT , TRUE );
			SetScrollInfo( SB_VERT , &si );
		}
		else
		{
			ShowScrollBar( SB_VERT , FALSE );
			SetScrollPos( SB_VERT , 0 );
		}

	}
}