submenu preparation in two methods encapsulated
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19533 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -125,7 +125,9 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
|
|||||||
pSubMenu->m_menuParent = this ;
|
pSubMenu->m_menuParent = this ;
|
||||||
|
|
||||||
if (wxMenuBar::MacGetInstalledMenuBar() == m_menuBar)
|
if (wxMenuBar::MacGetInstalledMenuBar() == m_menuBar)
|
||||||
::InsertMenu( MAC_WXHMENU( pSubMenu->m_hMenu ) , -1 ) ;
|
{
|
||||||
|
pSubMenu->MacBeforeDisplay( true ) ;
|
||||||
|
}
|
||||||
|
|
||||||
if ( pos == (size_t)-1 )
|
if ( pos == (size_t)-1 )
|
||||||
UMAAppendSubMenuItem(MAC_WXHMENU(m_hMenu), pItem->GetText(), pSubMenu->m_macMenuId);
|
UMAAppendSubMenuItem(MAC_WXHMENU(m_hMenu), pItem->GetText(), pSubMenu->m_macMenuId);
|
||||||
@@ -355,6 +357,72 @@ void wxMenu::MacEnableMenu( bool bDoEnable )
|
|||||||
::DrawMenuBar() ;
|
::DrawMenuBar() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MacOS needs to know about submenus somewhere within this menu
|
||||||
|
// before it can be displayed , also hide special menu items like preferences
|
||||||
|
// that are handled by the OS
|
||||||
|
void wxMenu::MacBeforeDisplay( bool isSubMenu )
|
||||||
|
{
|
||||||
|
wxMenuItem* previousItem = NULL ;
|
||||||
|
int pos ;
|
||||||
|
wxMenuItemList::Node *node;
|
||||||
|
wxMenuItem *item;
|
||||||
|
for (pos = 0, node = GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++)
|
||||||
|
{
|
||||||
|
item = (wxMenuItem *)node->GetData();
|
||||||
|
wxMenu* subMenu = item->GetSubMenu() ;
|
||||||
|
if (subMenu)
|
||||||
|
{
|
||||||
|
subMenu->MacBeforeDisplay( true ) ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if TARGET_CARBON
|
||||||
|
if ( UMAGetSystemVersion() >= 0x1000 )
|
||||||
|
{
|
||||||
|
if ( item->GetId() == wxApp::s_macPreferencesMenuItemId || item->GetId() == wxApp::s_macExitMenuItemId)
|
||||||
|
{
|
||||||
|
ChangeMenuItemAttributes( MAC_WXHMENU( GetHMenu() ) , pos + 1, kMenuItemAttrHidden, 0 );
|
||||||
|
if ( GetMenuItems().GetCount() == pos + 1 && previousItem != NULL && previousItem->IsSeparator() )
|
||||||
|
{
|
||||||
|
ChangeMenuItemAttributes( MAC_WXHMENU( GetHMenu() ) , pos , kMenuItemAttrHidden, 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
previousItem = item ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isSubMenu )
|
||||||
|
::InsertMenu(MAC_WXHMENU( GetHMenu()), -1);
|
||||||
|
|
||||||
|
}
|
||||||
|
// undo all changes from the MacBeforeDisplay call
|
||||||
|
void wxMenu::MacAfterDisplay( bool isSubMenu )
|
||||||
|
{
|
||||||
|
if ( isSubMenu )
|
||||||
|
::DeleteMenu(MacGetMenuId());
|
||||||
|
|
||||||
|
wxMenuItem* previousItem = NULL ;
|
||||||
|
int pos ;
|
||||||
|
wxMenuItemList::Node *node;
|
||||||
|
wxMenuItem *item;
|
||||||
|
for (pos = 0, node = GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++)
|
||||||
|
{
|
||||||
|
item = (wxMenuItem *)node->GetData();
|
||||||
|
wxMenu* subMenu = item->GetSubMenu() ;
|
||||||
|
if (subMenu)
|
||||||
|
{
|
||||||
|
subMenu->MacAfterDisplay( true ) ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// no need to undo hidings
|
||||||
|
}
|
||||||
|
previousItem = item ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Menu Bar
|
// Menu Bar
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -532,52 +600,8 @@ void wxMenuBar::MacInstallMenuBar()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , m_titles[i] ) ;
|
UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , m_titles[i] ) ;
|
||||||
wxArrayPtrVoid submenus ;
|
m_menus[i]->MacBeforeDisplay(false) ;
|
||||||
wxMenuItem* previousItem = NULL ;
|
|
||||||
for (pos = 0, node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++)
|
|
||||||
{
|
|
||||||
item = (wxMenuItem *)node->GetData();
|
|
||||||
subMenu = item->GetSubMenu() ;
|
|
||||||
if (subMenu)
|
|
||||||
{
|
|
||||||
submenus.Add(subMenu) ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#if TARGET_CARBON
|
|
||||||
if ( UMAGetSystemVersion() >= 0x1000 )
|
|
||||||
{
|
|
||||||
if ( item->GetId() == wxApp::s_macPreferencesMenuItemId || item->GetId() == wxApp::s_macExitMenuItemId)
|
|
||||||
{
|
|
||||||
ChangeMenuItemAttributes( MAC_WXHMENU( menu->GetHMenu() ) , pos + 1, kMenuItemAttrHidden, 0 );
|
|
||||||
if ( menu->GetMenuItems().GetCount() == pos + 1 && previousItem != NULL && previousItem->IsSeparator() )
|
|
||||||
{
|
|
||||||
ChangeMenuItemAttributes( MAC_WXHMENU( menu->GetHMenu() ) , pos , kMenuItemAttrHidden, 0 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
previousItem = item ;
|
|
||||||
}
|
|
||||||
::InsertMenu(MAC_WXHMENU(m_menus[i]->GetHMenu()), 0);
|
::InsertMenu(MAC_WXHMENU(m_menus[i]->GetHMenu()), 0);
|
||||||
for ( size_t i = 0 ; i < submenus.GetCount() ; ++i )
|
|
||||||
{
|
|
||||||
wxMenu* submenu = (wxMenu*) submenus[i] ;
|
|
||||||
wxMenuItemList::Node *subnode;
|
|
||||||
wxMenuItem *subitem;
|
|
||||||
int subpos ;
|
|
||||||
for ( subpos = 0 , subnode = submenu->GetMenuItems().GetFirst(); subnode; subnode = subnode->GetNext(), subpos++)
|
|
||||||
{
|
|
||||||
subitem = (wxMenuItem *)subnode->GetData();
|
|
||||||
wxMenu* itsSubMenu = subitem->GetSubMenu() ;
|
|
||||||
if (itsSubMenu)
|
|
||||||
{
|
|
||||||
submenus.Add(itsSubMenu) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
::InsertMenu( MAC_WXHMENU(submenu->GetHMenu()) , -1 ) ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
::DrawMenuBar() ;
|
::DrawMenuBar() ;
|
||||||
@@ -654,8 +678,10 @@ wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
|
|||||||
{
|
{
|
||||||
if (s_macInstalledMenuBar == this)
|
if (s_macInstalledMenuBar == this)
|
||||||
{
|
{
|
||||||
|
menuOld->MacAfterDisplay( false ) ;
|
||||||
::DeleteMenu( menuOld->MacGetMenuId() /* m_menus[pos]->MacGetMenuId() */ ) ;
|
::DeleteMenu( menuOld->MacGetMenuId() /* m_menus[pos]->MacGetMenuId() */ ) ;
|
||||||
{
|
{
|
||||||
|
menu->MacBeforeDisplay( false ) ;
|
||||||
UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , title ) ;
|
UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , title ) ;
|
||||||
if ( pos == m_menus.GetCount() - 1)
|
if ( pos == m_menus.GetCount() - 1)
|
||||||
{
|
{
|
||||||
@@ -683,8 +709,11 @@ bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
|
|||||||
|
|
||||||
UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , title ) ;
|
UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , title ) ;
|
||||||
|
|
||||||
if ( IsAttached() )
|
if ( IsAttached() && s_macInstalledMenuBar == this )
|
||||||
{
|
{
|
||||||
|
if (s_macInstalledMenuBar == this)
|
||||||
|
{
|
||||||
|
menu->MacBeforeDisplay( false ) ;
|
||||||
if ( pos == (size_t) -1 || pos + 1 == m_menus.GetCount() )
|
if ( pos == (size_t) -1 || pos + 1 == m_menus.GetCount() )
|
||||||
{
|
{
|
||||||
::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ;
|
::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ;
|
||||||
@@ -693,6 +722,7 @@ bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
|
|||||||
{
|
{
|
||||||
::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , m_menus[pos+1]->MacGetMenuId() ) ;
|
::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , m_menus[pos+1]->MacGetMenuId() ) ;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -386,40 +386,7 @@ bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y)
|
|||||||
menu->UpdateUI();
|
menu->UpdateUI();
|
||||||
ClientToScreen( &x , &y ) ;
|
ClientToScreen( &x , &y ) ;
|
||||||
|
|
||||||
wxArrayPtrVoid submenus ;
|
menu->MacBeforeDisplay( true ) ;
|
||||||
wxMenuItemList::Node *node;
|
|
||||||
wxMenuItem *item;
|
|
||||||
int pos ;
|
|
||||||
for (pos = 0, node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++)
|
|
||||||
{
|
|
||||||
item = (wxMenuItem *)node->GetData();
|
|
||||||
wxMenu* subMenu = item->GetSubMenu() ;
|
|
||||||
if (subMenu)
|
|
||||||
{
|
|
||||||
submenus.Add(subMenu) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
::InsertMenu( (MenuHandle) menu->GetHMenu() , -1 ) ;
|
|
||||||
|
|
||||||
for ( size_t i = 0 ; i < submenus.GetCount() ; ++i )
|
|
||||||
{
|
|
||||||
wxMenu* submenu = (wxMenu*) submenus[i] ;
|
|
||||||
wxMenuItemList::Node *subnode;
|
|
||||||
wxMenuItem *subitem;
|
|
||||||
int subpos ;
|
|
||||||
for ( subpos = 0 , subnode = submenu->GetMenuItems().GetFirst(); subnode; subnode = subnode->GetNext(), subpos++)
|
|
||||||
{
|
|
||||||
subitem = (wxMenuItem *)subnode->GetData();
|
|
||||||
wxMenu* itsSubMenu = subitem->GetSubMenu() ;
|
|
||||||
if (itsSubMenu)
|
|
||||||
{
|
|
||||||
submenus.Add(itsSubMenu) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
::InsertMenu( MAC_WXHMENU(submenu->GetHMenu()) , -1 ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
long menuResult = ::PopUpMenuSelect((MenuHandle) menu->GetHMenu() ,y,x, 0) ;
|
long menuResult = ::PopUpMenuSelect((MenuHandle) menu->GetHMenu() ,y,x, 0) ;
|
||||||
if ( HiWord(menuResult) != 0 )
|
if ( HiWord(menuResult) != 0 )
|
||||||
{
|
{
|
||||||
@@ -434,12 +401,7 @@ bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y)
|
|||||||
}
|
}
|
||||||
menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ;
|
menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ;
|
||||||
}
|
}
|
||||||
::DeleteMenu( menu->MacGetMenuId() ) ;
|
menu->MacAfterDisplay( true ) ;
|
||||||
for ( size_t i = 0 ; i < submenus.GetCount() ; ++i )
|
|
||||||
{
|
|
||||||
wxMenu* submenu = (wxMenu*) submenus[i] ;
|
|
||||||
::DeleteMenu( submenu->MacGetMenuId() ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
menu->SetInvokingWindow(NULL);
|
menu->SetInvokingWindow(NULL);
|
||||||
|
|
||||||
|
124
src/mac/menu.cpp
124
src/mac/menu.cpp
@@ -125,7 +125,9 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
|
|||||||
pSubMenu->m_menuParent = this ;
|
pSubMenu->m_menuParent = this ;
|
||||||
|
|
||||||
if (wxMenuBar::MacGetInstalledMenuBar() == m_menuBar)
|
if (wxMenuBar::MacGetInstalledMenuBar() == m_menuBar)
|
||||||
::InsertMenu( MAC_WXHMENU( pSubMenu->m_hMenu ) , -1 ) ;
|
{
|
||||||
|
pSubMenu->MacBeforeDisplay( true ) ;
|
||||||
|
}
|
||||||
|
|
||||||
if ( pos == (size_t)-1 )
|
if ( pos == (size_t)-1 )
|
||||||
UMAAppendSubMenuItem(MAC_WXHMENU(m_hMenu), pItem->GetText(), pSubMenu->m_macMenuId);
|
UMAAppendSubMenuItem(MAC_WXHMENU(m_hMenu), pItem->GetText(), pSubMenu->m_macMenuId);
|
||||||
@@ -355,6 +357,72 @@ void wxMenu::MacEnableMenu( bool bDoEnable )
|
|||||||
::DrawMenuBar() ;
|
::DrawMenuBar() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MacOS needs to know about submenus somewhere within this menu
|
||||||
|
// before it can be displayed , also hide special menu items like preferences
|
||||||
|
// that are handled by the OS
|
||||||
|
void wxMenu::MacBeforeDisplay( bool isSubMenu )
|
||||||
|
{
|
||||||
|
wxMenuItem* previousItem = NULL ;
|
||||||
|
int pos ;
|
||||||
|
wxMenuItemList::Node *node;
|
||||||
|
wxMenuItem *item;
|
||||||
|
for (pos = 0, node = GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++)
|
||||||
|
{
|
||||||
|
item = (wxMenuItem *)node->GetData();
|
||||||
|
wxMenu* subMenu = item->GetSubMenu() ;
|
||||||
|
if (subMenu)
|
||||||
|
{
|
||||||
|
subMenu->MacBeforeDisplay( true ) ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if TARGET_CARBON
|
||||||
|
if ( UMAGetSystemVersion() >= 0x1000 )
|
||||||
|
{
|
||||||
|
if ( item->GetId() == wxApp::s_macPreferencesMenuItemId || item->GetId() == wxApp::s_macExitMenuItemId)
|
||||||
|
{
|
||||||
|
ChangeMenuItemAttributes( MAC_WXHMENU( GetHMenu() ) , pos + 1, kMenuItemAttrHidden, 0 );
|
||||||
|
if ( GetMenuItems().GetCount() == pos + 1 && previousItem != NULL && previousItem->IsSeparator() )
|
||||||
|
{
|
||||||
|
ChangeMenuItemAttributes( MAC_WXHMENU( GetHMenu() ) , pos , kMenuItemAttrHidden, 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
previousItem = item ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isSubMenu )
|
||||||
|
::InsertMenu(MAC_WXHMENU( GetHMenu()), -1);
|
||||||
|
|
||||||
|
}
|
||||||
|
// undo all changes from the MacBeforeDisplay call
|
||||||
|
void wxMenu::MacAfterDisplay( bool isSubMenu )
|
||||||
|
{
|
||||||
|
if ( isSubMenu )
|
||||||
|
::DeleteMenu(MacGetMenuId());
|
||||||
|
|
||||||
|
wxMenuItem* previousItem = NULL ;
|
||||||
|
int pos ;
|
||||||
|
wxMenuItemList::Node *node;
|
||||||
|
wxMenuItem *item;
|
||||||
|
for (pos = 0, node = GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++)
|
||||||
|
{
|
||||||
|
item = (wxMenuItem *)node->GetData();
|
||||||
|
wxMenu* subMenu = item->GetSubMenu() ;
|
||||||
|
if (subMenu)
|
||||||
|
{
|
||||||
|
subMenu->MacAfterDisplay( true ) ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// no need to undo hidings
|
||||||
|
}
|
||||||
|
previousItem = item ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Menu Bar
|
// Menu Bar
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -532,52 +600,8 @@ void wxMenuBar::MacInstallMenuBar()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , m_titles[i] ) ;
|
UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , m_titles[i] ) ;
|
||||||
wxArrayPtrVoid submenus ;
|
m_menus[i]->MacBeforeDisplay(false) ;
|
||||||
wxMenuItem* previousItem = NULL ;
|
|
||||||
for (pos = 0, node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++)
|
|
||||||
{
|
|
||||||
item = (wxMenuItem *)node->GetData();
|
|
||||||
subMenu = item->GetSubMenu() ;
|
|
||||||
if (subMenu)
|
|
||||||
{
|
|
||||||
submenus.Add(subMenu) ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#if TARGET_CARBON
|
|
||||||
if ( UMAGetSystemVersion() >= 0x1000 )
|
|
||||||
{
|
|
||||||
if ( item->GetId() == wxApp::s_macPreferencesMenuItemId || item->GetId() == wxApp::s_macExitMenuItemId)
|
|
||||||
{
|
|
||||||
ChangeMenuItemAttributes( MAC_WXHMENU( menu->GetHMenu() ) , pos + 1, kMenuItemAttrHidden, 0 );
|
|
||||||
if ( menu->GetMenuItems().GetCount() == pos + 1 && previousItem != NULL && previousItem->IsSeparator() )
|
|
||||||
{
|
|
||||||
ChangeMenuItemAttributes( MAC_WXHMENU( menu->GetHMenu() ) , pos , kMenuItemAttrHidden, 0 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
previousItem = item ;
|
|
||||||
}
|
|
||||||
::InsertMenu(MAC_WXHMENU(m_menus[i]->GetHMenu()), 0);
|
::InsertMenu(MAC_WXHMENU(m_menus[i]->GetHMenu()), 0);
|
||||||
for ( size_t i = 0 ; i < submenus.GetCount() ; ++i )
|
|
||||||
{
|
|
||||||
wxMenu* submenu = (wxMenu*) submenus[i] ;
|
|
||||||
wxMenuItemList::Node *subnode;
|
|
||||||
wxMenuItem *subitem;
|
|
||||||
int subpos ;
|
|
||||||
for ( subpos = 0 , subnode = submenu->GetMenuItems().GetFirst(); subnode; subnode = subnode->GetNext(), subpos++)
|
|
||||||
{
|
|
||||||
subitem = (wxMenuItem *)subnode->GetData();
|
|
||||||
wxMenu* itsSubMenu = subitem->GetSubMenu() ;
|
|
||||||
if (itsSubMenu)
|
|
||||||
{
|
|
||||||
submenus.Add(itsSubMenu) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
::InsertMenu( MAC_WXHMENU(submenu->GetHMenu()) , -1 ) ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
::DrawMenuBar() ;
|
::DrawMenuBar() ;
|
||||||
@@ -654,8 +678,10 @@ wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
|
|||||||
{
|
{
|
||||||
if (s_macInstalledMenuBar == this)
|
if (s_macInstalledMenuBar == this)
|
||||||
{
|
{
|
||||||
|
menuOld->MacAfterDisplay( false ) ;
|
||||||
::DeleteMenu( menuOld->MacGetMenuId() /* m_menus[pos]->MacGetMenuId() */ ) ;
|
::DeleteMenu( menuOld->MacGetMenuId() /* m_menus[pos]->MacGetMenuId() */ ) ;
|
||||||
{
|
{
|
||||||
|
menu->MacBeforeDisplay( false ) ;
|
||||||
UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , title ) ;
|
UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , title ) ;
|
||||||
if ( pos == m_menus.GetCount() - 1)
|
if ( pos == m_menus.GetCount() - 1)
|
||||||
{
|
{
|
||||||
@@ -683,8 +709,11 @@ bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
|
|||||||
|
|
||||||
UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , title ) ;
|
UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , title ) ;
|
||||||
|
|
||||||
if ( IsAttached() )
|
if ( IsAttached() && s_macInstalledMenuBar == this )
|
||||||
{
|
{
|
||||||
|
if (s_macInstalledMenuBar == this)
|
||||||
|
{
|
||||||
|
menu->MacBeforeDisplay( false ) ;
|
||||||
if ( pos == (size_t) -1 || pos + 1 == m_menus.GetCount() )
|
if ( pos == (size_t) -1 || pos + 1 == m_menus.GetCount() )
|
||||||
{
|
{
|
||||||
::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ;
|
::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ;
|
||||||
@@ -693,6 +722,7 @@ bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
|
|||||||
{
|
{
|
||||||
::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , m_menus[pos+1]->MacGetMenuId() ) ;
|
::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , m_menus[pos+1]->MacGetMenuId() ) ;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -386,40 +386,7 @@ bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y)
|
|||||||
menu->UpdateUI();
|
menu->UpdateUI();
|
||||||
ClientToScreen( &x , &y ) ;
|
ClientToScreen( &x , &y ) ;
|
||||||
|
|
||||||
wxArrayPtrVoid submenus ;
|
menu->MacBeforeDisplay( true ) ;
|
||||||
wxMenuItemList::Node *node;
|
|
||||||
wxMenuItem *item;
|
|
||||||
int pos ;
|
|
||||||
for (pos = 0, node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++)
|
|
||||||
{
|
|
||||||
item = (wxMenuItem *)node->GetData();
|
|
||||||
wxMenu* subMenu = item->GetSubMenu() ;
|
|
||||||
if (subMenu)
|
|
||||||
{
|
|
||||||
submenus.Add(subMenu) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
::InsertMenu( (MenuHandle) menu->GetHMenu() , -1 ) ;
|
|
||||||
|
|
||||||
for ( size_t i = 0 ; i < submenus.GetCount() ; ++i )
|
|
||||||
{
|
|
||||||
wxMenu* submenu = (wxMenu*) submenus[i] ;
|
|
||||||
wxMenuItemList::Node *subnode;
|
|
||||||
wxMenuItem *subitem;
|
|
||||||
int subpos ;
|
|
||||||
for ( subpos = 0 , subnode = submenu->GetMenuItems().GetFirst(); subnode; subnode = subnode->GetNext(), subpos++)
|
|
||||||
{
|
|
||||||
subitem = (wxMenuItem *)subnode->GetData();
|
|
||||||
wxMenu* itsSubMenu = subitem->GetSubMenu() ;
|
|
||||||
if (itsSubMenu)
|
|
||||||
{
|
|
||||||
submenus.Add(itsSubMenu) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
::InsertMenu( MAC_WXHMENU(submenu->GetHMenu()) , -1 ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
long menuResult = ::PopUpMenuSelect((MenuHandle) menu->GetHMenu() ,y,x, 0) ;
|
long menuResult = ::PopUpMenuSelect((MenuHandle) menu->GetHMenu() ,y,x, 0) ;
|
||||||
if ( HiWord(menuResult) != 0 )
|
if ( HiWord(menuResult) != 0 )
|
||||||
{
|
{
|
||||||
@@ -434,12 +401,7 @@ bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y)
|
|||||||
}
|
}
|
||||||
menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ;
|
menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ;
|
||||||
}
|
}
|
||||||
::DeleteMenu( menu->MacGetMenuId() ) ;
|
menu->MacAfterDisplay( true ) ;
|
||||||
for ( size_t i = 0 ; i < submenus.GetCount() ; ++i )
|
|
||||||
{
|
|
||||||
wxMenu* submenu = (wxMenu*) submenus[i] ;
|
|
||||||
::DeleteMenu( submenu->MacGetMenuId() ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
menu->SetInvokingWindow(NULL);
|
menu->SetInvokingWindow(NULL);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user