2000-07-24 13:53:19 +00:00
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 1995 Matthias Ettrich
|
|
|
|
* Copyright 1995-2000 The LyX Team.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* ====================================================== */
|
|
|
|
|
|
|
|
#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"
|
2000-07-24 21:49:58 +00:00
|
|
|
#if 1
|
2000-09-23 04:57:18 +00:00
|
|
|
// only until we don't need access to the NEW_INSETS anymore
|
2000-07-24 21:49:58 +00:00
|
|
|
#include "lyxparagraph.h"
|
|
|
|
#endif
|
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
|
|
|
#ifndef NEW_INSETS
|
2000-03-12 10:36:28 +00:00
|
|
|
add(LFUN_FOOTMELT);
|
|
|
|
add(LFUN_MARGINMELT);
|
2000-07-24 21:49:58 +00:00
|
|
|
#else
|
|
|
|
add(LFUN_INSET_FOOTNOTE);
|
|
|
|
add(LFUN_INSET_MARGINAL);
|
|
|
|
#endif
|
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_TEX);
|
|
|
|
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);
|
2001-04-17 15:15:59 +00:00
|
|
|
#if 0
|
2000-03-12 10:36:28 +00:00
|
|
|
//add(LFUN_MELT);
|
2001-04-17 15:15:59 +00:00
|
|
|
#endif
|
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);
|
|
|
|
|
|
|
|
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:
|
2000-07-24 13:53:19 +00:00
|
|
|
if (lex.next()) {
|
2000-03-12 10:36:28 +00:00
|
|
|
func = lex.GetString();
|
2000-07-24 13:53:19 +00:00
|
|
|
lyxerr[Debug::GUI]
|
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();
|
2000-07-24 13:53:19 +00:00
|
|
|
lex.next();
|
2000-03-12 10:36:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
lyxerr << "Toolbar::add: no LyX command called`"
|
|
|
|
<< func << "'exists!" << endl;
|
|
|
|
} else {
|
|
|
|
add(tf);
|
|
|
|
}
|
|
|
|
}
|