merged in fix for GetValue() from the 2.2 branch
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8923 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
beed393c67
commit
ef7a25a73e
@ -95,7 +95,7 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
|
||||
!CreateBase( parent, id, pos, size, style, validator, name ))
|
||||
{
|
||||
wxFAIL_MSG( wxT("wxSlider creation failed") );
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_oldPos = 0.0;
|
||||
@ -108,7 +108,7 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
|
||||
if (style & wxSL_LABELS)
|
||||
{
|
||||
gtk_scale_set_draw_value( GTK_SCALE( m_widget ), TRUE );
|
||||
gtk_scale_set_digits( GTK_SCALE( m_widget ), 0 );
|
||||
gtk_scale_set_digits( GTK_SCALE( m_widget ), 0 );
|
||||
|
||||
/* labels need more space and too small window will
|
||||
cause junk to appear on the dialog */
|
||||
@ -157,7 +157,10 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
|
||||
|
||||
int wxSlider::GetValue() const
|
||||
{
|
||||
return (int)(m_adjust->value+0.5);
|
||||
// we want to round to the nearest integer, i.e. 0.9 is rounded to 1 and
|
||||
// -0.9 is rounded to -1
|
||||
double val = m_adjust->value;
|
||||
return (int)(val >= 0 ? val - 0.5 : val + 0.5);
|
||||
}
|
||||
|
||||
void wxSlider::SetValue( int value )
|
||||
|
@ -95,7 +95,7 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
|
||||
!CreateBase( parent, id, pos, size, style, validator, name ))
|
||||
{
|
||||
wxFAIL_MSG( wxT("wxSlider creation failed") );
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_oldPos = 0.0;
|
||||
@ -108,7 +108,7 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
|
||||
if (style & wxSL_LABELS)
|
||||
{
|
||||
gtk_scale_set_draw_value( GTK_SCALE( m_widget ), TRUE );
|
||||
gtk_scale_set_digits( GTK_SCALE( m_widget ), 0 );
|
||||
gtk_scale_set_digits( GTK_SCALE( m_widget ), 0 );
|
||||
|
||||
/* labels need more space and too small window will
|
||||
cause junk to appear on the dialog */
|
||||
@ -157,7 +157,10 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
|
||||
|
||||
int wxSlider::GetValue() const
|
||||
{
|
||||
return (int)(m_adjust->value+0.5);
|
||||
// we want to round to the nearest integer, i.e. 0.9 is rounded to 1 and
|
||||
// -0.9 is rounded to -1
|
||||
double val = m_adjust->value;
|
||||
return (int)(val >= 0 ? val - 0.5 : val + 0.5);
|
||||
}
|
||||
|
||||
void wxSlider::SetValue( int value )
|
||||
|
Loading…
Reference in New Issue
Block a user