2 * \file qt3/QLMenubar.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 // Qt defines a macro 'signals' that clashes with a boost namespace.
14 // All is well if the namespace is visible first.
17 #include "QLMenubar.h"
18 #include "QLPopupMenu.h"
20 #include "MenuBackend.h"
33 QLMenubar::QLMenubar(LyXView * view, MenuBackend & mbe)
34 : owner_(static_cast<QtView*>(view)), menubackend_(mbe)
36 , menubar_(new QMenuBar)
39 Menu::const_iterator m = mbe.getMenubar().begin();
40 Menu::const_iterator end = mbe.getMenubar().end();
41 for (; m != end; ++m) {
42 pair<int, QLPopupMenu *> menu =
43 createMenu(menuBar(), &(*m), this, true);
44 name_map_[m->submenuname()] = menu.second;
47 // this is the name of the menu that contains our special entries
48 menubackend_.specialMenu("LyX");
49 // make sure that the special entries are added to the first
50 // menu even before this menu has been opened.
51 name_map_[mbe.getMenubar().begin()->submenuname()]->showing();
55 void QLMenubar::openByName(docstring const & name)
57 NameMap::const_iterator const cit = name_map_.find(name);
58 if (cit == name_map_.end())
61 // this will have to do I'm afraid.
62 cit->second->exec(QCursor::pos());
66 void QLMenubar::update()
70 QtView * QLMenubar::view()
76 MenuBackend const & QLMenubar::backend()
83 Here is what the Qt documentation says about how a menubar is chosen:
85 1) If the window has a QMenuBar then it is used. 2) If the window
86 is a modal then its menubar is used. If no menubar is specified
87 then a default menubar is used (as documented below) 3) If the
88 window has no parent then the default menubar is used (as
91 The above 3 steps are applied all the way up the parent window
92 chain until one of the above are satisifed. If all else fails a
93 default menubar will be created, the default menubar on Qt/Mac is
94 an empty menubar, however you can create a different default
95 menubar by creating a parentless QMenuBar, the first one created
96 will thus be designated the default menubar, and will be used
97 whenever a default menubar is needed.
99 Thus, for Qt/Mac, we add the menus to a free standing menubar, so
100 that this menubar will be used also when one of LyX' dialogs has
103 QMenuBar * QLMenubar::menuBar() const
106 return menubar_.get();
108 return owner_->menuBar();
112 } // namespace frontend