-wxMenu::wxMenu(const wxString& Title, const wxFunction func)
-{
- m_title = Title;
- m_parent = NULL;
- m_eventHandler = this;
- m_pInvokingWindow = NULL;
- m_doBreak = FALSE ;
- m_noItems = 0;
- m_menuBar = NULL;
- m_hMenu = (WXHMENU) CreatePopupMenu();
- m_savehMenu = 0 ;
- m_topLevelMenu = this;
- if (m_title != "")
- {
- Append(-2, m_title) ;
- AppendSeparator() ;
- }
-
- Callback(func);
-}
-
-// The wxWindow destructor will take care of deleting the submenus.
-wxMenu::~wxMenu(void)
-{
- if (m_hMenu)
- DestroyMenu((HMENU) m_hMenu);
- m_hMenu = 0;
-
- // Windows seems really bad on Menu de-allocation...
- // After many try, here is what I do: RemoveMenu() will ensure
- // that popup are "disconnected" from their parent; then call
- // delete method on each child (which in turn do a recursive job),
- // and finally, DestroyMenu()
- //
- // With that, BoundCheckers is happy, and no complaints...
-/*
- int N = 0 ;
- if (m_hMenu)
- N = GetMenuItemCount(m_hMenu);
- int i;
- for (i = N-1; i >= 0; i--)
- RemoveMenu(m_hMenu, i, MF_BYPOSITION);
-*/
-
- // How is deleting submenus in this loop any different from deleting
- // the submenus in the children list, via ~wxWindow ?
- // I'll reinstate this deletion for now and remove addition
- // from children list (which doesn't exist now)
- // Julian 1/3/97
- wxNode *node = m_menuItems.First();
- while (node)
- {
- wxMenuItem *item = (wxMenuItem *)node->Data();
-
- // Delete child menus.
- // Beware: they must not be appended to children list!!!
- // (because order of delete is significant)
- if (item->GetSubMenu())
- item->DeleteSubMenu();
-
- wxNode *next = node->Next();
- delete item;
- delete node;
- node = next;
- }
-/*
- if (m_hMenu)
- DestroyMenu(m_hMenu);
- m_hMenu = 0;
-*/
-}
-
-void wxMenu::Break(void)
-{
- m_doBreak = TRUE ;
-}
-
-// function appends a new item or submenu to the menu
-void wxMenu::Append(wxMenuItem *pItem)
-{
- wxCHECK_RET( pItem != NULL, "can't append NULL item to the menu" );
-
- m_menuItems.Append(pItem);
-
- UINT flags = 0;
-
- if ( m_doBreak ) {
- flags |= MF_MENUBREAK;