X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/01ca9e8ea7d4c6f00bd46653b96857998be0ae83..288d4f8b91cd983893332218daa8c02a618e0c1d:/samples/minimal/minimal.cpp diff --git a/samples/minimal/minimal.cpp b/samples/minimal/minimal.cpp index 8a7835efe4..7f1ab0047c 100644 --- a/samples/minimal/minimal.cpp +++ b/samples/minimal/minimal.cpp @@ -29,13 +29,13 @@ #endif // for all others, include the necessary headers (this file is usually all you -// need because it includes almost all "standard" wxWindows headers +// need because it includes almost all "standard" wxWindows headers) #ifndef WX_PRECOMP #include "wx/wx.h" #endif // ---------------------------------------------------------------------------- -// ressources +// resources // ---------------------------------------------------------------------------- // the application icon #if defined(__WXGTK__) || defined(__WXMOTIF__) @@ -67,6 +67,16 @@ public: MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size); // event handlers (these functions should _not_ be virtual) + void OnPaint(wxPaintEvent& event) + { + wxPaintDC dc(this); + dc.DrawRectangle(20, 20, 100, 100); + dc.SetPen(*wxRED_PEN); + dc.SetDeviceOrigin(20, 20); + dc.SetClippingRegion(0, 0, 100, 100); + dc.DrawLine(0, 0, 1000, 1000); + } + void OnQuit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); @@ -95,6 +105,7 @@ enum // handlers) which process them. It can be also done at run-time, but for the // simple menu events like this the static method is much simpler. BEGIN_EVENT_TABLE(MyFrame, wxFrame) + EVT_PAINT(MyFrame::OnPaint) EVT_MENU(Minimal_Quit, MyFrame::OnQuit) EVT_MENU(Minimal_About, MyFrame::OnAbout) END_EVENT_TABLE() @@ -114,7 +125,7 @@ IMPLEMENT_APP(MyApp) // the application class // ---------------------------------------------------------------------------- -// `Main program' equivalent: the program execution "starts" here +// 'Main program' equivalent: the program execution "starts" here bool MyApp::OnInit() { // create the main application window @@ -165,24 +176,6 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) // ... and attach this menu bar to the frame SetMenuBar(menuBar); - wxPanel *panel = new wxPanel(this, -1); - wxStaticBox *box = new wxStaticBox(panel, -1, "box"); - wxComboBox *combo = new wxComboBox(panel, -1, "combo"); - wxLayoutConstraints *c; - c = new wxLayoutConstraints; - c->left.SameAs(panel, wxLeft); - c->right.SameAs(panel, wxRight); - c->top.SameAs(panel, wxTop); - c->bottom.SameAs(panel, wxBottom); - box->SetConstraints(c); - c = new wxLayoutConstraints; - c->left.SameAs(box, wxLeft, 20); - c->right.SameAs(box, wxRight, 10); - c->top.SameAs(box, wxTop, 10); - c->bottom.SameAs(box, wxBottom, 10); - combo->SetConstraints(c); - panel->SetAutoLayout(TRUE); - #if wxUSE_STATUSBAR // create a status bar just for fun (by default with 1 pane only) CreateStatusBar(2);