diff --git a/src/msw/graphics.cpp b/src/msw/graphics.cpp index 35237953b8..0ca6e03f73 100644 --- a/src/msw/graphics.cpp +++ b/src/msw/graphics.cpp @@ -281,7 +281,9 @@ protected: private: // common part of Create{Linear,Radial}GradientBrush() template - void SetGradientStops(T *brush, const wxGraphicsGradientStops& stops); + void SetGradientStops(T *brush, + const wxGraphicsGradientStops& stops, + bool reversed = false); Brush* m_brush; Image* m_brushImage; @@ -852,7 +854,8 @@ void wxGDIPlusBrushData::Init() template void wxGDIPlusBrushData::SetGradientStops(T *brush, - const wxGraphicsGradientStops& stops) + const wxGraphicsGradientStops& stops, + bool reversed) { const unsigned numStops = stops.GetCount(); if ( numStops <= 2 ) @@ -865,12 +868,25 @@ wxGDIPlusBrushData::SetGradientStops(T *brush, wxVector colors(numStops); wxVector positions(numStops); - for ( unsigned i = 0; i < numStops; i++ ) + if ( reversed ) { - wxGraphicsGradientStop stop = stops.Item(i); + for ( unsigned i = 0; i < numStops; i++ ) + { + wxGraphicsGradientStop stop = stops.Item(numStops - i - 1); - colors[i] = wxColourToColor(stop.GetColour()); - positions[i] = stop.GetPosition(); + colors[i] = wxColourToColor(stop.GetColour()); + positions[i] = 1.0 - stop.GetPosition(); + } + } + else + { + for ( unsigned i = 0; i < numStops; i++ ) + { + wxGraphicsGradientStop stop = stops.Item(i); + + colors[i] = wxColourToColor(stop.GetColour()); + positions[i] = stop.GetPosition(); + } } brush->SetInterpolationColors(&colors[0], &positions[0], numStops); @@ -909,7 +925,9 @@ wxGDIPlusBrushData::CreateRadialGradientBrush(wxDouble xo, wxDouble yo, int count = 1; brush->SetSurroundColors(&col, &count); - SetGradientStops(brush, stops); + // Because the GDI+ API draws radial gradients from outside towards the + // center we have to reverse the order of the gradient stops. + SetGradientStops(brush, stops, true); } //-----------------------------------------------------------------------------