- int max = (int)(m_vAdjust->upper - m_vAdjust->page_size + 0.5);
- if (max < 0) max = 0;
- if (y_pos > max) y_pos = max;
- if (y_pos < 0) y_pos = 0;
-
- int old_y = m_yScrollPosition;
- m_yScrollPosition = y_pos;
- m_vAdjust->value = y_pos;
-
- m_targetWindow->ScrollWindow( 0, (old_y-m_yScrollPosition)*m_yScrollPixelsPerLine );
-
- // Just update the scrollbar, don't send any wxWindows event
- GtkVDisconnectEvent();
- gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "value_changed" );
- GtkVConnectEvent();
- }
-}
-
-void wxScrolledWindow::GtkVScroll( float value )
-{
- if (!m_targetWindow)
- return;
-
- if (m_yScrollPixelsPerLine == 0)
- return;
-
- int y_pos = (int)(value+0.5);
-
- if (y_pos == m_yScrollPosition)
- return;
-
- GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(m_widget);
- GtkRange *range = GTK_RANGE(scrolledWindow->vscrollbar);
-
- wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
- if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
- else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
- else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
- else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
-
- wxScrollWinEvent event( command, y_pos, wxVERTICAL );
- event.SetEventObject( this );
- GetEventHandler()->ProcessEvent( event );
-}
-
-void wxScrolledWindow::GtkHScroll( float value )
-{
- if (!m_targetWindow)
- return;
-
- if (m_xScrollPixelsPerLine == 0)
- return;
-
- int x_pos = (int)(value+0.5);
-
- if (x_pos == m_xScrollPosition)
- return;
-
- GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(m_widget);
- GtkRange *range = GTK_RANGE(scrolledWindow->hscrollbar);
-
- wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
- if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
- else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
- else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
- else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
-
- wxScrollWinEvent event( command, x_pos, wxHORIZONTAL );
- event.SetEventObject( this );
- GetEventHandler()->ProcessEvent( event );
-}
-
-void wxScrolledWindow::EnableScrolling (bool x_scroll, bool y_scroll)
-{
- m_xScrollingEnabled = x_scroll;
- m_yScrollingEnabled = y_scroll;
-}
-
-void wxScrolledWindow::GetVirtualSize (int *x, int *y) const
-{
- if ( x )
- *x = m_xScrollPixelsPerLine * m_xScrollLines;
- if ( y )
- *y = m_yScrollPixelsPerLine * m_yScrollLines;
-}
-
-// Where the current view starts from
-void wxScrolledWindow::GetViewStart (int *x, int *y) const
-{
- if ( x )
- *x = m_xScrollPosition;
- if ( y )
- *y = m_yScrollPosition;
-}
-
-void wxScrolledWindow::CalcScrolledPosition(int x, int y, int *xx, int *yy) const
-{
- if ( xx )
- *xx = x - m_xScrollPosition * m_xScrollPixelsPerLine;
- if ( yy )
- *yy = y - m_yScrollPosition * m_yScrollPixelsPerLine;
-}