]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlMath.h
* src/frontend/controllers/frontend_helpers.cpp: safety fix suggested by Andre
[lyx.git] / src / frontends / controllers / ControlMath.h
1 // -*- C++ -*-
2 /**
3  * \file ControlMath.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef CONTROLMATH_H
13 #define CONTROLMATH_H
14
15
16 #include "Dialog.h"
17 #include "lfuns.h" // for kb_action
18 #include "Font.h"
19
20 #include <map>
21
22 namespace lyx {
23 namespace frontend {
24
25 struct MathSymbol {
26         MathSymbol(char_type uc = '?', unsigned char fc = 0,
27                 Font::FONT_FAMILY ff = Font::SYMBOL_FAMILY)
28                 : unicode(uc), fontcode(fc), fontfamily(ff)
29         {}
30         char_type unicode;
31         unsigned char fontcode;
32         Font::FONT_FAMILY fontfamily;
33 };
34
35 class ControlMath : public Dialog::Controller {
36 public:
37         ControlMath(Dialog &);
38
39         /// Nothing to initialise in this case.
40         virtual bool initialiseParams(std::string const &) { return true; }
41         virtual void clearParams() {}
42         virtual void dispatchParams() {}
43         virtual bool isBufferDependent() const { return true; }
44
45         /// dispatch an LFUN
46         void dispatchFunc(kb_action action, std::string const & arg = std::string()) const;
47         /// Insert a math symbol into the doc.
48         void dispatchInsert(std::string const & name) const;
49         /// Insert a subscript.
50         void dispatchSubscript() const;
51         /// Insert a superscript.
52         void dispatchSuperscript() const;
53         /// Insert a cube root
54         void dispatchCubeRoot() const;
55         /// Insert a matrix
56         void dispatchMatrix(std::string const & str) const;
57         /// Insert a variable size delimiter
58         void dispatchDelim(std::string const & str) const;
59         /// Insert a big delimiter
60         void dispatchBigDelim(std::string const & str) const;
61         /// Switch between display and inline
62         void dispatchToggleDisplay() const;
63         /** A request to the kernel to launch a dialog.
64          *  \param name the dialog identifier.
65          */
66         void showDialog(std::string const & name) const;
67
68         /// \return the math unicode symbol associated to a TeX name.
69         MathSymbol const & mathSymbol(std::string tex_name) const;
70         /// \return the TeX name associated to a math unicode symbol.
71         std::string const & texName(char_type math_symbol) const;
72
73 private:
74         /// TeX-name / Math-symbol map.
75         std::map<std::string, MathSymbol> math_symbols_;
76         /// Math-symbol / TeX-name map.
77         /// This one is for fast search, it contains the same data as
78         /// \c math_symbols_.
79         std::map<char_type, std::string> tex_names_;
80 };
81
82
83 extern char const * function_names[];
84 extern int const nr_function_names;
85 extern char const * latex_arrow[];
86 extern int const nr_latex_arrow;
87 extern char const * latex_bop[];
88 extern int const nr_latex_bop;
89 extern char const * latex_brel[];
90 extern int const nr_latex_brel;
91 extern char const * latex_dots[];
92 extern int const nr_latex_dots;
93 extern char const * latex_greek[];
94 extern int const nr_latex_greek;
95 extern char const * latex_deco[];
96 extern int const nr_latex_deco;
97 extern char const * latex_misc[];
98 extern int const nr_latex_misc;
99 extern char const * latex_varsz[];
100 extern int const nr_latex_varsz;
101 extern char const * latex_ams_misc[];
102 extern int const nr_latex_ams_misc;
103 extern char const * latex_ams_arrows[];
104 extern int const nr_latex_ams_arrows;
105 extern char const * latex_ams_rel[];
106 extern int const nr_latex_ams_rel;
107 extern char const * latex_ams_nrel[];
108 extern int const nr_latex_ams_nrel;
109 extern char const * latex_ams_ops[];
110 extern int const nr_latex_ams_ops;
111 extern char const * latex_delimiters[];
112 extern int const nr_latex_delimiters;
113
114 /**
115  * Return the mangled XPM filename of the given
116  * math symbol.
117  */
118 std::string const find_xpm(std::string const & name);
119
120 } // namespace frontend
121 } // namespace lyx
122
123 #endif // NOT CONTROLMATH