X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/69199aad025095def4b42214f7b44829397caf52..2e51fb3041e78ef15506ed746ed5898536be5955:/samples/minimal/minimal.cpp diff --git a/samples/minimal/minimal.cpp b/samples/minimal/minimal.cpp index ffad284b3b..80bf766199 100644 --- a/samples/minimal/minimal.cpp +++ b/samples/minimal/minimal.cpp @@ -16,10 +16,10 @@ // ---------------------------------------------------------------------------- // headers // ---------------------------------------------------------------------------- - + // For compilers that support precompilation, includes "wx/wx.h". #include "wx/wxprec.h" - + #ifdef __BORLANDC__ #pragma hdrstop #endif @@ -68,32 +68,6 @@ public: void OnQuit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); - void OnPaint(wxPaintEvent&) - { - wxPaintDC dc(this); - - wxBitmap bmp(100, 100, 1); - { - wxMemoryDC memdc(bmp); - memdc.SetBackground(*wxWHITE); - memdc.SetTextForeground(*wxBLACK); - memdc.Clear(); - memdc.DrawText(_T("Hello wx!"), 10, 10); - } - - wxBitmap bmp2 = bmp; - { - wxMemoryDC memdc(bmp2); - memdc.SetBackground(*wxWHITE); - memdc.SetTextForeground(*wxRED); - memdc.Clear(); - memdc.DrawText(_T("Goodbye!"), 10, 10); - } - - dc.DrawBitmap(bmp, 10, 10); - dc.DrawBitmap(bmp2, 120, 10); - } - private: // any class wishing to process wxWidgets events must use this macro DECLARE_EVENT_TABLE() @@ -151,7 +125,7 @@ bool MyApp::OnInit() return false; // create the main application window - MyFrame *frame = new MyFrame(_T("Minimal wxWidgets App")); + MyFrame *frame = new MyFrame("Minimal wxWidgets App"); // and show it (the frames, unlike simple controls, are not shown when // created initially) @@ -171,7 +145,6 @@ bool MyApp::OnInit() MyFrame::MyFrame(const wxString& title) : wxFrame(NULL, wxID_ANY, title) { - Connect(wxEVT_PAINT, wxPaintEventHandler(MyFrame::OnPaint)); // set the frame icon SetIcon(wxICON(sample)); @@ -181,30 +154,23 @@ MyFrame::MyFrame(const wxString& title) // the "About" item should be in the help menu wxMenu *helpMenu = new wxMenu; - helpMenu->Append(Minimal_About, _T("&About...\tF1"), _T("Show about dialog")); + helpMenu->Append(Minimal_About, "&About...\tF1", "Show about dialog"); - fileMenu->Append(Minimal_Quit, _T("E&xit\tAlt-X"), _T("Quit this program")); + fileMenu->Append(Minimal_Quit, "E&xit\tAlt-X", "Quit this program"); // now append the freshly created menu to the menu bar... wxMenuBar *menuBar = new wxMenuBar(); - menuBar->Append(fileMenu, _T("&File")); - menuBar->Append(helpMenu, _T("&Help")); + menuBar->Append(fileMenu, "&File"); + menuBar->Append(helpMenu, "&Help"); // ... and attach this menu bar to the frame SetMenuBar(menuBar); #endif // wxUSE_MENUS - wxTextCtrl *m_textctrl = new wxTextCtrl(this, -1, _T(""), wxPoint(100, - 100), wxSize(100, 100), wxTE_MULTILINE); - wxTextAttr t_style ( *wxRED ); - m_textctrl->SetDefaultStyle(t_style); - m_textctrl->Clear(); - m_textctrl->WriteText(_T("Must be red")); - #if wxUSE_STATUSBAR // create a status bar just for fun (by default with 1 pane only) CreateStatusBar(2); - SetStatusText(_T("Welcome to wxWidgets!")); + SetStatusText("Welcome to wxWidgets!"); #endif // wxUSE_STATUSBAR } @@ -219,15 +185,16 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { - wxMessageBox(wxString::Format( - _T("Welcome to %s!\n") - _T("\n") - _T("This is the minimal wxWidgets sample\n") - _T("running under %s."), + wxMessageBox(wxString::Format + ( + "Welcome to %s!\n" + "\n" + "This is the minimal wxWidgets sample\n" + "running under %s.", wxVERSION_STRING, - wxGetOsDescription().c_str() + wxGetOsDescription() ), - _T("About wxWidgets minimal sample"), + "About wxWidgets minimal sample", wxOK | wxICON_INFORMATION, this); }