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
wxRect GetBoundingBox() const;
// Get the height and, if the pointers are non NULL, widths of both labels.
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;
int GetLabelsSize(int *widthMin = NULL, int *widthMax = NULL) const;
{
if ( widthMin && widthMax )
{
{
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;
}
return HasFlag(wxSL_LABELS) ? GetCharHeight() : 0;
maxLabelWidth;
const int labelHeight = GetLabelsSize(&minLabelWidth, &maxLabelWidth);
const int longestLabelWidth = wxMax(minLabelWidth, maxLabelWidth);
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;
int labelOffset = 0;
int tickOffset = 0;
int hLabel = GetLabelsSize(&widthMin, &widthMax);
// account for the labels
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;
// labels are indented relative to the slider itself
size.y += hLabel;