]> git.lyx.org Git - features.git/blob - src/frontends/controllers/ControlMath.h
94322ddd4e8e28ed0b8f616c9024f4cf4219c6ae
[features.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 #include "Dialog.h"
16 #include "lfuns.h" // for kb_action
17 #include "Font.h"
18
19 #include <map>
20
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
36 class ControlMath : public Controller {
37 public:
38         ControlMath(Dialog &);
39
40         /// Nothing to initialise in this case.
41         virtual bool initialiseParams(std::string const &) { return true; }
42         virtual void clearParams() {}
43         virtual void dispatchParams() {}
44         virtual bool isBufferDependent() const { return true; }
45
46         /// dispatch an LFUN
47         void dispatchFunc(kb_action action, std::string const & arg = std::string()) const;
48         /// Insert a math symbol into the doc.
49         void dispatchInsert(std::string const & name) const;
50         /// Insert a subscript.
51         void dispatchSubscript() const;
52         /// Insert a superscript.
53         void dispatchSuperscript() const;
54         /// Insert a cube root
55         void dispatchCubeRoot() const;
56         /// Insert a matrix
57         void dispatchMatrix(std::string const & str) const;
58         /// Insert a variable size delimiter
59         void dispatchDelim(std::string const & str) const;
60         /// Insert a big delimiter
61         void dispatchBigDelim(std::string const & str) const;
62         /// Switch between display and inline
63         void dispatchToggleDisplay() const;
64         /** A request to the kernel to launch a dialog.
65          *  \param name the dialog identifier.
66          */
67         void showDialog(std::string const & name) const;
68
69         /// \return the math unicode symbol associated to a TeX name.
70         MathSymbol const & mathSymbol(std::string tex_name) const;
71         /// \return the TeX name associated to a math unicode symbol.
72         std::string const & texName(char_type math_symbol) const;
73
74 private:
75         /// TeX-name / Math-symbol map.
76         std::map<std::string, MathSymbol> math_symbols_;
77         /// Math-symbol / TeX-name map.
78         /// This one is for fast search, it contains the same data as
79         /// \c math_symbols_.
80         std::map<char_type, std::string> tex_names_;
81 };
82
83
84 } // namespace frontend
85 } // namespace lyx
86
87 #endif // NOT CONTROLMATH