diff --git a/src/propgrid/advprops.cpp b/src/propgrid/advprops.cpp index 25c9d1a01d..8ba51c7bee 100644 --- a/src/propgrid/advprops.cpp +++ b/src/propgrid/advprops.cpp @@ -64,6 +64,19 @@ #include "wx/odcombo.h" #include "wx/numformatter.h" +// Drawing ARGB on standard DC is supported by OSX and GTK3 +#if defined(__WXOSX__) || defined(__WXGTK3__) +#define wxPG_DC_SUPPORTS_ALPHA 1 +#else +#define wxPG_DC_SUPPORTS_ALPHA 0 +#endif // __WXOSX__ || __WXGTK3__ + +#define wxPG_USE_GC_FOR_ALPHA (wxUSE_GRAPHICS_CONTEXT && !wxPG_DC_SUPPORTS_ALPHA) + +#if wxPG_USE_GC_FOR_ALPHA +#include "wx/dcgraph.h" +#endif // wxPG_USE_GC_FOR_ALPHA + // ----------------------------------------------------------------------- #if defined(__WXMSW__) @@ -1396,8 +1409,42 @@ void wxSystemColourProperty::OnCustomPaint( wxDC& dc, const wxRect& rect, if ( col.IsOk() ) { - dc.SetBrush(col); - dc.DrawRectangle(rect); +#if wxPG_USE_GC_FOR_ALPHA + wxGCDC *gdc = NULL; + if ( col.Alpha() != wxALPHA_OPAQUE ) + { + if ( wxPaintDC *paintdc = wxDynamicCast(&dc, wxPaintDC) ) + { + gdc = new wxGCDC(*paintdc); + } + else if ( wxMemoryDC *memdc = wxDynamicCast(&dc, wxMemoryDC) ) + { + gdc = new wxGCDC(*memdc); + } +#if wxUSE_METAFILE && defined(wxMETAFILE_IS_ENH) + else if ( wxMetafileDC *metadc = wxDynamicCast(&dc, wxMetafileDC) ) + { + gdc = new wxGCDC(*metadc); + } +#endif + else + { + wxFAIL_MSG( wxS("Unknown wxDC kind") ); + } + } + + if ( gdc ) + { + gdc->SetBrush(col); + gdc->DrawRectangle(rect); + delete gdc; + } + else +#endif // wxPG_USE_GC_FOR_ALPHA + { + dc.SetBrush(col); + dc.DrawRectangle(rect); + } } }