);
AppendSeparator();
}
+ for (int i = 0; i < 128; i++)
+ m_vAccels[i] = NULL;
+ m_nNextAccel = 0;
} // end of wxMenu::Init
//
// Delete accels
//
#if (!(defined(__VISAGECPP__) && (__IBMCPP__ < 400 || __IBMC__ < 400 )))
- WX_CLEAR_ARRAY(m_vAccels);
+ for (int i = 0; i < 128; i++)
+ {
+ if (m_vAccels[i])
+ {
+ delete m_vAccels[i];
+ m_vAccels[i] = NULL;
+ }
+ }
+// WX_CLEAR_ARRAY(m_vAccels);
#endif
#endif // wxUSE_ACCEL
} // end of wxMenu::~wxMenu
) const
{
size_t n;
- size_t nCount = m_vAccels.GetCount();
+// size_t nCount = m_vAccels.GetCount();
- for (n = 0; n < nCount; n++)
+ for (n = 0; n < m_nNextAccel; n++)
{
- if (m_vAccels[n]->m_command == nId)
- return n;
+ if (m_vAccels[n] != NULL)
+ {
+ if (m_vAccels[n]->m_command == nId)
+ return n;
+ }
}
return wxNOT_FOUND;
} // end of wxMenu::FindAccel
wxMenuItem* pItem
)
{
- //
- // Find the (new) accel for this item
- //
- wxAcceleratorEntry* pAccel = wxGetAccelFromString(pItem->GetText());
-
- if (pAccel)
- pAccel->m_command = pItem->GetId();
-
- //
- // Find the old one
- //
- int n = FindAccel(pItem->GetId());
+ if (pItem->IsSubMenu())
+ {
+ wxMenu* pSubmenu = pItem->GetSubMenu();
+ wxMenuItemList::Node* pNode = pSubmenu->GetMenuItems().GetFirst();
- if (n == wxNOT_FOUND)
+ while (pNode)
+ {
+ UpdateAccel(pNode->GetData());
+ pNode = pNode->GetNext();
+ }
+ }
+ else if (!pItem->IsSeparator())
{
//
- // No old, add new if any
+ // Find the (new) accel for this item
//
+ wxAcceleratorEntry* pAccel = wxGetAccelFromString(pItem->GetText());
if (pAccel)
- m_vAccels.Add(pAccel);
- else
- return; // skipping RebuildAccelTable() below
- }
- else
- {
+ pAccel->m_command = pItem->GetId();
+
//
- // Replace old with new or just remove the old one if no new
+ // Find the old one
//
- delete m_vAccels[n];
+ size_t n = FindAccel(pItem->GetId());
- if (pAccel)
- m_vAccels[n] = pAccel;
+ if (n == wxNOT_FOUND)
+ {
+ //
+ // No old, add new if any
+ //
+ if (pAccel)
+ {
+ if (m_nNextAccel < 128)
+ {
+ m_vAccels[m_nNextAccel] = pAccel;
+ m_nNextAccel++;
+ }
+ else
+ return; // skipping RebuildAccelTable() below
+ }
+ else
+ return; // skipping RebuildAccelTable() below
+ }
else
- m_vAccels.RemoveAt(n);
- }
+ {
+ //
+ // Replace old with new or just remove the old one if no new
+ //
+ delete m_vAccels[n];
+ m_vAccels[n] = NULL;
- if (IsAttached())
- {
- m_menuBar->RebuildAccelTable();
+ if (pAccel)
+ m_vAccels[n] = pAccel;
+ }
+
+ if (IsAttached())
+ {
+ m_menuBar->RebuildAccelTable();
+ }
}
} // wxMenu::UpdateAccel
, size_t nPos
)
{
+ wxMenu* pSubmenu = pItem->GetSubMenu();
+ MENUITEM& rItem = (pSubmenu != NULL)?pSubmenu->m_vMenuData:
+ pItem->m_vMenuData;
+
ERRORID vError;
wxString sError;
char zMsg[128];
// MENUITEM for submenus as required by ::MM_INSERTITEM message API
//
- wxMenu* pSubmenu = pItem->GetSubMenu();
- MENUITEM& rItem = (pSubmenu != NULL)?pSubmenu->m_vMenuData:
- pItem->m_vMenuData;
if(pSubmenu != NULL)
{
wxASSERT_MSG(pSubmenu->GetHMenu(), wxT("invalid submenu"));
if (n != wxNOT_FOUND)
{
delete m_vAccels[n];
- m_vAccels.RemoveAt(n);
+ m_vAccels[n] = NULL;
}
#endif // wxUSE_ACCEL