X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/aec0ed2e25e8eb0b06067018045448ce5f052b2c..b49576e07725d578c231fdd09243d9edb0eab701:/src/gtk/spinctrl.cpp?ds=inline diff --git a/src/gtk/spinctrl.cpp b/src/gtk/spinctrl.cpp index 6411633ad3..10651bf765 100644 --- a/src/gtk/spinctrl.cpp +++ b/src/gtk/spinctrl.cpp @@ -17,7 +17,6 @@ #if wxUSE_SPINCTRL #include "wx/utils.h" -#include "wx/spinbutt.h" #include @@ -31,14 +30,14 @@ extern void wxapp_install_idle_handler(); extern bool g_isIdle; +static const float sensitivity = 0.02; + //----------------------------------------------------------------------------- // data //----------------------------------------------------------------------------- extern bool g_blockEventsOnDrag; -static const float sensitivity = 0.02; - //----------------------------------------------------------------------------- // "value_changed" //----------------------------------------------------------------------------- @@ -50,34 +49,10 @@ static void gtk_spinctrl_callback( GtkWidget *WXUNUSED(widget), wxSpinCtrl *win if (!win->m_hasVMT) return; if (g_blockEventsOnDrag) return; - float diff = win->m_adjust->value - win->m_oldPos; - if (fabs(diff) < sensitivity) return; - win->m_oldPos = win->m_adjust->value; - - wxEventType command = wxEVT_NULL; - - float line_step = win->m_adjust->step_increment; - - if (fabs(diff-line_step) < sensitivity) command = wxEVT_SCROLL_LINEDOWN; - else if (fabs(diff+line_step) < sensitivity) command = wxEVT_SCROLL_LINEUP; - else command = wxEVT_SCROLL_THUMBTRACK; - - int value = (int)ceil(win->m_adjust->value); - - wxSpinEvent event( command, win->GetId()); - event.SetPosition( value ); + wxCommandEvent event( wxEVT_COMMAND_SPINCTRL_UPDATED, win->GetId()); event.SetEventObject( win ); + event.SetInt( win->GetValue() ); win->GetEventHandler()->ProcessEvent( event ); - - /* 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 ); - } } //----------------------------------------------------------------------------- @@ -108,7 +83,7 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id, !CreateBase( parent, id, pos, new_size, style, wxDefaultValidator, name )) { wxFAIL_MSG( wxT("wxSpinCtrl creation failed") ); - return FALSE; + return FALSE; } m_oldPos = initial; @@ -221,13 +196,13 @@ void wxSpinCtrl::OnChar( wxKeyEvent &event ) wxWindow *top_frame = m_parent; while (top_frame->GetParent() && !(top_frame->GetParent()->m_isFrame)) top_frame = top_frame->GetParent(); - GtkWindow *window = GTK_WINDOW(top_frame->m_widget); + GtkWindow *window = GTK_WINDOW(top_frame->m_widget); - if (window->default_widget) + if (window->default_widget) { gtk_widget_activate (window->default_widget); - return; - } + return; + } } event.Skip();