- m_targetWindow->GetClientSize( &w, &h );
- m_targetWindow->GetVirtualSize( &vw, &vh );
-
- if (m_xScrollPixelsPerLine == 0)
- {
- m_hAdjust->upper = 1.0;
- m_hAdjust->page_increment = 1.0;
- m_hAdjust->page_size = 1.0;
- }
- else
- {
- m_hAdjust->upper = (vw+m_xScrollPixelsPerLine-1) / m_xScrollPixelsPerLine;
- m_hAdjust->page_size = w / m_xScrollPixelsPerLine;
- m_hAdjust->page_increment = w / m_xScrollPixelsPerLine;
-
- // Special case. When client and virtual size are very close but
- // the client is big enough, kill scrollbar.
-
- if ((m_hAdjust->page_size < m_hAdjust->upper) && (w >= vw))
- m_hAdjust->page_size += 1.0;
-
- // If the scrollbar hits the right side, move the window
- // right to keep it from over extending.
-
- if ((m_hAdjust->value != 0.0) && (m_hAdjust->value + m_hAdjust->page_size > m_hAdjust->upper))
- {
- m_hAdjust->value = m_hAdjust->upper - m_hAdjust->page_size;
- if (m_hAdjust->value < 0.0)
- m_hAdjust->value = 0.0;
-
- if (GetChildren().GetCount() == 0)
- m_xScrollPosition = (int)m_hAdjust->value; // This is enough without child windows
- else
- gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "value_changed" ); // Actually scroll window
- }
- }
-
- if (m_yScrollPixelsPerLine == 0)
- {
- m_vAdjust->upper = 1.0;
- m_vAdjust->page_increment = 1.0;
- m_vAdjust->page_size = 1.0;
- }
- else
- {
- m_vAdjust->upper = (vh+m_yScrollPixelsPerLine-1) / m_yScrollPixelsPerLine;
- m_vAdjust->page_size = h / m_yScrollPixelsPerLine;
- m_vAdjust->page_increment = h / m_yScrollPixelsPerLine;
-
- if ((m_vAdjust->page_size < m_vAdjust->upper) && (h >= vh))
- m_vAdjust->page_size += 1.0;
-
- if ((m_vAdjust->value != 0.0) && (m_vAdjust->value + m_vAdjust->page_size > m_vAdjust->upper))
- {
- m_vAdjust->value = m_vAdjust->upper - m_vAdjust->page_size;
- if (m_vAdjust->value < 0.0)
- m_vAdjust->value = 0.0;
-
- if (GetChildren().GetCount() == 0)
- m_yScrollPosition = (int)m_vAdjust->value;
- else
- gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "value_changed" );
- }
- }
-
- m_xScrollLinesPerPage = (int)(m_hAdjust->page_increment + 0.5);
- m_yScrollLinesPerPage = (int)(m_vAdjust->page_increment + 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() const
-{
- 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::DoPrepareDC(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