Fix the "click on panel locks up keyboard" for real

This commit is contained in:
Ilari Liusvaara 2012-07-06 18:40:11 +03:00
parent 2912e5a820
commit bc48bf1a92
3 changed files with 14 additions and 4 deletions

View file

@ -10,11 +10,13 @@ public:
class panel : public wxPanel
{
public:
panel(wxWindow* _parent, unsigned lines);
panel(wxWindow* _parent, wxWindow* tfocus, unsigned lines);
bool AcceptsFocus () const;
void on_focus(wxFocusEvent& e);
void on_paint(wxPaintEvent& e);
bool dirty;
wxWindow* parent;
wxWindow* tfocuswin;
};
wxwin_status();
~wxwin_status();

View file

@ -629,7 +629,7 @@ wxwin_mainwindow::wxwin_mainwindow()
Centre();
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->Add(spanel = new wxwin_status::panel(this, gpanel, 20), 1, wxGROW);
spanel_shown = true;
toplevel->SetSizeHints(this);
SetSizer(toplevel);

View file

@ -4,15 +4,17 @@
#define MAXSTATUS 30
wxwin_status::panel::panel(wxWindow* _parent, unsigned lines)
wxwin_status::panel::panel(wxWindow* _parent, wxWindow* focuswin, unsigned lines)
: wxPanel(_parent)
{
tfocuswin = focuswin;
parent = _parent;
dirty = false;
wxMemoryDC d;
wxSize s = d.GetTextExtent(wxT("MMMMMM"));
SetMinSize(wxSize(4 * s.x, lines * s.y));
this->Connect(wxEVT_PAINT, wxPaintEventHandler(wxwin_status::panel::on_paint), NULL, this);
this->Connect(wxEVT_SET_FOCUS, wxFocusEventHandler(wxwin_status::panel::on_focus), NULL, this);
}
bool wxwin_status::panel::AcceptsFocus () const
@ -20,12 +22,18 @@ bool wxwin_status::panel::AcceptsFocus () const
return false;
}
void wxwin_status::panel::on_focus(wxFocusEvent& e)
{
if(tfocuswin)
tfocuswin->SetFocus();
}
wxwin_status::wxwin_status()
: wxFrame(NULL, wxID_ANY, wxT("lsnes: Status"), wxDefaultPosition, wxSize(-1, -1),
wxMINIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN)
{
wxFlexGridSizer* top_s = new wxFlexGridSizer(1, 1, 0, 0);
top_s->Add(spanel = new wxwin_status::panel(this, MAXSTATUS));
top_s->Add(spanel = new wxwin_status::panel(this, NULL, MAXSTATUS));
top_s->SetSizeHints(this);
SetSizer(top_s);
Fit();