-{
- if (!win->HasVMT()) return;
- if (g_blockEventsOnDrag) return;
-
- float diff = win->m_adjust->value - win->m_oldPos;
- if (fabs(diff) < 0.2) return;
-
- wxEventType command = wxEVT_NULL;
-
- float line_step = win->m_adjust->step_increment;
- float page_step = win->m_adjust->page_increment;
-
- if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN;
- else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP;
- else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN;
- else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP;
- else command = wxEVT_SCROLL_THUMBTRACK;
-
- int value = (int)(win->m_adjust->value+0.5);
-
- wxSpinEvent event( command, win->GetId());
- event.SetPosition( value );
- event.SetOrientation( wxVERTICAL );
- event.SetEventObject( win );
-
- win->ProcessEvent( event );
+{
+ if (g_isIdle) wxapp_install_idle_handler();
+
+ if (!win->m_hasVMT) return;
+ if (g_blockEventsOnDrag) return;
+
+ float diff = win->m_adjust->value - win->m_oldPos;
+ if (fabs(diff) < sensitivity) return;
+
+ wxEventType command = wxEVT_NULL;
+
+ float line_step = win->m_adjust->step_increment;
+
+ if (fabs(diff-line_step) < sensitivity) command = wxEVT_SCROLL_LINEUP;
+ else if (fabs(diff+line_step) < sensitivity) command = wxEVT_SCROLL_LINEDOWN;
+ else command = wxEVT_SCROLL_THUMBTRACK;
+
+ int value = (int)ceil(win->m_adjust->value);
+
+ wxSpinEvent event( command, win->GetId());
+ event.SetPosition( value );
+ event.SetEventObject( win );
+
+ if ((win->GetEventHandler()->ProcessEvent( event )) &&
+ !event.IsAllowed() )
+ {
+ /* program has vetoed */
+ win->m_adjust->value = win->m_oldPos;
+
+ gtk_signal_disconnect_by_func( GTK_OBJECT (win->m_adjust),
+ (GtkSignalFunc) gtk_spinbutt_callback,
+ (gpointer) win );
+
+ gtk_signal_emit_by_name( GTK_OBJECT(win->m_adjust), "value_changed" );
+
+ gtk_signal_connect( GTK_OBJECT (win->m_adjust),
+ "value_changed",
+ (GtkSignalFunc) gtk_spinbutt_callback,
+ (gpointer) win );
+ return;
+ }
+
+ win->m_oldPos = win->m_adjust->value;
+
+ /* always send a thumbtrack event */
+ if (command != wxEVT_SCROLL_THUMBTRACK)
+ {
+ command = wxEVT_SCROLL_THUMBTRACK;
+ wxSpinEvent event2( command, win->GetId());
+ event2.SetPosition( value );
+ event2.SetEventObject( win );
+ win->GetEventHandler()->ProcessEvent( event2 );
+ }