+ wxCHECK_RET( pItem != NULL, wxT("can't append NULL item to the menu") );
+
+#if wxUSE_ACCEL
+ // check for accelerators: they are given after '\t'
+ wxString label = pItem->GetName();
+ int posTab = label.Find(wxT('\t'));
+ if ( posTab != wxNOT_FOUND ) {
+ // parse the accelerator string
+ int keyCode = 0;
+ int accelFlags = wxACCEL_NORMAL;
+ wxString current;
+ for ( size_t n = (size_t)posTab + 1; n < label.Len(); n++ ) {
+ if ( (label[n] == '+') || (label[n] == '-') ) {
+ if ( current == _("ctrl") )
+ accelFlags |= wxACCEL_CTRL;
+ else if ( current == _("alt") )
+ accelFlags |= wxACCEL_ALT;
+ else if ( current == _("shift") )
+ accelFlags |= wxACCEL_SHIFT;
+ else {
+ wxLogDebug(wxT("Unknown accel modifier: '%s'"),
+ current.c_str());
+ }
+
+ current.Empty();
+ }
+ else {
+ current += wxTolower(label[n]);
+ }
+ }
+
+ if ( current.IsEmpty() ) {
+ wxLogDebug(wxT("No accel key found, accel string ignored."));
+ }
+ else {
+ if ( current.Len() == 1 ) {
+ // it's a letter
+ keyCode = wxToupper(current[0U]);
+ }
+ else {
+ // it should be a function key
+ if ( current[0U] == 'f' && isdigit(current[1U]) &&
+ (current.Len() == 2 ||
+ (current.Len() == 3 && isdigit(current[2U]))) ) {
+ int n;
+ wxSscanf(current.c_str() + 1, wxT("%d"), &n);
+
+ keyCode = VK_F1 + n - 1;
+ }
+ else {
+ wxLogDebug(wxT("Unrecognized accel key '%s', accel "
+ "string ignored."), current.c_str());
+ }
+ }
+ }
+
+ if ( keyCode ) {
+ // do add an entry
+ m_accelKeyCodes.Add(keyCode);
+ m_accelFlags.Add(accelFlags);
+ m_accelIds.Add(pItem->GetId());
+ }
+ }
+#endif // wxUSE_ACCEL