#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();
// 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,
THREAD_EXEC_THREAD,
THREAD_SHOWCPUS,
- THREAD_ABOUT,
WORKER_EVENT // this one gets sent from the worker thread
};
void WriteText(const wxString& text);
public:
- size_t m_count;
+ unsigned m_count;
MyFrame *m_frame;
};
public:
MyFrame *m_frame;
- size_t m_count;
+ unsigned m_count;
};
MyWorkerThread::MyWorkerThread(MyFrame *frame)
m_waitingUntilAllDone = false;
}
-MyApp::~MyApp()
-{
-}
-
// `Main program' equivalent, creating windows and returning main app frame
bool MyApp::OnInit()
{
menuBar->Append(menuHelp, _T("&Help"));
frame->SetMenuBar(menuBar);
-
+
// Show the frame
frame->Show(true);
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);
void MyFrame::OnStartThreads(wxCommandEvent& WXUNUSED(event) )
{
- static long s_num = 10;
+ static long s_num;
s_num = wxGetNumberFromUser(_T("How many threads to start: "), _T(""),
_T("wxThread sample"), s_num, 1, 10000, this);
return;
}
- size_t count = (size_t)s_num, n;
+ unsigned count = unsigned(s_num), n;
wxArrayThread threads;
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
}
}
m_nRunning = nRunning;
m_nCount = nCount;
- wxLogStatus(this, wxT("%u threads total, %u running."), nCount, nRunning);
+ wxLogStatus(this, wxT("%u threads total, %u running."), unsigned(nCount), unsigned(nRunning));
}
//else: avoid flicker - don't print anything
if ( thread->Create() != wxTHREAD_NO_ERROR )
{
wxLogError(wxT("Can't create thread!"));
+ return;
}
m_dlgProgress = new wxProgressDialog