#if wxUSE_SLIDER
#include "wx/utils.h"
+
#include <math.h>
-#include "gdk/gdk.h"
-#include "gtk/gtk.h"
+#include <gdk/gdk.h>
+#include <gtk/gtk.h>
//-----------------------------------------------------------------------------
// idle system
extern bool g_blockEventsOnDrag;
+static const float sensitivity = 0.02;
+
//-----------------------------------------------------------------------------
// "value_changed"
//-----------------------------------------------------------------------------
if (g_blockEventsOnDrag) return;
float diff = adjust->value - win->m_oldPos;
- if (fabs(diff) < 0.2) return;
+ if (fabs(diff) < sensitivity) return;
win->m_oldPos = adjust->value;
IMPLEMENT_DYNAMIC_CLASS(wxSlider,wxControl)
-wxSlider::wxSlider(void)
-{
-}
-
-wxSlider::~wxSlider(void)
-{
-}
-
bool wxSlider::Create(wxWindow *parent, wxWindowID id,
int value, int minValue, int maxValue,
const wxPoint& pos, const wxSize& size,
!CreateBase( parent, id, pos, size, style, validator, name ))
{
wxFAIL_MSG( wxT("wxSlider creation failed") );
- return FALSE;
+ return FALSE;
}
m_oldPos = 0.0;
if (style & wxSL_LABELS)
{
gtk_scale_set_draw_value( GTK_SCALE( m_widget ), TRUE );
+ 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 */
return TRUE;
}
-int wxSlider::GetValue(void) const
+int wxSlider::GetValue() const
{
return (int)(m_adjust->value+0.5);
}
m_adjust->lower = fmin;
m_adjust->upper = fmax;
+ m_adjust->step_increment = 1.0;
+ m_adjust->page_increment = ceil((fmax-fmin) / 10.0);
gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "changed" );
}
-int wxSlider::GetMin(void) const
+int wxSlider::GetMin() const
{
return (int)ceil(m_adjust->lower);
}
-int wxSlider::GetMax(void) const
+int wxSlider::GetMax() const
{
return (int)ceil(m_adjust->upper);
}
gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "changed" );
}
-int wxSlider::GetPageSize(void) const
+int wxSlider::GetPageSize() const
{
return (int)ceil(m_adjust->page_increment);
}
gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "changed" );
}
-int wxSlider::GetThumbLength(void) const
+int wxSlider::GetThumbLength() const
{
return (int)ceil(m_adjust->page_size);
}
{
}
-int wxSlider::GetLineSize(void) const
+int wxSlider::GetLineSize() const
{
return 0;
}
{
}
-int wxSlider::GetTickFreq(void) const
+int wxSlider::GetTickFreq() const
{
return 0;
}
-void wxSlider::ClearTicks(void)
+void wxSlider::ClearTicks()
{
}
{
}
-int wxSlider::GetSelEnd(void) const
+int wxSlider::GetSelEnd() const
{
return 0;
}
-int wxSlider::GetSelStart(void) const
+int wxSlider::GetSelStart() const
{
return 0;
}
-void wxSlider::ClearSel(void)
+void wxSlider::ClearSel()
{
}