Fix regression in wxGCDC initialization from wxGraphicsContext
The changes of ae2cb7d347
resulted in
transformation matrix not being initialized correctly any more.
Fix this by adding yet another helper, DoInitContext(), called both when
initializing wxGCDC using an existing wxGraphicsContext in the
corresponding ctor and the just created one in the other ones.
Closes #18429.
This commit is contained in:
@@ -242,6 +242,10 @@ private:
|
||||
// is assumed to be newly created.
|
||||
void Init(wxGraphicsContext*);
|
||||
|
||||
// This method initializes m_graphicContext, m_ok and m_matrixOriginal
|
||||
// fields, returns true if the context was valid.
|
||||
bool DoInitContext(wxGraphicsContext* ctx);
|
||||
|
||||
wxDECLARE_CLASS(wxGCDCImpl);
|
||||
wxDECLARE_NO_COPY_CLASS(wxGCDCImpl);
|
||||
};
|
||||
|
@@ -126,8 +126,7 @@ wxGCDCImpl::wxGCDCImpl(wxDC *owner, wxGraphicsContext* context) :
|
||||
{
|
||||
CommonInit();
|
||||
|
||||
m_graphicContext = context;
|
||||
m_ok = m_graphicContext != NULL;
|
||||
DoInitContext(context);
|
||||
|
||||
// We can't currently initialize m_font, m_pen and m_brush here as we don't
|
||||
// have any way of converting the corresponding wxGraphicsXXX objects to
|
||||
@@ -146,13 +145,10 @@ wxGCDCImpl::wxGCDCImpl( wxDC *owner ) :
|
||||
void wxGCDCImpl::SetGraphicsContext( wxGraphicsContext* ctx )
|
||||
{
|
||||
delete m_graphicContext;
|
||||
m_graphicContext = ctx;
|
||||
if ( m_graphicContext )
|
||||
|
||||
if ( DoInitContext(ctx) )
|
||||
{
|
||||
m_matrixOriginal = m_graphicContext->GetTransform();
|
||||
m_ok = true;
|
||||
// apply the stored transformations to the passed in context
|
||||
ComputeScaleAndOrigin();
|
||||
// Reapply our attributes to the context.
|
||||
m_graphicContext->SetFont( m_font , m_textForegroundColour );
|
||||
m_graphicContext->SetPen( m_pen );
|
||||
m_graphicContext->SetBrush( m_brush);
|
||||
@@ -220,6 +216,21 @@ void wxGCDCImpl::Init(wxGraphicsContext* ctx)
|
||||
SetGraphicsContext(ctx);
|
||||
}
|
||||
|
||||
bool wxGCDCImpl::DoInitContext(wxGraphicsContext* ctx)
|
||||
{
|
||||
m_graphicContext = ctx;
|
||||
m_ok = m_graphicContext != NULL;
|
||||
|
||||
if ( m_ok )
|
||||
{
|
||||
// apply the stored transformations to the passed in context
|
||||
m_matrixOriginal = m_graphicContext->GetTransform();
|
||||
ComputeScaleAndOrigin();
|
||||
}
|
||||
|
||||
return m_ok;
|
||||
}
|
||||
|
||||
wxGCDCImpl::~wxGCDCImpl()
|
||||
{
|
||||
delete m_graphicContext;
|
||||
|
Reference in New Issue
Block a user