From: Vadim Zeitlin Date: Sun, 12 Dec 2004 18:59:42 +0000 (+0000) Subject: position the labels correctly when we're created with fixed size X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/8a8dcc3421f4740681173a6fbe8359fc977599dc position the labels correctly when we're created with fixed size git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30965 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/msw/slider95.cpp b/src/msw/slider95.cpp index 8d091ca80a..f58b8902fd 100644 --- a/src/msw/slider95.cpp +++ b/src/msw/slider95.cpp @@ -207,6 +207,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; } @@ -394,6 +402,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 +412,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 +422,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 +438,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 +448,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); } } @@ -625,4 +636,26 @@ bool wxSlider95::Show(bool show) return true; } +bool wxSlider95::Enable(bool enable) +{ + if ( !wxSliderBase::Enable(enable) ) + return false; + + if ( m_labels ) + m_labels->Enable(enable); + + return true; +} + +bool wxSlider95::SetFont(const wxFont& font) +{ + if ( !wxSliderBase::SetFont(font) ) + return false; + + if ( m_labels ) + m_labels->SetFont(font); + + return true; +} + #endif // wxUSE_SLIDER