From 3a762759ef649a9d0cc327954baabc837d640aa2 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Wed, 19 Sep 2012 12:13:08 +0300 Subject: [PATCH] Allow hiding the messages window --- include/platform/wxwidgets/platform.hpp | 1 + include/platform/wxwidgets/window_messages.hpp | 2 ++ src/platform/wxwidgets/main.cpp | 3 +++ src/platform/wxwidgets/mainwindow.cpp | 7 +++++++ src/platform/wxwidgets/messages.cpp | 16 +++++++++++++++- 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/include/platform/wxwidgets/platform.hpp b/include/platform/wxwidgets/platform.hpp index c56271da..f50346ec 100644 --- a/include/platform/wxwidgets/platform.hpp +++ b/include/platform/wxwidgets/platform.hpp @@ -81,5 +81,6 @@ void show_message_ok(wxWindow* parent, const std::string& title, const std::stri extern wxwin_messages* msg_window; extern wxwin_mainwindow* main_window; extern std::string our_rom_name; +extern bool wxwidgets_exiting; #endif diff --git a/include/platform/wxwidgets/window_messages.hpp b/include/platform/wxwidgets/window_messages.hpp index 42ac4ae0..c257d6bf 100644 --- a/include/platform/wxwidgets/window_messages.hpp +++ b/include/platform/wxwidgets/window_messages.hpp @@ -28,6 +28,8 @@ public: void on_scroll_pagedown(wxCommandEvent& e); void on_scroll_end(wxCommandEvent& e); void on_execute(wxCommandEvent& e); + void on_close(wxCloseEvent& e); + void reshow(); private: wxTextCtrl* command; panel* mpanel; diff --git a/src/platform/wxwidgets/main.cpp b/src/platform/wxwidgets/main.cpp index f16139f2..0b31a9c7 100644 --- a/src/platform/wxwidgets/main.cpp +++ b/src/platform/wxwidgets/main.cpp @@ -47,6 +47,7 @@ wxwin_mainwindow* main_window; std::string our_rom_name; bool dummy_interface = false; +bool wxwidgets_exiting = false; namespace { @@ -406,6 +407,8 @@ int lsnes_app::OnExit() if(settings_mode) return 0; //NULL these so no further messages will be sent. + auto x = msg_window; + auto y = main_window; msg_window = NULL; main_window = NULL; save_configuration(); diff --git a/src/platform/wxwidgets/mainwindow.cpp b/src/platform/wxwidgets/mainwindow.cpp index 82c08ca9..84abc082 100644 --- a/src/platform/wxwidgets/mainwindow.cpp +++ b/src/platform/wxwidgets/mainwindow.cpp @@ -29,6 +29,7 @@ #include "platform/wxwidgets/menu_dump.hpp" #include "platform/wxwidgets/platform.hpp" #include "platform/wxwidgets/window_mainwindow.hpp" +#include "platform/wxwidgets/window_messages.hpp" #include "platform/wxwidgets/window_status.hpp" extern "C" @@ -99,6 +100,7 @@ enum wxID_RELOAD_ROM_IMAGE, wxID_LOAD_ROM_IMAGE, wxID_NEW_MOVIE, + wxID_SHOW_MESSAGES, }; @@ -785,6 +787,7 @@ wxwin_mainwindow::wxwin_mainwindow() menu_start(wxT("Configure")); menu_entry_check(wxID_SHOW_STATUS, wxT("Show/Hide status panel")); menu_check(wxID_SHOW_STATUS, true); + menu_entry(wxID_SHOW_MESSAGES, wxT("Show messages")); menu_entry(wxID_SETTINGS, wxT("Configure emulator...")); menu_entry(wxID_SETTINGS_HOTKEYS, wxT("Configure hotkeys...")); if(platform::sound_initialized()) { @@ -842,6 +845,7 @@ void wxwin_mainwindow::notify_update_status() throw() void wxwin_mainwindow::notify_exit() throw() { + wxwidgets_exiting = true; join_emulator_thread(); Destroy(); } @@ -1126,5 +1130,8 @@ void wxwin_mainwindow::handle_menu_click_cancelable(wxCommandEvent& e) case wxID_NEW_MOVIE: show_projectwindow(this); return; + case wxID_SHOW_MESSAGES: + msg_window->reshow(); + return; }; } diff --git a/src/platform/wxwidgets/messages.cpp b/src/platform/wxwidgets/messages.cpp index 474fb5b9..2e324338 100644 --- a/src/platform/wxwidgets/messages.cpp +++ b/src/platform/wxwidgets/messages.cpp @@ -18,7 +18,7 @@ wxwin_messages::panel::panel(wxwin_messages* _parent, unsigned lines) wxwin_messages::wxwin_messages() : wxFrame(NULL, wxID_ANY, wxT("lsnes: Messages"), wxDefaultPosition, wxSize(-1, -1), - wxMINIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN) + wxMINIMIZE_BOX | wxCLOSE_BOX | wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN) { wxFlexGridSizer* top_s = new wxFlexGridSizer(3, 1, 0, 0); top_s->Add(mpanel = new panel(this, MAXMESSAGES)); @@ -58,6 +58,7 @@ wxwin_messages::wxwin_messages() cmd_s->SetSizeHints(this); top_s->Add(cmd_s, 0, wxGROW); + Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(wxwin_messages::on_close)); top_s->SetSizeHints(this); SetSizer(top_s); Fit(); @@ -89,6 +90,19 @@ void wxwin_messages::panel::on_paint(wxPaintEvent& e) } } +void wxwin_messages::on_close(wxCloseEvent& e) +{ + if(wxwidgets_exiting) + return; + e.Veto(); + Hide(); +} + +void wxwin_messages::reshow() +{ + Show(); +} + void wxwin_messages::on_scroll_home(wxCommandEvent& e) { mutex::holder h(platform::msgbuf_lock());