X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FToolbarDefaults.C;h=8930ae982a3b827be2f02ee4308fc2622483270c;hb=98c966c64594611e469313314abd1e59524adb4a;hp=ee902e53d0a55b9aeccbf0db4735cfb163319cd3;hpb=85798535a19919e82cc94a177a8414c542a9c5bf;p=lyx.git diff --git a/src/ToolbarDefaults.C b/src/ToolbarDefaults.C index ee902e53d0..8930ae982a 100644 --- a/src/ToolbarDefaults.C +++ b/src/ToolbarDefaults.C @@ -1,12 +1,53 @@ +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 1995 Matthias Ettrich + * Copyright 1995-2001 The LyX Team. + * + * + * ====================================================== */ + +#ifdef __GNUG__ +#pragma implementation +#endif + #include #include "ToolbarDefaults.h" #include "LyXAction.h" -#include "toolbar.h" +#include "lyxlex.h" +#include "debug.h" +#include "lyxlex.h" +#include "support/lstrings.h" using std::endl; extern LyXAction lyxaction; +ToolbarDefaults toolbardefaults; + +namespace { + +enum _tooltags { + TO_ADD = 1, + TO_ENDTOOLBAR, + TO_SEPARATOR, + TO_LAYOUTS, + TO_NEWLINE, + TO_LAST +}; + + +struct keyword_item toolTags[TO_LAST - 1] = { + { "end", TO_ENDTOOLBAR }, + { "icon", TO_ADD }, + { "layouts", TO_LAYOUTS }, + { "newline", TO_NEWLINE }, + { "separator", TO_SEPARATOR } +}; + +} // end of anon namespace ToolbarDefaults::ToolbarDefaults() @@ -21,107 +62,81 @@ void ToolbarDefaults::add(int action) } -void ToolbarDefaults::init() +void ToolbarDefaults::init() { - add(Toolbar::TOOL_LAYOUTS); - add(LFUN_MENUOPEN); + add(LAYOUTS); + add(LFUN_FILE_OPEN); //add(LFUN_CLOSEBUFFER); add(LFUN_MENUWRITE); add(LFUN_MENUPRINT); - add(Toolbar::TOOL_SEPARATOR); + add(SEPARATOR); add(LFUN_CUT); add(LFUN_COPY); add(LFUN_PASTE); - add(Toolbar::TOOL_SEPARATOR); - + add(SEPARATOR); + add(LFUN_EMPH); add(LFUN_NOUN); add(LFUN_FREE); - add(Toolbar::TOOL_SEPARATOR); - - add(LFUN_FOOTMELT); - add(LFUN_MARGINMELT); - add(LFUN_DEPTH); - add(Toolbar::TOOL_SEPARATOR); - - add(LFUN_TEX); - add(LFUN_MATH_MODE); - add(Toolbar::TOOL_SEPARATOR); - - add(LFUN_FIGURE); - add(LFUN_TABLE); - //add(LFUN_MELT); -} + add(SEPARATOR); + add(LFUN_INSET_FOOTNOTE); + add(LFUN_INSET_MARGINAL); -enum _tooltags { - TO_ADD = 1, - TO_ENDTOOLBAR, - TO_SEPARATOR, - TO_LAYOUTS, - TO_NEWLINE, - TO_LAST -}; + add(LFUN_DEPTH_PLUS); + add(SEPARATOR); + add(LFUN_MATH_MODE); + add(SEPARATOR); -struct keyword_item toolTags[TO_LAST - 1] = { - { "\\add", TO_ADD }, - { "\\end_toolbar", TO_ENDTOOLBAR }, - { "\\layouts", TO_LAYOUTS }, - { "\\newline", TO_NEWLINE }, - { "\\separator", TO_SEPARATOR } -}; + add(LFUN_INSET_GRAPHICS); + add(LFUN_DIALOG_TABULAR_INSERT); +} -void ToolbarDefaults::read(LyXLex & lex) +void ToolbarDefaults::read(LyXLex & lex) { - //consistency check - if (lex.GetString() != "\\begin_toolbar") + //consistency check + if (compare_no_case(lex.getString(), "toolbar")) { lyxerr << "Toolbar::read: ERROR wrong token:`" - << lex.GetString() << '\'' << endl; + << lex.getString() << '\'' << endl; + } defaults.clear(); - - string func; + bool quit = false; - + lex.pushTable(toolTags, TO_LAST - 1); if (lyxerr.debugging(Debug::PARSER)) lex.printTable(lyxerr); - - while (lex.IsOK() && !quit) { - - lyxerr[Debug::TOOLBAR] << "Toolbar::read: current lex text: `" - << lex.GetString() << '\'' << endl; - switch(lex.lex()) { + while (lex.isOK() && !quit) { + switch (lex.lex()) { case TO_ADD: - if (lex.EatLine()) { - func = lex.GetString(); - lyxerr[Debug::TOOLBAR] + if (lex.next(true)) { + string const func = lex.getString(); + lyxerr[Debug::PARSER] << "Toolbar::read TO_ADD func: `" << func << "'" << endl; add(func); } break; - + case TO_SEPARATOR: - add(Toolbar::TOOL_SEPARATOR); + add(SEPARATOR); break; - + case TO_LAYOUTS: - add(Toolbar::TOOL_LAYOUTS); + add(LAYOUTS); break; - + case TO_NEWLINE: - add(Toolbar::TOOL_NEWLINE); + add(NEWLINE); break; - + case TO_ENDTOOLBAR: - // should not set automatically - //set(); quit = true; break; default: @@ -136,11 +151,11 @@ void ToolbarDefaults::read(LyXLex & lex) void ToolbarDefaults::add(string const & func) { - int tf = lyxaction.LookupFunc(func); + int const tf = lyxaction.LookupFunc(func); if (tf == -1) { - lyxerr << "Toolbar::add: no LyX command called`" - << func << "'exists!" << endl; + lyxerr << "Toolbar::add: no LyX command called `" + << func << "' exists!" << endl; } else { add(tf); }