1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#ifndef CLTABHISTORY_H
#define CLTABHISTORY_H
#include "codelite_exports.h"
#include <vector>
#include <wx/sharedptr.h>
#include <wx/window.h>
#include <algorithm>
class WXDLLIMPEXP_SDK clTabHistory
{
std::vector<wxWindow*> m_history;
public:
typedef wxSharedPtr<clTabHistory> Ptr_t;
public:
clTabHistory() {}
virtual ~clTabHistory() {}
void Push(wxWindow* page)
{
if(page == NULL) return;
Pop(page);
m_history.insert(m_history.begin(), page);
}
void Pop(wxWindow* page)
{
if(!page) return;
std::vector<wxWindow*>::iterator iter =
std::find_if(m_history.begin(), m_history.end(), [&](wxWindow* w) { return w == page; });
if(iter != m_history.end()) {
m_history.erase(iter);
}
}
wxWindow* PrevPage()
{
if(m_history.empty()) {
return NULL;
}
// return the top of the heap
return m_history[0];
}
/**
* @brief clear the history
*/
void Clear() { m_history.clear(); }
/**
* @brief return the tabbing history
* @return
*/
const std::vector<wxWindow*>& GetHistory() const { return m_history; }
};
#endif // CLTABHISTORY_H
|