2 * \file Menubar_pimpl.C
3 * Copyright 1999-2001 The LyX Team.
4 * See the file COPYING.
6 * \author Lars Gullik Bjønnes, larsbj@lyx.org
14 #pragma implementation
17 #include "Menubar_pimpl.h"
18 #include "MenuBackend.h"
19 #include "LyXAction.h"
24 #include "FloatList.h"
25 #include "support/lstrings.h"
26 #include "support/LAssert.h"
33 #include <qpopupmenu.h>
41 typedef vector<int>::size_type size_type;
43 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
44 extern LyXAction lyxaction;
47 Menubar::Pimpl::Pimpl(LyXView * view, MenuBackend const & mbe)
48 : owner_(static_cast<QtView*>(view)), menubackend_(mbe)
50 Menu::const_iterator m = mbe.getMenubar().begin();
51 Menu::const_iterator end = mbe.getMenubar().end();
52 for (; m != end; ++m) {
53 makeMenu(owner_->menuBar(), *m);
58 void Menubar::Pimpl::makeMenu(QMenuData * parent, MenuItem const & menu)
61 QPopupMenu * pm = new QPopupMenu();
62 parent->insertItem(menu.label().c_str(), pm);
65 menubackend_.getMenu(menu.submenu()).expand(md, 0);
66 Menu::const_iterator m = md.begin();
67 Menu::const_iterator end = md.end();
68 for (; m != end; ++m) {
69 if (m->kind() == MenuItem::Separator) {
70 pm->insertSeparator();
72 pm->insertItem(m->label().c_str(), m->action());
78 void Menubar::Pimpl::set(string const & menu_name)
80 lyxerr[Debug::GUI] << "Entering Menubar::Pimpl::set "
81 << "for menu `" << menu_name << "'" << endl;
84 if (menu_name != current_menu_name_) {
85 MenubarMap::iterator mbit = menubarmap_.find(menu_name);
87 if (mbit == menubarmap_.end()) {
88 lyxerr << "ERROR:set: Unknown menu `" << menu_name
94 lyxerr[Debug::GUI] << " hiding group "
95 << current_group_ << endl;
96 fl_hide_object(current_group_);
99 lyxerr[Debug::GUI] << " showing group "
100 << mbit->second << endl;
101 fl_show_object(mbit->second);
102 current_menu_name_ = menu_name;
103 current_group_ = mbit->second;
104 lyxerr[Debug::GUI] << "Menubar::Pimpl::set: Menubar set."
107 lyxerr [Debug::GUI] << "Menubar::Pimpl::set: Nothing to do."
113 void Menubar::Pimpl::openByName(string const & name)
115 lyxerr << "Menubar::Pimpl::openByName: menu " << name << endl;
118 if (menubackend_->getMenu(current_menu_name_).hasSubmenu(name)) {
119 for (ButtonList::const_iterator cit = buttonlist_.begin();
120 cit != buttonlist_.end(); ++cit) {
121 if ((*cit)->item_->submenu() == name) {
122 MenuCallback((*cit)->obj_, 1);