]> git.lyx.org Git - features.git/commitdiff
start moving MenuBackend to the frontend
authorAndré Pönitz <poenitz@gmx.net>
Thu, 6 Mar 2008 21:50:27 +0000 (21:50 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Thu, 6 Mar 2008 21:50:27 +0000 (21:50 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23523 a592a061-630c-0410-9148-cb99ea01b6c8

src/LyX.cpp
src/Makefile.am
src/MenuBackend.cpp
src/MenuBackend.h
src/frontends/Application.h
src/frontends/qt4/GuiApplication.cpp
src/frontends/qt4/GuiApplication.h
src/insets/InsetInfo.cpp
src/insets/InsetInfo.h

index 56cf176cf176148ee1839308e81b50711ef3c7dd..041b5e3c3d6330b332beff381b01e921be4157c0 100644 (file)
 #include "Encoding.h"
 #include "ErrorList.h"
 #include "Format.h"
+#include "FuncStatus.h"
 #include "KeyMap.h"
 #include "Language.h"
 #include "Lexer.h"
 #include "LyXAction.h"
 #include "LyXFunc.h"
 #include "LyXRC.h"
-#include "MenuBackend.h"
 #include "ModuleList.h"
 #include "Mover.h"
 #include "Server.h"
@@ -1080,7 +1080,7 @@ bool LyX::readUIFile(string const & name, bool include)
                        break;
                }
                case ui_menuset:
-                       theApp()->menuBackend().read(lex);
+                       theApp()->readMenus(lex);
                        break;
 
                case ui_toolbarset:
index f8b6a2ee52142953ad2fe61714efc81ff8ca1439..005acf0209084db64ad03dbe229b66c477657637 100644 (file)
@@ -63,6 +63,8 @@ lyx_SOURCES = \
        $(ASPELL) $(PSPELL) $(ISPELL) SpellBase.cpp \
        Box.cpp \
        Box.h \
+       MenuBackend.cpp \
+       MenuBackend.h \
        Dimension.cpp \
        Dimension.h \
        PrinterParams.cpp \
@@ -132,7 +134,6 @@ SOURCEFILESCORE = \
        LyXFunc.cpp \
        LyXRC.cpp \
        LyXVC.cpp \
-       MenuBackend.cpp \
        MetricsInfo.cpp \
        ModuleList.cpp \
        Mover.cpp \
@@ -234,7 +235,6 @@ HEADERFILESCORE = \
        LyX.h \
        LyXRC.h \
        LyXVC.h \
-       MenuBackend.h \
        MetricsInfo.h \
        ModuleList.h \
        Mover.h \
index de7172f5d0bfa8436591fc56391729786c231207..4409135c4dc2e62767ff4dafc65677756b9a3b28 100644 (file)
@@ -404,21 +404,21 @@ void Menu::checkShortcuts() const
 }
 
 
-bool Menu::searchFunc(FuncRequest & func, stack<docstring> & names) const
+bool Menu::searchMenu(FuncRequest const & func, vector<docstring> & names) const
 {
        const_iterator m = begin();
        const_iterator m_end = end();
        for (; m != m_end; ++m) {
                if (m->kind() == MenuItem::Command && m->func() == func) {
-                       names.push(m->label());
+                       names.push_back(m->label());
                        return true;
-               } else if (m->kind() == MenuItem::Submenu) {
-                       names.push(m->label());
+               }
+               if (m->kind() == MenuItem::Submenu) {
+                       names.push_back(m->label());
                        Menu submenu = theApp()->menuBackend().getMenu(m->submenuname());
-                       if (submenu.searchFunc(func, names))
+                       if (submenu.searchMenu(func, names))
                                return true;
-                       else
-                               names.pop();
+                       names.pop_back();
                }
        }
        return false;
index 33e9d57b45c181bdf90ebfba02933eae83ce3f3f..65c2d97398e99ba038766f7131341f3b2b81d760 100644 (file)
@@ -19,7 +19,6 @@
 #include <boost/shared_ptr.hpp>
 
 #include <vector>
-#include <stack>
 
 
 namespace lyx {
@@ -187,7 +186,8 @@ public:
        
        // search for func in this menu iteratively, and put menu
        // names in a stack.
-       bool searchFunc(FuncRequest & func, std::stack<docstring> & names) const;
+       bool searchMenu(FuncRequest const & func, std::vector<docstring> & names)
+               const;
 
 private:
        friend class MenuBackend;
index 997d41a5af06a6954a9e44d4263f18de7dbc91b3..ebb98e9aff8f9237ec15632d81e530c3361bf875 100644 (file)
 #include "ColorCode.h"
 
 #include "support/strfwd.h"
+#include "support/docstring.h"
 
 #include <boost/function.hpp>
 
+#include <vector>
+
 
 namespace lyx {
 
@@ -25,6 +28,7 @@ class Buffer;
 class FuncRequest;
 class FuncStatus;
 class Inset;
+class Lexer;
 class MenuBackend;
 struct RGBColor;
 
@@ -211,6 +215,11 @@ public:
        */
        virtual void updateColor(ColorCode col) = 0;
 
+       /**
+       * read and create the menu structure
+       */
+       virtual void readMenus(Lexer & lex) = 0;
+
        /**
        * add a callback for socket read notification
        * @param fd socket descriptor (file/socket/etc)
@@ -227,6 +236,9 @@ public:
        ///
        virtual MenuBackend const & menuBackend() const = 0;
        virtual MenuBackend & menuBackend() = 0;
+
+       virtual bool searchMenu(FuncRequest const & func,
+               std::vector<docstring> & names) const = 0;
 };
 
 } // namespace frontend
index 693a396d5005545c9d2cef0967d218b1d99379be..0beb0f7c243bbc00a2998fb1973f5c1d2426375e 100644 (file)
@@ -29,7 +29,6 @@
 #include "Font.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
-#include "support/gettext.h"
 #include "LyX.h"
 #include "LyXFunc.h"
 #include "LyXRC.h"
@@ -40,6 +39,7 @@
 #include "support/ExceptionMessage.h"
 #include "support/FileName.h"
 #include "support/ForkedCalls.h"
+#include "support/gettext.h"
 #include "support/lstrings.h"
 #include "support/os.h"
 #include "support/Package.h"
@@ -649,6 +649,19 @@ Buffer const * GuiApplication::updateInset(Inset const * inset) const
 }
 
 
+void GuiApplication::readMenus(Lexer & lex)
+{
+       menuBackend().read(lex);
+}
+
+
+bool GuiApplication::searchMenu(FuncRequest const & func,
+       vector<docstring> & names) const
+{
+               return menuBackend().getMenubar().searchMenu(func, names);
+}
+
+
 ////////////////////////////////////////////////////////////////////////
 // X11 specific stuff goes here...
 #ifdef Q_WS_X11
index 29b522b647743993c76d5acb36ef6e2b7403c1f1..5460de3bc80e078cac46336e13bf67384f88fb8a 100644 (file)
@@ -73,8 +73,10 @@ public:
        virtual bool getRgbColor(ColorCode col, RGBColor & rgbcol);
        virtual std::string const hexName(ColorCode col);
        virtual void updateColor(ColorCode col);
+       virtual void readMenus(Lexer & lex);
        virtual void registerSocketCallback(int fd, SocketCallback func);
        void unregisterSocketCallback(int fd);
+       bool searchMenu(FuncRequest const & func, std::vector<docstring> & names) const;
        //@}
 
        Menus const & menus() const { return menus_; }
index dd4afdeafb016219d633db798fbf20ad42861272..910052f5a4fa38bc8990b426e725812819c0b8a8 100644 (file)
@@ -11,9 +11,6 @@
 
 #include "InsetInfo.h"
 
-#include <sstream>
-#include <stack>
-
 #include "BaseClassList.h"
 #include "Buffer.h"
 #include "BufferParams.h"
@@ -25,7 +22,6 @@
 #include "LyXAction.h"
 #include "LyXRC.h"
 #include "Lexer.h"
-#include "MenuBackend.h"
 #include "MetricsInfo.h"
 #include "ParagraphParameters.h"
 
@@ -38,6 +34,8 @@
 #include "support/lstrings.h"
 #include "support/ExceptionMessage.h"
 
+#include <sstream>
+
 using namespace std;
 using namespace lyx::support;
 
@@ -207,15 +205,14 @@ void InsetInfo::updateInfo()
                break;
        }
        case MENU_INFO: {
-               stack<docstring> names;
+               vector<docstring> names;
                FuncRequest func = lyxaction.lookupFunc(name_);
                if (func.action == LFUN_UNKNOWN_ACTION) {
                        setText(_("No menu entry for "), bp.getFont(), false);
                        break;
                }
                // iterate through the menubackend to find it
-               Menu menu = theApp()->menuBackend().getMenubar();
-               if (!menu.searchFunc(func, names)) {
+               if (!theApp()->searchMenu(func, names)) {
                        setText(_("No menu entry for "), bp.getFont(), false);
                        break;
                }
@@ -228,9 +225,9 @@ void InsetInfo::updateInfo()
                        if (i != 0)
                                info.insertInset(0, new InsetSpecialChar(InsetSpecialChar::MENU_SEPARATOR),
                                        Change(Change::UNCHANGED));
-                       for (i = 0; i < names.top().length(); ++i)
-                               info.insertChar(i, names.top()[i], bp.getFont(), false);
-                       names.pop();
+                       for (i = 0; i != names.back().length(); ++i)
+                               info.insertChar(i, names.back()[i], bp.getFont(), false);
+                       names.pop_back();
                }
                break;
        }
index 9a82e13d724d4683101e5d5a2d33d8a1c5b04b3d..0b5dfd191e6e1285f0167d8e57fe1b4d9cb3645f 100644 (file)
@@ -14,8 +14,9 @@
 
 #include "InsetText.h"
 #include "RenderButton.h"
-#include "support/gettext.h"
 #include "Cursor.h"
+
+#include "support/gettext.h"
 #include "support/Translator.h"
 
 /* InsetInfo displays shortcuts, lyxrc, package and textclass