X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6181cef53222dc7f04e0e52fc4a2d399709a076e..94ac840b49616e27ef30da6824aba9ec5c8321e7:/src/msw/slider95.cpp?ds=sidebyside diff --git a/src/msw/slider95.cpp b/src/msw/slider95.cpp index 8d091ca80a..1f1f651ff9 100644 --- a/src/msw/slider95.cpp +++ b/src/msw/slider95.cpp @@ -103,6 +103,7 @@ wxBEGIN_FLAGS( wxSliderStyle ) wxFLAGS_MEMBER(wxSL_BOTTOM) wxFLAGS_MEMBER(wxSL_BOTH) wxFLAGS_MEMBER(wxSL_SELRANGE) + wxFLAGS_MEMBER(wxSL_INVERSE) wxEND_FLAGS( wxSliderStyle ) @@ -207,6 +208,14 @@ wxSlider95::Create(wxWindow *parent, SetValue(value); SetPageSize((maxValue - minValue)/10); + // we need to position the labels correctly if we have them and if + // SetSize() hadn't been called before (when best size was determined by + // MSWCreateControl()) as in this case they haven't been put in place yet + if ( m_labels && size.x != wxDefaultCoord && size.y != wxDefaultCoord ) + { + SetSize(size); + } + return true; } @@ -298,7 +307,7 @@ bool wxSlider95::MSWOnScroll(int WXUNUSED(orientation), return false; } - int newPos = (int) ::SendMessage((HWND) control, TBM_GETPOS, 0, 0); + int newPos = ValueInvertOrNot((int) ::SendMessage((HWND) control, TBM_GETPOS, 0, 0)); if ( (newPos < GetMin()) || (newPos > GetMax()) ) { // out of range - but we did process it @@ -338,7 +347,11 @@ wxRect wxSlider95::GetBoundingBox() const wxRect rect(x, y, w, h); if ( m_labels ) - rect.Union(m_labels->GetBoundingBox()); + { + wxRect lrect = m_labels->GetBoundingBox(); + GetParent()->ScreenToClient(&lrect.x, &lrect.y); + rect.Union(lrect); + } return rect; } @@ -394,6 +407,9 @@ void wxSlider95::DoMoveWindow(int x, int y, int width, int height) return; } + // be careful to position the slider itself after moving the labels as + // otherwise our GetBoundingBox(), which is called from WM_SIZE handler, + // would return a wrong result and wrong size would be cached internally if ( HasFlag(wxSL_VERTICAL) ) { int wLabel; @@ -401,14 +417,6 @@ void wxSlider95::DoMoveWindow(int x, int y, int width, int height) int xLabel = HasFlag(wxSL_LEFT) ? x + width - wLabel : x; - // position the slider itself along the left/right edge - ::MoveWindow(GetHwnd(), - HasFlag(wxSL_LEFT) ? x : x + wLabel + HGAP, - y + hLabel/2, - width - wLabel - HGAP, - height - hLabel, - TRUE); - // position all labels: min at the top, value in the middle and max at // the bottom ::MoveWindow((*m_labels)[SliderLabel_Min], @@ -419,6 +427,14 @@ void wxSlider95::DoMoveWindow(int x, int y, int width, int height) ::MoveWindow((*m_labels)[SliderLabel_Max], xLabel, y + height - hLabel, wLabel, hLabel, TRUE); + + // position the slider itself along the left/right edge + ::MoveWindow(GetHwnd(), + HasFlag(wxSL_LEFT) ? x : x + wLabel + HGAP, + y + hLabel/2, + width - wLabel - HGAP, + height - hLabel, + TRUE); } else // horizontal { @@ -427,14 +443,6 @@ void wxSlider95::DoMoveWindow(int x, int y, int width, int height) int yLabel = HasFlag(wxSL_TOP) ? y + height - hLabel : y; - // position the slider itself along the top/bottom edge - ::MoveWindow(GetHwnd(), - x, - HasFlag(wxSL_TOP) ? y : y + hLabel, - width, - height - hLabel, - TRUE); - // position all labels: min on the left, value in the middle and max to // the right ::MoveWindow((*m_labels)[SliderLabel_Min], @@ -445,6 +453,14 @@ void wxSlider95::DoMoveWindow(int x, int y, int width, int height) ::MoveWindow((*m_labels)[SliderLabel_Max], x + width - wLabel, yLabel, wLabel, hLabel, TRUE); + + // position the slider itself along the top/bottom edge + ::MoveWindow(GetHwnd(), + x, + HasFlag(wxSL_TOP) ? y : y + hLabel, + width, + height - hLabel, + TRUE); } } @@ -493,12 +509,12 @@ wxSize wxSlider95::DoGetBestSize() const int wxSlider95::GetValue() const { - return ::SendMessage(GetHwnd(), TBM_GETPOS, 0, 0); + return ValueInvertOrNot(::SendMessage(GetHwnd(), TBM_GETPOS, 0, 0)); } void wxSlider95::SetValue(int value) { - ::SendMessage(GetHwnd(), TBM_SETPOS, (WPARAM)TRUE, (LPARAM)value); + ::SendMessage(GetHwnd(), TBM_SETPOS, (WPARAM)TRUE, (LPARAM)ValueInvertOrNot(value)); if ( m_labels ) { @@ -515,8 +531,8 @@ void wxSlider95::SetRange(int minValue, int maxValue) if ( m_labels ) { - ::SetWindowText((*m_labels)[SliderLabel_Min], Format(m_rangeMin)); - ::SetWindowText((*m_labels)[SliderLabel_Max], Format(m_rangeMax)); + ::SetWindowText((*m_labels)[SliderLabel_Min], Format(ValueInvertOrNot(m_rangeMin))); + ::SetWindowText((*m_labels)[SliderLabel_Max], Format(ValueInvertOrNot(m_rangeMax))); } } @@ -582,12 +598,12 @@ void wxSlider95::SetThumbLength(int len) int wxSlider95::GetThumbLength() const { - return (int)::SendMessage( GetHwnd(), TBM_GETTHUMBLENGTH, 0, 0); + return (int)::SendMessage( GetHwnd(), TBM_GETTHUMBLENGTH, 0, 0); } void wxSlider95::SetTick(int tickPos) { - ::SendMessage( GetHwnd(), TBM_SETTIC, (WPARAM) 0, (LPARAM) tickPos ); + ::SendMessage( GetHwnd(), TBM_SETTIC, (WPARAM) 0, (LPARAM) tickPos ); } // ---------------------------------------------------------------------------- @@ -609,20 +625,6 @@ WXHWND wxSlider95::GetEditValue() const return m_labels ? (WXHWND)(*m_labels)[SliderLabel_Value] : NULL; } -bool wxSlider95::ContainsHWND(WXHWND hWnd) const -{ - return m_labels && m_labels->HasWindow((HWND)hWnd); -} - -bool wxSlider95::Show(bool show) -{ - if ( !wxSliderBase::Show(show) ) - return false; - - if ( m_labels ) - m_labels->Show(show); - - return true; -} +WX_FORWARD_STD_METHODS_TO_SUBWINDOWS(wxSlider95, wxSliderBase, m_labels) #endif // wxUSE_SLIDER