X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/be5a51fb592f3fa2ba38ac6cd1e488d6d806058c..767e3be0fa755e435a070d145fa623e36762d7a8:/samples/thread/thread.cpp diff --git a/samples/thread/thread.cpp b/samples/thread/thread.cpp index 76965a7664..d239920382 100644 --- a/samples/thread/thread.cpp +++ b/samples/thread/thread.cpp @@ -47,7 +47,7 @@ class MyApp : public wxApp { public: MyApp(); - virtual ~MyApp(); + virtual ~MyApp(){}; virtual bool OnInit(); @@ -210,7 +210,7 @@ void MyThread::OnExit() // waiting for us if ( wxGetApp().m_waitingUntilAllDone ) { - wxGetApp().m_waitingUntilAllDone = FALSE; + wxGetApp().m_waitingUntilAllDone = false; wxGetApp().m_semAllDone.Post(); } @@ -355,11 +355,7 @@ END_EVENT_TABLE() MyApp::MyApp() : m_semAllDone() { - m_waitingUntilAllDone = FALSE; -} - -MyApp::~MyApp() -{ + m_waitingUntilAllDone = false; } // `Main program' equivalent, creating windows and returning main app frame @@ -407,25 +403,27 @@ bool MyApp::OnInit() frame->SetMenuBar(menuBar); // Show the frame - frame->Show(TRUE); + frame->Show(true); SetTopWindow(frame); - return TRUE; + return true; } // My frame constructor MyFrame::MyFrame(wxFrame *frame, const wxString& title, int x, int y, int w, int h) - : wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h)) + : wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h)) { m_nRunning = m_nCount = 0; m_dlgProgress = (wxProgressDialog *)NULL; +#if wxUSE_STATUSBAR CreateStatusBar(2); +#endif // wxUSE_STATUSBAR - m_txtctrl = new wxTextCtrl(this, -1, _T(""), wxPoint(0, 0), wxSize(0, 0), + m_txtctrl = new wxTextCtrl(this, wxID_ANY, _T(""), wxPoint(0, 0), wxSize(0, 0), wxTE_MULTILINE | wxTE_READONLY); } @@ -450,7 +448,7 @@ MyFrame::~MyFrame() if ( count ) { // set the flag for MyThread::OnExit() - wxGetApp().m_waitingUntilAllDone = TRUE; + wxGetApp().m_waitingUntilAllDone = true; // stop all threads while ( ! threads.IsEmpty() ) @@ -525,9 +523,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 +545,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 +572,9 @@ void MyFrame::OnStopThread(wxCommandEvent& WXUNUSED(event) ) thread->Delete(); +#if wxUSE_STATUSBAR SetStatusText(_T("Thread stopped."), 1); +#endif // wxUSE_STATUSBAR } } @@ -591,7 +595,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 +618,9 @@ void MyFrame::OnPauseThread(wxCommandEvent& WXUNUSED(event) ) { wxGetApp().m_threads[n]->Pause(); +#if wxUSE_STATUSBAR SetStatusText(_T("Thread paused."), 1); +#endif // wxUSE_STATUSBAR } } @@ -644,7 +652,7 @@ void MyFrame::OnIdle(wxIdleEvent& event) void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) ) { - Close(TRUE); + Close(true); } void MyFrame::OnExecMain(wxCommandEvent& WXUNUSED(event)) @@ -734,7 +742,7 @@ void MyFrame::OnStartWorker(wxCommandEvent& WXUNUSED(event)) ); // thread is not running yet, no need for crit sect - m_cancelled = FALSE; + m_cancelled = false; thread->Run(); } @@ -763,7 +771,7 @@ void MyFrame::OnWorkerEvent(wxCommandEvent& event) { wxCriticalSectionLocker lock(m_critsectWork); - m_cancelled = TRUE; + m_cancelled = true; } } #endif