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