Don't duplicate code for Apple menu creation.
Have just one copy of the code, instead of two. Eliminate differences between the two versions. As a result, applications now properly have preferences and about items even if window-less. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75229 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -588,39 +588,10 @@ wxMenu* emptyMenuBar = NULL;
|
|||||||
|
|
||||||
const int firstMenuPos = 1; // to account for the 0th application menu on mac
|
const int firstMenuPos = 1; // to account for the 0th application menu on mac
|
||||||
|
|
||||||
void wxMenuBar::Init()
|
static wxMenu *CreateAppleMenu()
|
||||||
{
|
{
|
||||||
if ( emptyMenuBar == NULL )
|
wxMenu *appleMenu = new wxMenu();
|
||||||
{
|
appleMenu->SetAllowRearrange(false);
|
||||||
emptyMenuBar = new wxMenu();
|
|
||||||
|
|
||||||
wxMenu* appleMenu = new wxMenu();
|
|
||||||
appleMenu->SetAllowRearrange(false);
|
|
||||||
#if !wxOSX_USE_CARBON
|
|
||||||
// standard menu items, handled in wxMenu::HandleCommandProcess(), see above:
|
|
||||||
wxString hideLabel;
|
|
||||||
hideLabel = wxString::Format(_("Hide %s"), wxTheApp ? wxTheApp->GetAppDisplayName() : _("Application"));
|
|
||||||
appleMenu->Append( wxID_OSX_HIDE, hideLabel + "\tCtrl+H" );
|
|
||||||
appleMenu->Append( wxID_OSX_HIDEOTHERS, _("Hide Others")+"\tAlt+Ctrl+H" );
|
|
||||||
appleMenu->Append( wxID_OSX_SHOWALL, _("Show All") );
|
|
||||||
appleMenu->AppendSeparator();
|
|
||||||
|
|
||||||
// Do always add "Quit" item unconditionally however, it can't be disabled.
|
|
||||||
wxString quitLabel;
|
|
||||||
quitLabel = wxString::Format(_("Quit %s"), wxTheApp ? wxTheApp->GetAppDisplayName() : _("Application"));
|
|
||||||
appleMenu->Append( wxApp::s_macExitMenuItemId, quitLabel + "\tCtrl+Q" );
|
|
||||||
#endif // !wxOSX_USE_CARBON
|
|
||||||
|
|
||||||
emptyMenuBar->AppendSubMenu(appleMenu, "\x14") ;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_eventHandler = this;
|
|
||||||
m_menuBarFrame = NULL;
|
|
||||||
m_rootMenu = new wxMenu();
|
|
||||||
m_rootMenu->Attach(this);
|
|
||||||
|
|
||||||
m_appleMenu = new wxMenu();
|
|
||||||
m_appleMenu->SetAllowRearrange(false);
|
|
||||||
|
|
||||||
// Create standard items unless the application explicitly disabled this by
|
// Create standard items unless the application explicitly disabled this by
|
||||||
// setting the corresponding ids to wxID_NONE: although this is not
|
// setting the corresponding ids to wxID_NONE: although this is not
|
||||||
@@ -632,32 +603,49 @@ void wxMenuBar::Init()
|
|||||||
aboutLabel << ' ' << wxTheApp->GetAppDisplayName();
|
aboutLabel << ' ' << wxTheApp->GetAppDisplayName();
|
||||||
else
|
else
|
||||||
aboutLabel << "...";
|
aboutLabel << "...";
|
||||||
m_appleMenu->Append( wxApp::s_macAboutMenuItemId, aboutLabel);
|
appleMenu->Append( wxApp::s_macAboutMenuItemId, aboutLabel);
|
||||||
m_appleMenu->AppendSeparator();
|
appleMenu->AppendSeparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !wxOSX_USE_CARBON
|
#if !wxOSX_USE_CARBON
|
||||||
if ( wxApp::s_macPreferencesMenuItemId != wxID_NONE )
|
if ( wxApp::s_macPreferencesMenuItemId != wxID_NONE )
|
||||||
{
|
{
|
||||||
m_appleMenu->Append( wxApp::s_macPreferencesMenuItemId,
|
appleMenu->Append( wxApp::s_macPreferencesMenuItemId,
|
||||||
_("Preferences...") + "\tCtrl+," );
|
_("Preferences...") + "\tCtrl+," );
|
||||||
m_appleMenu->AppendSeparator();
|
appleMenu->AppendSeparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
// standard menu items, handled in wxMenu::HandleCommandProcess(), see above:
|
// standard menu items, handled in wxMenu::HandleCommandProcess(), see above:
|
||||||
wxString hideLabel;
|
wxString hideLabel;
|
||||||
hideLabel = wxString::Format(_("Hide %s"), wxTheApp ? wxTheApp->GetAppDisplayName() : _("Application"));
|
hideLabel = wxString::Format(_("Hide %s"), wxTheApp ? wxTheApp->GetAppDisplayName() : _("Application"));
|
||||||
m_appleMenu->Append( wxID_OSX_HIDE, hideLabel + "\tCtrl+H" );
|
appleMenu->Append( wxID_OSX_HIDE, hideLabel + "\tCtrl+H" );
|
||||||
m_appleMenu->Append( wxID_OSX_HIDEOTHERS, _("Hide Others")+"\tAlt+Ctrl+H" );
|
appleMenu->Append( wxID_OSX_HIDEOTHERS, _("Hide Others")+"\tAlt+Ctrl+H" );
|
||||||
m_appleMenu->Append( wxID_OSX_SHOWALL, _("Show All") );
|
appleMenu->Append( wxID_OSX_SHOWALL, _("Show All") );
|
||||||
m_appleMenu->AppendSeparator();
|
appleMenu->AppendSeparator();
|
||||||
|
|
||||||
// Do always add "Quit" item unconditionally however, it can't be disabled.
|
// Do always add "Quit" item unconditionally however, it can't be disabled.
|
||||||
wxString quitLabel;
|
wxString quitLabel;
|
||||||
quitLabel = wxString::Format(_("Quit %s"), wxTheApp ? wxTheApp->GetAppDisplayName() : _("Application"));
|
quitLabel = wxString::Format(_("Quit %s"), wxTheApp ? wxTheApp->GetAppDisplayName() : _("Application"));
|
||||||
m_appleMenu->Append( wxApp::s_macExitMenuItemId, quitLabel + "\tCtrl+Q" );
|
appleMenu->Append( wxApp::s_macExitMenuItemId, quitLabel + "\tCtrl+Q" );
|
||||||
#endif // !wxOSX_USE_CARBON
|
#endif // !wxOSX_USE_CARBON
|
||||||
|
|
||||||
|
return appleMenu;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxMenuBar::Init()
|
||||||
|
{
|
||||||
|
if ( emptyMenuBar == NULL )
|
||||||
|
{
|
||||||
|
emptyMenuBar = new wxMenu();
|
||||||
|
emptyMenuBar->AppendSubMenu(CreateAppleMenu(), "\x14") ;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_eventHandler = this;
|
||||||
|
m_menuBarFrame = NULL;
|
||||||
|
m_rootMenu = new wxMenu();
|
||||||
|
m_rootMenu->Attach(this);
|
||||||
|
|
||||||
|
m_appleMenu = CreateAppleMenu();
|
||||||
m_rootMenu->AppendSubMenu(m_appleMenu, "\x14") ;
|
m_rootMenu->AppendSubMenu(m_appleMenu, "\x14") ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user