Partially account for the shifted origin in wxBufferedDC.
This change slightly improves wxBufferedDC and wxBufferedPaintDC behaviour when the origin of the DC is shifted, but they still don't work quite right in this case as they don't use the buffer area of correct size in this case, which results in cropping the final bitmap (as can be seen in the drawing sample, which was modified to show wxBufferedPaintDC in action). Closes #15497. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74951 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
#include "wx/colordlg.h"
|
#include "wx/colordlg.h"
|
||||||
#include "wx/image.h"
|
#include "wx/image.h"
|
||||||
#include "wx/artprov.h"
|
#include "wx/artprov.h"
|
||||||
|
#include "wx/dcbuffer.h"
|
||||||
#include "wx/dcgraph.h"
|
#include "wx/dcgraph.h"
|
||||||
#include "wx/overlay.h"
|
#include "wx/overlay.h"
|
||||||
#include "wx/graphics.h"
|
#include "wx/graphics.h"
|
||||||
@@ -101,6 +102,7 @@ public:
|
|||||||
#if wxUSE_GRAPHICS_CONTEXT
|
#if wxUSE_GRAPHICS_CONTEXT
|
||||||
void OnGraphicContext(wxCommandEvent& event);
|
void OnGraphicContext(wxCommandEvent& event);
|
||||||
#endif
|
#endif
|
||||||
|
void OnBuffer(wxCommandEvent& event);
|
||||||
void OnCopy(wxCommandEvent& event);
|
void OnCopy(wxCommandEvent& event);
|
||||||
void OnSave(wxCommandEvent& event);
|
void OnSave(wxCommandEvent& event);
|
||||||
void OnShow(wxCommandEvent &event);
|
void OnShow(wxCommandEvent &event);
|
||||||
@@ -148,6 +150,8 @@ public:
|
|||||||
#if wxUSE_GRAPHICS_CONTEXT
|
#if wxUSE_GRAPHICS_CONTEXT
|
||||||
void UseGraphicContext(bool use) { m_useContext = use; Refresh(); }
|
void UseGraphicContext(bool use) { m_useContext = use; Refresh(); }
|
||||||
#endif
|
#endif
|
||||||
|
void UseBuffer(bool use) { m_useBuffer = use; Refresh(); }
|
||||||
|
|
||||||
void Draw(wxDC& dc);
|
void Draw(wxDC& dc);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -189,6 +193,7 @@ private:
|
|||||||
#if wxUSE_GRAPHICS_CONTEXT
|
#if wxUSE_GRAPHICS_CONTEXT
|
||||||
bool m_useContext ;
|
bool m_useContext ;
|
||||||
#endif
|
#endif
|
||||||
|
bool m_useBuffer;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
@@ -227,6 +232,7 @@ enum
|
|||||||
#if wxUSE_GRAPHICS_CONTEXT
|
#if wxUSE_GRAPHICS_CONTEXT
|
||||||
File_GraphicContext,
|
File_GraphicContext,
|
||||||
#endif
|
#endif
|
||||||
|
File_Buffer,
|
||||||
File_Copy,
|
File_Copy,
|
||||||
File_Save,
|
File_Save,
|
||||||
|
|
||||||
@@ -410,6 +416,7 @@ MyCanvas::MyCanvas(MyFrame *parent)
|
|||||||
#if wxUSE_GRAPHICS_CONTEXT
|
#if wxUSE_GRAPHICS_CONTEXT
|
||||||
m_useContext = false;
|
m_useContext = false;
|
||||||
#endif
|
#endif
|
||||||
|
m_useBuffer = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyCanvas::DrawTestBrushes(wxDC& dc)
|
void MyCanvas::DrawTestBrushes(wxDC& dc)
|
||||||
@@ -1494,8 +1501,16 @@ void MyCanvas::DrawRegionsHelper(wxDC& dc, wxCoord x, bool firstTime)
|
|||||||
|
|
||||||
void MyCanvas::OnPaint(wxPaintEvent &WXUNUSED(event))
|
void MyCanvas::OnPaint(wxPaintEvent &WXUNUSED(event))
|
||||||
{
|
{
|
||||||
wxPaintDC pdc(this);
|
if ( m_useBuffer )
|
||||||
Draw(pdc);
|
{
|
||||||
|
wxBufferedPaintDC bpdc(this);
|
||||||
|
Draw(bpdc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxPaintDC pdc(this);
|
||||||
|
Draw(pdc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyCanvas::Draw(wxDC& pdc)
|
void MyCanvas::Draw(wxDC& pdc)
|
||||||
@@ -1729,6 +1744,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|||||||
#if wxUSE_GRAPHICS_CONTEXT
|
#if wxUSE_GRAPHICS_CONTEXT
|
||||||
EVT_MENU (File_GraphicContext, MyFrame::OnGraphicContext)
|
EVT_MENU (File_GraphicContext, MyFrame::OnGraphicContext)
|
||||||
#endif
|
#endif
|
||||||
|
EVT_MENU (File_Buffer, MyFrame::OnBuffer)
|
||||||
EVT_MENU (File_Copy, MyFrame::OnCopy)
|
EVT_MENU (File_Copy, MyFrame::OnCopy)
|
||||||
EVT_MENU (File_Save, MyFrame::OnSave)
|
EVT_MENU (File_Save, MyFrame::OnSave)
|
||||||
|
|
||||||
@@ -1769,6 +1785,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
|||||||
#if wxUSE_GRAPHICS_CONTEXT
|
#if wxUSE_GRAPHICS_CONTEXT
|
||||||
menuFile->AppendCheckItem(File_GraphicContext, wxT("&Use GraphicContext\tCtrl-Y"), wxT("Use GraphicContext"));
|
menuFile->AppendCheckItem(File_GraphicContext, wxT("&Use GraphicContext\tCtrl-Y"), wxT("Use GraphicContext"));
|
||||||
#endif
|
#endif
|
||||||
|
menuFile->AppendCheckItem(File_Buffer, wxT("&Use wx&BufferedPaintDC\tCtrl-Z"), wxT("Buffer painting"));
|
||||||
menuFile->AppendSeparator();
|
menuFile->AppendSeparator();
|
||||||
#if wxUSE_METAFILE && defined(wxMETAFILE_IS_ENH)
|
#if wxUSE_METAFILE && defined(wxMETAFILE_IS_ENH)
|
||||||
menuFile->Append(File_Copy, wxT("Copy to clipboard"));
|
menuFile->Append(File_Copy, wxT("Copy to clipboard"));
|
||||||
@@ -1881,6 +1898,11 @@ void MyFrame::OnGraphicContext(wxCommandEvent& event)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void MyFrame::OnBuffer(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
m_canvas->UseBuffer(event.IsChecked());
|
||||||
|
}
|
||||||
|
|
||||||
void MyFrame::OnCopy(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnCopy(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
#if wxUSE_METAFILE && defined(wxMETAFILE_IS_ENH)
|
#if wxUSE_METAFILE && defined(wxMETAFILE_IS_ENH)
|
||||||
|
@@ -157,7 +157,8 @@ void wxBufferedDC::UnMask()
|
|||||||
height = wxMin(height, heightDC);
|
height = wxMin(height, heightDC);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_dc->Blit(0, 0, width, height, this, -x, -y);
|
const wxPoint origin = GetLogicalOrigin();
|
||||||
|
m_dc->Blit(-origin.x, -origin.y, width, height, this, -x, -y);
|
||||||
m_dc = NULL;
|
m_dc = NULL;
|
||||||
|
|
||||||
if ( m_style & wxBUFFER_USES_SHARED_BUFFER )
|
if ( m_style & wxBUFFER_USES_SHARED_BUFFER )
|
||||||
|
Reference in New Issue
Block a user