Avoid creating and immediately destroying a wxGraphicsContext for most uses of wxGCDC.
This also causes the dummy "measuring context" to be properly initialized with a default font git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72019 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -68,9 +68,6 @@ public:
|
|||||||
|
|
||||||
virtual ~wxGCDCImpl();
|
virtual ~wxGCDCImpl();
|
||||||
|
|
||||||
void Init();
|
|
||||||
|
|
||||||
|
|
||||||
// implement base class pure virtuals
|
// implement base class pure virtuals
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
||||||
@@ -213,6 +210,9 @@ protected:
|
|||||||
|
|
||||||
wxGraphicsContext* m_graphicContext;
|
wxGraphicsContext* m_graphicContext;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Init(wxGraphicsContext*);
|
||||||
|
|
||||||
DECLARE_CLASS(wxGCDCImpl)
|
DECLARE_CLASS(wxGCDCImpl)
|
||||||
wxDECLARE_NO_COPY_CLASS(wxGCDCImpl);
|
wxDECLARE_NO_COPY_CLASS(wxGCDCImpl);
|
||||||
};
|
};
|
||||||
|
@@ -157,7 +157,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxGCDCImpl, wxDCImpl)
|
|||||||
wxGCDCImpl::wxGCDCImpl( wxDC *owner ) :
|
wxGCDCImpl::wxGCDCImpl( wxDC *owner ) :
|
||||||
wxDCImpl( owner )
|
wxDCImpl( owner )
|
||||||
{
|
{
|
||||||
Init();
|
Init(wxGraphicsContext::Create());
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGCDCImpl::SetGraphicsContext( wxGraphicsContext* ctx )
|
void wxGCDCImpl::SetGraphicsContext( wxGraphicsContext* ctx )
|
||||||
@@ -179,26 +179,21 @@ void wxGCDCImpl::SetGraphicsContext( wxGraphicsContext* ctx )
|
|||||||
wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxWindowDC& dc ) :
|
wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxWindowDC& dc ) :
|
||||||
wxDCImpl( owner )
|
wxDCImpl( owner )
|
||||||
{
|
{
|
||||||
Init();
|
Init(wxGraphicsContext::Create(dc));
|
||||||
SetGraphicsContext( wxGraphicsContext::Create(dc) );
|
|
||||||
m_window = dc.GetWindow();
|
m_window = dc.GetWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxMemoryDC& dc ) :
|
wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxMemoryDC& dc ) :
|
||||||
wxDCImpl( owner )
|
wxDCImpl( owner )
|
||||||
{
|
{
|
||||||
Init();
|
Init(wxGraphicsContext::Create(dc));
|
||||||
wxGraphicsContext* context;
|
|
||||||
context = wxGraphicsContext::Create(dc);
|
|
||||||
SetGraphicsContext( context );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if wxUSE_PRINTING_ARCHITECTURE
|
#if wxUSE_PRINTING_ARCHITECTURE
|
||||||
wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxPrinterDC& dc ) :
|
wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxPrinterDC& dc ) :
|
||||||
wxDCImpl( owner )
|
wxDCImpl( owner )
|
||||||
{
|
{
|
||||||
Init();
|
Init(wxGraphicsContext::Create(dc));
|
||||||
SetGraphicsContext( wxGraphicsContext::Create(dc) );
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -206,12 +201,11 @@ wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxPrinterDC& dc ) :
|
|||||||
wxGCDCImpl::wxGCDCImpl(wxDC *owner, const wxEnhMetaFileDC& dc)
|
wxGCDCImpl::wxGCDCImpl(wxDC *owner, const wxEnhMetaFileDC& dc)
|
||||||
: wxDCImpl(owner)
|
: wxDCImpl(owner)
|
||||||
{
|
{
|
||||||
Init();
|
Init(wxGraphicsContext::Create(dc));
|
||||||
SetGraphicsContext(wxGraphicsContext::Create(dc));
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void wxGCDCImpl::Init()
|
void wxGCDCImpl::Init(wxGraphicsContext* ctx)
|
||||||
{
|
{
|
||||||
m_ok = false;
|
m_ok = false;
|
||||||
m_colour = true;
|
m_colour = true;
|
||||||
@@ -222,11 +216,13 @@ void wxGCDCImpl::Init()
|
|||||||
m_font = *wxNORMAL_FONT;
|
m_font = *wxNORMAL_FONT;
|
||||||
m_brush = *wxWHITE_BRUSH;
|
m_brush = *wxWHITE_BRUSH;
|
||||||
|
|
||||||
m_graphicContext = wxGraphicsContext::Create();
|
m_graphicContext = NULL;
|
||||||
|
if (ctx)
|
||||||
|
SetGraphicsContext(ctx);
|
||||||
|
|
||||||
m_logicalFunctionSupported = true;
|
m_logicalFunctionSupported = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxGCDCImpl::~wxGCDCImpl()
|
wxGCDCImpl::~wxGCDCImpl()
|
||||||
{
|
{
|
||||||
delete m_graphicContext;
|
delete m_graphicContext;
|
||||||
|
Reference in New Issue
Block a user