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"
55 #include "equation.xpm"
57 char const * function_names[] = {
58 "arccos", "arcsin", "arctan", "arg", "bmod",
59 "cos", "cosh", "cot", "coth", "csc", "deg",
60 "det", "dim", "exp", "gcd", "hom", "inf", "ker",
61 "lg", "lim", "liminf", "limsup", "ln", "log",
62 "max", "min", "sec", "sin", "sinh", "sup",
66 int const nr_function_names = sizeof(function_names) /
69 char const * latex_arrow[] = {
70 "downarrow", "leftarrow", "Downarrow", "Leftarrow",
71 "hookleftarrow", "rightarrow", "uparrow", "Rightarrow", "Uparrow",
72 "hookrightarrow", "updownarrow", "Leftrightarrow", "leftharpoonup",
73 "rightharpoonup", "rightleftharpoons", "leftrightarrow", "Updownarrow",
74 "leftharpoondown", "rightharpoondown", "mapsto",
75 "Longleftarrow", "Longrightarrow", "Longleftrightarrow",
76 "longleftrightarrow", "longleftarrow", "longrightarrow", "longmapsto",
77 "nwarrow", "nearrow", "swarrow", "searrow", "",
80 int const nr_latex_arrow = sizeof(latex_arrow) / sizeof(char const *);
82 char const * latex_bop[] = {
83 "pm", "cap", "diamond", "oplus",
84 "mp", "cup", "bigtriangleup", "ominus",
85 "times", "uplus", "bigtriangledown", "otimes",
86 "div", "sqcap", "triangleright", "oslash",
87 "cdot", "sqcup", "triangleleft", "odot",
88 "star", "vee", "amalg", "bigcirc",
89 "setminus", "wedge", "dagger", "circ",
90 "bullet", "wr", "ddagger", ""
93 int const nr_latex_bop = sizeof(latex_bop) / sizeof(char const *);
95 char const * latex_brel[] = {
96 "leq", "geq", "equiv", "models",
97 "prec", "succ", "sim", "perp",
98 "preceq", "succeq", "simeq", "mid",
99 "ll", "gg", "asymp", "parallel",
100 "subset", "supset", "approx", "smile",
101 "subseteq", "supseteq", "cong", "frown",
102 "sqsubseteq", "sqsupseteq", "doteq", "neq",
103 "in", "ni", "propto", "notin",
104 "vdash", "dashv", "bowtie", ""
107 int const nr_latex_brel = sizeof(latex_brel) / sizeof(char const *);
109 char const * latex_dots[] = {
110 "ldots", "cdots", "vdots", "ddots"
113 int const nr_latex_dots = sizeof(latex_dots) / sizeof(char const *);
115 char const * latex_greek[] = {
116 "Gamma", "Delta", "Theta", "Lambda", "Xi", "Pi",
117 "Sigma", "Upsilon", "Phi", "Psi", "Omega",
118 "alpha", "beta", "gamma", "delta", "epsilon", "varepsilon", "zeta",
119 "eta", "theta", "vartheta", "iota", "kappa", "lambda", "mu",
120 "nu", "xi", "pi", "varpi", "rho", "sigma", "varsigma",
121 "tau", "upsilon", "phi", "varphi", "chi", "psi", "omega", ""
124 int const nr_latex_greek = sizeof(latex_greek) / sizeof(char const *);
126 char const * latex_misc[] = {
127 "nabla", "partial", "infty", "prime", "ell",
128 "emptyset", "exists", "forall", "imath", "jmath",
129 "Re", "Im", "aleph", "wp", "hbar",
130 "angle", "top", "bot", "Vert", "neg",
131 "flat", "natural", "sharp", "surd", "triangle",
132 "diamondsuit", "heartsuit", "clubsuit", "spadesuit",
133 "mathbb N", "mathbb Z", "mathbb Q",
134 "mathbb R", "mathbb C", "mathbb H",
135 "mathcal F", "mathcal L",
136 "mathcal H", "mathcal O",""
139 int const nr_latex_misc = sizeof(latex_misc) / sizeof(char const *);
141 char const * latex_varsz[] = {
142 "sum", "int", "oint",
143 "prod", "coprod", "bigsqcup",
144 "bigotimes", "bigodot", "bigoplus",
145 "bigcap", "bigcup", "biguplus",
146 "bigvee", "bigwedge", ""
149 int const nr_latex_varsz = sizeof(latex_varsz) / sizeof(char const *);
151 static char const ** mathed_get_pixmap_from_icon(int d)
154 case MM_FRAC: return frac;
155 case MM_SQRT: return sqrt_xpm;
156 case MM_SUPER: return super_xpm;
157 case MM_SUB: return sub_xpm;
158 case MM_STYLE: return style_xpm;
159 case MM_DELIM: return delim;
160 case MM_MATRIX: return matrix;
161 case MM_EQU: return equation;
162 case MM_DECO: return deco;
163 case MM_SPACE: return space_xpm;
168 static char const ** pixmapFromBitmapData(char const * s, int wx, int hx)
170 char const ** data = 0;
176 char const ** latex_str = 0;
178 case 0: latex_str = latex_greek; break;
179 case 1: latex_str = latex_bop; break;
180 case 2: latex_str = latex_brel; break;
181 case 3: latex_str = latex_arrow; break;
182 case 4: latex_str = latex_varsz; break;
183 case 5: latex_str = latex_misc; break;
186 for (int k = 0; latex_str[k][0] > ' '; ++k) {
187 if (compare(latex_str[k], s) == 0) {
194 if (i < 6 && id >= 0) {
195 unsigned char const * bdata = 0;
201 lyxerr[Debug::MATHED] << "Imando " << i << ", " << id << endl;
240 } else if (id > 28) {
270 } else if (id > 36) {
289 XImage * xima = XCreateImage(fl_get_display(), 0, 1, XYBitmap, 0,
290 const_cast<char*>(reinterpret_cast<char const *>(bdata)), w, h, 8, 0);
291 xima->byte_order = LSBFirst;
292 xima->bitmap_bit_order = LSBFirst;
293 int x = (id % dw) * ww;
294 int y = (id/dw) * hh;
295 if (ww > wx) ww = wx;
296 if (hh > hx) hh = hx;
297 XImage * sbima = XSubImage(xima, x, y, ww, hh);
298 XpmCreateDataFromImage(fl_get_display(), const_cast<char***>(&data), sbima, sbima, 0);
300 // Dirty hack to get blue symbols quickly
301 char * sx = const_cast<char*>(strstr(data[2], "FFFFFFFF"));
303 for (int k = 0; k < 8; ++k) sx[k] = '0';
306 // XDestroyImage(xima);
313 char const ** get_pixmap_from_symbol(char const * arg, int wx, int hx)
317 char const ** data = 0;
318 latexkeys const * l = in_word_set(arg);
324 data = mathed_get_pixmap_from_icon(MM_FRAC);
327 data = mathed_get_pixmap_from_icon(MM_SQRT);
336 // I have to use directly the bitmap data since the
337 // bitmap tables are not yet created when this
338 // function is called.
339 data = pixmapFromBitmapData(arg, wx, hx);