diff --git a/include/wx/gtk/spinctrl.h b/include/wx/gtk/spinctrl.h index 900a1f2dc1..72de31d7ed 100644 --- a/include/wx/gtk/spinctrl.h +++ b/include/wx/gtk/spinctrl.h @@ -71,6 +71,8 @@ public: virtual GTKInputResult GTKInput(double* value) const = 0; virtual bool GTKOutput(wxString* text) const = 0; + virtual void GTKValueChanged() = 0; + protected: double DoGetValue() const; double DoGetMin() const; @@ -153,6 +155,7 @@ public: virtual GTKInputResult GTKInput(double* value) const wxOVERRIDE; virtual bool GTKOutput(wxString* text) const wxOVERRIDE; + virtual void GTKValueChanged() wxOVERRIDE; protected: virtual void GtkSetEntryWidth() wxOVERRIDE; @@ -224,6 +227,7 @@ public: virtual GTKInputResult GTKInput(double* value) const wxOVERRIDE; virtual bool GTKOutput(wxString* text) const wxOVERRIDE; + virtual void GTKValueChanged() wxOVERRIDE; protected: virtual void GtkSetEntryWidth() wxOVERRIDE; diff --git a/src/gtk/spinctrl.cpp b/src/gtk/spinctrl.cpp index fe64c3a906..c25be9a517 100644 --- a/src/gtk/spinctrl.cpp +++ b/src/gtk/spinctrl.cpp @@ -37,27 +37,12 @@ extern bool g_blockEventsOnDrag; extern "C" { static void -gtk_value_changed(GtkSpinButton* spinbutton, wxSpinCtrlGTKBase* win) +gtk_value_changed(GtkSpinButton*, wxSpinCtrlGTKBase* win) { if (g_blockEventsOnDrag) return; - if (wxIsKindOf(win, wxSpinCtrl)) - { - wxSpinEvent event(wxEVT_SPINCTRL, win->GetId()); - event.SetEventObject( win ); - event.SetPosition(static_cast(win)->GetValue()); - event.SetString(gtk_entry_get_text(GTK_ENTRY(spinbutton))); - win->HandleWindowEvent( event ); - } - else // wxIsKindOf(win, wxSpinCtrlDouble) - { - wxSpinDoubleEvent event( wxEVT_SPINCTRLDOUBLE, win->GetId()); - event.SetEventObject( win ); - event.SetValue(static_cast(win)->GetValue()); - event.SetString(gtk_entry_get_text(GTK_ENTRY(spinbutton))); - win->HandleWindowEvent( event ); - } + win->GTKValueChanged(); } } @@ -523,6 +508,15 @@ bool wxSpinCtrl::GTKOutput(wxString* text) const return true; } +void wxSpinCtrl::GTKValueChanged() +{ + wxSpinEvent event(wxEVT_SPINCTRL, GetId()); + event.SetEventObject( this ); + event.SetPosition(GetValue()); + event.SetString(GetTextValue()); + HandleWindowEvent( event ); +} + //----------------------------------------------------------------------------- // wxSpinCtrlDouble //----------------------------------------------------------------------------- @@ -568,4 +562,13 @@ bool wxSpinCtrlDouble::GTKOutput(wxString* WXUNUSED(text)) const return false; } +void wxSpinCtrlDouble::GTKValueChanged() +{ + wxSpinDoubleEvent event( wxEVT_SPINCTRLDOUBLE, GetId()); + event.SetEventObject( this ); + event.SetValue(GetValue()); + event.SetString(GetTextValue()); + HandleWindowEvent( event ); +} + #endif // wxUSE_SPINCTRL