+void MyFrame::DoCreateInputWindow(InputKind inputKind)
+{
+ wxWindow* const oldWin = m_inputWin;
+
+ switch ( inputKind )
+ {
+ case Input_Custom:
+ m_inputWin = new wxWindow(this, wxID_ANY,
+ wxDefaultPosition, wxSize(-1, 50),
+ wxRAISED_BORDER);
+ break;
+
+ case Input_Entry:
+ m_inputWin = new wxTextCtrl(this, wxID_ANY, "Press keys here");
+ break;
+
+ case Input_Text:
+ m_inputWin = new wxTextCtrl(this, wxID_ANY, "Press keys here",
+ wxDefaultPosition, wxSize(-1, 50),
+ wxTE_MULTILINE);
+ break;
+ }
+
+ m_inputWin->SetBackgroundColour(*wxBLUE);
+ m_inputWin->SetForegroundColour(*wxWHITE);
+
+ // connect event handlers for the blue input window
+ m_inputWin->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(MyFrame::OnKeyDown),
+ NULL, this);
+ m_inputWin->Connect(wxEVT_KEY_UP, wxKeyEventHandler(MyFrame::OnKeyUp),
+ NULL, this);
+ m_inputWin->Connect(wxEVT_CHAR, wxKeyEventHandler(MyFrame::OnChar),
+ NULL, this);
+
+ if ( inputKind == Input_Custom )
+ {
+ m_inputWin->Connect(wxEVT_PAINT,
+ wxPaintEventHandler(MyFrame::OnPaintInputWin),
+ NULL, this);
+ }
+
+ if ( oldWin )
+ {
+ GetSizer()->Replace(oldWin, m_inputWin);
+ Layout();
+ delete oldWin;
+ }
+}
+
+void MyFrame::OnInputWindowKind(wxCommandEvent& event)
+{
+ DoCreateInputWindow(
+ static_cast<InputKind>(event.GetId() - IDInputCustom)
+ );
+}
+