Removed redundant wxColour constructor (how come this didn't cause problems before...)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6125 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -35,7 +35,7 @@ public:
|
||||
|
||||
// copy ctors and assignment operators
|
||||
wxColour( const wxColour& col );
|
||||
wxColour( const wxColour* col );
|
||||
/* wxColour( const wxColour* col ); */
|
||||
wxColour& operator = ( const wxColour& col );
|
||||
|
||||
// dtor
|
||||
|
@@ -26,6 +26,7 @@ public:
|
||||
|
||||
~wxMemoryDC();
|
||||
|
||||
virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
|
||||
virtual void SelectObject(const wxBitmap& bitmap);
|
||||
|
||||
virtual void DoGetSize(int* width, int* height) const;
|
||||
|
@@ -598,7 +598,9 @@ void MyCanvas::DrawDefault(wxDC& dc)
|
||||
//dc.SetBrush( *wxTRANSPARENT_BRUSH );
|
||||
#include "../image/smile.xpm"
|
||||
wxBitmap bmp(smile_xpm);
|
||||
dc.DrawBitmap(bmp, x + rectSize - 20, rectSize - 10, TRUE);
|
||||
|
||||
if (bmp.Ok())
|
||||
dc.DrawBitmap(bmp, x + rectSize - 20, rectSize - 10, TRUE);
|
||||
|
||||
dc.SetBrush( *wxBLACK_BRUSH );
|
||||
dc.DrawRectangle( 0, 160, 1000, 300 );
|
||||
@@ -717,12 +719,11 @@ void MyCanvas::DrawDefault(wxDC& dc)
|
||||
wxMemoryDC memdc2;
|
||||
memdc2.SelectObject(bitmap2);
|
||||
|
||||
memdc2.SetBackground(*wxWHITE_BRUSH);
|
||||
wxBrush yellowBrush(wxColour(255, 255, 0), wxSOLID);
|
||||
memdc2.SetBackground(yellowBrush);
|
||||
memdc2.Clear();
|
||||
|
||||
// Draw a yellow rectangle filling the bitmap
|
||||
memdc2.SetPen(wxPen(wxColour(255, 255, 0), 1, wxSOLID));
|
||||
memdc2.SetBrush(wxBrush(wxColour(255, 255, 0), wxSOLID));
|
||||
memdc2.DrawRectangle(0, 0, totalWidth+2, totalHeight+2); // Just to make sure!
|
||||
wxPen yellowPen(wxColour(255, 255, 0), 1, wxSOLID);
|
||||
|
||||
// Now draw a white rectangle with red outline. It should
|
||||
// entirely eclipse the yellow background.
|
||||
@@ -736,6 +737,21 @@ void MyCanvas::DrawDefault(wxDC& dc)
|
||||
memdc2.SelectObject(wxNullBitmap);
|
||||
|
||||
dc.DrawBitmap(bitmap2, 500, 270);
|
||||
|
||||
// Repeat, but draw directly on dc
|
||||
// Draw a yellow rectangle filling the bitmap
|
||||
|
||||
x = 600; int y = 270;
|
||||
dc.SetPen(yellowPen);
|
||||
dc.SetBrush(yellowBrush);
|
||||
dc.DrawRectangle(x, y, totalWidth, totalHeight);
|
||||
|
||||
// Now draw a white rectangle with red outline. It should
|
||||
// entirely eclipse the yellow background.
|
||||
dc.SetPen(*wxRED_PEN);
|
||||
dc.SetBrush(*wxWHITE_BRUSH);
|
||||
|
||||
dc.DrawRectangle(x, y, totalWidth, totalHeight);
|
||||
}
|
||||
|
||||
void MyCanvas::DrawText(wxDC& dc)
|
||||
|
@@ -139,3 +139,50 @@ void wxMemoryDC::DoGetSize(int *width, int *height) const
|
||||
}
|
||||
}
|
||||
|
||||
// For some reason, drawing a rectangle on a memory DC has problems.
|
||||
// Use this substitute if we can.
|
||||
static void wxDrawRectangle(wxDC& dc, wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
||||
{
|
||||
wxBrush brush(dc.GetBrush());
|
||||
wxPen pen(dc.GetPen());
|
||||
if (brush.Ok() && brush.GetStyle() != wxTRANSPARENT)
|
||||
{
|
||||
HBRUSH hBrush = (HBRUSH) brush.GetResourceHandle() ;
|
||||
if (hBrush)
|
||||
{
|
||||
RECT rect;
|
||||
rect.left = x; rect.top = y;
|
||||
rect.right = x + width - 1;
|
||||
rect.bottom = y + height - 1;
|
||||
::FillRect((HDC) dc.GetHDC(), &rect, hBrush);
|
||||
}
|
||||
}
|
||||
width --; height --;
|
||||
if (pen.Ok() && pen.GetStyle() != wxTRANSPARENT)
|
||||
{
|
||||
dc.DrawLine(x, y, x + width, y);
|
||||
dc.DrawLine(x, y, x, y + height);
|
||||
dc.DrawLine(x, y+height, x+width, y + height);
|
||||
dc.DrawLine(x+width, y+height, x+width, y);
|
||||
}
|
||||
}
|
||||
|
||||
void wxMemoryDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
||||
{
|
||||
// Set this to 0 to demonstrate strange rectangle behaviour in the Drawing sample.
|
||||
#if 0
|
||||
if (m_brush.Ok() && m_pen.Ok() &&
|
||||
(m_brush.GetStyle() == wxSOLID || m_brush.GetStyle() == wxTRANSPARENT) &&
|
||||
(m_pen.GetStyle() == wxSOLID || m_pen.GetStyle() == wxTRANSPARENT))
|
||||
{
|
||||
wxDrawRectangle(* this, x, y, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
wxDC::DoDrawRectangle(x, y, width, height);
|
||||
}
|
||||
#else
|
||||
wxDC::DoDrawRectangle(x, y, width, height);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user