MenuItem::MenuItem(Kind kind, string const & label,
FuncRequest const & func, bool optional)
: kind_(kind), label_(label), func_(func), optional_(optional)
-{}
+{
+ func_.origin = FuncRequest::UI;
+}
MenuItem::~MenuItem()
}
+MenuItem const & Menu::operator[](size_type i) const
+{
+ return items_[i];
+}
+
+
+bool Menu::hasFunc(FuncRequest const & func) const
+{
+ return find_if(begin(), end(),
+ bind(std::equal_to<FuncRequest>(),
+ bind(&MenuItem::func, _1),
+ func)) != end();
+}
+
void Menu::checkShortcuts() const
{
// This is a quadratic algorithm, but we do not care because
}
+void MenuBackend::specialMenu(string const &name)
+{
+ if (hasMenu(name))
+ specialmenu_ = &getMenu(name);
+}
+
+
namespace {
class compare_format {
}
break;
- default:
+ case MenuItem::Separator:
tomenu.add(*cit, view);
+ break;
+
+ case MenuItem::Command:
+ if (!specialmenu_
+ || !specialmenu_->hasFunc(cit->func()))
+ tomenu.add(*cit, view);
}
}
}
-bool Menu::hasSubmenu(string const & name) const
-{
-#if 1
- return find_if(begin(), end(),
- bind(std::equal_to<string>(),
- bind(&MenuItem::submenuname, _1),
- name)) != end();
-#else
- // I would have prefered this, but I am not sure if it
- // makes a difference. (Lgb)
- return find_if(
- make_transform_iterator(begin(),
- bind(&MenuItem::submenuname, _1)),
- make_transform_iterator(end(),
- bind(&MenuItem::submenuname, _1)),
- name
- ).base() != end();
-#endif
-}
-
-
void MenuBackend::read(LyXLex & lex)
{
enum Menutags {