Move the wxwidgets stuff to one directory
[lsnes.git] / platform / wxwidgets / status_window.cpp
blob271c4206c7ed4aaff90ba9b2e2fbb9005a74f2ed
1 #include "status_window.hpp"
2 #include "window.hpp"
3 #include "emufn.hpp"
6 #define MAXSTATUS 30
8 class wx_status_panel : public wxPanel
10 public:
11 wx_status_panel(unsigned lines);
12 void on_paint(wxPaintEvent& e);
13 bool dirty;
16 wx_status_window* wx_status_window::ptr;
18 wx_status_panel::wx_status_panel(unsigned lines)
19 : wxPanel(wx_status_window::ptr)
21 dirty = false;
22 wxMemoryDC d;
23 wxSize s = d.GetTextExtent(wxT("MMMMMM"));
24 SetMinSize(wxSize(6 * s.x, lines * s.y));
25 this->Connect(wxEVT_PAINT, wxPaintEventHandler(wx_status_panel::on_paint), NULL, this);
29 namespace {
30 wx_status_panel* spanel;
33 wx_status_window::wx_status_window()
34 : wxFrame(NULL, wxID_ANY, wxT("lsnes: Status"), wxDefaultPosition, wxSize(-1, -1), secondary_window_style)
36 ptr = this;
37 wxFlexGridSizer* top_s = new wxFlexGridSizer(1, 1, 0, 0);
38 top_s->Add(spanel = new wx_status_panel(MAXSTATUS));
39 top_s->SetSizeHints(this);
40 SetSizer(top_s);
41 Fit();
44 wx_status_window::~wx_status_window()
46 ptr = NULL;
49 void wx_status_panel::on_paint(wxPaintEvent& e)
51 wxPaintDC dc(this);
52 dc.Clear();
53 int y = 0;
54 auto& status = window::get_emustatus();
55 for(auto i : status) {
56 std::string pstr = i.first + ": " + i.second;
57 wxSize s = dc.GetTextExtent(towxstring(pstr));
58 dc.DrawText(towxstring(pstr), 0, y);
59 y += s.y;
61 dirty = false;
64 void wx_status_window::notify_status_change()
66 if(!spanel || spanel->dirty)
67 return;
68 spanel->dirty = true;
69 spanel->Refresh();
72 bool wx_status_window::ShouldPreventAppExit() const
74 return false;