+void wxMenu::UpdateAccel(wxMenuItem *item)
+{
+ if ( item->IsSubMenu() )
+ {
+ wxMenu *submenu = item->GetSubMenu();
+ wxMenuItemList::Node *node = submenu->GetMenuItems().GetFirst();
+ while ( node )
+ {
+ UpdateAccel(node->GetData());
+
+ node = node->GetNext();
+ }
+ }
+ else if ( !item->IsSeparator() )
+ {
+ // find the (new) accel for this item
+ wxAcceleratorEntry *accel = wxGetAccelFromString(item->GetText());
+ if ( accel )
+ accel->m_command = item->GetId();
+
+ // find the old one
+ int n = FindAccel(item->GetId());
+ if ( n == wxNOT_FOUND )
+ {
+ // no old, add new if any
+ if ( accel )
+ m_accels.Add(accel);
+ else
+ return; // skipping RebuildAccelTable() below
+ }
+ else
+ {
+ // replace old with new or just remove the old one if no new
+ delete m_accels[n];
+ if ( accel )
+ m_accels[n] = accel;
+ else
+ m_accels.Remove(n);
+ }
+
+ if ( IsAttached() )
+ {
+ m_menuBar->RebuildAccelTable();
+ }
+ }
+ //else: it is a separator, they can't have accels, nothing to do
+}
+
+#endif // wxUSE_ACCEL
+
+// append a new item or submenu to the menu
+bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
+{
+#if wxUSE_ACCEL
+ UpdateAccel(pItem);
+#endif // wxUSE_ACCEL
+
+ UINT flags = 0;
+
+ // if "Break" has just been called, insert a menu break before this item
+ // (and don't forget to reset the flag)
+ if ( m_doBreak ) {
+ flags |= MF_MENUBREAK;
+ m_doBreak = FALSE;
+ }
+
+ if ( pItem->IsSeparator() ) {
+ flags |= MF_SEPARATOR;
+ }
+
+ // id is the numeric id for normal menu items and HMENU for submenus as
+ // required by ::AppendMenu() API
+ UINT id;
+ wxMenu *submenu = pItem->GetSubMenu();
+ if ( submenu != NULL ) {
+ wxASSERT_MSG( submenu->GetHMenu(), wxT("invalid submenu") );
+
+ submenu->SetParent(this);
+
+ id = (UINT)submenu->GetHMenu();
+
+ flags |= MF_POPUP;
+ }
+ else {
+ id = pItem->GetId();
+ }
+
+ LPCTSTR pData;