#include "wx/wx.h"
#endif
+#ifndef __WXMSW__
+ #include "../sample.xpm"
+#endif
// Define a new frame type: this is going to be our main frame
class MyFrame : public wxFrame
// event handlers
void OnQuit(wxCommandEvent& WXUNUSED(event)) { Close(true); }
void OnAbout(wxCommandEvent& event);
+
+ void OnTestAccelA(wxCommandEvent& WXUNUSED(event))
+ { m_logText->AppendText("Test accelerator \"A\" used.\n"); }
+ void OnTestAccelCtrlA(wxCommandEvent& WXUNUSED(event))
+ { m_logText->AppendText("Test accelerator \"Ctrl-A\" used.\n"); }
+ void OnTestAccelEsc(wxCommandEvent& WXUNUSED(event))
+ { m_logText->AppendText("Test accelerator \"Esc\" used.\n"); }
+
void OnClear(wxCommandEvent& WXUNUSED(event)) { m_logText->Clear(); }
void OnSkip(wxCommandEvent& event) { m_skip = event.IsChecked(); }
+
void OnKeyDown(wxKeyEvent& event) { LogEvent("KeyDown", event); }
void OnKeyUp(wxKeyEvent& event) { LogEvent("KeyUp", event); }
void OnChar(wxKeyEvent& event) { LogEvent("Char", event); }
m_inputWin(NULL),
m_skip(true)
{
+ SetIcon(wxICON(sample));
+
// IDs for menu items
enum
{
QuitID = wxID_EXIT,
ClearID = wxID_CLEAR,
SkipID = 100,
+ TestAccelA,
+ TestAccelCtrlA,
+ TestAccelEsc
};
// create a menu bar
menuFile->Append(ClearID, "&Clear log\tCtrl-L");
menuFile->AppendSeparator();
+ menuFile->Append(TestAccelA, "Test accelerator &1\tA");
+ menuFile->Append(TestAccelCtrlA, "Test accelerator &2\tCtrl-A");
+ menuFile->Append(TestAccelEsc, "Test accelerator &3\tEsc");
+ menuFile->AppendSeparator();
+
menuFile->AppendCheckItem(SkipID, "Call event.&Skip()\tCtrl-S");
menuFile->Check(SkipID, true);
menuFile->AppendSeparator();
" RawKeyCode RawKeyFlags");
- m_logText = new wxTextCtrl(this, wxID_ANY, "",
+ m_logText = new wxTextCtrl(this, wxID_ANY, "",
wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL);
// set monospace font to have output in nice columns
- wxFont font(10, wxFONTFAMILY_TELETYPE,
+ wxFont font(10, wxFONTFAMILY_TELETYPE,
wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
headerText->SetFont(font);
m_logText->SetFont(font);
Connect(SkipID, wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(MyFrame::OnSkip));
- // connect event handlers for the blue input window
+ Connect(TestAccelA, wxEVT_COMMAND_MENU_SELECTED,
+ wxCommandEventHandler(MyFrame::OnTestAccelA));
+
+ Connect(TestAccelCtrlA, wxEVT_COMMAND_MENU_SELECTED,
+ wxCommandEventHandler(MyFrame::OnTestAccelCtrlA));
+
+ Connect(TestAccelEsc, wxEVT_COMMAND_MENU_SELECTED,
+ wxCommandEventHandler(MyFrame::OnTestAccelEsc));
+
+ // 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);
- m_inputWin->Connect(wxEVT_PAINT,
+ m_inputWin->Connect(wxEVT_PAINT,
wxPaintEventHandler(MyFrame::OnPaintInputWin),
NULL, this);
font.SetPointSize(font.GetPointSize() + 2);
dc.SetFont(font);
- dc.DrawLabel("Press keys here",
+ dc.DrawLabel("Press keys here",
m_inputWin->GetClientRect(), wxALIGN_CENTER);
}
switch ( keycode )
{
#define WXK_(x) \
- case WXK_##x: return #x;
+ case WXK_##x: return #x;
WXK_(BACK)
WXK_(TAB)
WXK_(NUMPAD_DECIMAL)
WXK_(NUMPAD_DIVIDE)
#undef WXK_
- default:
- return NULL;
+ default:
+ return NULL;
}
}
void MyFrame::LogEvent(const wxString& name, wxKeyEvent& event)
{
wxString msg;
- // event key_name KeyCode modifiers Unicode raw_code raw_flags
+ // event key_name KeyCode modifiers Unicode raw_code raw_flags
msg.Printf("%7s %15s %5d %c%c%c%c"
#if wxUSE_UNICODE
"%5d (U+%04x)"