--- /dev/null
+/**
+ * \file Menubar_pimpl.C
+ * Copyright 1999-2001 The LyX Team.
+ * See the file COPYING.
+ *
+ * \author Lars Gullik Bjønnes, larsbj@lyx.org
+ */
+
+#include <config.h>
+
+#include <algorithm>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "Menubar_pimpl.h"
+#include "MenuBackend.h"
+#include "LyXAction.h"
+#include "kbmap.h"
+#include "buffer.h"
+#include "Dialogs.h"
+#include "lyxfunc.h"
+#include "FloatList.h"
+#include "support/lstrings.h"
+#include "support/LAssert.h"
+#include "gettext.h"
+#include "debug.h"
+
+#include "QtView.h"
+
+#include <qmenubar.h>
+#include <qpopupmenu.h>
+
+using std::endl;
+using std::vector;
+using std::max;
+using std::min;
+using std::for_each;
+
+typedef vector<int>::size_type size_type;
+
+extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
+extern LyXAction lyxaction;
+
+
+Menubar::Pimpl::Pimpl(LyXView * view, MenuBackend const & mb)
+ : owner_(static_cast<QtView*>(view)), menubackend_(mb)
+{
+ MenuBackend::const_iterator mb = menubackend_.begin();
+ MenuBackend::const_iterator mbend = menubackend_.end();
+ for (; mb != mbend; ++mb) {
+ if (mb->menubar() && mb->name() == "main") {
+ Menu::const_iterator m = mb->begin();
+ Menu::const_iterator end = mb->end();
+ for (; m != end; ++m) {
+ makeMenu(owner_->menuBar(), *m);
+ }
+ }
+ }
+}
+
+
+void Menubar::Pimpl::makeMenu(QMenuData * parent, MenuItem const & menu)
+{
+ // FIXME: leak
+ QPopupMenu * pm = new QPopupMenu();
+ parent->insertItem(menu.label().c_str(), pm);
+
+ Menu md;
+ menubackend_.getMenu(menu.submenu()).expand(md, 0);
+ Menu::const_iterator m = md.begin();
+ Menu::const_iterator end = md.end();
+ for (; m != end; ++m) {
+ if (m->kind() == MenuItem::Separator) {
+ pm->insertSeparator();
+ } else {
+ pm->insertItem(m->label().c_str(), m->action());
+ }
+ }
+}
+
+
+void Menubar::Pimpl::set(string const & menu_name)
+{
+ lyxerr[Debug::GUI] << "Entering Menubar::Pimpl::set "
+ << "for menu `" << menu_name << "'" << endl;
+
+#if 0
+ if (menu_name != current_menu_name_) {
+ MenubarMap::iterator mbit = menubarmap_.find(menu_name);
+
+ if (mbit == menubarmap_.end()) {
+ lyxerr << "ERROR:set: Unknown menu `" << menu_name
+ << "'" << endl;
+ return;
+ }
+
+ if (current_group_) {
+ lyxerr[Debug::GUI] << " hiding group "
+ << current_group_ << endl;
+ fl_hide_object(current_group_);
+ }
+
+ lyxerr[Debug::GUI] << " showing group "
+ << mbit->second << endl;
+ fl_show_object(mbit->second);
+ current_menu_name_ = menu_name;
+ current_group_ = mbit->second;
+ lyxerr[Debug::GUI] << "Menubar::Pimpl::set: Menubar set."
+ << endl;
+ } else
+ lyxerr [Debug::GUI] << "Menubar::Pimpl::set: Nothing to do."
+ << endl;
+#endif
+}
+
+
+void Menubar::Pimpl::openByName(string const & name)
+{
+ lyxerr << "Menubar::Pimpl::openByName: menu " << name << endl;
+
+#if 0
+ if (menubackend_->getMenu(current_menu_name_).hasSubmenu(name)) {
+ for (ButtonList::const_iterator cit = buttonlist_.begin();
+ cit != buttonlist_.end(); ++cit) {
+ if ((*cit)->item_->submenu() == name) {
+ MenuCallback((*cit)->obj_, 1);
+ return;
+ }
+ }
+ }
+#endif
+}
#include "LString.h"
+int q_is_modifier(int qkey)
+{
+ switch (qkey) {
+ case Qt::Key_Hyper_L:
+ case Qt::Key_Hyper_R:
+ case Qt::Key_Super_L:
+ case Qt::Key_Super_R:
+ case Qt::Key_Shift:
+ case Qt::Key_Control:
+ case Qt::Key_Meta:
+ case Qt::Key_Alt:
+ return true;
+ }
+ return false;
+}
+
+
+// FIXME
+int string_to_qkey(string const & str)
+{
+ if (str == "Escape") return Qt::Key_Escape;
+ if (str == "Tab") return Qt::Key_Tab;
+ if (str == "BackSpace") return Qt::Key_BackSpace;
+ if (str == "Return") return Qt::Key_Return;
+ if (str == "KP_Enter") // correct ?? return Qt::Key_Enter;
+ if (str == "Insert") return Qt::Key_Insert;
+ if (str == "Delete") return Qt::Key_Delete;
+ if (str == "Pause") return Qt::Key_Pause;
+ if (str == "Print") return Qt::Key_Print;
+ if (str == "Sys_Req") return Qt::Key_SysReq;
+ if (str == "Home") return Qt::Key_Home;
+ if (str == "End") return Qt::Key_End;
+ if (str == "Left") return Qt::Key_Left;
+ if (str == "Up") return Qt::Key_Up;
+ if (str == "Right") return Qt::Key_Right;
+ if (str == "Down") return Qt::Key_Down;
+ if (str == "Prior") return Qt::Key_Prior;
+ if (str == "Next") return Qt::Key_Next;
+ if (str == "Shift_L") return Qt::Key_Shift;
+ if (str == "Control_L") return Qt::Key_Control;
+ if (str == "Alt_L") // correct ? return Qt::Key_Meta;
+ if (str == "Alt_L") return Qt::Key_Alt;
+ if (str == "Caps_Lock") return Qt::Key_CapsLock;
+ if (str == "Num_Lock") return Qt::Key_NumLock;
+ if (str == "Scroll_Lock") return Qt::Key_ScrollLock;
+ if (str == "F1") return Qt::Key_F1;
+ if (str == "F2") return Qt::Key_F2;
+ if (str == "F3") return Qt::Key_F3;
+ if (str == "F4") return Qt::Key_F4;
+ if (str == "F5") return Qt::Key_F5;
+ if (str == "F6") return Qt::Key_F6;
+ if (str == "F7") return Qt::Key_F7;
+ if (str == "F8") return Qt::Key_F8;
+ if (str == "F9") return Qt::Key_F9;
+ if (str == "F10") return Qt::Key_F10;
+ if (str == "F11") return Qt::Key_F11;
+ if (str == "F12") return Qt::Key_F12;
+ if (str == "F13") return Qt::Key_F13;
+ if (str == "F14") return Qt::Key_F14;
+ if (str == "F15") return Qt::Key_F15;
+ if (str == "F16") return Qt::Key_F16;
+ if (str == "F17") return Qt::Key_F17;
+ if (str == "F18") return Qt::Key_F18;
+ if (str == "F19") return Qt::Key_F19;
+ if (str == "F20") return Qt::Key_F20;
+ if (str == "F21") return Qt::Key_F21;
+ if (str == "F22") return Qt::Key_F22;
+ if (str == "F23") return Qt::Key_F23;
+ if (str == "F24") return Qt::Key_F24;
+ if (str == "F25") return Qt::Key_F25;
+ if (str == "F26") return Qt::Key_F26;
+ if (str == "F27") return Qt::Key_F27;
+ if (str == "F28") return Qt::Key_F28;
+ if (str == "F29") return Qt::Key_F29;
+ if (str == "F30") return Qt::Key_F30;
+ if (str == "F31") return Qt::Key_F31;
+ if (str == "F32") return Qt::Key_F32;
+ if (str == "F33") return Qt::Key_F33;
+ if (str == "F34") return Qt::Key_F34;
+ if (str == "F35") return Qt::Key_F35;
+ if (str == "0") return Qt::Key_0;
+ if (str == "1") return Qt::Key_1;
+ if (str == "2") return Qt::Key_2;
+ if (str == "3") return Qt::Key_3;
+ if (str == "4") return Qt::Key_4;
+ if (str == "5") return Qt::Key_5;
+ if (str == "6") return Qt::Key_6;
+ if (str == "7") return Qt::Key_7;
+ if (str == "8") return Qt::Key_8;
+ if (str == "9") return Qt::Key_9;
+ if (str == "colon") return Qt::Key_Colon;
+ if (str == "semicolon") return Qt::Key_Semicolon;
+ if (str == "less") return Qt::Key_Less;
+ if (str == "equal") return Qt::Key_Equal;
+ if (str == "greater") return Qt::Key_Greater;
+ if (str == "question") return Qt::Key_Question;
+ if (str == "at") return Qt::Key_At;
+ if (str == "a") return Qt::Key_A;
+ if (str == "b") return Qt::Key_B;
+ if (str == "c") return Qt::Key_C;
+ if (str == "d") return Qt::Key_D;
+ if (str == "e") return Qt::Key_E;
+ if (str == "f") return Qt::Key_F;
+ if (str == "g") return Qt::Key_G;
+ if (str == "h") return Qt::Key_H;
+ if (str == "i") return Qt::Key_I;
+ if (str == "j") return Qt::Key_J;
+ if (str == "k") return Qt::Key_K;
+ if (str == "l") return Qt::Key_L;
+ if (str == "m") return Qt::Key_M;
+ if (str == "n") return Qt::Key_N;
+ if (str == "o") return Qt::Key_O;
+ if (str == "p") return Qt::Key_P;
+ if (str == "q") return Qt::Key_Q;
+ if (str == "r") return Qt::Key_R;
+ if (str == "s") return Qt::Key_S;
+ if (str == "t") return Qt::Key_T;
+ if (str == "u") return Qt::Key_U;
+ if (str == "v") return Qt::Key_V;
+ if (str == "w") return Qt::Key_W;
+ if (str == "x") return Qt::Key_X;
+ if (str == "y") return Qt::Key_Y;
+ if (str == "z") return Qt::Key_Z;
+ if (str == "bracketleft") return Qt::Key_BracketLeft;
+ if (str == "backslash") return Qt::Key_Backslash;
+ if (str == "bracketright") return Qt::Key_BracketRight;
+ if (str == "underscore") return Qt::Key_Underscore;
+ if (str == "space") return Qt::Key_Space;
+ if (str == "parenleft") return Qt::Key_ParenLeft;
+ if (str == "parenright") return Qt::Key_ParenRight;
+ if (str == "quotedbl") return Qt::Key_QuoteDbl;
+ if (str == "exclam") return Qt::Key_Exclam;
+ if (str == "numbersign") return Qt::Key_NumberSign;
+ if (str == "asciicircum") return Qt::Key_AsciiCircum;
+ if (str == "dollar") return Qt::Key_Dollar;
+ if (str == "percent") return Qt::Key_Percent;
+ if (str == "ampersand") return Qt::Key_Ampersand;
+ if (str == "asterisk") return Qt::Key_Asterisk;
+ if (str == "apostrophe") return Qt::Key_Apostrophe;
+ if (str == "plus") return Qt::Key_Plus;
+ if (str == "minus") return Qt::Key_Minus;
+ if (str == "comma") return Qt::Key_Comma;
+ if (str == "period") return Qt::Key_Period;
+ if (str == "slash") return Qt::Key_Slash;
+ if (str == "asciitilde") return Qt::Key_AsciiTilde;
+ if (str == "braceleft") return Qt::Key_BraceLeft;
+ if (str == "braceright") return Qt::Key_BraceRight;
+ if (str == "grave") // ??? return Qt::Key_QuoteLeft;
+ if (str == "notsign") return Qt::Key_notsign;
+ if (str == "nobreakspace") return Qt::Key_nobreakspace;
+ if (str == "exclamdown") return Qt::Key_exclamdown;
+ if (str == "cent") return Qt::Key_cent;
+ if (str == "sterling") return Qt::Key_sterling;
+ if (str == "currency") return Qt::Key_currency;
+ if (str == "yen") return Qt::Key_yen;
+ if (str == "brokenbar") return Qt::Key_brokenbar;
+ if (str == "section") return Qt::Key_section;
+ if (str == "diaeresis") return Qt::Key_diaeresis;
+ if (str == "copyright") return Qt::Key_copyright;
+ if (str == "ordfeminine") return Qt::Key_ordfeminine;
+ if (str == "guillemotleft") return Qt::Key_guillemotleft;
+ if (str == "hyphen") return Qt::Key_hyphen;
+ if (str == "registered") return Qt::Key_registered;
+ if (str == "macron") return Qt::Key_macron;
+ if (str == "degree") return Qt::Key_degree;
+ if (str == "plusminus") return Qt::Key_plusminus;
+ if (str == "twosuperior") return Qt::Key_twosuperior;
+ if (str == "threesuperior") return Qt::Key_threesuperior;
+ if (str == "acute") return Qt::Key_acute;
+ if (str == "mu") return Qt::Key_mu;
+ if (str == "paragraph") return Qt::Key_paragraph;
+ if (str == "periodcentered") return Qt::Key_periodcentered;
+ if (str == "cedilla") return Qt::Key_cedilla;
+ if (str == "onesuperior") return Qt::Key_onesuperior;
+ if (str == "masculine") return Qt::Key_masculine;
+ if (str == "guillemotright") return Qt::Key_guillemotright;
+ if (str == "onequarter") return Qt::Key_onequarter;
+ if (str == "onehalf") return Qt::Key_onehalf;
+ if (str == "threequarters") return Qt::Key_threequarters;
+ if (str == "questiondown") return Qt::Key_questiondown;
+ if (str == "Agrave") return Qt::Key_Agrave;
+ if (str == "Aacute") return Qt::Key_Aacute;
+ if (str == "Acircumflex") return Qt::Key_Acircumflex;
+ if (str == "Atilde") return Qt::Key_Atilde;
+ if (str == "Adiaeresis") return Qt::Key_Adiaeresis;
+ if (str == "Aring") return Qt::Key_Aring;
+ if (str == "AE") return Qt::Key_AE;
+ if (str == "Ccedilla") return Qt::Key_Ccedilla;
+ if (str == "Egrave") return Qt::Key_Egrave;
+ if (str == "Eacute") return Qt::Key_Eacute;
+ if (str == "Ecircumflex") return Qt::Key_Ecircumflex;
+ if (str == "Ediaeresis") return Qt::Key_Ediaeresis;
+ if (str == "Igrave") return Qt::Key_Igrave;
+ if (str == "Iacute") return Qt::Key_Iacute;
+ if (str == "Icircumflex") return Qt::Key_Icircumflex;
+ if (str == "Idiaeresis") return Qt::Key_Idiaeresis;
+ if (str == "ETH") return Qt::Key_ETH;
+ if (str == "Ntilde") return Qt::Key_Ntilde;
+ if (str == "Ograve") return Qt::Key_Ograve;
+ if (str == "Oacute") return Qt::Key_Oacute;
+ if (str == "Ocircumflex") return Qt::Key_Ocircumflex;
+ if (str == "Otilde") return Qt::Key_Otilde;
+ if (str == "Odiaeresis") return Qt::Key_Odiaeresis;
+ if (str == "multiply") return Qt::Key_multiply;
+ if (str == "Ooblique") return Qt::Key_Ooblique;
+ if (str == "Ugrave") return Qt::Key_Ugrave;
+ if (str == "Uacute") return Qt::Key_Uacute;
+ if (str == "Ucircumflex") return Qt::Key_Ucircumflex;
+ if (str == "Udiaeresis") return Qt::Key_Udiaeresis;
+ if (str == "Yacute") return Qt::Key_Yacute;
+ if (str == "THORN") return Qt::Key_THORN;
+ if (str == "ssharp") return Qt::Key_ssharp;
+ if (str == "agrave") return Qt::Key_agrave;
+ if (str == "aacute") return Qt::Key_aacute;
+ if (str == "acircumflex") return Qt::Key_acircumflex;
+ if (str == "atilde") return Qt::Key_atilde;
+ if (str == "adiaeresis") return Qt::Key_adiaeresis;
+ if (str == "aring") return Qt::Key_aring;
+ if (str == "ae") return Qt::Key_ae;
+ if (str == "ccedilla") return Qt::Key_ccedilla;
+ if (str == "egrave") return Qt::Key_egrave;
+ if (str == "eacute") return Qt::Key_eacute;
+ if (str == "ecircumflex") return Qt::Key_ecircumflex;
+ if (str == "ediaeresis") return Qt::Key_ediaeresis;
+ if (str == "igrave") return Qt::Key_igrave;
+ if (str == "iacute") return Qt::Key_iacute;
+ if (str == "icircumflex") return Qt::Key_icircumflex;
+ if (str == "idiaeresis") return Qt::Key_idiaeresis;
+ if (str == "eth") return Qt::Key_eth;
+ if (str == "ntilde") return Qt::Key_ntilde;
+ if (str == "ograve") return Qt::Key_ograve;
+ if (str == "oacute") return Qt::Key_oacute;
+ if (str == "ocircumflex") return Qt::Key_ocircumflex;
+ if (str == "otilde") return Qt::Key_otilde;
+ if (str == "odiaeresis") return Qt::Key_odiaeresis;
+ if (str == "division") return Qt::Key_division;
+ if (str == "oslash") return Qt::Key_oslash;
+ if (str == "ugrave") return Qt::Key_ugrave;
+ if (str == "uacute") return Qt::Key_uacute;
+ if (str == "ucircumflex") return Qt::Key_ucircumflex;
+ if (str == "udiaeresis") return Qt::Key_udiaeresis;
+ if (str == "yacute") return Qt::Key_yacute;
+ if (str == "thorn") return Qt::Key_thorn;
+ if (str == "ydiaeresis") return Qt::Key_ydiaeresis;
+
+ // FIXME: these ones I don't know the names of ... help !
+ // what's here is basically guesses ...
+ if (str == "Super_L") return Qt::Key_Super_L;
+ if (str == "Super_R") return Qt::Key_Super_R;
+ if (str == "Menu") return Qt::Key_Menu;
+ if (str == "Hyper_L") return Qt::Key_Hyper_L;
+ if (str == "Hyper_R") return Qt::Key_Hyper_R;
+ if (str == "Help") return Qt::Key_Help;
+ if (str == "Bar") return Qt::Key_Bar;
+ if (str == "BackTab") return Qt::Key_Backtab;
+
+ return Qt::Key_unknown;
+}
+
+
/**
* q_to_lkey - convert Qt keypress into LyX
*
* Convert the Qt keypress into a string understandable
* by the LyX core (same as XKeysymToString)
*/
-string const q_to_lkey(int lkey)
+string const qkey_to_string(int lkey)
{
switch(lkey) {
case Qt::Key_Escape: return "Escape";