From 0338ad5124917abef99cfe7108ef8f3539ecfd7b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 15 Dec 2018 16:51:49 +0100 Subject: [PATCH] Factor out wxGCDCImpl::CommonInit() No real changes, just a small refactoring that will allow reusing the new CommonInit() method in the next commit. --- include/wx/dcgraph.h | 6 ++++++ src/common/dcgraph.cpp | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/include/wx/dcgraph.h b/include/wx/dcgraph.h index c2482d78c3..c29ab57876 100644 --- a/include/wx/dcgraph.h +++ b/include/wx/dcgraph.h @@ -234,6 +234,12 @@ protected: bool m_isClipBoxValid; private: + // This method only initializes trivial fields. + void CommonInit(); + + // This method initializes all fields (including those initialized by + // CommonInit() as it calls it) and the given context, if non-null, which + // is assumed to be newly created. void Init(wxGraphicsContext*); wxDECLARE_CLASS(wxGCDCImpl); diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index a744e94adb..a13546fbb7 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -185,23 +185,29 @@ wxGCDCImpl::wxGCDCImpl(wxDC* owner, int) Init(NULL); } -void wxGCDCImpl::Init(wxGraphicsContext* ctx) +void wxGCDCImpl::CommonInit() { - m_ok = false; m_mm_to_pix_x = mm2pt; m_mm_to_pix_y = mm2pt; + m_isClipBoxValid = false; + + m_logicalFunctionSupported = true; +} + +void wxGCDCImpl::Init(wxGraphicsContext* ctx) +{ + CommonInit(); + + m_ok = false; + m_pen = *wxBLACK_PEN; m_font = *wxNORMAL_FONT; m_brush = *wxWHITE_BRUSH; - m_isClipBoxValid = false; - m_graphicContext = NULL; if (ctx) SetGraphicsContext(ctx); - - m_logicalFunctionSupported = true; } wxGCDCImpl::~wxGCDCImpl()