1 #include "platform/wxwidgets/menu_recent.hpp"
2 #include "platform/wxwidgets/platform.hpp"
3 #include "library/eatarg.hpp"
6 recent_menu
<T
>::recent_menu(wxWindow
* win
, emulator_instance
& _inst
, int wxid_low
, int wxid_high
,
7 const std::string
& cfg
, void (*cb
)(emulator_instance
& inst
, const T
& name
))
8 : inst(_inst
), hook(*this), rfiles(cfg
, wxid_high
- wxid_low
) //Reserve wxid_high for refresh.
12 wxid_range_low
= wxid_low
;
13 wxid_range_high
= wxid_high
;
15 win
->Connect(wxid_low
, wxid_high
, wxEVT_COMMAND_MENU_SELECTED
,
16 wxCommandEventHandler(recent_menu::on_select
), NULL
, this);
17 rfiles
.add_hook(hook
);
21 template<class T
> void recent_menu
<T
>::on_select(wxCommandEvent
& e
)
25 if(id
< wxid_range_low
|| id
> wxid_range_high
)
27 if(id
== wxid_range_high
) {
32 if(entries
.count(id
)) {
33 callback(inst
, entries
[id
]);
34 rfiles
.add(entries
[id
]);
39 template<class T
> void recent_menu
<T
>::update()
42 auto ents
= rfiles
.get();
43 int id
= wxid_range_low
;
47 bool has_ents
= false;
50 if(id
>= wxid_range_high
)
53 items
[id
] = Append(id
, towxstring(i
.display()));
57 items
[-1] = AppendSeparator();
58 items
[wxid_range_high
] = Append(wxid_range_high
, wxT("Refresh"));
61 template<class T
> void recent_menu
<T
>::add(const T
& file
)
66 void _dummy_3642632773273272787237272723()
68 recent_menu
<recentfiles::path
> x(NULL
, *(emulator_instance
*)NULL
, 0, 0, "", NULL
);
69 recent_menu
<recentfiles::multirom
> y(NULL
, *(emulator_instance
*)NULL
, 0, 0, "", NULL
);
70 eat_argument(&recent_menu
<recentfiles::path
>::add
);
71 eat_argument(&recent_menu
<recentfiles::multirom
>::add
);