Fixed drawing colours with alpha in wxSystemColourProperty (wxPG).

For systems which don't support drawing with alpha on standard DC (like e.g. Win, GTK2) there is necessary to use graphics context for this purposes.
This commit is contained in:
Artur Wieczorek
2015-11-27 21:36:21 +01:00
parent 9990959c99
commit 7be75892a3

View File

@@ -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);
}
}
}