wxSL_INVERSE for MSW. Heavily modified patch 1096922.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31912 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -99,6 +99,9 @@ protected:
|
|||||||
// format an integer value as string
|
// format an integer value as string
|
||||||
static wxString Format(int n) { return wxString::Format(_T("%d"), n); }
|
static wxString Format(int n) { return wxString::Format(_T("%d"), n); }
|
||||||
|
|
||||||
|
// Common processing to invert slider values based on wxSL_INVERSE
|
||||||
|
int MSWInvertOrNot(int value) const;
|
||||||
|
|
||||||
// get the boundig box for the slider and possible labels
|
// get the boundig box for the slider and possible labels
|
||||||
wxRect GetBoundingBox() const;
|
wxRect GetBoundingBox() const;
|
||||||
|
|
||||||
|
@@ -103,6 +103,7 @@ wxBEGIN_FLAGS( wxSliderStyle )
|
|||||||
wxFLAGS_MEMBER(wxSL_BOTTOM)
|
wxFLAGS_MEMBER(wxSL_BOTTOM)
|
||||||
wxFLAGS_MEMBER(wxSL_BOTH)
|
wxFLAGS_MEMBER(wxSL_BOTH)
|
||||||
wxFLAGS_MEMBER(wxSL_SELRANGE)
|
wxFLAGS_MEMBER(wxSL_SELRANGE)
|
||||||
|
wxFLAGS_MEMBER(wxSL_INVERSE)
|
||||||
|
|
||||||
wxEND_FLAGS( wxSliderStyle )
|
wxEND_FLAGS( wxSliderStyle )
|
||||||
|
|
||||||
@@ -306,7 +307,7 @@ bool wxSlider95::MSWOnScroll(int WXUNUSED(orientation),
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int newPos = (int) ::SendMessage((HWND) control, TBM_GETPOS, 0, 0);
|
int newPos = MSWInvertOrNot((int) ::SendMessage((HWND) control, TBM_GETPOS, 0, 0));
|
||||||
if ( (newPos < GetMin()) || (newPos > GetMax()) )
|
if ( (newPos < GetMin()) || (newPos > GetMax()) )
|
||||||
{
|
{
|
||||||
// out of range - but we did process it
|
// out of range - but we did process it
|
||||||
@@ -506,14 +507,22 @@ wxSize wxSlider95::DoGetBestSize() const
|
|||||||
// slider-specific methods
|
// slider-specific methods
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
int wxSlider95::MSWInvertOrNot(int value) const
|
||||||
|
{
|
||||||
|
if (m_windowStyle & wxSL_INVERSE)
|
||||||
|
return (m_rangeMax + m_rangeMin) - value;
|
||||||
|
else
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
int wxSlider95::GetValue() const
|
int wxSlider95::GetValue() const
|
||||||
{
|
{
|
||||||
return ::SendMessage(GetHwnd(), TBM_GETPOS, 0, 0);
|
return MSWInvertOrNot(::SendMessage(GetHwnd(), TBM_GETPOS, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSlider95::SetValue(int value)
|
void wxSlider95::SetValue(int value)
|
||||||
{
|
{
|
||||||
::SendMessage(GetHwnd(), TBM_SETPOS, (WPARAM)TRUE, (LPARAM)value);
|
::SendMessage(GetHwnd(), TBM_SETPOS, (WPARAM)TRUE, (LPARAM)MSWInvertOrNot(value));
|
||||||
|
|
||||||
if ( m_labels )
|
if ( m_labels )
|
||||||
{
|
{
|
||||||
@@ -530,8 +539,8 @@ void wxSlider95::SetRange(int minValue, int maxValue)
|
|||||||
|
|
||||||
if ( m_labels )
|
if ( m_labels )
|
||||||
{
|
{
|
||||||
::SetWindowText((*m_labels)[SliderLabel_Min], Format(m_rangeMin));
|
::SetWindowText((*m_labels)[SliderLabel_Min], Format(MSWInvertOrNot(m_rangeMin)));
|
||||||
::SetWindowText((*m_labels)[SliderLabel_Max], Format(m_rangeMax));
|
::SetWindowText((*m_labels)[SliderLabel_Max], Format(MSWInvertOrNot(m_rangeMax)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user