Allow using wxRendererNative::DrawGauge() for vertical gauges too

It was unexpected that this method could only be used for horizontal
gauges, so make it work for the vertical ones if wxCONTROL_SPECIAL flag
is specified.

Update MSW and generic implementations and the render sample to show a
vertical gauge as well.
This commit is contained in:
Vadim Zeitlin
2018-02-03 18:12:13 +01:00
parent 3284420b09
commit 5f8f60107a
6 changed files with 37 additions and 7 deletions

View File

@@ -910,7 +910,7 @@ void wxRendererGeneric::DrawGauge(wxWindow* win,
const wxRect& rect,
int value,
int max,
int WXUNUSED(flags))
int flags)
{
// Use same background as text controls.
DrawTextCtrl(win, dc, rect);
@@ -918,7 +918,16 @@ void wxRendererGeneric::DrawGauge(wxWindow* win,
// Calculate the progress bar size.
wxRect progRect(rect);
progRect.Deflate(2);
progRect.width = wxMulDivInt32(progRect.width, value, max);
if ( flags & wxCONTROL_SPECIAL )
{
const int h = wxMulDivInt32(progRect.height, value, max);
progRect.y += progRect.height - h;
progRect.height = h;
}
else // Horizontal.
{
progRect.width = wxMulDivInt32(progRect.width, value, max);
}
dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
dc.SetPen(*wxTRANSPARENT_PEN);