Include "stdmenus.ui"
Include "stdtoolbars.ui"
+
+# Which toolbars to use.
+#
+# The second parameter are the flags :
+#
+# on: the toolbar is visible
+# off: the toolbar is not visible
+# math: the toolbar is visible only when in math
+# table: the toolbar is visible only when in a table
+# top: the toolbar should be at the top of the window
+# bottom: the toolbar should be at the bottom of the window
+# left: the toolbar should be at the left of the window
+# right: the toolbar should be at the right of the window
+#
+Toolbars
+ "Standard" "on,top"
+ "Extra" "on,top"
+ "Table" "off,bottom"
+ "Math" "off,bottom"
+ "Command Buffer" "off,bottom"
+End
# A Toolbar starts like :
#
-# Toolbar "Name" "on"
-#
-# The second parameter are the flags :
-#
-# on: the toolbar is visible
-# off: the toolbar is not visible
-# math: the toolbar is visible only when in math
-# table: the toolbar is visible only when in a table
-# top: the toolbar should be at the top of the window
-# bottom: the toolbar should be at the bottom of the window
-# left: the toolbar should be at the left of the window
-# right: the toolbar should be at the right of the window
+# Toolbar "Name"
#
# Only four commands are allowed inside the begin_toolbar and end_toolbar
# directives:
#
# This is the default toolbar:
-# slight rationalisations here
-
Toolbar "Standard" "on,top"
Layouts
Item "New document" "buffer-new"
tb.name = lex.getString();
lex.next(true);
- tb.flags = static_cast<Flags>(0);
- string flagstr = lex.getString();
- vector<string> flags = getVectorFromString(flagstr);
-
- vector<string>::const_iterator cit = flags.begin();
- vector<string>::const_iterator end = flags.end();
-
- for (; cit != end; ++cit) {
- int flag = 0;
- if (!compare_ascii_no_case(*cit, "off"))
- flag = OFF;
- else if (!compare_ascii_no_case(*cit, "on"))
- flag = ON;
- else if (!compare_ascii_no_case(*cit, "math"))
- flag = MATH;
- else if (!compare_ascii_no_case(*cit, "table"))
- flag = TABLE;
- else if (!compare_ascii_no_case(*cit, "top"))
- flag = TOP;
- else if (!compare_ascii_no_case(*cit, "bottom"))
- flag = BOTTOM;
- else if (!compare_ascii_no_case(*cit, "left"))
- flag = LEFT;
- else if (!compare_ascii_no_case(*cit, "right"))
- flag = RIGHT;
- else {
- lyxerr << "ToolbarBackend::read: unrecognised token:`"
- << *cit << '\'' << endl;
- }
- tb.flags = static_cast<Flags>(tb.flags | flag);
- }
-
bool quit = false;
lex.pushTable(toolTags, TO_LAST - 1);
}
+void ToolbarBackend::readToolbars(LyXLex & lex)
+{
+ //consistency check
+ if (compare_ascii_no_case(lex.getString(), "toolbars")) {
+ lyxerr << "ToolbarBackend::read: ERROR wrong token:`"
+ << lex.getString() << '\'' << endl;
+ }
+
+ lex.next(true);
+
+ while (lex.isOK()) {
+ string name = lex.getString();
+ lex.next(true);
+
+ if (!compare_ascii_no_case(name, "end"))
+ return;
+
+ Toolbars::iterator tcit = toolbars.begin();
+ Toolbars::iterator tend = toolbars.end();
+ for (; tcit != tend; ++tcit) {
+ if (tcit->name == name)
+ break;
+ }
+
+ if (tcit == tend) {
+ lyxerr << "ToolbarBackend: undefined toolbar "
+ << name << endl;
+ return;
+ }
+
+ tcit->flags = static_cast<Flags>(0);
+ string flagstr = lex.getString();
+ lex.next(true);
+ vector<string> flags = getVectorFromString(flagstr);
+
+ vector<string>::const_iterator cit = flags.begin();
+ vector<string>::const_iterator end = flags.end();
+
+ for (; cit != end; ++cit) {
+ int flag = 0;
+ if (!compare_ascii_no_case(*cit, "off"))
+ flag = OFF;
+ else if (!compare_ascii_no_case(*cit, "on"))
+ flag = ON;
+ else if (!compare_ascii_no_case(*cit, "math"))
+ flag = MATH;
+ else if (!compare_ascii_no_case(*cit, "table"))
+ flag = TABLE;
+ else if (!compare_ascii_no_case(*cit, "top"))
+ flag = TOP;
+ else if (!compare_ascii_no_case(*cit, "bottom"))
+ flag = BOTTOM;
+ else if (!compare_ascii_no_case(*cit, "left"))
+ flag = LEFT;
+ else if (!compare_ascii_no_case(*cit, "right"))
+ flag = RIGHT;
+ else {
+ lyxerr << "ToolbarBackend::read: unrecognised token:`"
+ << *cit << '\'' << endl;
+ }
+ tcit->flags = static_cast<Flags>(tcit->flags | flag);
+ }
+
+ usedtoolbars.push_back(*tcit);
+ }
+}
+
+
void ToolbarBackend::add(Toolbar & tb, int action, string const & tooltip)
{
tb.items.push_back(make_pair(action, tooltip));
enum Uitags {
ui_menuset = 1,
ui_toolbar,
+ ui_toolbars,
ui_include,
ui_last
};
struct keyword_item uitags[ui_last - 1] = {
{ "include", ui_include },
{ "menuset", ui_menuset },
- { "toolbar", ui_toolbar }
+ { "toolbar", ui_toolbar },
+ { "toolbars", ui_toolbars }
};
// Ensure that a file is read only once (prevents include loops)
toolbarbackend.read(lex);
break;
+ case ui_toolbars:
+ toolbarbackend.readToolbars(lex);
+ break;
+
default:
if (!rtrim(lex.getString()).empty())
lex.printError("LyX::ReadUIFile: "