3 * Copyright 2001 the LyX Team
4 * Read the file COPYING
6 * \author Alejandro Aguilar Sierra
13 #include XPM_H_LOCATION
16 #pragma implementation
19 #include "support/LAssert.h"
22 #include "MathsSymbols.h"
23 #include "FormMathsPanel.h"
29 /* Latex code for those bitmaps */
38 #include "mathed/math_parser.h"
47 #include "equation.xpm"
49 char const * function_names[] = {
50 "arccos", "arcsin", "arctan", "arg", "bmod",
51 "cos", "cosh", "cot", "coth", "csc", "deg",
52 "det", "dim", "exp", "gcd", "hom", "inf", "ker",
53 "lg", "lim", "liminf", "limsup", "ln", "log",
54 "max", "min", "sec", "sin", "sinh", "sup",
58 int const nr_function_names = sizeof(function_names) /
61 char const * latex_arrow[] = {
62 "downarrow", "leftarrow", "Downarrow", "Leftarrow",
63 "hookleftarrow", "rightarrow", "uparrow", "Rightarrow", "Uparrow",
64 "hookrightarrow", "updownarrow", "Leftrightarrow", "leftharpoonup",
65 "rightharpoonup", "rightleftharpoons", "leftrightarrow", "Updownarrow",
66 "leftharpoondown", "rightharpoondown", "mapsto",
67 "Longleftarrow", "Longrightarrow", "Longleftrightarrow",
68 "longleftrightarrow", "longleftarrow", "longrightarrow", "longmapsto",
69 "nwarrow", "nearrow", "swarrow", "searrow", "",
72 int const nr_latex_arrow = sizeof(latex_arrow) / sizeof(char const *);
74 char const * latex_bop[] = {
75 "pm", "cap", "diamond", "oplus",
76 "mp", "cup", "bigtriangleup", "ominus",
77 "times", "uplus", "bigtriangledown", "otimes",
78 "div", "sqcap", "triangleright", "oslash",
79 "cdot", "sqcup", "triangleleft", "odot",
80 "star", "vee", "amalg", "bigcirc",
81 "setminus", "wedge", "dagger", "circ",
82 "bullet", "wr", "ddagger", ""
85 int const nr_latex_bop = sizeof(latex_bop) / sizeof(char const *);
87 char const * latex_brel[] = {
88 "leq", "geq", "equiv", "models",
89 "prec", "succ", "sim", "perp",
90 "preceq", "succeq", "simeq", "mid",
91 "ll", "gg", "asymp", "parallel",
92 "subset", "supset", "approx", "smile",
93 "subseteq", "supseteq", "cong", "frown",
94 "sqsubseteq", "sqsupseteq", "doteq", "neq",
95 "in", "ni", "propto", "notin",
96 "vdash", "dashv", "bowtie", ""
99 int const nr_latex_brel = sizeof(latex_brel) / sizeof(char const *);
101 char const * latex_dots[] = {
102 "ldots", "cdots", "vdots", "ddots"
105 int const nr_latex_dots = sizeof(latex_dots) / sizeof(char const *);
107 char const * latex_greek[] = {
108 "Gamma", "Delta", "Theta", "Lambda", "Xi", "Pi",
109 "Sigma", "Upsilon", "Phi", "Psi", "Omega",
110 "alpha", "beta", "gamma", "delta", "epsilon", "varepsilon", "zeta",
111 "eta", "theta", "vartheta", "iota", "kappa", "lambda", "mu",
112 "nu", "xi", "pi", "varpi", "rho", "sigma", "varsigma",
113 "tau", "upsilon", "phi", "varphi", "chi", "psi", "omega", ""
116 int const nr_latex_greek = sizeof(latex_greek) / sizeof(char const *);
118 char const * latex_misc[] = {
119 "nabla", "partial", "infty", "prime", "ell",
120 "emptyset", "exists", "forall", "imath", "jmath",
121 "Re", "Im", "aleph", "wp", "hbar",
122 "angle", "top", "bot", "Vert", "neg",
123 "flat", "natural", "sharp", "surd", "triangle",
124 "diamondsuit", "heartsuit", "clubsuit", "spadesuit", ""
127 int const nr_latex_misc = sizeof(latex_misc) / sizeof(char const *);
129 char const * latex_varsz[] = {
130 "sum", "int", "oint",
131 "prod", "coprod", "bigsqcup",
132 "bigotimes", "bigodot", "bigoplus",
133 "bigcap", "bigcup", "biguplus",
134 "bigvee", "bigwedge", ""
137 int const nr_latex_varsz = sizeof(latex_varsz) / sizeof(char const *);
139 static char const ** mathed_get_pixmap_from_icon(int d)
142 case MM_FRAC: return frac;
143 case MM_SQRT: return sqrt_xpm;
144 case MM_DELIM: return delim;
145 case MM_MATRIX: return matrix;
146 case MM_EQU: return equation;
147 case MM_DECO: return deco;
148 case MM_SPACE: return space_xpm;
153 static char const ** pixmapFromBitmapData(char const * s, int wx, int hx)
155 char const ** data = 0;
161 char const ** latex_str = 0;
163 case 0: latex_str = latex_greek; break;
164 case 1: latex_str = latex_bop; break;
165 case 2: latex_str = latex_brel; break;
166 case 3: latex_str = latex_arrow; break;
167 case 4: latex_str = latex_varsz; break;
168 case 5: latex_str = latex_misc; break;
171 for (int k = 0; latex_str[k][0] > ' '; ++k) {
172 if (compare(latex_str[k], s) == 0) {
179 if (i < 6 && id >= 0) {
180 unsigned char const * bdata = 0;
186 lyxerr[Debug::MATHED] << "Imando " << i << ", " << id << endl;
225 } else if (id > 28) {
259 XImage * xima = XCreateImage(fl_get_display(), 0, 1, XYBitmap, 0,
260 const_cast<char*>(reinterpret_cast<char const *>(bdata)), w, h, 8, 0);
261 xima->byte_order = LSBFirst;
262 xima->bitmap_bit_order = LSBFirst;
263 int x = (id % dw) * ww;
264 int y = (id/dw) * hh;
265 if (ww > wx) ww = wx;
266 if (hh > hx) hh = hx;
267 XImage * sbima = XSubImage(xima, x, y, ww, hh);
268 XpmCreateDataFromImage(fl_get_display(), const_cast<char***>(&data), sbima, sbima, 0);
270 // Dirty hack to get blue symbols quickly
271 char * sx = const_cast<char*>(std::strstr(data[2], "FFFFFFFF"));
273 for (int k = 0; k < 8; ++k) sx[k] = '0';
276 // XDestroyImage(xima);
283 char const ** get_pixmap_from_symbol(char const * arg, int wx, int hx)
287 char const ** data = 0;
288 latexkeys const * l = in_word_set(arg);
294 data = mathed_get_pixmap_from_icon(MM_FRAC);
297 data = mathed_get_pixmap_from_icon(MM_SQRT);
301 // I have to use directly the bitmap data since the
302 // bitmap tables are not yet created when this
303 // function is called.
304 data = pixmapFromBitmapData(arg, wx, hx);