-{
- 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;
+
+ g_signal_handlers_disconnect_by_func (win->m_adjust,
+ (gpointer) gtk_spinbutt_callback,
+ win);
+
+ g_signal_emit_by_name (win->m_adjust, "value_changed");
+
+ g_signal_connect (win->m_adjust, "value_changed",
+ G_CALLBACK (gtk_spinbutt_callback), 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 );
+ }
+}