#include "wx/progdlg.h"
+#include "../sample.xpm"
+
// define this to use wxExecute in the exec tests, otherwise just use system
#define USE_EXECUTE
{
public:
MyApp();
- virtual ~MyApp();
+ virtual ~MyApp(){};
virtual bool OnInit();
// waiting for us
if ( wxGetApp().m_waitingUntilAllDone )
{
- wxGetApp().m_waitingUntilAllDone = FALSE;
+ wxGetApp().m_waitingUntilAllDone = false;
wxGetApp().m_semAllDone.Post();
}
MyApp::MyApp()
: m_semAllDone()
{
- m_waitingUntilAllDone = FALSE;
-}
-
-MyApp::~MyApp()
-{
+ m_waitingUntilAllDone = false;
}
// `Main program' equivalent, creating windows and returning main app frame
menuBar->Append(menuHelp, _T("&Help"));
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))
{
+ 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, -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);
}
if ( count )
{
// set the flag for MyThread::OnExit()
- wxGetApp().m_waitingUntilAllDone = TRUE;
+ wxGetApp().m_waitingUntilAllDone = true;
// stop all threads
while ( ! threads.IsEmpty() )
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++ )
wxLogError(wxT("Can't start thread!"));
}
+#if wxUSE_STATUSBAR
SetStatusText(_T("New thread started."), 1);
+#endif // wxUSE_STATUSBAR
}
void MyFrame::OnStopThread(wxCommandEvent& WXUNUSED(event) )
thread->Delete();
+#if wxUSE_STATUSBAR
SetStatusText(_T("Thread stopped."), 1);
+#endif // wxUSE_STATUSBAR
}
}
{
wxGetApp().m_threads[n]->Resume();
+#if wxUSE_STATUSBAR
SetStatusText(_T("Thread resumed."), 1);
+#endif // wxUSE_STATUSBAR
}
}
{
wxGetApp().m_threads[n]->Pause();
+#if wxUSE_STATUSBAR
SetStatusText(_T("Thread paused."), 1);
+#endif // wxUSE_STATUSBAR
}
}
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )
{
- Close(TRUE);
+ Close(true);
}
void MyFrame::OnExecMain(wxCommandEvent& WXUNUSED(event))
if ( thread->Create() != wxTHREAD_NO_ERROR )
{
wxLogError(wxT("Can't create thread!"));
+ return;
}
m_dlgProgress = new wxProgressDialog
);
// thread is not running yet, no need for crit sect
- m_cancelled = FALSE;
+ m_cancelled = false;
thread->Run();
}
{
wxCriticalSectionLocker lock(m_critsectWork);
- m_cancelled = TRUE;
+ m_cancelled = true;
}
}
#endif