Ensure that submenus are also added to the system when their parent

menu is used in a wxMenuBar::Repalce call.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@20262 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2003-04-17 20:06:17 +00:00
parent 99a5137c2d
commit 4a1a1d848d
2 changed files with 112 additions and 72 deletions

View File

@@ -738,6 +738,25 @@ int wxMenuBar::FindMenu(const wxString& title)
// wxMenuBar construction
// ---------------------------------------------------------------------------
// This allows Replace to work with menus that have submenus. Is it needed
// anywhere else? (Like in Insert and Append?)
static wxMenuBarInsertSubmenus(wxMenu* menu)
{
int pos ;
wxMenuItemList::Node *node;
wxMenuItem *item;
for (pos = 0, node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++)
{
item = (wxMenuItem *)node->GetData();
wxMenu* subMenu = item->GetSubMenu() ;
if (subMenu)
{
::InsertMenu(MAC_WXHMENU( subMenu->GetHMenu()), -1);
wxMenuBarInsertSubmenus(subMenu);
}
}
}
wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
{
wxMenu *menuOld = wxMenuBarBase::Replace(pos, menu, title);
@@ -762,6 +781,7 @@ wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
{
::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , m_menus[pos+1]->MacGetMenuId() ) ;
}
wxMenuBarInsertSubmenus(menu);
}
}

View File

@@ -738,6 +738,25 @@ int wxMenuBar::FindMenu(const wxString& title)
// wxMenuBar construction
// ---------------------------------------------------------------------------
// This allows Replace to work with menus that have submenus. Is it needed
// anywhere else? (Like in Insert and Append?)
static wxMenuBarInsertSubmenus(wxMenu* menu)
{
int pos ;
wxMenuItemList::Node *node;
wxMenuItem *item;
for (pos = 0, node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++)
{
item = (wxMenuItem *)node->GetData();
wxMenu* subMenu = item->GetSubMenu() ;
if (subMenu)
{
::InsertMenu(MAC_WXHMENU( subMenu->GetHMenu()), -1);
wxMenuBarInsertSubmenus(subMenu);
}
}
}
wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
{
wxMenu *menuOld = wxMenuBarBase::Replace(pos, menu, title);
@@ -762,6 +781,7 @@ wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
{
::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , m_menus[pos+1]->MacGetMenuId() ) ;
}
wxMenuBarInsertSubmenus(menu);
}
}