X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/bc2ec626ea6114fdafb18da7752be495088b8832..40711af81b4a412892045837997211d597d98ff2:/samples/thread/thread.cpp diff --git a/samples/thread/thread.cpp b/samples/thread/thread.cpp index 7a6b0ef5e7..248b3dee44 100644 --- a/samples/thread/thread.cpp +++ b/samples/thread/thread.cpp @@ -30,6 +30,8 @@ #include "wx/progdlg.h" +#include "../sample.xpm" + // define this to use wxExecute in the exec tests, otherwise just use system #define USE_EXECUTE @@ -47,7 +49,7 @@ class MyApp : public wxApp { public: MyApp(); - virtual ~MyApp(); + virtual ~MyApp(){}; virtual bool OnInit(); @@ -132,7 +134,8 @@ private: // ID for the menu commands enum { - THREAD_QUIT = 1, + THREAD_QUIT = wxID_EXIT, + THREAD_ABOUT = wxID_ABOUT, THREAD_TEXT = 101, THREAD_CLEAR, THREAD_START_THREAD = 201, @@ -146,7 +149,6 @@ enum THREAD_EXEC_THREAD, THREAD_SHOWCPUS, - THREAD_ABOUT, WORKER_EVENT // this one gets sent from the worker thread }; @@ -358,10 +360,6 @@ MyApp::MyApp() m_waitingUntilAllDone = false; } -MyApp::~MyApp() -{ -} - // `Main program' equivalent, creating windows and returning main app frame bool MyApp::OnInit() { @@ -405,7 +403,7 @@ bool MyApp::OnInit() menuBar->Append(menuHelp, _T("&Help")); frame->SetMenuBar(menuBar); - + // Show the frame frame->Show(true); @@ -419,11 +417,15 @@ MyFrame::MyFrame(wxFrame *frame, const wxString& title, int x, int y, int w, int h) : wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h)) { + SetIcon(wxIcon(sample_xpm)); + m_nRunning = m_nCount = 0; m_dlgProgress = (wxProgressDialog *)NULL; +#if wxUSE_STATUSBAR CreateStatusBar(2); +#endif // wxUSE_STATUSBAR m_txtctrl = new wxTextCtrl(this, wxID_ANY, _T(""), wxPoint(0, 0), wxSize(0, 0), wxTE_MULTILINE | wxTE_READONLY); @@ -525,9 +527,11 @@ void MyFrame::OnStartThreads(wxCommandEvent& WXUNUSED(event) ) threads.Add(thr); } +#if wxUSE_STATUSBAR wxString msg; msg.Printf(wxT("%d new threads created."), count); SetStatusText(msg, 1); +#endif // wxUSE_STATUSBAR // ...and then start them for ( n = 0; n < count; n++ ) @@ -545,7 +549,9 @@ void MyFrame::OnStartThread(wxCommandEvent& WXUNUSED(event) ) wxLogError(wxT("Can't start thread!")); } +#if wxUSE_STATUSBAR SetStatusText(_T("New thread started."), 1); +#endif // wxUSE_STATUSBAR } void MyFrame::OnStopThread(wxCommandEvent& WXUNUSED(event) ) @@ -570,7 +576,9 @@ void MyFrame::OnStopThread(wxCommandEvent& WXUNUSED(event) ) thread->Delete(); +#if wxUSE_STATUSBAR SetStatusText(_T("Thread stopped."), 1); +#endif // wxUSE_STATUSBAR } } @@ -591,7 +599,9 @@ void MyFrame::OnResumeThread(wxCommandEvent& WXUNUSED(event) ) { wxGetApp().m_threads[n]->Resume(); +#if wxUSE_STATUSBAR SetStatusText(_T("Thread resumed."), 1); +#endif // wxUSE_STATUSBAR } } @@ -612,7 +622,9 @@ void MyFrame::OnPauseThread(wxCommandEvent& WXUNUSED(event) ) { wxGetApp().m_threads[n]->Pause(); +#if wxUSE_STATUSBAR SetStatusText(_T("Thread paused."), 1); +#endif // wxUSE_STATUSBAR } } @@ -718,6 +730,7 @@ void MyFrame::OnStartWorker(wxCommandEvent& WXUNUSED(event)) if ( thread->Create() != wxTHREAD_NO_ERROR ) { wxLogError(wxT("Can't create thread!")); + return; } m_dlgProgress = new wxProgressDialog