Fix some memory leak complaints from Valgrind
[lsnes.git] / include / platform / wxwidgets / platform.hpp
blob77d49856314bc50bb991c954d3d500c7dbcb5b69
1 #ifndef _plat_wxwidgets__platform__hpp__included__
2 #define _plat_wxwidgets__platform__hpp__included__
4 #include "core/moviefile.hpp"
5 #include "core/window.hpp"
7 #include <cstdlib>
8 #include <cstdint>
9 #include <cstddef>
11 #include <wx/string.h>
13 class wxwin_mainwindow;
14 class wxwin_messages;
15 class wxwin_status;
16 class wxWindow;
17 class wxKeyEvent;
19 //Scaling
20 extern double video_scale_factor;
21 extern int scaling_flags;
22 extern bool arcorrect_enabled;
23 extern bool hflip_enabled;
24 extern bool vflip_enabled;
25 extern bool rotate_enabled;
26 extern int wx_escape_count;
28 wxString towxstring(const std::string& str) throw(std::bad_alloc);
29 std::string tostdstring(const wxString& str) throw(std::bad_alloc);
30 wxString towxstring(const std::u32string& str) throw(std::bad_alloc);
31 std::u32string tou32string(const wxString& str) throw(std::bad_alloc);
32 void bring_app_foreground();
33 std::string pick_archive_member(wxWindow* parent, const std::string& filename) throw(std::bad_alloc);
34 void boot_emulator(loaded_rom& rom, moviefile& movie, bool fscreen);
35 void handle_wx_keyboard(wxKeyEvent& e, bool polarity);
36 std::string map_keycode_to_key(int kcode);
37 void initialize_wx_keyboard();
38 void deinitialize_wx_keyboard();
39 void signal_program_exit();
40 void signal_resize_needed();
41 void _runuifun_async(void (*fn)(void*), void* arg);
42 void show_projectwindow(wxWindow* modwin);
43 void signal_core_change();
45 std::vector<interface_action_paramval> prompt_action_params(wxWindow* parent, const std::string& label,
46 const std::list<interface_action_param>& params);
49 //Editor dialogs.
50 void wxeditor_authors_display(wxWindow* parent);
51 void wxeditor_hotkeys_display(wxWindow* parent);
52 void wxeditor_memorywatches_display(wxWindow* parent);
53 void wxeditor_subtitles_display(wxWindow* parent);
54 std::string wxeditor_keyselect(wxWindow* parent, bool clearable);
55 void show_wxeditor_voicesub(wxWindow* parent);
56 void open_rom_select_window();
57 void open_new_project_window(wxWindow* parent);
58 void show_conflictwindow(wxWindow* parent);
59 void open_vumeter_window(wxWindow* parent);
60 void wxeditor_movie_display(wxWindow* parent);
61 void wxeditor_movie_update();
62 void wxeditor_autohold_display(wxWindow* parent);
63 void wxeditor_tasinput_display(wxWindow* parent);
64 void wxeditor_macro_display(wxWindow* parent);
65 void wxeditor_hexedit_display(wxWindow* parent);
66 void wxeditor_multitrack_display(wxWindow* parent);
67 bool wxeditor_plugin_manager_display(wxWindow* parent);
68 void wxeditor_tracelog_display(wxWindow* parent, int cpuid, const std::string& cpuname);
69 void wxeditor_disassembler_display(wxWindow* parent);
70 void wxeditor_plugin_manager_notify_fail(const std::string& libname);
72 //Auxillary windows.
73 void wxwindow_memorysearch_display();
74 void wxwindow_memorysearch_update();
75 void wxeditor_hexeditor_update();
76 class memory_search;
77 memory_search* wxwindow_memorysearch_active();
78 bool wxeditor_hexeditor_available();
79 bool wxeditor_hexeditor_jumpto(uint64_t addr);
80 void wxwindow_tasinput_update();
82 template<typename T>
83 void functor_call_helper2(void* args)
85 (*reinterpret_cast<T*>(args))();
86 delete reinterpret_cast<T*>(args);
89 template<typename T>
90 void runuifun(T fn)
92 _runuifun_async(functor_call_helper2<T>, new T(fn));
95 //Thrown by various dialog functions if canceled.
96 class canceled_exception : public std::runtime_error
98 public:
99 canceled_exception();
102 //Prompt for stuff. These all can throw canceled_exception.
103 std::string pick_file_member(wxWindow* parent, const std::string& title, const std::string& startdir);
104 std::string pick_among(wxWindow* parent, const std::string& title, const std::string& prompt,
105 const std::vector<std::string>& choices, unsigned defaultchoice = 0);
106 std::string pick_text(wxWindow* parent, const std::string& title, const std::string& prompt,
107 const std::string& dflt = "", bool multiline = false);
108 //Show message box with OK button.
109 void show_message_ok(wxWindow* parent, const std::string& title, const std::string& text, int icon);
112 //Some important windows (if open).
113 extern wxwin_messages* msg_window;
114 extern wxwin_mainwindow* main_window;
115 extern std::string our_rom_name;
116 extern bool wxwidgets_exiting;
118 //Some important settings.
119 extern std::map<std::string, std::string> core_selections;
121 template<typename T> void runemufn_async(T fn)
123 platform::queue(functor_call_helper2<T>, new T(fn), false);
126 #endif