2002-06-19 05:20:29 +00:00
|
|
|
/**
|
2003-07-25 21:34:45 +00:00
|
|
|
* \file qt2/QLMenubar.C
|
2002-09-24 13:57:09 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-06-19 05:20:29 +00:00
|
|
|
*
|
2003-07-25 21:34:45 +00:00
|
|
|
* \author John Levon
|
2002-09-24 13:57:09 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-06-19 05:20:29 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2004-05-20 09:36:28 +00:00
|
|
|
// Qt defines a macro 'signals' that clashes with a boost namespace.
|
|
|
|
// All is well if the namespace is visible first.
|
2002-06-19 05:20:29 +00:00
|
|
|
#include "QtView.h"
|
2004-05-20 09:36:28 +00:00
|
|
|
|
2003-07-25 21:34:45 +00:00
|
|
|
#include "QLMenubar.h"
|
2002-08-25 18:26:45 +00:00
|
|
|
#include "QLPopupMenu.h"
|
2002-09-24 13:57:09 +00:00
|
|
|
|
2004-05-20 09:36:28 +00:00
|
|
|
#include "MenuBackend.h"
|
|
|
|
|
2002-06-19 05:20:29 +00:00
|
|
|
#include <qmenubar.h>
|
2002-09-12 02:10:19 +00:00
|
|
|
#include <qcursor.h>
|
2002-09-24 13:57:09 +00:00
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-09-12 02:10:19 +00:00
|
|
|
using std::pair;
|
2003-10-06 15:43:21 +00:00
|
|
|
using std::string;
|
2002-06-19 05:20:29 +00:00
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2003-07-25 21:34:45 +00:00
|
|
|
QLMenubar::QLMenubar(LyXView * view, MenuBackend const & mbe)
|
2002-06-21 16:40:54 +00:00
|
|
|
: owner_(static_cast<QtView*>(view)), menubackend_(mbe)
|
2002-06-19 05:20:29 +00:00
|
|
|
{
|
2002-07-21 01:38:24 +00:00
|
|
|
Menu::const_iterator m = mbe.getMenubar().begin();
|
|
|
|
Menu::const_iterator end = mbe.getMenubar().end();
|
|
|
|
for (; m != end; ++m) {
|
2002-09-12 02:10:19 +00:00
|
|
|
pair<int, QLPopupMenu *> menu =
|
|
|
|
createMenu(owner_->menuBar(), &(*m), this, true);
|
|
|
|
name_map_[m->submenuname()] = menu.second;
|
2004-01-15 16:07:17 +00:00
|
|
|
#ifdef Q_WS_MACX
|
2003-07-10 14:39:38 +00:00
|
|
|
/* The qt/mac menu code has a very silly hack that
|
|
|
|
moves some menu entries that it recognizes by name
|
|
|
|
(ex: "Preferences...") to the "LyX" menu. This
|
|
|
|
feature can only work if the menu entries are
|
|
|
|
always available. Since we build menus on demand,
|
|
|
|
we have to have a reasonable default value before
|
|
|
|
the menus have been explicitely opened. (JMarc)
|
|
|
|
*/
|
|
|
|
menu.second->showing();
|
|
|
|
#endif
|
2002-06-19 05:20:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-25 21:34:45 +00:00
|
|
|
void QLMenubar::openByName(string const & name)
|
2002-06-19 05:20:29 +00:00
|
|
|
{
|
2002-09-24 13:57:09 +00:00
|
|
|
NameMap::const_iterator const cit = name_map_.find(name);
|
|
|
|
if (cit == name_map_.end())
|
2002-09-12 02:10:19 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// this will have to do I'm afraid.
|
|
|
|
cit->second->exec(QCursor::pos());
|
2002-06-19 05:20:29 +00:00
|
|
|
}
|
2003-05-14 09:17:22 +00:00
|
|
|
|
|
|
|
|
2003-07-25 21:34:45 +00:00
|
|
|
void QLMenubar::update()
|
2003-05-14 09:17:22 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2003-07-25 21:34:45 +00:00
|
|
|
QtView * QLMenubar::view()
|
2003-05-14 09:17:22 +00:00
|
|
|
{
|
|
|
|
return owner_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-25 21:34:45 +00:00
|
|
|
MenuBackend const & QLMenubar::backend()
|
2003-05-14 09:17:22 +00:00
|
|
|
{
|
|
|
|
return menubackend_;
|
|
|
|
}
|
2004-05-19 15:11:37 +00:00
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|