]> git.lyx.org Git - lyx.git/blob - src/ToolbarDefaults.C
fix "make dist" target
[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-2000 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
24 using std::endl;
25
26 extern LyXAction lyxaction;
27 ToolbarDefaults toolbardefaults;
28
29
30 ToolbarDefaults::ToolbarDefaults()
31 {
32         init();
33 }
34
35
36 void ToolbarDefaults::add(int action)
37 {
38         defaults.push_back(action);
39 }
40
41
42 void ToolbarDefaults::init() 
43 {
44         add(LAYOUTS);
45         add(LFUN_FILE_OPEN);
46         //add(LFUN_CLOSEBUFFER);
47         add(LFUN_MENUWRITE);
48         add(LFUN_MENUPRINT);
49         add(SEPARATOR);
50
51         add(LFUN_CUT);
52         add(LFUN_COPY);
53         add(LFUN_PASTE);
54         add(SEPARATOR);
55         
56         add(LFUN_EMPH);
57         add(LFUN_NOUN);
58         add(LFUN_FREE);
59         add(SEPARATOR);
60         
61         add(LFUN_INSET_FOOTNOTE);
62         add(LFUN_INSET_MARGINAL);
63
64         add(LFUN_DEPTH);
65         add(SEPARATOR);
66
67         add(LFUN_TEX);
68         add(LFUN_MATH_MODE);
69         add(SEPARATOR);
70
71         add(LFUN_FIGURE);
72         add(LFUN_DIALOG_TABULAR_INSERT);
73 }
74
75
76 enum _tooltags {
77         TO_ADD = 1,
78         TO_ENDTOOLBAR,
79         TO_SEPARATOR,
80         TO_LAYOUTS,
81         TO_NEWLINE,
82         TO_LAST
83 };
84
85
86 struct keyword_item toolTags[TO_LAST - 1] = {
87         { "end", TO_ENDTOOLBAR },
88         { "icon", TO_ADD },
89         { "layouts", TO_LAYOUTS },
90         { "newline", TO_NEWLINE },
91         { "separator", TO_SEPARATOR }
92 };
93
94
95 void ToolbarDefaults::read(LyXLex & lex) 
96 {
97         //consistency check
98         if (compare_no_case(lex.GetString(), "toolbar"))
99                 lyxerr << "Toolbar::read: ERROR wrong token:`"
100                        << lex.GetString() << '\'' << endl;
101
102         defaults.clear();
103         
104         string func;
105         bool quit = false;
106         
107         lex.pushTable(toolTags, TO_LAST - 1);
108
109         if (lyxerr.debugging(Debug::PARSER))
110                 lex.printTable(lyxerr);
111
112         while (lex.IsOK() && !quit) {
113                 switch (lex.lex()) {
114                 case TO_ADD:
115                         if (lex.next()) {
116                                 func = lex.GetString();
117                                 lyxerr[Debug::PARSER]
118                                         << "Toolbar::read TO_ADD func: `"
119                                         << func << "'" << endl;
120                                 add(func);
121                         }
122                         break;
123                    
124                 case TO_SEPARATOR:
125                         add(SEPARATOR);
126                         break;
127                    
128                 case TO_LAYOUTS:
129                         add(LAYOUTS);
130                         break;
131                    
132                 case TO_NEWLINE:
133                         add(NEWLINE);
134                         break;
135                         
136                 case TO_ENDTOOLBAR:
137                         // should not set automatically
138                         //set();
139                         quit = true;
140                         break;
141                 default:
142                         lex.printError("Toolbar::read: "
143                                        "Unknown toolbar tag: `$$Token'");
144                         break;
145                 }
146         }
147         lex.popTable();
148 }
149
150
151 void ToolbarDefaults::add(string const & func)
152 {
153         int const tf = lyxaction.LookupFunc(func);
154
155         if (tf == -1) {
156                 lyxerr << "Toolbar::add: no LyX command called`"
157                        << func << "'exists!" << endl; 
158         } else {
159                 add(tf);
160         }
161 }