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