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
This commit is contained in:
Vadim Zeitlin
2005-04-10 18:28:18 +00:00
parent 7c2cb1f4bd
commit cbc6af74d8

View File

@@ -255,6 +255,13 @@ WXDWORD wxSlider::MSWGetStyle(long style, WXDWORD *exstyle) const
// TBS_HORZ, TBS_RIGHT and TBS_BOTTOM are 0 but do include them for clarity // TBS_HORZ, TBS_RIGHT and TBS_BOTTOM are 0 but do include them for clarity
msStyle |= style & wxSL_VERTICAL ? TBS_VERT : TBS_HORZ; msStyle |= style & wxSL_VERTICAL ? TBS_VERT : TBS_HORZ;
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 ) if ( style & wxSL_LEFT )
msStyle |= TBS_LEFT; msStyle |= TBS_LEFT;
else if ( style & wxSL_RIGHT ) else if ( style & wxSL_RIGHT )
@@ -263,9 +270,7 @@ WXDWORD wxSlider::MSWGetStyle(long style, WXDWORD *exstyle) const
msStyle |= TBS_TOP; msStyle |= TBS_TOP;
else if ( style & wxSL_BOTTOM ) else if ( style & wxSL_BOTTOM )
msStyle |= TBS_BOTTOM; msStyle |= TBS_BOTTOM;
}
if ( style & wxSL_BOTH )
msStyle |= TBS_BOTH;
if ( style & wxSL_AUTOTICKS ) if ( style & wxSL_AUTOTICKS )
msStyle |= TBS_AUTOTICKS; msStyle |= TBS_AUTOTICKS;
@@ -497,13 +502,16 @@ wxSize wxSlider::DoGetBestSize() const
{ {
// these values are arbitrary // these values are arbitrary
static const int length = 100; static const int length = 100;
static const int thickness = 26; static const int thumb = 24;
static const int ticks = 8;
int *width;
wxSize size; wxSize size;
if ( HasFlag(wxSL_VERTICAL) ) if ( HasFlag(wxSL_VERTICAL) )
{ {
size.x = thickness; size.x = thumb;
size.y = length; size.y = length;
width = &size.x;
if ( m_labels ) if ( m_labels )
{ {
@@ -520,7 +528,8 @@ wxSize wxSlider::DoGetBestSize() const
else // horizontal else // horizontal
{ {
size.x = length; size.x = length;
size.y = thickness; size.y = thumb;
width = &size.y;
if ( m_labels ) 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; return size;
} }