Event sources and toolbar management now more dynamic

This commit is contained in:
2016-08-27 13:01:58 +02:00
parent 6ee34cdd47
commit 2a88c4f2a8
5 changed files with 164 additions and 142 deletions

View File

@@ -58,6 +58,7 @@ class wxPersistentETWListCtrl;
#include <memory>
#include <vector>
#include <set>
class wxETWEvent : public wxEvent
@@ -110,6 +111,30 @@ protected:
class wxETWListCtrl : public wxListCtrl
{
protected:
///
/// Functor for GUID comparison
///
struct less_guid : public std::binary_function<GUID, GUID, bool>
{
bool operator()(const GUID &a, const GUID &b) const
{
if (a.Data1 < b.Data1) return true;
if (a.Data1 > b.Data1) return false;
if (a.Data2 < b.Data2) return true;
if (a.Data2 > b.Data2) return false;
if (a.Data3 < b.Data3) return true;
if (a.Data3 > b.Data3) return false;
if (memcmp(a.Data4, b.Data4, sizeof(a.Data4)) < 0) return true;
return false;
}
};
///
/// A set of GUIDs
///
typedef std::set<GUID, less_guid> guidset;
public:
wxETWListCtrl(
wxWindow *parent,
@@ -121,7 +146,7 @@ public:
const wxString &name = wxListCtrlNameStr);
virtual ~wxETWListCtrl();
bool IsEmpty() const { return m_rec_db.empty(); }
inline bool IsEmpty() const { return m_rec_db.empty(); }
void CopySelected() const;
void CopyAll() const;
void ClearAll();
@@ -129,6 +154,27 @@ public:
void SelectNone();
void RebuildItems();
inline bool IsSourceEnabled(const GUID &guid) const
{
return m_sources.find(guid) != m_sources.end();
}
inline void EnableSource(const GUID &guid, bool enable = true)
{
guidset::iterator s = m_sources.find(guid);
if (enable) {
if (s == m_sources.end()) {
m_sources.insert(guid);
RebuildItems();
}
} else {
if (s != m_sources.end()) {
m_sources.erase(s);
RebuildItems();
}
}
}
friend class wxPersistentETWListCtrl; // Allow saving/restoring window state.
protected:
@@ -144,9 +190,6 @@ protected:
public:
bool m_scroll_auto; ///< Is autoscrolling enabled?
bool m_source_eaphost; ///< Shows EapHost messages
bool m_source_schannel; ///< Shows Schannel messages
bool m_source_product; ///< Shows native messages
UCHAR m_level; ///< Shows messages up to this level of verboseness
static const GUID s_provider_eaphost; ///< EapHost event provider ID
@@ -155,7 +198,8 @@ public:
protected:
winstd::event_session m_session; ///< Event session
wxEventTraceProcessorThread *m_proc; ///< Processor thread
long m_item_id; ///< Next free list item ID
guidset m_sources; ///< Set of enabled sources
wxListItemAttr m_item_attr[2][4]; ///< Current item attributes
winstd::vector_queue<winstd::event_rec> m_rec_db; ///< Event record database