lsnes/include/platform/wxwidgets/menu_recent.hpp

38 lines
876 B
C++
Raw Normal View History

2012-09-25 23:05:57 +03:00
#ifndef _plat_wxwidgets__menu_recent__hpp__included__
#define _plat_wxwidgets__menu_recent__hpp__included__
#include <wx/string.h>
#include <wx/wx.h>
#include "library/recentfiles.hpp"
#include <map>
2013-09-22 17:39:52 +03:00
template<class T>
2012-09-25 23:05:57 +03:00
class recent_menu : public wxMenu
{
public:
recent_menu(wxWindow* win, int wxid_low, int wxid_high, const std::string& cfg,
2013-09-27 22:57:24 +03:00
void (*cb)(const T& name)) __attribute__((noinline));
2012-09-25 23:05:57 +03:00
void on_select(wxCommandEvent& e);
void update();
2013-09-22 17:39:52 +03:00
void add(const T& file);
2012-09-25 23:05:57 +03:00
private:
2013-09-22 17:39:52 +03:00
class rhook : public recent_files_hook
2012-09-25 23:05:57 +03:00
{
public:
rhook(recent_menu& _pmenu) : pmenu(_pmenu) {}
~rhook() {}
void operator()() { pmenu.update(); }
private:
recent_menu& pmenu;
} hook;
2013-09-22 17:39:52 +03:00
recent_files<T> rfiles;
2012-09-25 23:05:57 +03:00
wxWindow* pwin;
2013-09-22 17:39:52 +03:00
std::map<int, T> entries;
2012-09-25 23:05:57 +03:00
std::map<int, wxMenuItem*> items;
int wxid_range_low;
int wxid_range_high;
2013-09-22 17:39:52 +03:00
void (*callback)(const T& name);
2012-09-25 23:05:57 +03:00
};
#endif