- 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) );
+
+ gtk_signal_connect( GTK_OBJECT(m_adjust),
+ "value_changed",
+ (GtkSignalFunc) gtk_scrollbar_callback,
+ (gpointer) this );
+
+ gtk_signal_connect( GTK_OBJECT(m_widget),
+ "button_press_event",
+ (GtkSignalFunc)gtk_scrollbar_button_press_callback,
+ (gpointer) this );
+
+ gtk_signal_connect( GTK_OBJECT(m_widget),
+ "button_release_event",
+ (GtkSignalFunc)gtk_scrollbar_button_release_callback,
+ (gpointer) this );
+
+ m_parent->DoAddChild( this );
+
+ PostCreation();
+
+ SetBestSize(size);
+
+ SetBackgroundColour( parent->GetBackgroundColour() );
+
+ Show( TRUE );
+
+ return TRUE;
+}
+
+int wxScrollBar::GetThumbPosition() const
+{
+ double val = m_adjust->value;
+ return (int)(val < 0 ? val - 0.5 : val + 0.5);
+}