From cbc6af74d890e3814bfe20ddbeb33f8fcba955ee Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 10 Apr 2005 18:28:18 +0000 Subject: [PATCH] fixed slider positioning/sizing (especially when ticks are shown on both sides) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33484 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/slider95.cpp | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/src/msw/slider95.cpp b/src/msw/slider95.cpp index 40d6d98e52..5db488c88c 100644 --- a/src/msw/slider95.cpp +++ b/src/msw/slider95.cpp @@ -255,17 +255,22 @@ WXDWORD wxSlider::MSWGetStyle(long style, WXDWORD *exstyle) const // TBS_HORZ, TBS_RIGHT and TBS_BOTTOM are 0 but do include them for clarity msStyle |= style & wxSL_VERTICAL ? TBS_VERT : TBS_HORZ; - if ( style & wxSL_LEFT ) - msStyle |= TBS_LEFT; - else if ( style & wxSL_RIGHT ) - msStyle |= TBS_RIGHT; - else if ( style & wxSL_TOP ) - msStyle |= TBS_TOP; - else if ( style & wxSL_BOTTOM ) - msStyle |= TBS_BOTTOM; - if ( style & wxSL_BOTH ) + { + // this fully specifies the style combined with TBS_VERT/HORZ above msStyle |= TBS_BOTH; + } + else // choose one direction + { + if ( style & wxSL_LEFT ) + msStyle |= TBS_LEFT; + else if ( style & wxSL_RIGHT ) + msStyle |= TBS_RIGHT; + else if ( style & wxSL_TOP ) + msStyle |= TBS_TOP; + else if ( style & wxSL_BOTTOM ) + msStyle |= TBS_BOTTOM; + } if ( style & wxSL_AUTOTICKS ) msStyle |= TBS_AUTOTICKS; @@ -497,13 +502,16 @@ wxSize wxSlider::DoGetBestSize() const { // these values are arbitrary static const int length = 100; - static const int thickness = 26; + static const int thumb = 24; + static const int ticks = 8; + int *width; wxSize size; if ( HasFlag(wxSL_VERTICAL) ) { - size.x = thickness; + size.x = thumb; size.y = length; + width = &size.x; if ( m_labels ) { @@ -520,7 +528,8 @@ wxSize wxSlider::DoGetBestSize() const else // horizontal { size.x = length; - size.y = thickness; + size.y = thumb; + width = &size.y; if ( m_labels ) { @@ -529,6 +538,16 @@ wxSize wxSlider::DoGetBestSize() const } } + // need extra space to show ticks + if ( HasFlag(wxSL_TICKS) ) + { + *width += ticks; + + // and maybe twice as much if we show them on both sides + if ( HasFlag(wxSL_BOTH) ) + *width += ticks; + } + return size; } -- 2.45.2