- m_targetWindow->GetClientSize( &w, &h );
- m_targetWindow->GetVirtualSize( &vw, &vh );
-
- if (m_xScrollPixelsPerLine == 0)
- {
- m_hAdjust->upper = 1.0;
- m_hAdjust->page_size = 1.0;
- }
- else
- {
- m_hAdjust->upper = vw / m_xScrollPixelsPerLine;
- m_hAdjust->page_size = (w / m_xScrollPixelsPerLine);
-
- // If the scrollbar hits the right side, move the window
- // right to keep it from over extending.
-
- if( m_hAdjust->value + m_hAdjust->page_size > m_hAdjust->upper )
- {
- m_hAdjust->value = m_hAdjust->upper - m_hAdjust->page_size;
- m_xScrollPosition = (int)m_hAdjust->value;
- }
- }
-
- if (m_yScrollPixelsPerLine == 0)
- {
- m_vAdjust->upper = 1.0;
- m_vAdjust->page_size = 1.0;
- }
- else
- {
- m_vAdjust->upper = vh / m_yScrollPixelsPerLine;
- m_vAdjust->page_size = (h / m_yScrollPixelsPerLine);
-
- if( m_vAdjust->value + m_vAdjust->page_size > m_vAdjust->upper )
- {
- m_vAdjust->value = m_vAdjust->upper - m_vAdjust->page_size;
- m_yScrollPosition = (int)m_vAdjust->value;
- }
- }
-
- m_xScrollLinesPerPage = (int)(m_hAdjust->page_size + 0.5);
- m_yScrollLinesPerPage = (int)(m_vAdjust->page_size + 0.5);
-
- gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" );
- gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" );
-}
-
-
-// ----------------------------------------------------------------------------
-// target window handling
-// ----------------------------------------------------------------------------
-
-void wxScrolledWindow::SetTargetWindow( wxWindow *target, bool WXUNUSED(pushEventHandler) )
-{
- wxASSERT_MSG( target, wxT("target window must not be NULL") );
- m_targetWindow = target;
-}
-
-wxWindow *wxScrolledWindow::GetTargetWindow()
-{
- return m_targetWindow;
-}
-
-// Override this function if you don't want to have wxScrolledWindow
-// automatically change the origin according to the scroll position.
-void wxScrolledWindow::PrepareDC(wxDC& dc)
-{
- dc.SetDeviceOrigin( -m_xScrollPosition * m_xScrollPixelsPerLine,
- -m_yScrollPosition * m_yScrollPixelsPerLine );
-}
-
-void wxScrolledWindow::SetScrollRate( int xstep, int ystep )
-{
- int old_x = m_xScrollPixelsPerLine * m_xScrollPosition;
- int old_y = m_yScrollPixelsPerLine * m_yScrollPosition;
-
- m_xScrollPixelsPerLine = xstep;
- m_yScrollPixelsPerLine = ystep;
-
- int new_x = m_xScrollPixelsPerLine * m_xScrollPosition;
- int new_y = m_yScrollPixelsPerLine * m_yScrollPosition;
-
- m_targetWindow->ScrollWindow( old_x - new_x, old_y - new_y );
-
- AdjustScrollbars();
-}
-
-void wxScrolledWindow::GetScrollPixelsPerUnit (int *x_unit, int *y_unit) const
-{
- if ( x_unit )
- *x_unit = m_xScrollPixelsPerLine;
- if ( y_unit )
- *y_unit = m_yScrollPixelsPerLine;
-}
-
-int wxScrolledWindow::GetScrollPageSize(int orient) const
-{
- if ( orient == wxHORIZONTAL )
- return m_xScrollLinesPerPage;
- else
- return m_yScrollLinesPerPage;
-}
-
-void wxScrolledWindow::SetScrollPageSize(int orient, int pageSize)
-{
- if ( orient == wxHORIZONTAL )
- m_xScrollLinesPerPage = pageSize;
- else
- m_yScrollLinesPerPage = pageSize;
-}
-
-void wxScrolledWindow::OnScroll(wxScrollWinEvent& event)
-{
- int orient = event.GetOrientation();
-
- int nScrollInc = CalcScrollInc(event);
- if (nScrollInc == 0) return;
-
- if (orient == wxHORIZONTAL)
- {
- int newPos = m_xScrollPosition + nScrollInc;
- SetScrollPos(wxHORIZONTAL, newPos, TRUE );
- }
- else