// Author: Stefan Csomor
// Modified by:
// Created: 1998-01-01
-// RCS-ID: $Id: slider.cpp 54129 2008-06-11 19:30:52Z SC $
+// RCS-ID: $Id$
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/slider.h"
#include "wx/osx/private.h"
-IMPLEMENT_DYNAMIC_CLASS(wxSlider, wxControl)
-
BEGIN_EVENT_TABLE(wxSlider, wxControl)
END_EVENT_TABLE()
// The dimensions of the different styles of sliders (from Aqua document)
-#define wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS 24
-#define wxSLIDER_DIMENSIONACROSS_ARROW 18
+#if wxOSX_USE_COCOA
+ #define wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS 28
+ #define wxSLIDER_DIMENSIONACROSS_ARROW 21
+#else
+ #define wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS 24
+ #define wxSLIDER_DIMENSIONACROSS_ARROW 18
+#endif
// Distance between slider and text
#define wxSLIDER_BORDERTEXT 5
void wxSlider::SetRange(int minValue, int maxValue)
{
+ // Changing the range preserves the value of the native control but may
+ // change our logical value if we're inverting the native value to get it
+ // as ValueInvertOrNot() depends on the range so preserve it before
+ // changing the range.
+ const int valueOld = GetValue();
+
wxString value;
m_rangeMin = minValue;
m_macMaximumStatic->SetLabel( value );
}
- // If the range is out of bounds, set it to a
+ // If the range is out of bounds, set it to a
// value that is within bounds
- // RN: Testing reveals OSX does its own
+ // RN: Testing reveals OSX does its own
// bounding, perhaps this isn't needed?
int currentValue = GetValue();
SetValue(m_rangeMin);
else if(currentValue > m_rangeMax)
SetValue(m_rangeMax);
+
+ // Ensure that our value didn't change.
+ SetValue(valueOld);
}
// For trackbars only
-void wxSlider::SetTickFreq(int n, int WXUNUSED(pos))
+void wxSlider::DoSetTickFreq(int n)
{
// TODO
m_tickFreq = n;
ProcessCommand(event);
}
-void wxSlider::MacHandleControlClick(WXWidget WXUNUSED(control),
- wxInt16 WXUNUSED(controlpart),
- bool WXUNUSED(mouseStillDown))
+void wxSlider::TriggerScrollEvent( wxEventType scrollEvent)
{
// Whatever the native value is, we may need to invert it for calling
// SetValue and putting the possibly inverted value in the event
SetValue( value );
- wxScrollEvent event( wxEVT_SCROLL_THUMBTRACK, m_windowId );
+ wxScrollEvent event( scrollEvent, m_windowId );
event.SetPosition( value );
event.SetEventObject( this );
HandleWindowEvent( event );
HandleWindowEvent( cevent );
}
-bool wxSlider::HandleClicked( double timestampsec )
+bool wxSlider::OSXHandleClicked( double WXUNUSED(timestampsec) )
{
- // Whatever the native value is, we may need to invert it for calling
- // SetValue and putting the possibly inverted value in the event
- int value = ValueInvertOrNot( m_peer->GetValue() ) ;
-
- SetValue( value ) ;
-
- wxScrollEvent event( wxEVT_SCROLL_THUMBRELEASE, m_windowId );
- event.SetPosition( value );
- event.SetEventObject( this );
- HandleWindowEvent( event );
-
- wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, m_windowId );
- cevent.SetInt( value );
- cevent.SetEventObject( this );
-
- HandleWindowEvent( cevent );
+ TriggerScrollEvent(wxEVT_SCROLL_THUMBRELEASE);
return true;
}