]> git.lyx.org Git - lyx.git/blob - src/ToolbarDefaults.C
fix typo that put too many include paths for most people
[lyx.git] / src / ToolbarDefaults.C
1 /* This file is part of
2  * ======================================================
3  *
4  *           LyX, The Document Processor
5  *
6  *           Copyright 1995 Matthias Ettrich
7  *           Copyright 1995-2001 The LyX Team.
8  *
9  *
10  * ====================================================== */
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include <config.h>
17
18 #include "ToolbarDefaults.h"
19 #include "LyXAction.h"
20 #include "lyxlex.h"
21 #include "debug.h"
22 #include "lyxlex.h"
23 #include "support/lstrings.h"
24
25 using std::endl;
26
27 extern LyXAction lyxaction;
28 ToolbarDefaults toolbardefaults;
29
30 namespace {
31
32 enum _tooltags {
33         TO_ADD = 1,
34         TO_ENDTOOLBAR,
35         TO_SEPARATOR,
36         TO_LAYOUTS,
37         TO_NEWLINE,
38         TO_LAST
39 };
40
41
42 struct keyword_item toolTags[TO_LAST - 1] = {
43         { "end", TO_ENDTOOLBAR },
44         { "icon", TO_ADD },
45         { "layouts", TO_LAYOUTS },
46         { "newline", TO_NEWLINE },
47         { "separator", TO_SEPARATOR }
48 };
49
50 } // end of anon namespace
51
52
53 ToolbarDefaults::ToolbarDefaults()
54 {
55         init();
56 }
57
58
59 void ToolbarDefaults::add(int action)
60 {
61         defaults.push_back(action);
62 }
63
64
65 void ToolbarDefaults::init()
66 {
67         add(LAYOUTS);
68         add(LFUN_FILE_OPEN);
69         //add(LFUN_CLOSEBUFFER);
70         add(LFUN_MENUWRITE);
71         add(LFUN_MENUPRINT);
72         add(SEPARATOR);
73
74         add(LFUN_CUT);
75         add(LFUN_COPY);
76         add(LFUN_PASTE);
77         add(SEPARATOR);
78
79         add(LFUN_EMPH);
80         add(LFUN_NOUN);
81         add(LFUN_FREE);
82         add(SEPARATOR);
83
84         add(LFUN_INSET_FOOTNOTE);
85         add(LFUN_INSET_MARGINAL);
86
87         add(LFUN_DEPTH_PLUS);
88         add(SEPARATOR);
89
90         add(LFUN_MATH_MODE);
91         add(SEPARATOR);
92
93         add(LFUN_INSET_GRAPHICS);
94         add(LFUN_DIALOG_TABULAR_INSERT);
95 }
96
97
98 void ToolbarDefaults::read(LyXLex & lex)
99 {
100         //consistency check
101         if (compare_no_case(lex.getString(), "toolbar")) {
102                 lyxerr << "Toolbar::read: ERROR wrong token:`"
103                        << lex.getString() << '\'' << endl;
104         }
105
106         defaults.clear();
107
108         bool quit = false;
109
110         lex.pushTable(toolTags, TO_LAST - 1);
111
112         if (lyxerr.debugging(Debug::PARSER))
113                 lex.printTable(lyxerr);
114
115         while (lex.isOK() && !quit) {
116                 switch (lex.lex()) {
117                 case TO_ADD:
118                         if (lex.next(true)) {
119                                 string const func = lex.getString();
120                                 lyxerr[Debug::PARSER]
121                                         << "Toolbar::read TO_ADD func: `"
122                                         << func << "'" << endl;
123                                 add(func);
124                         }
125                         break;
126
127                 case TO_SEPARATOR:
128                         add(SEPARATOR);
129                         break;
130
131                 case TO_LAYOUTS:
132                         add(LAYOUTS);
133                         break;
134
135                 case TO_NEWLINE:
136                         add(NEWLINE);
137                         break;
138
139                 case TO_ENDTOOLBAR:
140                         quit = true;
141                         break;
142                 default:
143                         lex.printError("Toolbar::read: "
144                                        "Unknown toolbar tag: `$$Token'");
145                         break;
146                 }
147         }
148         lex.popTable();
149 }
150
151
152 void ToolbarDefaults::add(string const & func)
153 {
154         int const tf = lyxaction.LookupFunc(func);
155
156         if (tf == -1) {
157                 lyxerr << "Toolbar::add: no LyX command called `"
158                        << func << "' exists!" << endl;
159         } else {
160                 add(tf);
161         }
162 }