+// ----------------------------------------------------------------------------
+// helper functions
+// ----------------------------------------------------------------------------
+
+// compare 2 adjustment values up to some (hardcoded) precision
+static inline bool AreSameAdjustValues(double x, double y)
+{
+ return fabs(x - y) < 0.02;
+}
+
+static inline int AdjustValueToInt(double x)
+{
+ // we want to round to the nearest integer, i.e. 0.9 is rounded to 1 and
+ // -0.9 is rounded to -1
+ return (int)(x < 0 ? x - 0.5 : x + 0.5);
+}
+
+// process a scroll event
+static void
+ProcessScrollEvent(wxSlider *win, wxEventType evtType, double dvalue)
+{
+ int orient = win->GetWindowStyleFlag() & wxSL_VERTICAL ? wxVERTICAL
+ : wxHORIZONTAL;
+
+ int value = (int)(dvalue < 0 ? dvalue - 0.5 : dvalue + 0.5);
+ wxScrollEvent event( evtType, win->GetId(), value, orient );
+ event.SetEventObject( win );
+ win->GetEventHandler()->ProcessEvent( event );
+
+ if ( evtType != wxEVT_SCROLL_THUMBTRACK )
+ {
+ wxScrollEvent event2(wxEVT_SCROLL_CHANGED, win->GetId(), value, orient);
+ event2.SetEventObject( win );
+ win->GetEventHandler()->ProcessEvent( event2 );
+ }
+
+ wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, win->GetId() );
+ cevent.SetEventObject( win );
+ cevent.SetInt( value );
+ win->GetEventHandler()->ProcessEvent( cevent );
+}