- if (style & wxSL_VERTICAL == wxSL_VERTICAL)
- m_widget = gtk_hscale_new( (GtkAdjustment *) NULL );
- else
- m_widget = gtk_vscale_new( (GtkAdjustment *) NULL );
-
- gtk_scale_set_draw_value( GTK_SCALE( m_widget ), FALSE );
-
- m_adjust = gtk_range_get_adjustment( GTK_RANGE(m_widget) );
-
- gtk_signal_connect( GTK_OBJECT(m_adjust),
- "value_changed",
- (GtkSignalFunc) gtk_slider_callback,
- (gpointer) this );
-
- SetRange( minValue, maxValue );
- SetValue( value );
-
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
-
- PostCreation();
-
- SetBackgroundColour( parent->GetBackgroundColour() );
-
- Show( TRUE );
-
- return TRUE;
+ GtkAdjustment* adj = gtk_range_get_adjustment (range);
+ const int pos = wxRound(adj->value);
+ const double oldPos = win->m_pos;
+ win->m_pos = adj->value;
+ if (win->m_blockScrollEvent)
+ {
+ win->m_scrollEventType = GTK_SCROLL_NONE;
+ return;
+ }
+
+ wxEventType eventType = wxEVT_NULL;
+ if (win->m_isScrolling)
+ {
+ eventType = wxEVT_SCROLL_THUMBTRACK;
+ }
+ else if (win->m_scrollEventType != GTK_SCROLL_NONE)
+ {
+ // Scroll event from "move-slider" (keyboard)
+ eventType = GtkScrollTypeToWx(win->m_scrollEventType);
+ }
+ else if (win->m_mouseButtonDown)
+ {
+ // Difference from last change event
+ const double diff = adj->value - oldPos;
+ const bool isDown = diff > 0;
+
+ if (IsScrollIncrement(adj->page_increment, diff))
+ {
+ eventType = isDown ? wxEVT_SCROLL_PAGEDOWN : wxEVT_SCROLL_PAGEUP;
+ }
+ else if (wxIsSameDouble(adj->value, 0))
+ {
+ eventType = wxEVT_SCROLL_PAGEUP;
+ }
+ else if (wxIsSameDouble(adj->value, adj->upper))
+ {
+ eventType = wxEVT_SCROLL_PAGEDOWN;
+ }
+ else
+ {
+ // Assume track event
+ eventType = wxEVT_SCROLL_THUMBTRACK;
+ // Remember that we're tracking
+ win->m_isScrolling = true;
+ }
+ }
+
+ win->m_scrollEventType = GTK_SCROLL_NONE;
+
+ // If integral position has changed
+ if (wxRound(oldPos) != pos)
+ {
+ wxCHECK_RET(eventType != wxEVT_NULL, _T("Unknown slider scroll event type"));
+ ProcessScrollEvent(win, eventType);
+ win->m_needThumbRelease = eventType == wxEVT_SCROLL_THUMBTRACK;
+ }
+}