Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "wx/wx.h"
- #include "wx/dcbuffer.h"
- #include "vector"
- using namespace std;
- class MyFrame : public wxFrame {
- public:
- wxPen blackPen3;
- wxColor brown;
- wxColor yellow;
- wxColor blue;
- wxBrush brownBrush;
- wxBrush yellowBrush;
- wxBrush blueBrush;
- wxBrush *wxBROWN_BRUSH;
- vector<wxPoint> mountainPeaks;
- MyFrame (const wxString& title) : wxFrame(nullptr, wxID_ANY, title, wxPoint(50,50), wxSize(640,500)){
- SetBackgroundStyle (wxBG_STYLE_PAINT);
- blackPen3 = wxPen(*wxBLACK);
- blackPen3.SetWidth (3);
- brown = wxColor (165,42,42);
- yellow = wxColor (255,255,0);
- blue = wxColor (0,0,255);
- brownBrush= wxBrush(brown);
- yellowBrush= wxBrush(yellow);
- blueBrush= wxBrush(blue);
- *wxBROWN_BRUSH= wxBrush(brown);
- mountainPeaks = vector<wxPoint> {wxPoint(640,0), wxPoint(540,40),wxPoint(600,55),wxPoint(520,85),wxPoint(600,100),wxPoint(560,120),wxPoint(640,150)};
- Bind(wxEVT_PAINT, &MyFrame :: OnPaint,this);
- Bind(wxEVT_CLOSE_WINDOW, &MyFrame ::OnClose, this);
- }
- void OnClose (wxCloseEvent& event){
- Destroy();
- }
- void OnPaint(wxPaintEvent &event){
- wxAutoBufferedPaintDC dc(this);
- dc.SetBackground(blueBrush);
- dc.Clear();
- dc.SetPen(blackPen3);
- dc.SetBrush(*wxYELLOW_BRUSH);
- dc.DrawEllipse(wxPoint(0,500), wxSize(70,70));
- dc.SetBrush(*wxBROWN_BRUSH);
- dc.DrawPolygon(mountainPeaks.size(), mountainPeaks.data());
- }
- };
- class MyApp : public wxApp{
- public:
- virtual bool OnInit(){
- MyFrame *frame = new MyFrame (wxT("mountains"));
- frame->Show(true);
- return true;
- }
- };
- IMPLEMENT_APP(MyApp)
Advertisement
Add Comment
Please, Sign In to add comment