+void wxScrolledWindow::SetScrollPos( int orient, int pos, bool refresh )
+{
+ wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
+
+ wxCHECK_RET( m_wxwindow != NULL, wxT("window needs client area for scrolling") );
+
+ if (orient == wxHORIZONTAL)
+ {
+ int max = (int)(m_hAdjust->upper - m_hAdjust->page_size + 0.5);
+ if (max < 0) max = 0;
+
+ if (pos > max) pos = 0;
+ if (pos < 0) pos = 0;
+
+ if (pos == (int)(m_hAdjust->value+0.5)) return;
+ m_hAdjust->value = pos;
+ }
+ else
+ {
+ int max = (int)(m_vAdjust->upper - m_vAdjust->page_size + 0.5);
+ if (max < 0) max = 0;
+
+ if (pos > max) pos = 0;
+ if (pos < 0) pos = 0;
+
+ if (pos == (int)(m_vAdjust->value+0.5)) return;
+ m_vAdjust->value = pos;
+ }
+
+ if (m_wxwindow->window)
+ {
+ if (orient == wxHORIZONTAL)
+ {
+ // Just update the scrollbar, don't send any wxWindows event
+ GtkHDisconnectEvent();
+ gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "value_changed" );
+ GtkHConnectEvent();
+ }
+ else
+ {
+ // 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::GtkVConnectEvent()
+{
+ gtk_signal_connect( GTK_OBJECT(m_vAdjust), "value_changed",
+ (GtkSignalFunc) gtk_scrolled_window_vscroll_callback, (gpointer) this );
+}
+
+void wxScrolledWindow::GtkHConnectEvent()
+{
+ gtk_signal_connect( GTK_OBJECT(m_hAdjust), "value_changed",
+ (GtkSignalFunc) gtk_scrolled_window_hscroll_callback, (gpointer) this );
+}
+
+void wxScrolledWindow::GtkHDisconnectEvent()
+{
+ gtk_signal_disconnect_by_func( GTK_OBJECT(m_hAdjust),
+ (GtkSignalFunc) gtk_scrolled_window_hscroll_callback, (gpointer) this );
+}
+
+void wxScrolledWindow::GtkVDisconnectEvent()
+{
+ gtk_signal_disconnect_by_func( GTK_OBJECT(m_vAdjust),
+ (GtkSignalFunc) gtk_scrolled_window_vscroll_callback, (gpointer) this );
+}
+