Introduce run_show_error() and use it to clean up some code
[lsnes.git] / include / platform / wxwidgets / platform.hpp
blobf257d90e78bf54a2c12bf9c387fb27d8b138ef18
1 #ifndef _plat_wxwidgets__platform__hpp__included__
2 #define _plat_wxwidgets__platform__hpp__included__
4 #include "core/instance.hpp"
5 #include "core/moviefile.hpp"
6 #include "core/window.hpp"
8 #include <cstdlib>
9 #include <cstdint>
10 #include <cstddef>
12 #include <wx/string.h>
14 class wxwin_mainwindow;
15 class wxwin_messages;
16 class wxwin_status;
17 class wxWindow;
18 class wxKeyEvent;
20 //Scaling
21 extern double video_scale_factor;
22 extern int scaling_flags;
23 extern bool arcorrect_enabled;
24 extern bool hflip_enabled;
25 extern bool vflip_enabled;
26 extern bool rotate_enabled;
27 extern int wx_escape_count;
29 wxString towxstring(const std::string& str) throw(std::bad_alloc);
30 std::string tostdstring(const wxString& str) throw(std::bad_alloc);
31 wxString towxstring(const std::u32string& str) throw(std::bad_alloc);
32 std::u32string tou32string(const wxString& str) throw(std::bad_alloc);
33 void bring_app_foreground();
34 std::string pick_archive_member(wxWindow* parent, const std::string& filename) throw(std::bad_alloc);
35 void boot_emulator(loaded_rom& rom, moviefile& movie, bool fscreen);
36 void handle_wx_keyboard(wxKeyEvent& e, bool polarity);
37 std::string map_keycode_to_key(int kcode);
38 void initialize_wx_keyboard();
39 void deinitialize_wx_keyboard();
40 void signal_program_exit();
41 void signal_resize_needed();
42 void _runuifun_async(void (*fn)(void*), void* arg);
43 void show_projectwindow(wxWindow* modwin);
44 void signal_core_change();
45 void do_save_configuration();
47 std::vector<interface_action_paramval> prompt_action_params(wxWindow* parent, const std::string& label,
48 const std::list<interface_action_param>& params);
51 //Editor dialogs.
52 void wxeditor_authors_display(wxWindow* parent);
53 void wxeditor_hotkeys_display(wxWindow* parent);
54 void wxeditor_memorywatches_display(wxWindow* parent);
55 void wxeditor_subtitles_display(wxWindow* parent);
56 std::string wxeditor_keyselect(wxWindow* parent, bool clearable);
57 void show_wxeditor_voicesub(wxWindow* parent);
58 void open_rom_select_window();
59 void open_new_project_window(wxWindow* parent);
60 void show_conflictwindow(wxWindow* parent);
61 void open_vumeter_window(wxWindow* parent);
62 void wxeditor_movie_display(wxWindow* parent);
63 void wxeditor_movie_update();
64 void wxeditor_autohold_display(wxWindow* parent);
65 void wxeditor_tasinput_display(wxWindow* parent);
66 void wxeditor_macro_display(wxWindow* parent);
67 void wxeditor_hexedit_display(wxWindow* parent);
68 void wxeditor_multitrack_display(wxWindow* parent);
69 bool wxeditor_plugin_manager_display(wxWindow* parent);
70 void wxeditor_tracelog_display(wxWindow* parent, int cpuid, const std::string& cpuname);
71 void wxeditor_disassembler_display(wxWindow* parent);
72 void wxeditor_plugin_manager_notify_fail(const std::string& libname);
74 //Auxillary windows.
75 void wxwindow_memorysearch_display();
76 void wxwindow_memorysearch_update();
77 void wxeditor_hexeditor_update();
78 class memory_search;
79 memory_search* wxwindow_memorysearch_active();
80 bool wxeditor_hexeditor_available();
81 bool wxeditor_hexeditor_jumpto(uint64_t addr);
82 void wxwindow_tasinput_update();
84 template<typename T>
85 void runuifun(T fn)
87 _runuifun_async(functor_call_helper2<T>, new T(fn));
90 //Thrown by various dialog functions if canceled.
91 class canceled_exception : public std::runtime_error
93 public:
94 canceled_exception();
97 //Prompt for stuff. These all can throw canceled_exception.
98 std::string pick_file_member(wxWindow* parent, const std::string& title, const std::string& startdir);
99 std::string pick_among(wxWindow* parent, const std::string& title, const std::string& prompt,
100 const std::vector<std::string>& choices, unsigned defaultchoice = 0);
101 std::string pick_text(wxWindow* parent, const std::string& title, const std::string& prompt,
102 const std::string& dflt = "", bool multiline = false);
103 //Show message box with OK button.
104 void show_message_ok(wxWindow* parent, const std::string& title, const std::string& text, int icon);
106 //Run function and show errors. Returns true on error.
107 bool run_show_error(wxWindow* parent, const std::string& title, const std::string& text, std::function<void()> fn);
109 //Some important windows (if open).
110 extern wxwin_messages* msg_window;
111 extern wxwin_mainwindow* main_window;
112 extern std::string our_rom_name;
113 extern bool wxwidgets_exiting;
115 //Some important settings.
116 extern std::map<std::string, std::string> core_selections;
119 #endif