// Name: src/gtk1/slider.cpp
// Purpose:
// Author: Robert Roebling
-// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
return fabs(x - y) < 0.02;
}
-static inline int AdjustValueToInt(double x)
-{
- // we want to round to the nearest integer, i.e. 0.9 is rounded to 1 and
- // -0.9 is rounded to -1
- return (int)(x < 0 ? x - 0.5 : x + 0.5);
-}
-
// process a scroll event
static void
ProcessScrollEvent(wxSlider *win, wxEventType evtType, double dvalue)
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 );
+ win->HandleWindowEvent( event );
if ( evtType != wxEVT_SCROLL_THUMBTRACK )
{
wxScrollEvent event2(wxEVT_SCROLL_CHANGED, win->GetId(), value, orient);
event2.SetEventObject( win );
- win->GetEventHandler()->ProcessEvent( event2 );
+ win->HandleWindowEvent( event2 );
}
- wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, win->GetId() );
+ wxCommandEvent cevent( wxEVT_SLIDER, win->GetId() );
cevent.SetEventObject( win );
cevent.SetInt( value );
- win->GetEventHandler()->ProcessEvent( cevent );
+ win->HandleWindowEvent( cevent );
}
//-----------------------------------------------------------------------------
// wxSlider
//-----------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(wxSlider,wxControl)
-
bool wxSlider::Create(wxWindow *parent, wxWindowID id,
int value, int minValue, int maxValue,
const wxPoint& pos, const wxSize& size,
m_oldPos = 0.0;
if (style & wxSL_VERTICAL)
- m_widget = gtk_vscale_new( (GtkAdjustment *) NULL );
+ m_widget = gtk_vscale_new( NULL );
else
- m_widget = gtk_hscale_new( (GtkAdjustment *) NULL );
+ m_widget = gtk_hscale_new( NULL );
if (style & wxSL_LABELS)
{
int wxSlider::GetValue() const
{
- return AdjustValueToInt(m_adjust->value);
+ return wxRound(m_adjust->value);
}
void wxSlider::SetValue( int value )