X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4eb5a0ec0421b3dba1c46c1dcb27a711af4bec36..9c894932284cac53d9cd8d8b2f16308bc65f44d6:/src/osx/slider_osx.cpp diff --git a/src/osx/slider_osx.cpp b/src/osx/slider_osx.cpp index ce4815ad3d..ef3a7f1b7d 100644 --- a/src/osx/slider_osx.cpp +++ b/src/osx/slider_osx.cpp @@ -4,7 +4,7 @@ // 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 ///////////////////////////////////////////////////////////////////////////// @@ -16,13 +16,11 @@ #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) -#ifdef wxOSX_USE_COCOA +#if wxOSX_USE_COCOA #define wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS 28 #define wxSLIDER_DIMENSIONACROSS_ARROW 21 #else @@ -166,6 +164,12 @@ void wxSlider::SetValue(int value) 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; @@ -186,9 +190,9 @@ void wxSlider::SetRange(int minValue, int maxValue) 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(); @@ -196,10 +200,13 @@ void wxSlider::SetRange(int minValue, int maxValue) 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; @@ -296,10 +303,10 @@ void wxSlider::TriggerScrollEvent( wxEventType scrollEvent) HandleWindowEvent( cevent ); } -bool wxSlider::OSXHandleClicked( double timestampsec ) +bool wxSlider::OSXHandleClicked( double WXUNUSED(timestampsec) ) { TriggerScrollEvent(wxEVT_SCROLL_THUMBRELEASE); - + return true; }