1 /*************************************************************** 2 * Name: ThreadSearchEvent 3 * 4 * Purpose: This class implements the events sent by the 5 * worker search thread (ThreadSearchThread) to the 6 * ThreadSearchView to update the logger window with 7 * file/line/text. 8 * wxCommandEvent m_commandString contains file path. 9 * m_LineTextArray contains Line/FoundText series of items 10 * 11 * Author: Jerome ANTOINE 12 * Created: 2007-10-08 13 * Copyright: Jerome ANTOINE 14 * License: GPL 15 **************************************************************/ 16 #ifndef THREAD_SEARCH_EVENT_H 17 #define THREAD_SEARCH_EVENT_H 18 19 #include <wx/event.h> 20 #include <wx/arrstr.h> 21 22 class ThreadSearchEvent : public wxCommandEvent 23 { 24 public: 25 /** Constructor. */ 26 ThreadSearchEvent(wxEventType commandType = wxEVT_NULL, int id = 0); 27 28 /** Copy constructor. */ 29 ThreadSearchEvent(const ThreadSearchEvent& event); 30 31 /** Destructor. */ 32 ~ThreadSearchEvent(); 33 Clone()34 virtual wxEvent *Clone() const {return new ThreadSearchEvent(*this);} 35 36 DECLARE_DYNAMIC_CLASS(ThreadSearchEvent); 37 GetLineTextArray()38 wxArrayString GetLineTextArray() const {return m_LineTextArray;}; // Contains a series of string containing 39 // line index (starting from 1), matching line SetLineTextArray(const wxArrayString & ArrayString)40 void SetLineTextArray(const wxArrayString& ArrayString) {m_LineTextArray = ArrayString;}; 41 GetNumberOfMatches()42 size_t GetNumberOfMatches() const { return m_LineTextArray.GetCount() / 2; } 43 44 private: 45 wxArrayString m_LineTextArray; 46 }; 47 48 typedef void (wxEvtHandler::*ThreadSearchEventFunction)(ThreadSearchEvent&); 49 50 BEGIN_DECLARE_EVENT_TYPES() 51 DECLARE_EXPORTED_EVENT_TYPE(WXEXPORT, wxEVT_THREAD_SEARCH, wxID_ANY) 52 DECLARE_EXPORTED_EVENT_TYPE(WXEXPORT, wxEVT_THREAD_SEARCH_ERROR, wxID_ANY) 53 END_DECLARE_EVENT_TYPES() 54 55 #define EVT_THREAD_SEARCH(id, fn) \ 56 DECLARE_EVENT_TABLE_ENTRY(wxEVT_THREAD_SEARCH, id, -1, \ 57 (wxObjectEventFunction)(wxEventFunction)(wxCommandEventFunction) (ThreadSearchEventFunction) & fn,(wxObject *) NULL ), 58 59 #define EVT_THREAD_SEARCH_ERROR(id, fn) \ 60 DECLARE_EVENT_TABLE_ENTRY(wxEVT_THREAD_SEARCH_ERROR, id, -1, \ 61 (wxObjectEventFunction)(wxEventFunction)(wxCommandEventFunction) (ThreadSearchEventFunction) & fn,(wxObject *) NULL ), 62 63 #endif // THREAD_SEARCH_EVENT_H 64 65 66