mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-17 00:20:06 +02:00
Fix OSX special menu items (About, Preferences, Quit)
And convert a few more command manager arguments to const
This commit is contained in:
parent
b7fc0e4631
commit
7757297d82
@ -1159,14 +1159,14 @@ bool AudacityApp::OnInit()
|
|||||||
|
|
||||||
#ifdef AUDACITY_NAME
|
#ifdef AUDACITY_NAME
|
||||||
wxString appName = wxT(AUDACITY_NAME);
|
wxString appName = wxT(AUDACITY_NAME);
|
||||||
wxString vendorName = wxT(AUDACITY_NAME);
|
|
||||||
#else
|
#else
|
||||||
wxString vendorName = wxT("Audacity");
|
|
||||||
wxString appName = wxT("Audacity");
|
wxString appName = wxT("Audacity");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxTheApp->SetVendorName(vendorName);
|
|
||||||
wxTheApp->SetAppName(appName);
|
wxTheApp->SetAppName(appName);
|
||||||
|
// Explicitly set since OSX will use it for the "Quit" menu item
|
||||||
|
wxTheApp->SetAppDisplayName(wxT("Audacity"));
|
||||||
|
wxTheApp->SetVendorName(wxT("Audacity"));
|
||||||
|
|
||||||
// Unused strings that we want to be translated, even though
|
// Unused strings that we want to be translated, even though
|
||||||
// we're not using them yet...
|
// we're not using them yet...
|
||||||
|
@ -450,7 +450,7 @@ void CommandManager::PurgeData()
|
|||||||
/// Names it according to the passed-in string argument.
|
/// Names it according to the passed-in string argument.
|
||||||
///
|
///
|
||||||
/// If the menubar already exists, simply returns it.
|
/// If the menubar already exists, simply returns it.
|
||||||
wxMenuBar *CommandManager::AddMenuBar(wxString sMenu)
|
wxMenuBar *CommandManager::AddMenuBar(const wxString & sMenu)
|
||||||
{
|
{
|
||||||
wxMenuBar *menuBar = GetMenuBar(sMenu);
|
wxMenuBar *menuBar = GetMenuBar(sMenu);
|
||||||
if (menuBar)
|
if (menuBar)
|
||||||
@ -470,7 +470,7 @@ wxMenuBar *CommandManager::AddMenuBar(wxString sMenu)
|
|||||||
///
|
///
|
||||||
/// Retrieves the menubar based on the name given in AddMenuBar(name)
|
/// Retrieves the menubar based on the name given in AddMenuBar(name)
|
||||||
///
|
///
|
||||||
wxMenuBar * CommandManager::GetMenuBar(wxString sMenu) const
|
wxMenuBar * CommandManager::GetMenuBar(const wxString & sMenu) const
|
||||||
{
|
{
|
||||||
for(unsigned int i = 0; i < mMenuBarList.GetCount(); i++)
|
for(unsigned int i = 0; i < mMenuBarList.GetCount(); i++)
|
||||||
{
|
{
|
||||||
@ -495,29 +495,26 @@ wxMenuBar * CommandManager::CurrentMenuBar() const
|
|||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// This makes a new menu and adds it to the 'CurrentMenuBar'
|
/// This starts a new menu
|
||||||
///
|
///
|
||||||
/// If the menu already exists, all of the items in it are
|
void CommandManager::BeginMenu(const wxString & tName)
|
||||||
/// cleared instead.
|
|
||||||
///
|
|
||||||
void CommandManager::BeginMenu(wxString tNameIn)
|
|
||||||
{
|
{
|
||||||
wxString tName = tNameIn;
|
|
||||||
|
|
||||||
wxMenu *tmpMenu = new wxMenu();
|
wxMenu *tmpMenu = new wxMenu();
|
||||||
|
|
||||||
mCurrentMenu = tmpMenu;
|
mCurrentMenu = tmpMenu;
|
||||||
mCurrentMenuName = tName;
|
mCurrentMenuName = tName;
|
||||||
|
|
||||||
CurrentMenuBar()->Append(mCurrentMenu, tName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// This ends a menu by setting the pointer to it
|
/// This attaches a menu to the menubar and ends the menu
|
||||||
/// to NULL. It is still attached to the CurrentMenuBar()
|
///
|
||||||
void CommandManager::EndMenu()
|
void CommandManager::EndMenu()
|
||||||
{
|
{
|
||||||
|
// Add the menu to the menubard after all menu items have been
|
||||||
|
// added to the menu to allow OSX to rearrange special menu
|
||||||
|
// items like Preferences, About, and Quit.
|
||||||
|
CurrentMenuBar()->Append(mCurrentMenu, mCurrentMenuName);
|
||||||
mCurrentMenu = NULL;
|
mCurrentMenu = NULL;
|
||||||
mCurrentMenuName = COMMAND;
|
mCurrentMenuName = COMMAND;
|
||||||
}
|
}
|
||||||
@ -526,10 +523,8 @@ void CommandManager::EndMenu()
|
|||||||
///
|
///
|
||||||
/// This starts a new submenu, and names it according to
|
/// This starts a new submenu, and names it according to
|
||||||
/// the function's argument.
|
/// the function's argument.
|
||||||
wxMenu* CommandManager::BeginSubMenu(wxString tNameIn)
|
wxMenu* CommandManager::BeginSubMenu(const wxString & tName)
|
||||||
{
|
{
|
||||||
wxString tName = tNameIn;
|
|
||||||
|
|
||||||
SubMenuListEntry *tmpEntry = new SubMenuListEntry;
|
SubMenuListEntry *tmpEntry = new SubMenuListEntry;
|
||||||
|
|
||||||
tmpEntry->menu = new wxMenu();
|
tmpEntry->menu = new wxMenu();
|
||||||
@ -597,12 +592,12 @@ wxMenu * CommandManager::CurrentMenu() const
|
|||||||
///
|
///
|
||||||
/// Add a menu item to the current menu. When the user selects it, the
|
/// Add a menu item to the current menu. When the user selects it, the
|
||||||
/// given functor will be called
|
/// given functor will be called
|
||||||
void CommandManager::InsertItem(wxString name, wxString label_in,
|
void CommandManager::InsertItem(const wxString & name,
|
||||||
CommandFunctor *callback, wxString after,
|
const wxString & label_in,
|
||||||
|
CommandFunctor *callback,
|
||||||
|
const wxString & after,
|
||||||
int checkmark)
|
int checkmark)
|
||||||
{
|
{
|
||||||
wxString label = label_in;
|
|
||||||
|
|
||||||
wxMenuBar *bar = GetActiveProject()->GetMenuBar();
|
wxMenuBar *bar = GetActiveProject()->GetMenuBar();
|
||||||
wxArrayString names = ::wxStringTokenize(after, wxT(":"));
|
wxArrayString names = ::wxStringTokenize(after, wxT(":"));
|
||||||
size_t cnt = names.GetCount();
|
size_t cnt = names.GetCount();
|
||||||
@ -649,9 +644,9 @@ void CommandManager::InsertItem(wxString name, wxString label_in,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandListEntry *entry = NewIdentifier(name, label, menu, callback, false, 0, 0);
|
CommandListEntry *entry = NewIdentifier(name, label_in, menu, callback, false, 0, 0);
|
||||||
int ID = entry->id;
|
int ID = entry->id;
|
||||||
label = GetLabel(entry);
|
wxString label = GetLabel(entry);
|
||||||
|
|
||||||
if (checkmark >= 0) {
|
if (checkmark >= 0) {
|
||||||
menu->InsertCheckItem(pos, ID, label);
|
menu->InsertCheckItem(pos, ID, label);
|
||||||
@ -727,7 +722,8 @@ void CommandManager::AddItem(const wxChar *name,
|
|||||||
/// with its position in the list as the index number.
|
/// with its position in the list as the index number.
|
||||||
/// When you call Enable on this command name, it will enable or disable
|
/// When you call Enable on this command name, it will enable or disable
|
||||||
/// all of the items at once.
|
/// all of the items at once.
|
||||||
void CommandManager::AddItemList(wxString name, wxArrayString labels,
|
void CommandManager::AddItemList(const wxString & name,
|
||||||
|
const wxArrayString & labels,
|
||||||
CommandFunctor *callback)
|
CommandFunctor *callback)
|
||||||
{
|
{
|
||||||
for (size_t i = 0, cnt = labels.GetCount(); i < cnt; i++) {
|
for (size_t i = 0, cnt = labels.GetCount(); i < cnt; i++) {
|
||||||
|
@ -90,21 +90,25 @@ class AUDACITY_DLL_API CommandManager: public XMLTagHandler
|
|||||||
// Creating menus and adding commands
|
// Creating menus and adding commands
|
||||||
//
|
//
|
||||||
|
|
||||||
wxMenuBar *AddMenuBar(wxString sMenu);
|
wxMenuBar *AddMenuBar(const wxString & sMenu);
|
||||||
|
|
||||||
void BeginMenu(wxString tName);
|
void BeginMenu(const wxString & tName);
|
||||||
void EndMenu();
|
void EndMenu();
|
||||||
|
|
||||||
wxMenu* BeginSubMenu(wxString tName);
|
wxMenu* BeginSubMenu(const wxString & tName);
|
||||||
void EndSubMenu();
|
void EndSubMenu();
|
||||||
void SetToMenu( wxMenu * menu ){
|
void SetToMenu( wxMenu * menu ){
|
||||||
mCurrentMenu = menu;
|
mCurrentMenu = menu;
|
||||||
};
|
};
|
||||||
|
|
||||||
void InsertItem(wxString name, wxString label, CommandFunctor *callback,
|
void InsertItem(const wxString & name,
|
||||||
wxString after, int checkmark = -1);
|
const wxString & label,
|
||||||
|
CommandFunctor *callback,
|
||||||
|
const wxString & after,
|
||||||
|
int checkmark = -1);
|
||||||
|
|
||||||
void AddItemList(wxString name, wxArrayString labels,
|
void AddItemList(const wxString & name,
|
||||||
|
const wxArrayString & labels,
|
||||||
CommandFunctor *callback);
|
CommandFunctor *callback);
|
||||||
|
|
||||||
void AddCheck(const wxChar *name,
|
void AddCheck(const wxChar *name,
|
||||||
@ -267,7 +271,7 @@ protected:
|
|||||||
//
|
//
|
||||||
|
|
||||||
wxMenuBar * CurrentMenuBar() const;
|
wxMenuBar * CurrentMenuBar() const;
|
||||||
wxMenuBar * GetMenuBar(wxString sMenu) const;
|
wxMenuBar * GetMenuBar(const wxString & sMenu) const;
|
||||||
wxMenu * CurrentSubMenu() const;
|
wxMenu * CurrentSubMenu() const;
|
||||||
wxMenu * CurrentMenu() const;
|
wxMenu * CurrentMenu() const;
|
||||||
wxString GetLabel(const CommandListEntry *entry) const;
|
wxString GetLabel(const CommandListEntry *entry) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user