#include "wx/wx.h"
class MyFrame : public wxFrame
{
public:
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style = wxDEFAULT_FRAME_STYLE);
void OnSize(wxSizeEvent& event);
void OnPaint(wxPaintEvent& event);
private:
DECLARE_EVENT_TABLE();
};
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_SIZE(MyFrame::OnSize)
EVT_PAINT(MyFrame::OnPaint)
END_EVENT_TABLE()
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style)
: wxFrame((wxFrame *)NULL, -1, title, pos, size, style)
{
}
void MyFrame::OnSize(wxSizeEvent& event)
{
wxFrame::OnSize(event);
Refresh();
}
void MyFrame::OnPaint(wxPaintEvent& event)
{
int width, height;
wxBrush bgBrush(wxColour(255,255,255), wxSOLID);
wxBrush fgBrush(wxColour(0,0,255), wxSOLID);
wxMemoryDC memdc;
wxPaintDC myDC(this);
GetClientSize(&width, &height);
wxBitmap bmp(width, height);
memdc.SelectObject(bmp);
memdc.SetBrush(bgBrush);
memdc.DrawRectangle(0, 0, width, height);
memdc.SetBrush(fgBrush);
memdc.DrawCircle(width >> 1, height >> 1, width >> 1);
myDC.Blit(0, 0, width, height, &memdc, 0, 0, wxCOPY);
/*
or
myDC.SetBrush(fgBrush);
myDC.DrawCircle(width >> 1, height >> 1, width >> 1); */
}
class MyApp : public wxApp
{
public:
virtual bool OnInit();
};
IMPLEMENT_APP(MyApp)
bool MyApp::OnInit()
{
MyFrame *frame = new MyFrame(_T(".."), wxPoint(50, 50), wxSize(450, 340));
frame->Show(TRUE);
SetTopWindow(frame);
return TRUE;
}