]> git.saurik.com Git - wxWidgets.git/commitdiff
merged in fix for GetValue() from the 2.2 branch
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 14 Dec 2000 15:48:30 +0000 (15:48 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 14 Dec 2000 15:48:30 +0000 (15:48 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8923 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/slider.cpp
src/gtk1/slider.cpp

index 838a5d2549b0ed95c6ceb645bafc25d27f54543f..58aa39db8193429e5844070da999d97ba0226394 100644 (file)
@@ -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 )
index 838a5d2549b0ed95c6ceb645bafc25d27f54543f..58aa39db8193429e5844070da999d97ba0226394 100644 (file)
@@ -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 )