2000-07-24 13:53:19 +00:00
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 1995 Matthias Ettrich
|
2001-05-30 13:53:44 +00:00
|
|
|
* Copyright 1995-2001 The LyX Team.
|
2000-07-24 13:53:19 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* ====================================================== */
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2000-03-12 10:36:28 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "ToolbarDefaults.h"
|
|
|
|
#include "LyXAction.h"
|
2000-07-24 13:53:19 +00:00
|
|
|
#include "lyxlex.h"
|
2000-07-19 12:30:49 +00:00
|
|
|
#include "debug.h"
|
2000-07-21 18:47:54 +00:00
|
|
|
#include "lyxlex.h"
|
2001-07-29 17:39:01 +00:00
|
|
|
#include "support/lstrings.h"
|
2000-03-12 10:36:28 +00:00
|
|
|
|
2000-03-28 02:18:55 +00:00
|
|
|
using std::endl;
|
|
|
|
|
2000-03-12 10:36:28 +00:00
|
|
|
extern LyXAction lyxaction;
|
2000-07-24 13:53:19 +00:00
|
|
|
ToolbarDefaults toolbardefaults;
|
2000-03-12 10:36:28 +00:00
|
|
|
|
2000-11-21 15:46:13 +00:00
|
|
|
|
2000-03-12 10:36:28 +00:00
|
|
|
ToolbarDefaults::ToolbarDefaults()
|
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ToolbarDefaults::add(int action)
|
|
|
|
{
|
|
|
|
defaults.push_back(action);
|
|
|
|
}
|
|
|
|
|
2000-11-21 15:46:13 +00:00
|
|
|
|
2000-03-12 10:36:28 +00:00
|
|
|
void ToolbarDefaults::init()
|
|
|
|
{
|
2000-07-24 13:53:19 +00:00
|
|
|
add(LAYOUTS);
|
2001-03-07 14:25:31 +00:00
|
|
|
add(LFUN_FILE_OPEN);
|
2000-03-12 10:36:28 +00:00
|
|
|
//add(LFUN_CLOSEBUFFER);
|
|
|
|
add(LFUN_MENUWRITE);
|
|
|
|
add(LFUN_MENUPRINT);
|
2000-07-24 13:53:19 +00:00
|
|
|
add(SEPARATOR);
|
2000-03-12 10:36:28 +00:00
|
|
|
|
|
|
|
add(LFUN_CUT);
|
|
|
|
add(LFUN_COPY);
|
|
|
|
add(LFUN_PASTE);
|
2000-07-24 13:53:19 +00:00
|
|
|
add(SEPARATOR);
|
2000-03-12 10:36:28 +00:00
|
|
|
|
|
|
|
add(LFUN_EMPH);
|
|
|
|
add(LFUN_NOUN);
|
|
|
|
add(LFUN_FREE);
|
2000-07-24 13:53:19 +00:00
|
|
|
add(SEPARATOR);
|
2000-03-12 10:36:28 +00:00
|
|
|
|
2000-07-24 21:49:58 +00:00
|
|
|
add(LFUN_INSET_FOOTNOTE);
|
|
|
|
add(LFUN_INSET_MARGINAL);
|
2001-05-03 14:31:33 +00:00
|
|
|
|
2000-03-12 10:36:28 +00:00
|
|
|
add(LFUN_DEPTH);
|
2000-07-24 13:53:19 +00:00
|
|
|
add(SEPARATOR);
|
2000-03-12 10:36:28 +00:00
|
|
|
|
|
|
|
add(LFUN_MATH_MODE);
|
2000-07-24 13:53:19 +00:00
|
|
|
add(SEPARATOR);
|
2000-03-12 10:36:28 +00:00
|
|
|
|
|
|
|
add(LFUN_FIGURE);
|
2000-08-25 13:37:24 +00:00
|
|
|
add(LFUN_DIALOG_TABULAR_INSERT);
|
2000-03-12 10:36:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
enum _tooltags {
|
|
|
|
TO_ADD = 1,
|
|
|
|
TO_ENDTOOLBAR,
|
|
|
|
TO_SEPARATOR,
|
|
|
|
TO_LAYOUTS,
|
|
|
|
TO_NEWLINE,
|
|
|
|
TO_LAST
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct keyword_item toolTags[TO_LAST - 1] = {
|
2000-07-24 13:53:19 +00:00
|
|
|
{ "end", TO_ENDTOOLBAR },
|
|
|
|
{ "icon", TO_ADD },
|
|
|
|
{ "layouts", TO_LAYOUTS },
|
|
|
|
{ "newline", TO_NEWLINE },
|
|
|
|
{ "separator", TO_SEPARATOR }
|
2000-03-12 10:36:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void ToolbarDefaults::read(LyXLex & lex)
|
|
|
|
{
|
2000-07-24 13:53:19 +00:00
|
|
|
//consistency check
|
|
|
|
if (compare_no_case(lex.GetString(), "toolbar"))
|
2000-03-12 10:36:28 +00:00
|
|
|
lyxerr << "Toolbar::read: ERROR wrong token:`"
|
|
|
|
<< lex.GetString() << '\'' << endl;
|
|
|
|
|
|
|
|
defaults.clear();
|
|
|
|
|
|
|
|
string func;
|
|
|
|
bool quit = false;
|
|
|
|
|
|
|
|
lex.pushTable(toolTags, TO_LAST - 1);
|
|
|
|
|
|
|
|
if (lyxerr.debugging(Debug::PARSER))
|
|
|
|
lex.printTable(lyxerr);
|
|
|
|
|
2001-05-03 15:38:24 +00:00
|
|
|
while (lex.IsOK() && !quit) {
|
2000-11-04 10:00:12 +00:00
|
|
|
switch (lex.lex()) {
|
2000-03-12 10:36:28 +00:00
|
|
|
case TO_ADD:
|
2001-07-23 09:11:14 +00:00
|
|
|
if (lex.next(true)) {
|
2000-03-12 10:36:28 +00:00
|
|
|
func = lex.GetString();
|
2001-05-03 15:38:24 +00:00
|
|
|
lyxerr[Debug::PARSER]
|
2000-03-12 10:36:28 +00:00
|
|
|
<< "Toolbar::read TO_ADD func: `"
|
|
|
|
<< func << "'" << endl;
|
|
|
|
add(func);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_SEPARATOR:
|
2000-07-24 13:53:19 +00:00
|
|
|
add(SEPARATOR);
|
2000-03-12 10:36:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_LAYOUTS:
|
2000-07-24 13:53:19 +00:00
|
|
|
add(LAYOUTS);
|
2000-03-12 10:36:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_NEWLINE:
|
2000-07-24 13:53:19 +00:00
|
|
|
add(NEWLINE);
|
2000-03-12 10:36:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_ENDTOOLBAR:
|
|
|
|
// should not set automatically
|
|
|
|
//set();
|
|
|
|
quit = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
lex.printError("Toolbar::read: "
|
|
|
|
"Unknown toolbar tag: `$$Token'");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lex.popTable();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ToolbarDefaults::add(string const & func)
|
|
|
|
{
|
2000-11-21 15:46:13 +00:00
|
|
|
int const tf = lyxaction.LookupFunc(func);
|
2000-03-12 10:36:28 +00:00
|
|
|
|
|
|
|
if (tf == -1) {
|
2001-07-11 12:10:46 +00:00
|
|
|
lyxerr << "Toolbar::add: no LyX command called `"
|
|
|
|
<< func << "' exists!" << endl;
|
2000-03-12 10:36:28 +00:00
|
|
|
} else {
|
|
|
|
add(tf);
|
|
|
|
}
|
|
|
|
}
|