/// /// Add a list of menu items to the current menu. When the user selects any /// one of these, the given functor will be called /// with its position in the list as the index number. /// When you call Enable on this command name, it will enable or disable /// all of the items at once. void CommandManager::AddItemList(wxString name, wxArrayString labels, CommandFunctor *callback, bool plugins /*= false*/) { unsigned int i; #ifndef __WXGTK__ plugins = false; #endif if( mHidingLevel > 0 ) return; if (CurrentMenu()->GetMenuItemCount() + labels.GetCount() < MAX_MENU_LEN) plugins = false; if (!plugins) { for(i=0; i<labels.GetCount(); i++) { int ID = NewIdentifier(name, labels[i], CurrentMenu(), callback, true, i, labels.GetCount()); CurrentMenu()->Append(ID, labels[i]); } mbSeparatorAllowed = true; return; } wxString label; unsigned int effLen = labels.GetCount(); int listnum = 1; int tmpmax = MAX_SUBMENU_LEN < effLen? MAX_SUBMENU_LEN: effLen; //The first submenu starts at 1. BeginSubMenu(wxString::Format(_("Plugins 1 to %i"), tmpmax)); for(i=0; i<effLen; i++) { int ID = NewIdentifier(name, labels[i], CurrentMenu(), callback, true, i, effLen); CurrentMenu()->Append(ID, labels[i]); if(((i+1) % MAX_SUBMENU_LEN) == 0 && i != (effLen - 1)) { EndSubMenu(); listnum++; //This label the plugins by number in the submenu title (1 to 15, 15 to 30, etc.) tmpmax = i + MAX_SUBMENU_LEN < effLen? 1 + i + MAX_SUBMENU_LEN: effLen; BeginSubMenu(wxString::Format(_("Plugins %i to %i"),i+2,tmpmax)); } } EndSubMenu(); }
/// /// Add a list of menu items to the current menu. When the user selects any /// one of these, the given functor will be called /// with its position in the list as the index number. /// When you call Enable on this command name, it will enable or disable /// all of the items at once. void CommandManager::AddItemList(wxString name, wxArrayString labels, CommandFunctor *callback, bool plugins /*= false*/) { unsigned int i; #ifndef __WXGTK__ plugins = false; #endif if( mHidingLevel > 0 ) return; unsigned int effLen = labels.GetCount(); unsigned int nVisibleEffects=0; wxString label; int tmpmax; // Count the visible effects. for(i=0; i<effLen; i++) { // ItemShouldBeHidden removes the ! so do it to a temporary. label = labels[i]; if (!ItemShouldBeHidden(label)) { nVisibleEffects++; } } if (CurrentMenu()->GetMenuItemCount() + nVisibleEffects < MAX_MENU_LEN) plugins = false; // j counts the visible menu items, i counts the actual menu items. // These numbers are the same unless we are using a simplified interface // by hiding effects with a ! before them when translated. int j=0; for(i=0; i<effLen; i++) { if (!ItemShouldBeHidden(labels[i])) { // ---- Start of code for Plugin sub-menus. Only relevant on wxGTK. // If plugins, and at start of a sublist.... if( plugins && ((j % MAX_SUBMENU_LEN) == 0 )) { // End previous sub-menu, if there was one. if( j>0 ) EndSubMenu(); // Start new sub-menu // tmpmax is number of last plugin for this sub-menu tmpmax = wxMin(j + MAX_SUBMENU_LEN, (int)nVisibleEffects); // Submenu titles are 1 to 15, 15 to 30, etc. BeginSubMenu(wxString::Format(_("Plug-ins %i to %i"),j+1,tmpmax)); } // ---- End of code for Plugin sub-menus. j++; int ID = NewIdentifier(name, labels[i], CurrentMenu(), callback, true, i, effLen); CurrentMenu()->Append(ID, labels[i]); mbSeparatorAllowed = true; } } if( plugins && (nVisibleEffects>0 )) EndSubMenu(); }