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