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"
20 #include "support/lstrings.h"
22 #include "MathsSymbols.h"
23 #include "FormMathsPanel.h"
29 #ifndef CXX_GLOBAL_CSTD
34 /* Latex code for those bitmaps */
43 #include "mathed/math_parser.h"
52 #include "equation.xpm"
54 char const * function_names[] = {
55 "arccos", "arcsin", "arctan", "arg", "bmod",
56 "cos", "cosh", "cot", "coth", "csc", "deg",
57 "det", "dim", "exp", "gcd", "hom", "inf", "ker",
58 "lg", "lim", "liminf", "limsup", "ln", "log",
59 "max", "min", "sec", "sin", "sinh", "sup",
63 int const nr_function_names = sizeof(function_names) /
66 char const * latex_arrow[] = {
67 "downarrow", "leftarrow", "Downarrow", "Leftarrow",
68 "hookleftarrow", "rightarrow", "uparrow", "Rightarrow", "Uparrow",
69 "hookrightarrow", "updownarrow", "Leftrightarrow", "leftharpoonup",
70 "rightharpoonup", "rightleftharpoons", "leftrightarrow", "Updownarrow",
71 "leftharpoondown", "rightharpoondown", "mapsto",
72 "Longleftarrow", "Longrightarrow", "Longleftrightarrow",
73 "longleftrightarrow", "longleftarrow", "longrightarrow", "longmapsto",
74 "nwarrow", "nearrow", "swarrow", "searrow", "",
77 int const nr_latex_arrow = sizeof(latex_arrow) / sizeof(char const *);
79 char const * latex_bop[] = {
80 "pm", "cap", "diamond", "oplus",
81 "mp", "cup", "bigtriangleup", "ominus",
82 "times", "uplus", "bigtriangledown", "otimes",
83 "div", "sqcap", "triangleright", "oslash",
84 "cdot", "sqcup", "triangleleft", "odot",
85 "star", "vee", "amalg", "bigcirc",
86 "setminus", "wedge", "dagger", "circ",
87 "bullet", "wr", "ddagger", ""
90 int const nr_latex_bop = sizeof(latex_bop) / sizeof(char const *);
92 char const * latex_brel[] = {
93 "leq", "geq", "equiv", "models",
94 "prec", "succ", "sim", "perp",
95 "preceq", "succeq", "simeq", "mid",
96 "ll", "gg", "asymp", "parallel",
97 "subset", "supset", "approx", "smile",
98 "subseteq", "supseteq", "cong", "frown",
99 "sqsubseteq", "sqsupseteq", "doteq", "neq",
100 "in", "ni", "propto", "notin",
101 "vdash", "dashv", "bowtie", ""
104 int const nr_latex_brel = sizeof(latex_brel) / sizeof(char const *);
106 char const * latex_dots[] = {
107 "ldots", "cdots", "vdots", "ddots"
110 int const nr_latex_dots = sizeof(latex_dots) / sizeof(char const *);
112 char const * latex_greek[] = {
113 "Gamma", "Delta", "Theta", "Lambda", "Xi", "Pi",
114 "Sigma", "Upsilon", "Phi", "Psi", "Omega",
115 "alpha", "beta", "gamma", "delta", "epsilon", "varepsilon", "zeta",
116 "eta", "theta", "vartheta", "iota", "kappa", "lambda", "mu",
117 "nu", "xi", "pi", "varpi", "rho", "sigma", "varsigma",
118 "tau", "upsilon", "phi", "varphi", "chi", "psi", "omega", ""
121 int const nr_latex_greek = sizeof(latex_greek) / sizeof(char const *);
123 char const * latex_misc[] = {
124 "nabla", "partial", "infty", "prime", "ell",
125 "emptyset", "exists", "forall", "imath", "jmath",
126 "Re", "Im", "aleph", "wp", "hbar",
127 "angle", "top", "bot", "Vert", "neg",
128 "flat", "natural", "sharp", "surd", "triangle",
129 "diamondsuit", "heartsuit", "clubsuit", "spadesuit", ""
132 int const nr_latex_misc = sizeof(latex_misc) / sizeof(char const *);
134 char const * latex_varsz[] = {
135 "sum", "int", "oint",
136 "prod", "coprod", "bigsqcup",
137 "bigotimes", "bigodot", "bigoplus",
138 "bigcap", "bigcup", "biguplus",
139 "bigvee", "bigwedge", ""
142 int const nr_latex_varsz = sizeof(latex_varsz) / sizeof(char const *);
144 static char const ** mathed_get_pixmap_from_icon(int d)
147 case MM_FRAC: return frac;
148 case MM_SQRT: return sqrt_xpm;
149 case MM_DELIM: return delim;
150 case MM_MATRIX: return matrix;
151 case MM_EQU: return equation;
152 case MM_DECO: return deco;
153 case MM_SPACE: return space_xpm;
158 static char const ** pixmapFromBitmapData(char const * s, int wx, int hx)
160 char const ** data = 0;
166 char const ** latex_str = 0;
168 case 0: latex_str = latex_greek; break;
169 case 1: latex_str = latex_bop; break;
170 case 2: latex_str = latex_brel; break;
171 case 3: latex_str = latex_arrow; break;
172 case 4: latex_str = latex_varsz; break;
173 case 5: latex_str = latex_misc; break;
176 for (int k = 0; latex_str[k][0] > ' '; ++k) {
177 if (compare(latex_str[k], s) == 0) {
184 if (i < 6 && id >= 0) {
185 unsigned char const * bdata = 0;
191 lyxerr[Debug::MATHED] << "Imando " << i << ", " << id << endl;
230 } else if (id > 28) {
264 XImage * xima = XCreateImage(fl_get_display(), 0, 1, XYBitmap, 0,
265 const_cast<char*>(reinterpret_cast<char const *>(bdata)), w, h, 8, 0);
266 xima->byte_order = LSBFirst;
267 xima->bitmap_bit_order = LSBFirst;
268 int x = (id % dw) * ww;
269 int y = (id/dw) * hh;
270 if (ww > wx) ww = wx;
271 if (hh > hx) hh = hx;
272 XImage * sbima = XSubImage(xima, x, y, ww, hh);
273 XpmCreateDataFromImage(fl_get_display(), const_cast<char***>(&data), sbima, sbima, 0);
275 // Dirty hack to get blue symbols quickly
276 char * sx = const_cast<char*>(strstr(data[2], "FFFFFFFF"));
278 for (int k = 0; k < 8; ++k) sx[k] = '0';
281 // XDestroyImage(xima);
288 char const ** get_pixmap_from_symbol(char const * arg, int wx, int hx)
292 char const ** data = 0;
293 latexkeys const * l = in_word_set(arg);
299 data = mathed_get_pixmap_from_icon(MM_FRAC);
302 data = mathed_get_pixmap_from_icon(MM_SQRT);
311 // I have to use directly the bitmap data since the
312 // bitmap tables are not yet created when this
313 // function is called.
314 data = pixmapFromBitmapData(arg, wx, hx);