+2002-11-20 John Levon <levon@movementarian.org>
+
+ * ControlMath.h:
+ * ControlMath.C: add find_xpm mangler
+
2002-11-17 John Levon <levon@movementarian.org>
* helper_funcs.C and users: specify save/open in file dialog
#include "ControlMath.h"
+#include "support/lstrings.h"
+#include "support/filetools.h"
+#include "debug.h"
+
char const * function_names[] = {
"arccos", "arcsin", "arctan", "arg", "bmod",
"cos", "cosh", "cot", "coth", "csc", "deg",
};
int const nr_latex_ams_ops = sizeof(latex_ams_ops) / sizeof(char const *);
+
+
+string const find_xpm(string const & name)
+{
+ string xpm_name = subst(name, ' ', '_');
+ if (xpm_name == "(") xpm_name = "lparen";
+ else if (xpm_name == ")") xpm_name = "rparen";
+ else if (xpm_name == "[") xpm_name = "lbracket";
+ else if (xpm_name == "]") xpm_name = "rbracket";
+ else if (xpm_name == "{") xpm_name = "lbrace";
+ else if (xpm_name == "}") xpm_name = "rbrace";
+ else if (xpm_name == "|") xpm_name = "bars";
+ else if (xpm_name == "Bumpeq") xpm_name = "bumpeq2";
+ else if (xpm_name == "Cap") xpm_name = "cap2";
+ else if (xpm_name == "Cup") xpm_name = "cup2";
+ else if (xpm_name == "Delta") xpm_name = "delta2";
+ else if (xpm_name == "Downarrow") xpm_name = "downarrow2";
+ else if (xpm_name == "Gamma") xpm_name = "gamma2";
+ else if (xpm_name == "Lambda") xpm_name = "lambda2";
+ else if (xpm_name == "Leftarrow") xpm_name = "leftarrow2";
+ else if (xpm_name == "Leftrightarrow") xpm_name = "leftrightarrow2";
+ else if (xpm_name == "Longleftarrow") xpm_name = "longleftarrow2";
+ else if (xpm_name == "Longleftrightarrow") xpm_name = "longleftrightarrow2";
+ else if (xpm_name == "Longrightarrow") xpm_name = "longrightarrow2";
+ else if (xpm_name == "nLeftarrow") xpm_name = "nleftarrow2";
+ else if (xpm_name == "nLeftrightarrow") xpm_name = "nleftrightarrow2";
+ else if (xpm_name == "nRightarrow") xpm_name = "nrightarrow2";
+ else if (xpm_name == "nvDash") xpm_name = "nvdash2";
+ else if (xpm_name == "nVDash") xpm_name = "nvdash3";
+ else if (xpm_name == "Omega") xpm_name = "omega2";
+ else if (xpm_name == "Phi") xpm_name = "phi2";
+ else if (xpm_name == "Pi") xpm_name = "pi2";
+ else if (xpm_name == "Psi") xpm_name = "psi2";
+ else if (xpm_name == "Rightarrow") xpm_name = "rightarrow2";
+ else if (xpm_name == "Sigma") xpm_name = "sigma2";
+ else if (xpm_name == "Subset") xpm_name = "subset2";
+ else if (xpm_name == "Supset") xpm_name = "supset2";
+ else if (xpm_name == "Theta") xpm_name = "theta2";
+ else if (xpm_name == "Uparrow") xpm_name = "uparrow2";
+ else if (xpm_name == "Updownarrow") xpm_name = "updownarrow2";
+ else if (xpm_name == "Upsilon") xpm_name = "upsilon2";
+ else if (xpm_name == "vDash") xpm_name = "vdash2";
+ else if (xpm_name == "Vdash") xpm_name = "vdash3";
+ else if (xpm_name == "Xi") xpm_name = "xi2";
+
+ lyxerr[Debug::GUI] << "Looking for math XPM called \""
+ << xpm_name << "\"" << std::endl;
+
+ return LibFileSearch("images/math/", xpm_name, "xpm");
+}
#ifndef CONTROL_MATH_H
#define CONTROL_MATH_H
+#include "LString.h"
+
extern char const * function_names[];
extern int const nr_function_names;
extern char const * latex_arrow[];
extern char const * latex_ams_ops[];
extern int const nr_latex_ams_ops;
+/**
+ * Return the mangled XPM filename of the given
+ * math symbol.
+ */
+string const find_xpm(string const & name);
+
#endif /* CONTROL_MATH_H */
+2002-11-20 John Levon <levon@movementarian.org>
+
+ * Toolbar_pimpl.C:
+ * QDelimiterDialog.C:
+ * QMathDialog.C: use find_xpm to mangle name
+
2002-11-20 John Levon <levon@movementarian.org>
* QDelimiterDialog.h:
#include "debug.h"
#include "QMath.h"
+#include "ControlMath.h"
#include "QDelimiterDialog.h"
#include "iconpalette.h"
setCaption(_("LyX: Delimiters"));
for (int i = 0; *delim[i]; ++i) {
- string xpm_name = LibFileSearch("images/math/", delim[i], "xpm");
- leftIP->add(QPixmap(xpm_name.c_str()), delim[i], delim[i]);
+ string xpm(find_xpm(delim[i]));
+ leftIP->add(QPixmap(xpm.c_str()), delim[i], delim[i]);
+ rightIP->add(QPixmap(xpm.c_str()), delim[i], delim[i]);
}
- leftIP->add(QPixmap(LibFileSearch("images/math/", "empty", "xpm").c_str()), "empty", "empty");
+
+ string empty_xpm(find_xpm("empty"));
+
+ leftIP->add(QPixmap(empty_xpm.c_str()), "empty", "empty");
+ rightIP->add(QPixmap(empty_xpm.c_str()), "empty", "empty");
connect(leftIP, SIGNAL(button_clicked(string const &)), this, SLOT(ldelim_clicked(string const &)));
- ldelim_clicked("(");
-
- for (int i = 0; *delim[i]; ++i) {
- string xpm_name = LibFileSearch("images/math/", delim[i], "xpm");
- rightIP->add(QPixmap(xpm_name.c_str()), delim[i], delim[i]);
- }
- rightIP->add(QPixmap(LibFileSearch("images/math/", "empty", "xpm").c_str()), "empty", "empty");
connect(rightIP, SIGNAL(button_clicked(string const &)), this, SLOT(rdelim_clicked(string const &)));
+ ldelim_clicked("(");
rdelim_clicked(")");
}
void QDelimiterDialog::set_label(QLabel * label, string const & str)
{
- string xpm_name = LibFileSearch("images/math/", str, "xpm");
label->setUpdatesEnabled(false);
- label->setPixmap(QPixmap(xpm_name.c_str()));
+ label->setPixmap(QPixmap(find_xpm(str).c_str()));
label->setUpdatesEnabled(true);
label->update();
}
{
IconPalette * p = new IconPalette(parent);
for (int i = 0; *entries[i]; ++i) {
- string xpm_name = LibFileSearch("images/math/", entries[i], "xpm");
- p->add(QPixmap(xpm_name.c_str()), entries[i], string("\\") + entries[i]);
+ p->add(QPixmap(find_xpm(entries[i]).c_str()), entries[i], string("\\") + entries[i]);
}
connect(p, SIGNAL(button_clicked(string const &)), this, SLOT(symbol_clicked(string const &)));
#include "QtView.h"
+#include "ControlMath.h"
#include "Toolbar_pimpl.h"
#include <boost/tuple/tuple.hpp>
{
FuncRequest f = lyxaction.retrieveActionArg(action);
- string xpm_name;
-
+ string fullname;
+
if (f.action == LFUN_INSERT_MATH && !f.argument.empty()) {
- xpm_name = "math/" + subst(f.argument.substr(1), ' ', '_');
+ fullname = find_xpm(f.argument.substr(1));
} else {
string const name = lyxaction.getActionName(f.action);
+ string xpm_name(name);
+
if (!f.argument.empty())
xpm_name = subst(name + ' ' + f.argument, ' ','_');
- else
- xpm_name = name;
+
+ fullname = LibFileSearch("images", xpm_name, "xpm");
}
- string fullname = LibFileSearch("images", xpm_name, "xpm");
if (!fullname.empty()) {
lyxerr[Debug::GUI] << "Full icon name is `"
return QPixmap(fullname.c_str());
}
- lyxerr << "Unable to find icon `" << xpm_name << "'" << endl;
+ lyxerr << "Unable to find icon `" << fullname << "'" << endl;
fullname = LibFileSearch("images", "unknown", "xpm");
if (!fullname.empty()) {
lyxerr[Debug::GUI] << "Using default `unknown' icon"