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"
31 QLMenubar::QLMenubar(LyXView * view, MenuBackend & mbe)
32 : owner_(static_cast<QtView*>(view)), menubackend_(mbe)
34 , menubar_(new QMenuBar)
37 Menu::const_iterator m = mbe.getMenubar().begin();
38 Menu::const_iterator end = mbe.getMenubar().end();
39 for (; m != end; ++m) {
40 pair<int, QLPopupMenu *> menu =
41 createMenu(menuBar(), &(*m), this, true);
42 name_map_[m->submenuname()] = menu.second;
45 // this is the name of the menu that contains our special entries
46 menubackend_.specialMenu("LyX");
47 // make sure that the special entries are added to the first
48 // menu even before this menu has been opened.
49 name_map_[mbe.getMenubar().begin()->submenuname()]->showing();
53 void QLMenubar::openByName(string const & name)
55 NameMap::const_iterator const cit = name_map_.find(name);
56 if (cit == name_map_.end())
59 // this will have to do I'm afraid.
60 cit->second->exec(QCursor::pos());
64 void QLMenubar::update()
68 QtView * QLMenubar::view()
74 MenuBackend const & QLMenubar::backend()
81 Here is what the Qt documentation says about how a menubar is chosen:
83 1) If the window has a QMenuBar then it is used. 2) If the window
84 is a modal then its menubar is used. If no menubar is specified
85 then a default menubar is used (as documented below) 3) If the
86 window has no parent then the default menubar is used (as
89 The above 3 steps are applied all the way up the parent window
90 chain until one of the above are satisifed. If all else fails a
91 default menubar will be created, the default menubar on Qt/Mac is
92 an empty menubar, however you can create a different default
93 menubar by creating a parentless QMenuBar, the first one created
94 will thus be designated the default menubar, and will be used
95 whenever a default menubar is needed.
97 Thus, for Qt/Mac, we add the menus to a free standing menubar, so
98 that this menubar will be used also when one of LyX' dialogs has
101 QMenuBar * QLMenubar::menuBar() const
104 return menubar_.get();
106 return owner_->menuBar();
110 } // namespace frontend