LogoSearch packages:      

Sourcecode: audacity version File versions

void CommandManager::AddItem ( wxString  name,
wxString  label,
CommandFunctor callback 
)

Add a menu item to the current menu. When the user selects it, the given functor will be called

Definition at line 310 of file CommandManager.cpp.

References CurrentMenu(), and NewIdentifier().

Referenced by AudacityProject::CreateMenusAndCommands().

{
   int ID = NewIdentifier(name, label, CurrentMenu(), callback, false, 0, 0);

   // Replace the accel key with the one from the preferences
   label = label.BeforeFirst(wxT('\t'));

   // This is a very weird hack.  Under GTK, menu labels are totally
   // linked to accelerators the first time you create a menu item
   // with that label and can't be changed.  This causes all sorts of
   // problems.  As a workaround, we create each menu item with a
   // made-up name (just an ID number string) but with the accelerator
   // we want, then immediately change the label to the correct string.
   // -DMM
   mHiddenID++;
   wxString dummy, newLabel;
   dummy.Printf(wxT("%s%08d"), label.c_str(), mHiddenID);
   newLabel = label;

   bool shortcut = false;

   if (mCommandIDHash[ID]->key.Length() > 0)
      shortcut = true;
   
   // Mac OS X fixes
  #ifdef __WXMAC__
   if (newLabel.Length() > 0 && newLabel[0] == wxT('&'))
      newLabel = newLabel.Right(newLabel.Length()-1);

   if (shortcut == true &&
       (mCommandIDHash[ID]->key.Length() < 5 ||
        mCommandIDHash[ID]->key.Left(5) != wxT("Ctrl+")))
      shortcut = false;
  #endif
   
   if (shortcut) {
      dummy = dummy + wxT("\t") + mCommandIDHash[ID]->key;
   }

   CurrentMenu()->Append(ID, dummy);
   CurrentMenu()->SetLabel(ID, newLabel);
}


Generated by  Doxygen 1.5.1   Back to index