Replace dynamic cast with a virtual GTKValueChanged() function
No real changes, but using a virtual function is simpler and safer than using wxIsKindOf().
This commit is contained in:
@@ -71,6 +71,8 @@ public:
|
|||||||
virtual GTKInputResult GTKInput(double* value) const = 0;
|
virtual GTKInputResult GTKInput(double* value) const = 0;
|
||||||
virtual bool GTKOutput(wxString* text) const = 0;
|
virtual bool GTKOutput(wxString* text) const = 0;
|
||||||
|
|
||||||
|
virtual void GTKValueChanged() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
double DoGetValue() const;
|
double DoGetValue() const;
|
||||||
double DoGetMin() const;
|
double DoGetMin() const;
|
||||||
@@ -153,6 +155,7 @@ public:
|
|||||||
|
|
||||||
virtual GTKInputResult GTKInput(double* value) const wxOVERRIDE;
|
virtual GTKInputResult GTKInput(double* value) const wxOVERRIDE;
|
||||||
virtual bool GTKOutput(wxString* text) const wxOVERRIDE;
|
virtual bool GTKOutput(wxString* text) const wxOVERRIDE;
|
||||||
|
virtual void GTKValueChanged() wxOVERRIDE;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void GtkSetEntryWidth() wxOVERRIDE;
|
virtual void GtkSetEntryWidth() wxOVERRIDE;
|
||||||
@@ -224,6 +227,7 @@ public:
|
|||||||
|
|
||||||
virtual GTKInputResult GTKInput(double* value) const wxOVERRIDE;
|
virtual GTKInputResult GTKInput(double* value) const wxOVERRIDE;
|
||||||
virtual bool GTKOutput(wxString* text) const wxOVERRIDE;
|
virtual bool GTKOutput(wxString* text) const wxOVERRIDE;
|
||||||
|
virtual void GTKValueChanged() wxOVERRIDE;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void GtkSetEntryWidth() wxOVERRIDE;
|
virtual void GtkSetEntryWidth() wxOVERRIDE;
|
||||||
|
@@ -37,27 +37,12 @@ extern bool g_blockEventsOnDrag;
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
static void
|
static void
|
||||||
gtk_value_changed(GtkSpinButton* spinbutton, wxSpinCtrlGTKBase* win)
|
gtk_value_changed(GtkSpinButton*, wxSpinCtrlGTKBase* win)
|
||||||
{
|
{
|
||||||
if (g_blockEventsOnDrag)
|
if (g_blockEventsOnDrag)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (wxIsKindOf(win, wxSpinCtrl))
|
win->GTKValueChanged();
|
||||||
{
|
|
||||||
wxSpinEvent event(wxEVT_SPINCTRL, win->GetId());
|
|
||||||
event.SetEventObject( win );
|
|
||||||
event.SetPosition(static_cast<wxSpinCtrl*>(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<wxSpinCtrlDouble*>(win)->GetValue());
|
|
||||||
event.SetString(gtk_entry_get_text(GTK_ENTRY(spinbutton)));
|
|
||||||
win->HandleWindowEvent( event );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -523,6 +508,15 @@ bool wxSpinCtrl::GTKOutput(wxString* text) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxSpinCtrl::GTKValueChanged()
|
||||||
|
{
|
||||||
|
wxSpinEvent event(wxEVT_SPINCTRL, GetId());
|
||||||
|
event.SetEventObject( this );
|
||||||
|
event.SetPosition(GetValue());
|
||||||
|
event.SetString(GetTextValue());
|
||||||
|
HandleWindowEvent( event );
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxSpinCtrlDouble
|
// wxSpinCtrlDouble
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -568,4 +562,13 @@ bool wxSpinCtrlDouble::GTKOutput(wxString* WXUNUSED(text)) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxSpinCtrlDouble::GTKValueChanged()
|
||||||
|
{
|
||||||
|
wxSpinDoubleEvent event( wxEVT_SPINCTRLDOUBLE, GetId());
|
||||||
|
event.SetEventObject( this );
|
||||||
|
event.SetValue(GetValue());
|
||||||
|
event.SetString(GetTextValue());
|
||||||
|
HandleWindowEvent( event );
|
||||||
|
}
|
||||||
|
|
||||||
#endif // wxUSE_SPINCTRL
|
#endif // wxUSE_SPINCTRL
|
||||||
|
Reference in New Issue
Block a user