X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/be9abe3fd0edec7215fa00aa158f7581da4df2fe..9a98a85452729f479bad8538738ee899a0b1aa34:/samples/controls/controls.cpp?ds=sidebyside diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index 282a5ef86c..c6c8d0f96c 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -83,8 +83,8 @@ public: void OnChar(wxKeyEvent& event); private: - static inline char GetChar(bool on, char c) { return on ? c : '-'; } - void LogEvent(const char *name, wxKeyEvent& event) const; + static inline wxChar GetChar(bool on, wxChar c) { return on ? c : _T('-'); } + void LogEvent(const wxChar *name, wxKeyEvent& event) const; DECLARE_EVENT_TABLE() }; @@ -126,6 +126,8 @@ public: wxGauge *m_gauge; wxSlider *m_slider; wxButton *m_fontButton; + wxButton *m_lbSelectNum; + wxButton *m_lbSelectThis; #ifndef wxUSE_SPINBUTTON wxSpinButton *m_spinbutton; wxButton *m_btnProgress; @@ -231,12 +233,12 @@ BEGIN_EVENT_TABLE(MyTextCtrl, wxTextCtrl) EVT_CHAR(MyTextCtrl::OnChar) END_EVENT_TABLE() -void MyTextCtrl::LogEvent(const char *name, wxKeyEvent& event) const +void MyTextCtrl::LogEvent(const wxChar *name, wxKeyEvent& event) const { wxString key; long keycode = event.KeyCode(); - if ( isprint((int)keycode) ) - key.Printf("'%c'", (char)keycode); + if ( wxIsprint((int)keycode) ) + key.Printf( _T("'%c'") , (char)keycode); else { switch ( keycode ) @@ -254,6 +256,7 @@ void MyTextCtrl::LogEvent(const char *name, wxKeyEvent& event) const case WXK_MBUTTON: key = "MBUTTON"; break; case WXK_CLEAR: key = "CLEAR"; break; case WXK_SHIFT: key = "SHIFT"; break; + case WXK_ALT: key = "ALT"; break; case WXK_CONTROL: key = "CONTROL"; break; case WXK_MENU: key = "MENU"; break; case WXK_PAUSE: key = "PAUSE"; break; @@ -343,30 +346,30 @@ void MyTextCtrl::LogEvent(const char *name, wxKeyEvent& event) const case WXK_NUMPAD_DECIMAL: key = "NUMPAD_DECIMAL"; break; default: - key.Printf("unknown (%ld)", keycode); + key.Printf( _T("unknown (%ld)"), keycode); } } wxLogMessage( _T("%s event: %s (flags = %c%c%c%c)"), name, key.c_str(), - GetChar(event.ControlDown(), 'C'), - GetChar(event.AltDown(), 'A'), - GetChar(event.ShiftDown(), 'S'), - GetChar(event.MetaDown(), 'M')); + GetChar( event.ControlDown(), _T('C') ), + GetChar( event.AltDown(), _T('A') ), + GetChar( event.ShiftDown(), _T('S') ), + GetChar( event.MetaDown(), _T('M') ) ); } void MyTextCtrl::OnChar(wxKeyEvent& event) { - LogEvent("Char", event); + LogEvent( _T("Char"), event); event.Skip(); } void MyTextCtrl::OnKeyUp(wxKeyEvent& event) { - LogEvent("Key up", event); + LogEvent( _("Key up"), event); event.Skip(); } @@ -405,7 +408,7 @@ void MyTextCtrl::OnKeyDown(wxKeyEvent& event) break; } - LogEvent("Key down", event); + LogEvent( _("Key down"), event); event.Skip(); } @@ -599,8 +602,8 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) m_listbox->SetToolTip( "This is a list box" ); #endif // wxUSE_TOOLTIPS - (void)new wxButton( panel, ID_LISTBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) ); - (void)new wxButton( panel, ID_LISTBOX_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) ); + m_lbSelectNum = new wxButton( panel, ID_LISTBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) ); + m_lbSelectThis = new wxButton( panel, ID_LISTBOX_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) ); (void)new wxButton( panel, ID_LISTBOX_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) ); (void)new wxButton( panel, ID_LISTBOX_APPEND, "Append 'Hi!'", wxPoint(340,80), wxSize(140,30) ); (void)new wxButton( panel, ID_LISTBOX_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) ); @@ -899,11 +902,13 @@ void MyPanel::OnListBoxButtons( wxCommandEvent &event ) case ID_LISTBOX_SEL_NUM: { m_listbox->SetSelection( 2 ); + m_lbSelectThis->WarpPointer( 40, 14 ); break; } case ID_LISTBOX_SEL_STR: { m_listbox->SetStringSelection( "This" ); + m_lbSelectNum->WarpPointer( 40, 14 ); break; } case ID_LISTBOX_CLEAR: