Fix showing slider label in wxMSW when wxSL_MIN_MAX_LABELS was not used.
wxSlider with wxSL_LABELS style but without wxSL_MIN_MAX_LABELS didn't show the current value because the width of the value label was 0. Fix this by always computing the widths of min and max labels and using the longest of them for the value label, even if we don't actually show them. Closes #13291. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68230 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
5db9025368
commit
16e79d4879
@ -106,6 +106,10 @@ protected:
|
||||
wxRect GetBoundingBox() const;
|
||||
|
||||
// Get the height and, if the pointers are non NULL, widths of both labels.
|
||||
//
|
||||
// Notice that the return value will be 0 if we don't have wxSL_LABELS
|
||||
// style but we do fill widthMin and widthMax even if we don't have
|
||||
// wxSL_MIN_MAX_LABELS style set so the caller should account for it.
|
||||
int GetLabelsSize(int *widthMin = NULL, int *widthMax = NULL) const;
|
||||
|
||||
|
||||
|
@ -369,16 +369,8 @@ int wxSlider::GetLabelsSize(int *widthMin, int *widthMax) const
|
||||
{
|
||||
if ( widthMin && widthMax )
|
||||
{
|
||||
if ( HasFlag(wxSL_MIN_MAX_LABELS) )
|
||||
{
|
||||
*widthMin = GetTextExtent(Format(m_rangeMin)).x;
|
||||
*widthMax = GetTextExtent(Format(m_rangeMax)).x;
|
||||
}
|
||||
else
|
||||
{
|
||||
*widthMin =
|
||||
*widthMax = 0;
|
||||
}
|
||||
*widthMin = GetTextExtent(Format(m_rangeMin)).x;
|
||||
*widthMax = GetTextExtent(Format(m_rangeMax)).x;
|
||||
}
|
||||
|
||||
return HasFlag(wxSL_LABELS) ? GetCharHeight() : 0;
|
||||
@ -398,6 +390,11 @@ void wxSlider::DoMoveWindow(int x, int y, int width, int height)
|
||||
maxLabelWidth;
|
||||
const int labelHeight = GetLabelsSize(&minLabelWidth, &maxLabelWidth);
|
||||
const int longestLabelWidth = wxMax(minLabelWidth, maxLabelWidth);
|
||||
if ( !HasFlag(wxSL_MIN_MAX_LABELS) )
|
||||
{
|
||||
minLabelWidth =
|
||||
maxLabelWidth = 0;
|
||||
}
|
||||
|
||||
int labelOffset = 0;
|
||||
int tickOffset = 0;
|
||||
@ -594,7 +591,8 @@ wxSize wxSlider::DoGetBestSize() const
|
||||
int hLabel = GetLabelsSize(&widthMin, &widthMax);
|
||||
|
||||
// account for the labels
|
||||
size.x += HGAP + wxMax(widthMin, widthMax);
|
||||
if ( HasFlag(wxSL_MIN_MAX_LABELS) )
|
||||
size.x += HGAP + wxMax(widthMin, widthMax);
|
||||
|
||||
// labels are indented relative to the slider itself
|
||||
size.y += hLabel;
|
||||
|
Loading…
Reference in New Issue
Block a user