fixed clip rect when logical coords != device ones
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10604 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -344,9 +344,11 @@ BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
|
|||||||
EVT_MOTION (MyCanvas::OnMouseMove)
|
EVT_MOTION (MyCanvas::OnMouseMove)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
#include "../image/smile.xpm"
|
#include "smile.xpm"
|
||||||
|
|
||||||
MyCanvas::MyCanvas( MyFrame *parent ) : wxScrolledWindow( parent )
|
MyCanvas::MyCanvas(MyFrame *parent)
|
||||||
|
: wxScrolledWindow(parent, -1, wxDefaultPosition, wxDefaultSize,
|
||||||
|
wxHSCROLL | wxVSCROLL | wxNO_FULL_REPAINT_ON_RESIZE)
|
||||||
{
|
{
|
||||||
m_owner = parent;
|
m_owner = parent;
|
||||||
m_show = Show_Default;
|
m_show = Show_Default;
|
||||||
@@ -983,32 +985,38 @@ void MyCanvas::DrawCircles(wxDC& dc)
|
|||||||
|
|
||||||
void MyCanvas::DrawRegions(wxDC& dc)
|
void MyCanvas::DrawRegions(wxDC& dc)
|
||||||
{
|
{
|
||||||
|
dc.DrawText("You should see a red rect partly covered by a cyan one "
|
||||||
|
"on the left", 10, 5);
|
||||||
|
dc.DrawText("and 5 smileys from which 4 are partially clipped on the "
|
||||||
|
"right", 10, 5 + dc.GetCharHeight());
|
||||||
|
|
||||||
dc.SetBrush( *wxWHITE_BRUSH );
|
dc.SetBrush( *wxWHITE_BRUSH );
|
||||||
dc.SetPen( *wxTRANSPARENT_PEN );
|
dc.SetPen( *wxTRANSPARENT_PEN );
|
||||||
dc.DrawRectangle( 10,10,310,310 );
|
dc.DrawRectangle( 10,50,310,310 );
|
||||||
|
|
||||||
dc.SetClippingRegion( 20,20,100,270 );
|
dc.SetClippingRegion( 20,60,100,270 );
|
||||||
|
|
||||||
dc.SetBrush( *wxRED_BRUSH );
|
dc.SetBrush( *wxRED_BRUSH );
|
||||||
dc.DrawRectangle( 10,10,310,310 );
|
dc.DrawRectangle( 10,50,310,310 );
|
||||||
|
|
||||||
dc.SetClippingRegion( 20,20,100,100 );
|
dc.SetClippingRegion( 20,60,100,100 );
|
||||||
|
|
||||||
dc.SetBrush( *wxCYAN_BRUSH );
|
dc.SetBrush( *wxCYAN_BRUSH );
|
||||||
dc.DrawRectangle( 10,10,310,310 );
|
dc.DrawRectangle( 10,50,310,310 );
|
||||||
|
|
||||||
dc.DestroyClippingRegion();
|
dc.DestroyClippingRegion();
|
||||||
dc.SetClippingRegion( 120,30,100,270 );
|
dc.SetClippingRegion( 120,70,100,270 );
|
||||||
|
|
||||||
dc.SetBrush( *wxGREY_BRUSH );
|
dc.SetBrush( *wxGREY_BRUSH );
|
||||||
dc.DrawRectangle( 10,10,310,310 );
|
dc.DrawRectangle( 10,50,310,310 );
|
||||||
|
|
||||||
if (m_smile_bmp.Ok())
|
if (m_smile_bmp.Ok())
|
||||||
{
|
{
|
||||||
dc.DrawBitmap( m_smile_bmp, 140, 20, TRUE );
|
dc.DrawBitmap( m_smile_bmp, 160, 200, TRUE );
|
||||||
dc.DrawBitmap( m_smile_bmp, 140, 290, TRUE );
|
dc.DrawBitmap( m_smile_bmp, 140, 60, TRUE );
|
||||||
dc.DrawBitmap( m_smile_bmp, 110, 80, TRUE );
|
dc.DrawBitmap( m_smile_bmp, 140, 330, TRUE );
|
||||||
dc.DrawBitmap( m_smile_bmp, 210, 80, TRUE );
|
dc.DrawBitmap( m_smile_bmp, 110, 120, TRUE );
|
||||||
|
dc.DrawBitmap( m_smile_bmp, 210, 120, TRUE );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1124,7 +1132,8 @@ END_EVENT_TABLE()
|
|||||||
|
|
||||||
// frame constructor
|
// frame constructor
|
||||||
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||||
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
|
: wxFrame((wxFrame *)NULL, -1, title, pos, size,
|
||||||
|
wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
|
||||||
{
|
{
|
||||||
// set the frame icon
|
// set the frame icon
|
||||||
SetIcon(wxICON(mondrian));
|
SetIcon(wxICON(mondrian));
|
||||||
|
42
samples/drawing/smile.xpm
Normal file
42
samples/drawing/smile.xpm
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
/* XPM */
|
||||||
|
static char * smile_xpm[] = {
|
||||||
|
/* width height ncolors chars_per_pixel */
|
||||||
|
"32 32 4 1",
|
||||||
|
/* colors */
|
||||||
|
" s None c None",
|
||||||
|
". c #000000",
|
||||||
|
"+ c #ff0000",
|
||||||
|
"@ c #ffff00",
|
||||||
|
/* pixels */
|
||||||
|
" ........ ",
|
||||||
|
" ...@@@@@@@@... ",
|
||||||
|
" ..@@@@@@@@@@@@@@.. ",
|
||||||
|
" ..@@@@@@@@@@@@@@@@.. ",
|
||||||
|
" .@@@@@@@@@@@@@@@@@@@@. ",
|
||||||
|
" .@@@@@@@@@@@@@@@@@@@@@@. ",
|
||||||
|
" .@@@@@@@@@@@@@@@@@@@@@@@@. ",
|
||||||
|
" ..@@@@@@@@@@@@@@@@@@@@@@@@.. ",
|
||||||
|
" .@@@@@@@@..@@@@@@..@@@@@@@@. ",
|
||||||
|
" .@@@@@@@@....@@@@....@@@@@@@@. ",
|
||||||
|
" .@@@@@@@@....@@@@....@@@@@@@@. ",
|
||||||
|
" .@@@@@@@@....@@@@....@@@@@@@@. ",
|
||||||
|
".@@@@@@@@@....@@@@....@@@@@@@@@.",
|
||||||
|
".@@@@@@@@@....@@@@....@@@@@@@@@.",
|
||||||
|
".@@@@@@@@@@..@@@@@@..@@@@@@@@@@.",
|
||||||
|
".@@@@@@@.@@@@@@@@@@@@@@.@@@@@@@.",
|
||||||
|
".@@@@@@@.@@@@@@@@@@@@@@.@@@@@@@.",
|
||||||
|
".@@@@@@.@@@@@@@@@@@@@@@@.@@@@@@.",
|
||||||
|
".@@@....@@@@@@@@@@@@@@@@....@@@.",
|
||||||
|
".@@@@@@@.@@@@@@@@@@@@@@.@@@@@@@.",
|
||||||
|
" .@@@@@@@.@@@@@@@@@@@@.@@@@@@@. ",
|
||||||
|
" .@@@@@@@..@@@@@@@@@@..@@@@@@@. ",
|
||||||
|
" .@@@@@@@@...@@@@@@...@@@@@@@@. ",
|
||||||
|
" .@@@@@@@@.+......+.@@@@@@@@. ",
|
||||||
|
" ..@@@@@@@@.++++++.@@@@@@@@.. ",
|
||||||
|
" .@@@@@@@@@.++++.@@@@@@@@@. ",
|
||||||
|
" .@@@@@@@@@....@@@@@@@@@. ",
|
||||||
|
" .@@@@@@@@@@@@@@@@@@@@. ",
|
||||||
|
" ..@@@@@@@@@@@@@@@@.. ",
|
||||||
|
" ..@@@@@@@@@@@@@@.. ",
|
||||||
|
" ...@@@@@@@@... ",
|
||||||
|
" ........ "};
|
@@ -276,12 +276,16 @@ void wxDC::SelectOldObjects(WXHDC dc)
|
|||||||
m_clipY2 = (wxCoord) YDEV2LOG(rect.bottom); \
|
m_clipY2 = (wxCoord) YDEV2LOG(rect.bottom); \
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDC::DoSetClippingRegion(wxCoord cx, wxCoord cy, wxCoord cw, wxCoord ch)
|
void wxDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
|
||||||
{
|
{
|
||||||
m_clipping = TRUE;
|
m_clipping = TRUE;
|
||||||
|
|
||||||
HRGN hrgn = ::CreateRectRgn(XLOG2DEV(cx), YLOG2DEV(cy),
|
// the region coords are always the device ones, so do the translation
|
||||||
XLOG2DEV(cx + cw), YLOG2DEV(cy + ch));
|
// manually
|
||||||
|
HRGN hrgn = ::CreateRectRgn(LogicalToDeviceX(x),
|
||||||
|
LogicalToDeviceY(y),
|
||||||
|
LogicalToDeviceX(x + w),
|
||||||
|
LogicalToDeviceY(y + h));
|
||||||
if ( !hrgn )
|
if ( !hrgn )
|
||||||
{
|
{
|
||||||
wxLogLastError(_T("CreateRectRgn"));
|
wxLogLastError(_T("CreateRectRgn"));
|
||||||
|
Reference in New Issue
Block a user