]> git.lyx.org Git - lyx.git/blobdiff - src/ToolbarBackend.C
Point fix, earlier forgotten
[lyx.git] / src / ToolbarBackend.C
index b16f85120b3273c418cef9656f3389c5bcf89d01..099d9cafaf7af9dfd885e7432587759d99662571 100644 (file)
@@ -3,9 +3,10 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author unknown
+ * \author Jean-Marc Lasgouttes
+ * \author John Levon
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
 #include "frontends/controllers/ControlMath.h"
 
+#include <vector>
+
+using namespace lyx::support;
+
 using std::endl;
+using std::vector;
+using std::make_pair;
 
 ToolbarBackend toolbarbackend;
 
@@ -33,14 +40,15 @@ enum tooltags {
        TO_ENDTOOLBAR,
        TO_SEPARATOR,
        TO_LAYOUTS,
+       TO_MINIBUFFER,
        TO_LAST
 };
 
-
 struct keyword_item toolTags[TO_LAST - 1] = {
        { "end", TO_ENDTOOLBAR },
        { "item", TO_ADD },
        { "layouts", TO_LAYOUTS },
+       { "minibuffer", TO_MINIBUFFER },
        { "separator", TO_SEPARATOR }
 };
 
@@ -65,21 +73,6 @@ void ToolbarBackend::read(LyXLex & lex)
        Toolbar tb;
        tb.name = lex.getString();
 
-       lex.next(true);
-       string type = lex.getString();
-       if (!compare_ascii_no_case(type, "off"))
-               tb.display_type = OFF;
-       else if (!compare_ascii_no_case(type, "on"))
-               tb.display_type = ON;
-       else if (!compare_ascii_no_case(type, "math"))
-               tb.display_type = MATH;
-       else if (!compare_ascii_no_case(type, "table"))
-               tb.display_type = TABLE;
-       else {
-               lyxerr << "ToolbarBackend::read: unrecognised token:`"
-                      << type << '\'' << endl;
-       }
-
        bool quit = false;
 
        lex.pushTable(toolTags, TO_LAST - 1);
@@ -101,6 +94,10 @@ void ToolbarBackend::read(LyXLex & lex)
                        }
                        break;
 
+               case TO_MINIBUFFER:
+                       add(tb, MINIBUFFER);
+                       break;
+
                case TO_SEPARATOR:
                        add(tb, SEPARATOR);
                        break;
@@ -125,6 +122,74 @@ void ToolbarBackend::read(LyXLex & lex)
 }
 
 
+void ToolbarBackend::readToolbars(LyXLex & lex)
+{
+       //consistency check
+       if (compare_ascii_no_case(lex.getString(), "toolbars")) {
+               lyxerr << "ToolbarBackend::read: ERROR wrong token:`"
+                      << lex.getString() << '\'' << endl;
+       }
+
+       lex.next(true);
+
+       while (lex.isOK()) {
+               string name = lex.getString();
+               lex.next(true);
+
+               if (!compare_ascii_no_case(name, "end"))
+                       return;
+
+               Toolbars::iterator tcit = toolbars.begin();
+               Toolbars::iterator tend = toolbars.end();
+               for (; tcit != tend; ++tcit) {
+                       if (tcit->name == name)
+                               break;
+               }
+
+               if (tcit == tend) {
+                       lyxerr << "ToolbarBackend: undefined toolbar "
+                               << name << endl;
+                       return;
+               }
+
+               tcit->flags = static_cast<Flags>(0);
+               string flagstr = lex.getString();
+               lex.next(true);
+               vector<string> flags = getVectorFromString(flagstr);
+
+               vector<string>::const_iterator cit = flags.begin();
+               vector<string>::const_iterator end = flags.end();
+
+               for (; cit != end; ++cit) {
+                       int flag = 0;
+                       if (!compare_ascii_no_case(*cit, "off"))
+                               flag = OFF;
+                       else if (!compare_ascii_no_case(*cit, "on"))
+                               flag = ON;
+                       else if (!compare_ascii_no_case(*cit, "math"))
+                               flag = MATH;
+                       else if (!compare_ascii_no_case(*cit, "table"))
+                               flag = TABLE;
+                       else if (!compare_ascii_no_case(*cit, "top"))
+                               flag = TOP;
+                       else if (!compare_ascii_no_case(*cit, "bottom"))
+                               flag = BOTTOM;
+                       else if (!compare_ascii_no_case(*cit, "left"))
+                               flag = LEFT;
+                       else if (!compare_ascii_no_case(*cit, "right"))
+                               flag = RIGHT;
+                       else {
+                               lyxerr << "ToolbarBackend::read: unrecognised token:`"
+                                      << *cit << '\'' << endl;
+                       }
+                       tcit->flags = static_cast<Flags>(tcit->flags | flag);
+               }
+
+               usedtoolbars.push_back(*tcit);
+       }
+}
+
+
 void ToolbarBackend::add(Toolbar & tb, int action, string const & tooltip)
 {
        tb.items.push_back(make_pair(action, tooltip));
@@ -175,5 +240,8 @@ string const ToolbarBackend::getIcon(int action)
                return fullname;
        }
 
+       lyxerr[Debug::GUI] << "Cannot find icon for command \""
+                          << lyxaction.getActionName(f.action)
+                          << ' ' << f.argument << '"' << endl;
        return LibFileSearch("images", "unknown", "xpm");
 }