I tried to draw something on a window but without any effect. Look at this :
Code: Select all
#include "wx/wx.h"
#include "wx/sizer.h"
class MyWindow : public wxFrame
{
public:
MyWindow(const wxString& title);
void paintEvent(wxPaintEvent& evt);
void render(wxDC& dc);
};
class MyApp: public wxApp
{
bool OnInit();
};
IMPLEMENT_APP(MyApp)
bool MyApp::OnInit()
{
MyWindow *myWindow = new MyWindow(wxT("Test"));
myWindow->Show(true);
return true;
}
MyWindow::MyWindow(const wxString& title): wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(1000,800))
{
this->Connect(wxID_ANY,wxEVT_PAINT ,wxCommandEventHandler(MyWindow::paintEvent),NULL,this); // this dosent, any ideas how to connect here=
wxClientDC dc(this);
render(dc);
}
void MyWindow::paintEvent(wxPaintEvent& evt)
{
wxPaintDC dc(this);
render(dc);
}
void MyWindow::render(wxDC& dc)
{
dc.DrawText(wxT("Testing"), 40, 60);
dc.SetBrush(*wxGREEN_BRUSH);
dc.SetPen( wxPen( wxColor(255,0,0), 5 ) );
dc.DrawCircle( wxPoint(200,100), 25 );
dc.SetBrush(*wxBLUE_BRUSH); // blue filling
dc.SetPen( wxPen( wxColor(255,175,175), 10 ) );
dc.DrawRectangle( 300, 100, 400, 200 );
dc.SetPen( wxPen( wxColor(0,0,0), 3 ) );
dc.DrawLine( 300, 100, 700, 300 );
}