X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9fa72bd2a637cee761c56e2ce61cec3e43c62765..5d584acb8824a99b875a90aa48e6e6ccbe88b2ab:/src/gtk/slider.cpp diff --git a/src/gtk/slider.cpp b/src/gtk/slider.cpp index 8d497507d8..bcaacf7a73 100644 --- a/src/gtk/slider.cpp +++ b/src/gtk/slider.cpp @@ -18,13 +18,6 @@ #include "wx/math.h" #include "wx/gtk/private.h" -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - //----------------------------------------------------------------------------- // data //----------------------------------------------------------------------------- @@ -52,25 +45,34 @@ static inline int AdjustValueToInt(double x) static void ProcessScrollEvent(wxSlider *win, wxEventType evtType, double dvalue) { - int orient = win->GetWindowStyleFlag() & wxSL_VERTICAL ? wxVERTICAL - : wxHORIZONTAL; + const int orient = win->HasFlag(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 ); + const int value = (int)(dvalue < 0 ? dvalue - 0.5 : dvalue + 0.5); + // if we have any "special" event (i.e. the value changed by a line or a + // page), send this specific event first + if ( evtType != wxEVT_NULL ) + { + wxScrollEvent event( evtType, win->GetId(), value, orient ); + event.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent( event ); + } + + // but, in any case, except if we're dragging the slider (and so the change + // is not definitive), send a generic "changed" event if ( evtType != wxEVT_SCROLL_THUMBTRACK ) { - wxScrollEvent event2(wxEVT_SCROLL_CHANGED, win->GetId(), value, orient); - event2.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( event2 ); + wxScrollEvent event(wxEVT_SCROLL_CHANGED, win->GetId(), value, orient); + event.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent( event ); } - wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, win->GetId() ); - cevent.SetEventObject( win ); - cevent.SetInt( value ); - win->GetEventHandler()->ProcessEvent( cevent ); + // and also generate a command event for compatibility + wxCommandEvent event( wxEVT_COMMAND_SLIDER_UPDATED, win->GetId() ); + event.SetEventObject( win ); + event.SetInt( value ); + win->GetEventHandler()->ProcessEvent( event ); } //----------------------------------------------------------------------------- @@ -79,7 +81,6 @@ ProcessScrollEvent(wxSlider *win, wxEventType evtType, double dvalue) extern "C" { static void gtk_slider_callback( GtkAdjustment *adjust, - SCROLLBAR_CBACK_ARG wxSlider *win ) { if (g_isIdle) wxapp_install_idle_handler(); @@ -108,6 +109,8 @@ static void gtk_slider_callback( GtkAdjustment *adjust, evtType = wxEVT_SCROLL_TOP; else if ( AreSameAdjustValues(adjust->value, adjust->upper) ) evtType = wxEVT_SCROLL_BOTTOM; + else + evtType = wxEVT_NULL; // wxEVT_SCROLL_CHANGED will still be generated ProcessScrollEvent(win, evtType, dvalue);