#include <wx/wx.h>
class Simple:public wxFrame
{
public:
Simple(const wxString& title);
protected:
void OnPaint(wxPaintEvent& event);
};
Simple::Simple(const wxString& title)
:wxFrame(NULL,-1,title,wxPoint(-1,-1),wxSize(680,580))
{
wxClientDC dc(this);
dc.SetPen(wxPen(*wxYELLOW, 1));//wxPen(*wxYELLOW, 1)定义一个画笔,颜色为黄色,画笔宽度为1
dc.DrawPoint(wxPoint(20,120));//在鼠标的位置绘制一个点
dc.SetPen(wxNullPen);//清除画笔
Bind(wxEVT_PAINT,wxPaintEventHandler(Simple::OnPaint),this);
Centre();
}
void Simple::OnPaint(wxPaintEvent& event)
{
wxPaintDC dc(this);
wxPoint lines[]={
wxPoint(20,260),wxPoint(100,260),
wxPoint(20,210),wxPoint(100,210)
};
wxPoint polygon []={
wxPoint(130,140),wxPoint(180,170)
,wxPoint(180,140),wxPoint(220,110),wxPoint(140,100)
};
wxPoint splines[] ={
wxPoint(240,170),wxPoint(280,170)
,wxPoint(285,110),wxPoint(325,110)
};
dc.SetPen(wxPen(wxTheColourDatabase->Find("MAGENTA"),5,wxSOLID));//solid
dc.SetBrush(wxTheColourDatabase->Find("LIME GREEN"));
dc.DrawEllipse(20,20,90,60);
dc.SetPen(wxPen(*wxCYAN,5,wxDOT));//dot
dc.SetBrush(wxTheColourDatabase->Find("AQUAMARINE"));
dc.DrawRoundedRectangle(wxPoint(130,15),wxSize(90,60),10);
dc.SetPen(wxPen(*wxBLUE,3,wxLONG_DASH));//long dash
dc.SetBrush(wxTheColourDatabase->Find("WHEAT"));
dc.DrawArc(240,40,340,40,290,20);
dc.SetPen(*wxWHITE);
dc.SetBrush(wxTheColourDatabase->Find("MAROON"));
dc.DrawEllipticArc(20,120,100,100,20,160);
dc.SetPen(wxPen(*wxWHITE,4,wxSOLID));
dc.SetBrush(wxTheColourDatabase->Find("CORAL"));
dc.DrawPolygon(4,polygon);
dc.SetPen(wxTheColourDatabase->Find("PINK"));
dc.DrawSpline(4,splines);
dc.SetPen(wxPen(wxTheColourDatabase->Find("FIREBRICK"),5,wxDOT_DASH));
dc.DrawLines(4,lines);
// dc.DrawEllipse(wxPoint(130,105),wxSize(90,60));
dc.SetPen(wxPen(wxTheColourDatabase->Find("NAVY"),5,wxSOLID));
dc.SetBrush(wxTheColourDatabase->Find("GOLD"));//,wxTRANSPARENT));
dc.DrawCircle(170,230,30);
dc.DrawRotatedText("wxWidgets",240,260,30);
}