00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00012
00013 #ifdef __GNUG__
00014 #pragma implementation "CRCaptureControl.h"
00015 #endif
00016
00017 #include <wxGuiTest/CRCaptureControl.h>
00018
00019 #include <wx/xrc/xmlres.h>
00020
00021 #include <wxGuiTest/WxGuiTestHelper.h>
00022 #include <wxGuiTest/CREventCaptureManager.h>
00023 #include <wxGuiTest/CRCppEmitter.h>
00024
00025 BEGIN_EVENT_TABLE(wxTst::CRCaptureControl, wxEvtHandler)
00026 EVT_BUTTON( XRCID("StartButton"), CRCaptureControl::OnStart )
00027 EVT_BUTTON( XRCID("StopButton"), CRCaptureControl::OnStop )
00028 EVT_BUTTON( XRCID("CommentButton"), CRCaptureControl::OnAddComment )
00029 EVT_BUTTON( XRCID("ExitButton"), CRCaptureControl::OnOK )
00030 EVT_CLOSE ( CRCaptureControl::OnClose )
00031 END_EVENT_TABLE()
00032
00033 using namespace wxTst;
00034
00035
00036 CRCaptureControl::CRCaptureControl (wxDialog *dialog)
00037 {
00038 m_dialog = dialog;
00039 }
00040
00041
00042 CRCaptureControl::~CRCaptureControl ()
00043 {
00044
00045 }
00046
00047
00048 void CRCaptureControl::OnStart (wxCommandEvent& WXUNUSED(event))
00049 {
00050 CREventCaptureManager::GetInstance ()->On ();
00051 this->SetButtonStates (false);
00052 }
00053
00054
00055 void CRCaptureControl::OnStop (wxCommandEvent& WXUNUSED(event))
00056 {
00057 CREventCaptureManager::GetInstance ()->Off ();
00058 this->SetButtonStates (true);
00059 }
00060
00061
00062 void CRCaptureControl::OnAddComment (wxCommandEvent& WXUNUSED(event))
00063 {
00064 CREventCaptureManager::GetInstance ()->EmitPendingEvent ();
00065
00066 wxTextCtrl *commentTextCtrl = XRCCTRL (*m_dialog, "CommentTextCtrl",
00067 wxTextCtrl);
00068 wxASSERT (commentTextCtrl != NULL);
00069
00070 if (!commentTextCtrl->GetValue ().IsEmpty ()) {
00071
00072 CRCppEmitter::GetInstance ()->AddComment (commentTextCtrl->GetValue ());
00073 }
00074 }
00075
00076
00077 void CRCaptureControl::OnOK (wxCommandEvent& WXUNUSED(event))
00078 {
00079 Finish ();
00080 }
00081
00082
00083 void CRCaptureControl::OnClose (wxCloseEvent& WXUNUSED(event))
00084 {
00085 Finish ();
00086 }
00087
00088
00089 void CRCaptureControl::Finish ()
00090 {
00091 CREventCaptureManager::GetInstance ()->Off ();
00092
00093 m_dialog->Hide ();
00094 wxTheApp->ExitMainLoop ();
00095 }
00096
00097
00098 void CRCaptureControl::SetButtonStates (bool isInit) const
00099 {
00100 wxButton *startBtn = XRCCTRL (*m_dialog, "StartButton", wxButton);
00101 wxASSERT (startBtn != NULL);
00102 startBtn->Enable (isInit);
00103
00104 wxButton *stopBtn = XRCCTRL (*m_dialog, "StopButton", wxButton);
00105 wxASSERT (stopBtn != NULL);
00106 stopBtn->Enable (!isInit);
00107 }
00108
00109