From 4f65fcf2fad0cd226140b58c615c618a6a7fbb81 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Wed, 18 Jan 2012 20:56:54 +0200 Subject: [PATCH] Merge status panel and main window --- include/plat-wxwidgets/window_mainwindow.hpp | 4 ++++ include/plat-wxwidgets/window_status.hpp | 4 ++-- src/plat-wxwidgets/main.cpp | 9 ++------- src/plat-wxwidgets/mainwindow.cpp | 13 +++++++++++-- src/plat-wxwidgets/status.cpp | 4 ++-- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/include/plat-wxwidgets/window_mainwindow.hpp b/include/plat-wxwidgets/window_mainwindow.hpp index 761bf10c..fe5d9a6f 100644 --- a/include/plat-wxwidgets/window_mainwindow.hpp +++ b/include/plat-wxwidgets/window_mainwindow.hpp @@ -1,6 +1,8 @@ #ifndef _plat_wxwidgets__window_mainwindow__hpp__included__ #define _plat_wxwidgets__window_mainwindow__hpp__included__ +#include "plat-wxwidgets/window_status.hpp" + #include #include @@ -23,6 +25,7 @@ public: wxwin_mainwindow(); void request_paint(); void notify_update() throw(); + void notify_update_status() throw(); void notify_exit() throw(); void on_close(wxCloseEvent& e); void menu_start(wxString name); @@ -46,6 +49,7 @@ private: panel* gpanel; wxMenu* current_menu; wxMenuBar* menubar; + wxwin_status::panel* spanel; std::map checkitems; std::stack upper; void* ahmenu; diff --git a/include/plat-wxwidgets/window_status.hpp b/include/plat-wxwidgets/window_status.hpp index aeb6dbb7..663419f9 100644 --- a/include/plat-wxwidgets/window_status.hpp +++ b/include/plat-wxwidgets/window_status.hpp @@ -10,10 +10,10 @@ public: class panel : public wxPanel { public: - panel(wxwin_status* _parent, unsigned lines); + panel(wxWindow* _parent, unsigned lines); void on_paint(wxPaintEvent& e); bool dirty; - wxwin_status* parent; + wxWindow* parent; }; wxwin_status(); ~wxwin_status(); diff --git a/src/plat-wxwidgets/main.cpp b/src/plat-wxwidgets/main.cpp index 4ae91efb..1c0d9172 100644 --- a/src/plat-wxwidgets/main.cpp +++ b/src/plat-wxwidgets/main.cpp @@ -43,7 +43,6 @@ #define UISERV_MODAL 9999 wxwin_messages* msg_window; -wxwin_status* status_window; wxwin_mainwindow* main_window; std::string our_rom_name; @@ -123,8 +122,8 @@ namespace if(msg_window) msg_window->notify_update(); } else if(c == UISERV_UPDATE_STATUS) { - if(status_window) - status_window->notify_update(); + if(main_window) + main_window->notify_update_status(); } else if(c == UISERV_UPDATE_SCREEN) { if(main_window) main_window->notify_update(); @@ -328,9 +327,6 @@ bool lsnes_app::OnInit() msg_window = new wxwin_messages(); msg_window->Show(); - status_window = new wxwin_status(); - status_window->Show(); - wxwin_romselect* romwin = new wxwin_romselect(); romwin->Show(); @@ -341,7 +337,6 @@ int lsnes_app::OnExit() { //NULL these so no further messages will be sent. msg_window = NULL; - status_window = NULL; main_window = NULL; information_dispatch::do_dump_end(); rrdata::close(); diff --git a/src/plat-wxwidgets/mainwindow.cpp b/src/plat-wxwidgets/mainwindow.cpp index 4ca1bf80..9302b4a8 100644 --- a/src/plat-wxwidgets/mainwindow.cpp +++ b/src/plat-wxwidgets/mainwindow.cpp @@ -779,8 +779,9 @@ wxwin_mainwindow::wxwin_mainwindow() { broadcast_listener* blistener = new broadcast_listener(this); Centre(); - wxFlexGridSizer* toplevel = new wxFlexGridSizer(1, 1, 0, 0); + wxFlexGridSizer* toplevel = new wxFlexGridSizer(1, 2, 0, 0); toplevel->Add(gpanel = new panel(this), 1, wxGROW); + toplevel->Add(spanel = new wxwin_status::panel(this, 20), 1, wxGROW); toplevel->SetSizeHints(this); SetSizer(toplevel); Fit(); @@ -881,6 +882,14 @@ void wxwin_mainwindow::notify_update() throw() } } +void wxwin_mainwindow::notify_update_status() throw() +{ + if(!spanel->dirty) { + spanel->dirty = true; + spanel->Refresh(); + } +} + void wxwin_mainwindow::notify_exit() throw() { join_emulator_thread(); @@ -1216,7 +1225,7 @@ void wxwin_mainwindow::menu_edit_jukebox(wxCommandEvent& e) new_jukebox.push_back(l); } runemufn([&new_jukebox]() { set_jukebox_names(new_jukebox); }); - status_window->notify_update(); + notify_update_status(); platform::set_modal_pause(false); } diff --git a/src/plat-wxwidgets/status.cpp b/src/plat-wxwidgets/status.cpp index 908e8cb7..dc4c096d 100644 --- a/src/plat-wxwidgets/status.cpp +++ b/src/plat-wxwidgets/status.cpp @@ -4,14 +4,14 @@ #define MAXSTATUS 30 -wxwin_status::panel::panel(wxwin_status* _parent, unsigned lines) +wxwin_status::panel::panel(wxWindow* _parent, unsigned lines) : wxPanel(_parent) { parent = _parent; dirty = false; wxMemoryDC d; wxSize s = d.GetTextExtent(wxT("MMMMMM")); - SetMinSize(wxSize(6 * s.x, lines * s.y)); + SetMinSize(wxSize(4 * s.x, lines * s.y)); this->Connect(wxEVT_PAINT, wxPaintEventHandler(wxwin_status::panel::on_paint), NULL, this); } -- 2.11.4.GIT