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:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user