Files
wxWidgets/src/qt/dcmemory.cpp
Mariano Reingart 8fc5475e15 Update author's credits comments for wxQT
Commit history was lost in the git to svn merge for trunk, so this reflect work done in two GSOC projects and/or by several authors.
Lines changed by each user was the main metric used to ack major contributions.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77497 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-08-29 03:37:46 +00:00

86 lines
2.2 KiB
C++

/////////////////////////////////////////////////////////////////////////////
// Name: src/qt/dcmemory.cpp
// Author: Peter Most, Javier Torres, Mariano Reingart
// Copyright: (c) 2010 wxWidgets dev team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/dcmemory.h"
#include "wx/qt/dcmemory.h"
wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner )
: wxQtDCImpl( owner )
{
m_qtImage = NULL;
m_ok = false;
m_qtPainter = new QPainter();
}
wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner, wxBitmap& bitmap )
: wxQtDCImpl( owner )
{
m_qtImage = NULL;
m_ok = false;
m_qtPainter = new QPainter();
DoSelect( bitmap );
}
wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner, wxDC *WXUNUSED(dc) )
: wxQtDCImpl( owner )
{
m_qtImage = NULL;
m_ok = false;
}
wxMemoryDCImpl::~wxMemoryDCImpl()
{
// Deselect the bitmap, if any (warning: it can be already deleted)
DoSelect( wxNullBitmap );
}
void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap )
{
if ( IsOk() )
{
// Finish the painting in the intermediate image device:
m_qtPainter->end();
if (m_selected.IsOk() && !m_selected.GetHandle()->isNull())
{
// Copy intermediate image to the bitmap
m_qtPainter->begin( m_selected.GetHandle() );
m_qtPainter->drawImage( QPoint( 0, 0 ), *m_qtImage );
m_qtPainter->end();
}
m_ok = false;
}
// clean up the intermediate image device:
if ( m_qtImage )
{
delete m_qtImage;
m_qtImage = NULL;
}
m_selected = bitmap;
if ( bitmap.IsOk() && !bitmap.GetHandle()->isNull() ) {
// create the intermediate image for the pixmap:
m_qtImage = new QImage( bitmap.GetHandle()->toImage() );
// start drawing on the intermediary device:
m_ok = m_qtPainter->begin( m_qtImage );
}
}
const wxBitmap& wxMemoryDCImpl::GetSelectedBitmap() const
{
return m_selected;
}
wxBitmap& wxMemoryDCImpl::GetSelectedBitmap()
{
return m_selected;
}