]> git.lyx.org Git - lyx.git/commitdiff
math icon name fixups
authorJohn Levon <levon@movementarian.org>
Wed, 20 Nov 2002 16:11:18 +0000 (16:11 +0000)
committerJohn Levon <levon@movementarian.org>
Wed, 20 Nov 2002 16:11:18 +0000 (16:11 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5676 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlMath.C
src/frontends/controllers/ControlMath.h
src/frontends/qt2/ChangeLog
src/frontends/qt2/QDelimiterDialog.C
src/frontends/qt2/QMathDialog.C
src/frontends/qt2/Toolbar_pimpl.C

index 1fcb51d51ce27f6d16ddae0ee8096b8c19257ac9..5e610bd0c6784a8fa4d82b930ce228932cf40ae6 100644 (file)
@@ -1,3 +1,8 @@
+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
index 8d911c40d746ab592c26779895e6477d9d2d12e9..a0dc7aaf561233ae205c90e9094bcba8aaf1b7b3 100644 (file)
 
 #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",
@@ -197,3 +201,53 @@ char const * latex_ams_ops[] = {
 };
 
 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");
+}
index b5f2e227120b88e58644378604d87d01e321ed29..2391a5f6ee114c24ce03896c8dcb42b5c7f5d08f 100644 (file)
@@ -13,6 +13,8 @@
 #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[];
@@ -42,4 +44,10 @@ extern int const nr_latex_ams_nrel;
 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 */
index 4a3afaa0889b1e683cac7d50625dd29031a24646..d617d63f1455809cb5584b52021302c26a532e40 100644 (file)
@@ -1,3 +1,9 @@
+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:
index dc3cbaca0c2e7d621554f709760a8660e86398e5..18a0dc656f0711405c89bce85cb6efcf68b7f37c 100644 (file)
@@ -19,6 +19,7 @@
 #include "debug.h"
 
 #include "QMath.h"
+#include "ControlMath.h"
 #include "QDelimiterDialog.h"
 
 #include "iconpalette.h"
@@ -80,19 +81,18 @@ QDelimiterDialog::QDelimiterDialog(QMath * form)
        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(")");
 }
 
@@ -105,9 +105,8 @@ void QDelimiterDialog::insertClicked()
 
 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();
 }
index 492035d9321bc858a6272bb1f566aabb2b318b8d..5570fd1e7c743cefef42b2fa0fb06d674914e828 100644 (file)
@@ -180,8 +180,7 @@ IconPalette * QMathDialog::makePanel(QWidget * parent, char const ** entries)
 {
        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 &)));
 
index 43ba1b62300a0c3441113d80f25009a5ac449de1..107515115c9cb0272e050ef4831d55c83c385947 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "QtView.h"
 
+#include "ControlMath.h" 
 #include "Toolbar_pimpl.h"
 
 #include <boost/tuple/tuple.hpp>
@@ -47,19 +48,20 @@ QPixmap getIconPixmap(int action)
 {
        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 `"
@@ -67,7 +69,7 @@ QPixmap getIconPixmap(int action)
                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"