]> git.lyx.org Git - lyx.git/blobdiff - src/ToolbarBackend.cpp
this we don't need anymore
[lyx.git] / src / ToolbarBackend.cpp
index 948a5ae9a12305df7cd4636be81872cb95c9ea8d..419f0518f4008bf2e39b41078d1a4c8a2fa53fa7 100644 (file)
 #include "ToolbarBackend.h"
 #include "FuncRequest.h"
 #include "Lexer.h"
-#include "debug.h"
-#include "gettext.h"
 #include "LyXAction.h"
 #include "support/lstrings.h"
 
+#include "support/debug.h"
+#include "support/gettext.h"
+
 #include <boost/bind.hpp>
+
 #include <algorithm>
 
-#include "frontends/controllers/ControlMath.h"
+using namespace std;
+using namespace lyx::support;
 
 namespace lyx {
 
-using support::compare_ascii_no_case;
-using support::getVectorFromString;
-
-using std::endl;
-using std::make_pair;
-using std::string;
-using std::vector;
-using std::find_if;
-
-
 namespace {
 
-class ToolbarNamesEqual : public std::unary_function<ToolbarInfo, bool> {
+class ToolbarNamesEqual
+{
 public:
-       ToolbarNamesEqual(string const & name)
-               : name_(name) {}
+       ToolbarNamesEqual(string const & name) : name_(name) {}
        bool operator()(ToolbarInfo const & tbinfo) const
        {
                return tbinfo.name == name_;
@@ -56,6 +49,12 @@ private:
 ToolbarBackend toolbarbackend;
 
 
+/////////////////////////////////////////////////////////////////////////
+//
+// ToolbarItem
+//
+/////////////////////////////////////////////////////////////////////////
+
 ToolbarItem::ToolbarItem(Type type, FuncRequest const & func, docstring const & label)
        : type_(type), func_(func), label_(label)
 {
@@ -63,7 +62,7 @@ ToolbarItem::ToolbarItem(Type type, FuncRequest const & func, docstring const &
 
 
 ToolbarItem::ToolbarItem(Type type, string const & name, docstring const & label)
-       : type_(type), name_(name), label_(label)
+       : type_(type), label_(label), name_(name)
 {
 }
 
@@ -81,7 +80,7 @@ void ToolbarInfo::add(ToolbarItem const & item)
 
 ToolbarInfo & ToolbarInfo::read(Lexer & lex)
 {
-       enum tooltags {
+       enum {
                TO_COMMAND = 1,
                TO_ENDTOOLBAR,
                TO_SEPARATOR,
@@ -90,10 +89,9 @@ ToolbarInfo & ToolbarInfo::read(Lexer & lex)
                TO_TABLEINSERT,
                TO_POPUPMENU,
                TO_ICONPALETTE,
-               TO_LAST
        };
-       
-       struct keyword_item toolTags[TO_LAST - 1] = {
+
+       struct LexerKeyword toolTags[] = {
                { "end", TO_ENDTOOLBAR },
                { "iconpalette", TO_ICONPALETTE },
                { "item", TO_COMMAND },
@@ -106,8 +104,8 @@ ToolbarInfo & ToolbarInfo::read(Lexer & lex)
 
        //consistency check
        if (compare_ascii_no_case(lex.getString(), "toolbar")) {
-               lyxerr << "ToolbarInfo::read: ERROR wrong token:`"
-                      << lex.getString() << '\'' << endl;
+               LYXERR0("ToolbarInfo::read: ERROR wrong token:`"
+                      << lex.getString() << '\'');
        }
 
        lex.next(true);
@@ -118,14 +116,14 @@ ToolbarInfo & ToolbarInfo::read(Lexer & lex)
 
        // FIXME what to do here?
        if (!lex) {
-               lyxerr << "ToolbarInfo::read: Malformed toolbar "
-                       "description " <<  lex.getString() << endl;
+               LYXERR0("ToolbarInfo::read: Malformed toolbar "
+                       "description " <<  lex.getString());
                return *this;
        }
 
        bool quit = false;
 
-       lex.pushTable(toolTags, TO_LAST - 1);
+       lex.pushTable(toolTags);
 
        if (lyxerr.debugging(Debug::PARSER))
                lex.printTable(lyxerr);
@@ -137,9 +135,8 @@ ToolbarInfo & ToolbarInfo::read(Lexer & lex)
                                docstring const tooltip = translateIfPossible(lex.getDocString());
                                lex.next(true);
                                string const func_arg = lex.getString();
-                               LYXERR(Debug::PARSER)
-                                       << "ToolbarInfo::read TO_COMMAND func: `"
-                                       << func_arg << '\'' << endl;
+                               LYXERR(Debug::PARSER, "ToolbarInfo::read TO_COMMAND func: `"
+                                       << func_arg << '\'');
 
                                FuncRequest func =
                                        lyxaction.lookupFunc(func_arg);
@@ -149,12 +146,12 @@ ToolbarInfo & ToolbarInfo::read(Lexer & lex)
 
                case TO_MINIBUFFER:
                        add(ToolbarItem(ToolbarItem::MINIBUFFER,
-                               FuncRequest(kb_action(ToolbarItem::MINIBUFFER))));
+                               FuncRequest(FuncCode(ToolbarItem::MINIBUFFER))));
                        break;
 
                case TO_SEPARATOR:
                        add(ToolbarItem(ToolbarItem::SEPARATOR,
-                               FuncRequest(kb_action(ToolbarItem::SEPARATOR))));
+                               FuncRequest(FuncCode(ToolbarItem::SEPARATOR))));
                        break;
 
                case TO_POPUPMENU:
@@ -165,7 +162,7 @@ ToolbarInfo & ToolbarInfo::read(Lexer & lex)
                                add(ToolbarItem(ToolbarItem::POPUPMENU, name, label));
                        }
                        break;
-                       
+
                case TO_ICONPALETTE:
                        if (lex.next(true)) {
                                string const name = lex.getString();
@@ -174,20 +171,20 @@ ToolbarInfo & ToolbarInfo::read(Lexer & lex)
                                add(ToolbarItem(ToolbarItem::ICONPALETTE, name, label));
                        }
                        break;
-                       
+
                case TO_LAYOUTS:
                        add(ToolbarItem(ToolbarItem::LAYOUTS,
-                               FuncRequest(kb_action(ToolbarItem::LAYOUTS))));
+                               FuncRequest(FuncCode(ToolbarItem::LAYOUTS))));
                        break;
-                       
+
                case TO_TABLEINSERT:
                        if (lex.next(true)) {
                                docstring const tooltip = lex.getDocString();
                                add(ToolbarItem(ToolbarItem::TABLEINSERT,
-                                       FuncRequest(kb_action(ToolbarItem::TABLEINSERT)), tooltip));
+                                       FuncRequest(FuncCode(ToolbarItem::TABLEINSERT)), tooltip));
                        }
                        break;
-                       
+
                case TO_ENDTOOLBAR:
                        quit = true;
                        break;
@@ -205,32 +202,38 @@ ToolbarInfo & ToolbarInfo::read(Lexer & lex)
 
 
 
+/////////////////////////////////////////////////////////////////////////
+//
+// ToolbarBackend
+//
+/////////////////////////////////////////////////////////////////////////
+
 
 ToolbarBackend::ToolbarBackend()
 {
+       fullScreenWindows = 0;
 }
 
 
 void ToolbarBackend::readToolbars(Lexer & lex)
 {
-       enum tooltags {
+       enum {
                TO_TOOLBAR = 1,
                TO_ENDTOOLBARSET,
-               TO_LAST
        };
-       
-       struct keyword_item toolTags[TO_LAST - 1] = {
+
+       struct LexerKeyword toolTags[] = {
                { "end", TO_ENDTOOLBARSET },
                { "toolbar", TO_TOOLBAR }
        };
 
        //consistency check
        if (compare_ascii_no_case(lex.getString(), "toolbarset")) {
-               lyxerr << "ToolbarBackend::readToolbars: ERROR wrong token:`"
-                      << lex.getString() << '\'' << endl;
+               LYXERR0("ToolbarBackend::readToolbars: ERROR wrong token:`"
+                      << lex.getString() << '\'');
        }
 
-       lex.pushTable(toolTags, TO_LAST - 1);
+       lex.pushTable(toolTags);
 
        if (lyxerr.debugging(Debug::PARSER))
                lex.printTable(lyxerr);
@@ -262,8 +265,8 @@ void ToolbarBackend::readToolbarSettings(Lexer & lex)
 {
        //consistency check
        if (compare_ascii_no_case(lex.getString(), "toolbars")) {
-               lyxerr << "ToolbarBackend::readToolbarSettings: ERROR wrong token:`"
-                      << lex.getString() << '\'' << endl;
+               LYXERR0("ToolbarBackend::readToolbarSettings: ERROR wrong token:`"
+                      << lex.getString() << '\'');
        }
 
        lex.next(true);
@@ -283,8 +286,7 @@ void ToolbarBackend::readToolbarSettings(Lexer & lex)
                }
 
                if (tcit == tend) {
-                       lyxerr << "ToolbarBackend: undefined toolbar "
-                               << name << endl;
+                       LYXERR0("ToolbarBackend: undefined toolbar " << name);
                        return;
                }
 
@@ -306,6 +308,8 @@ void ToolbarBackend::readToolbarSettings(Lexer & lex)
                                flag = ToolbarInfo::MATH;
                        else if (!compare_ascii_no_case(*cit, "table"))
                                flag = ToolbarInfo::TABLE;
+                       else if (!compare_ascii_no_case(*cit, "mathmacrotemplate"))
+                               flag = ToolbarInfo::MATHMACROTEMPLATE;
                        else if (!compare_ascii_no_case(*cit, "review"))
                                flag = ToolbarInfo::REVIEW;
                        else if (!compare_ascii_no_case(*cit, "top"))
@@ -316,9 +320,12 @@ void ToolbarBackend::readToolbarSettings(Lexer & lex)
                                flag = ToolbarInfo::LEFT;
                        else if (!compare_ascii_no_case(*cit, "right"))
                                flag = ToolbarInfo::RIGHT;
+                       else if (!compare_ascii_no_case(*cit, "auto"))
+                               flag = ToolbarInfo::AUTO;
                        else {
-                               lyxerr << "ToolbarBackend::readToolbarSettings: unrecognised token:`"
-                                      << *cit << '\'' << endl;
+                               LYXERR(Debug::ANY,
+                                       "ToolbarBackend::readToolbarSettings: unrecognised token:`"
+                                       << *cit << '\'');
                        }
                        tcit->flags = static_cast<ToolbarInfo::Flags>(tcit->flags | flag);
                }
@@ -328,24 +335,21 @@ void ToolbarBackend::readToolbarSettings(Lexer & lex)
 }
 
 
-ToolbarInfo const & ToolbarBackend::getToolbar(string const & name) const
+ToolbarInfo const * ToolbarBackend::getDefinedToolbarInfo(string const & name) const
 {
-       Toolbars::const_iterator cit = find_if(toolbars.begin(), toolbars.end(), ToolbarNamesEqual(name));
-       if (cit == toolbars.end())
-               lyxerr << "No toolbar named " << name << endl;
-       BOOST_ASSERT(cit != toolbars.end());
-       return (*cit);
+       Toolbars::const_iterator it = find_if(toolbars.begin(), toolbars.end(), ToolbarNamesEqual(name));
+       if (it == toolbars.end())
+               return 0;
+       return &(*it);
 }
 
 
-ToolbarInfo & ToolbarBackend::getToolbar(string const & name)
+ToolbarInfo * ToolbarBackend::getUsedToolbarInfo(string const &name)
 {
-       Toolbars::iterator it = find_if(toolbars.begin(), toolbars.end(), ToolbarNamesEqual(name));
-       if (it == toolbars.end())
-               lyxerr << "No toolbar named " << name << endl;
-       BOOST_ASSERT(it != toolbars.end());
-       return (*it);
+       Toolbars::iterator it = find_if(usedtoolbars.begin(), usedtoolbars.end(), ToolbarNamesEqual(name));
+       if (it == usedtoolbars.end())
+               return 0;
+       return &(*it);
 }
 
-
 } // namespace lyx