- long style, const wxString& name )
-{
- m_needParent = TRUE;
-
- PreCreation( parent, id, pos, size, style, name );
-
- m_oldPos = 0.0;
-
- if (style & wxSB_VERTICAL == wxSB_VERTICAL)
- m_widget = gtk_hscrollbar_new( NULL );
- else
- m_widget = gtk_vscrollbar_new( NULL );
-
- m_adjust = gtk_range_get_adjustment( GTK_RANGE(m_widget) );
-
- gtk_signal_connect (GTK_OBJECT (m_adjust), "value_changed",
- (GtkSignalFunc) gtk_scrollbar_callback, (gpointer) this );
-
- PostCreation();
-
- Show( TRUE );
-
- return TRUE;
-};
-
-int wxScrollBar::GetPosition(void) const
-{
- return (int)(m_adjust->value+0.5);
-};
+ long style, const wxValidator& validator, const wxString& name )
+{
+ m_needParent = true;
+ m_acceptsFocus = true;
+
+ if (!PreCreation( parent, pos, size ) ||
+ !CreateBase( parent, id, pos, size, style, validator, name ))
+ {
+ wxFAIL_MSG( wxT("wxScrollBar creation failed") );
+ return false;
+ }
+
+ m_oldPos = 0.0;
+
+ if ((style & wxSB_VERTICAL) == wxSB_VERTICAL)
+ m_widget = gtk_vscrollbar_new( (GtkAdjustment *) NULL );
+ else
+ m_widget = gtk_hscrollbar_new( (GtkAdjustment *) NULL );
+
+ m_adjust = gtk_range_get_adjustment( GTK_RANGE(m_widget) );
+ if ( style & wxSB_VERTICAL )
+ {
+ SetVScrollAdjustment(m_adjust);
+ }
+
+ g_signal_connect (m_adjust, "value_changed",
+ G_CALLBACK (gtk_scrollbar_callback), this);
+ g_signal_connect (m_widget, "button_press_event",
+ G_CALLBACK (gtk_scrollbar_button_press_callback),
+ this);
+ g_signal_connect (m_widget, "button_release_event",
+ G_CALLBACK (gtk_scrollbar_button_release_callback),
+ this);
+
+ m_parent->DoAddChild( this );
+
+ PostCreation(size);
+
+ return true;
+}
+
+int wxScrollBar::GetThumbPosition() const
+{
+ double val = m_adjust->value;
+ return (int)(val < 0 ? val - 0.5 : val + 0.5);
+}