/**
* \file Menubar_pimpl.C
- * Copyright 1999-2001 The LyX Team.
- * See the file COPYING.
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * \author Lars Gullik Bjønnes, larsbj@lyx.org
+ * \author Lars Gullik Bjønnes
+ *
+ * Full author contact details are available in file CREDITS
*/
#include <config.h>
#include "Dialogs.h"
#include "XFormsView.h"
#include "lyxfunc.h"
-#include "FloatList.h"
#include "support/lstrings.h"
#include "support/LAssert.h"
#include "gettext.h"
#include "debug.h"
-#include "toc.h"
#include FORMS_H_LOCATION
#include <boost/scoped_ptr.hpp>
typedef vector<int>::size_type size_type;
extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
-extern LyXAction lyxaction;
namespace {
}
+Menubar::Pimpl::~Pimpl()
+{}
+
+
void Menubar::Pimpl::makeMenubar(Menu const & menu)
{
FL_FORM * form = owner_->getForm();
int Menubar::Pimpl::create_submenu(Window win, XFormsView * view,
- Menu const & menu, vector<int> & smn)
+ Menu const & menu, vector<int> & smn,
+ bool & all_disabled)
{
const int menuid = get_new_submenu(smn, win);
lyxerr[Debug::GUI] << "Menubar::Pimpl::create_submenu: creating "
if (i->kind() == MenuItem::Separator)
*last = "%l";
else if (!i->optional() ||
- !(view->getLyXFunc()->getStatus(i->action()).disabled()))
+ !(view->getLyXFunc().getStatus(i->action()).disabled()))
last = it;
it = extra_labels.begin();
size_type count = 0;
+ all_disabled = true;
int curmenuid = menuid;
for (Menu::const_iterator i = menu.begin(); i != end; ++i, ++it) {
MenuItem const & item = (*i);
switch (item.kind()) {
case MenuItem::Command: {
FuncStatus const flag =
- view->getLyXFunc()->getStatus(item.action());
+ view->getLyXFunc().getStatus(item.action());
// handle optional entries.
if (item.optional()
&& (flag.disabled())) {
pupmode += "%b";
if (flag.disabled() || flag.unknown())
pupmode += "%i";
+ else
+ all_disabled = false;
label += pupmode;
// Finally the menu shortcut
}
case MenuItem::Submenu: {
+ bool sub_all_disabled;
int submenuid = create_submenu(win, view,
- *item.submenu(), smn);
+ *item.submenu(), smn,
+ sub_all_disabled);
+ all_disabled &= sub_all_disabled;
if (submenuid == -1)
return -1;
string label = fixlabel(item.label());
label += extra_label + "%m";
+ if (sub_all_disabled)
+ label += "%i";
string shortcut = item.shortcut();
if (!shortcut.empty()) {
shortcut += lowercase(shortcut[0]);
Menu const frommenu = menubackend_->getMenu(item->submenuname());
menubackend_->expand(frommenu, tomenu, view->buffer());
vector<int> submenus;
+ bool all_disabled = true;
int menu = iteminfo->pimpl_->
- create_submenu(FL_ObjWin(ob), view, tomenu, submenus);
+ create_submenu(FL_ObjWin(ob), view, tomenu,
+ submenus, all_disabled);
if (menu != -1) {
// place popup
fl_setpup_position(view->getForm()->x + ob->x,
// If the action value is too low, then it is not a
// valid action, but something else.
if (choice >= action_offset + 1) {
- view->getLyXFunc()->dispatch(choice - action_offset, true);
+ view->getLyXFunc().dispatch(choice - action_offset, true);
} else {
lyxerr[Debug::GUI]
<< "MenuCallback: ignoring bogus action "
fl_set_tabstop(default_tabstop);
}
+
+
+Menubar::Pimpl::ItemInfo::ItemInfo
+ (Menubar::Pimpl * p, MenuItem const * i, FL_OBJECT * o)
+ : pimpl_(p), obj_(o)
+{
+ item_.reset(i);
+}
+
+
+Menubar::Pimpl::ItemInfo::~ItemInfo()
+{}