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>
|
|
|
|
|
2014-06-02 11:08:37 +03:00
|
|
|
class emulator_instance;
|
|
|
|
|
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:
|
2014-06-02 11:08:37 +03:00
|
|
|
recent_menu(wxWindow* win, emulator_instance& _inst, int wxid_low, int wxid_high, const std::string& cfg,
|
|
|
|
void (*cb)(emulator_instance& inst, 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:
|
2014-06-02 11:08:37 +03:00
|
|
|
emulator_instance& inst;
|
2014-02-25 02:11:36 +02:00
|
|
|
class rhook : public recentfiles::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;
|
2014-02-25 02:11:36 +02:00
|
|
|
recentfiles::set<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;
|
2014-06-02 11:08:37 +03:00
|
|
|
void (*callback)(emulator_instance& inst, const T& name);
|
2012-09-25 23:05:57 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|